Movie editor: Fix the reset delay counters to be right way around
[lsnes.git] / bsnes-patches / v086 / 0004-Fix-mouse-polling.patch
blob7484c29cb9a65b75d0af7669b6cf57b29a84c67c
1 From 395130ad02c50c329c0290b675086ff104839943 Mon Sep 17 00:00:00 2001
2 From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
3 Date: Wed, 7 Mar 2012 16:57:18 +0200
4 Subject: [PATCH 4/4] Fix mouse polling
6 Don't poll for mouse motion excessive number of times (no need to poll it for
7 each bit!)
8 ---
9 snes/controller/mouse/mouse.cpp | 12 ++++++++++--
10 snes/controller/mouse/mouse.hpp | 2 ++
11 2 files changed, 12 insertions(+), 2 deletions(-)
13 diff --git a/snes/controller/mouse/mouse.cpp b/snes/controller/mouse/mouse.cpp
14 index 6b26fae..824ecd3 100755
15 --- a/snes/controller/mouse/mouse.cpp
16 +++ b/snes/controller/mouse/mouse.cpp
17 @@ -3,8 +3,10 @@
18 uint2 Mouse::data() {
19 if(counter >= 32) return 1;
21 - int position_x = interface->inputPoll(port, Input::Device::Mouse, 0, (unsigned)Input::MouseID::X); //-n = left, 0 = center, +n = right
22 - int position_y = interface->inputPoll(port, Input::Device::Mouse, 0, (unsigned)Input::MouseID::Y); //-n = up, 0 = center, +n = down
23 + if(counter == 0) {
24 + position_x = interface->inputPoll(port, Input::Device::Mouse, 0, (unsigned)Input::MouseID::X); //-n = left, 0 = center, +n = right
25 + position_y = interface->inputPoll(port, Input::Device::Mouse, 0, (unsigned)Input::MouseID::Y); //-n = up, 0 = center, +n = down
26 + }
28 bool direction_x = position_x < 0; //0 = right, 1 = left
29 bool direction_y = position_y < 0; //0 = down, 1 = up
30 @@ -67,10 +69,16 @@ void Mouse::serialize(serializer& s) {
31 unsigned char block[Controller::SaveSize] = {0};
32 block[0] = latched ? 1 : 0;
33 block[1] = counter;
34 + block[2] = (unsigned short)position_x >> 8;
35 + block[3] = (unsigned short)position_x;
36 + block[4] = (unsigned short)position_y >> 8;
37 + block[5] = (unsigned short)position_y;
38 s.array(block, Controller::SaveSize);
39 if(s.mode() == nall::serializer::Load) {
40 latched = (block[0] != 0);
41 counter = block[1];
42 + position_x = (short)(((unsigned short)block[2] << 8) | (unsigned short)block[3]);
43 + position_y = (short)(((unsigned short)block[4] << 8) | (unsigned short)block[5]);
47 diff --git a/snes/controller/mouse/mouse.hpp b/snes/controller/mouse/mouse.hpp
48 index b66ea51..6074f34 100755
49 --- a/snes/controller/mouse/mouse.hpp
50 +++ b/snes/controller/mouse/mouse.hpp
51 @@ -6,4 +6,6 @@ struct Mouse : Controller {
52 private:
53 bool latched;
54 unsigned counter;
55 + int position_x;
56 + int position_y;
58 --
59 1.7.9.48.g85da4d