Add missing $(CROSS_PREFIX) to pkg-config for libopus
[lsnes.git] / bsnes-patches / v087 / 0004-Fix-mouse-polling.patch
blob300e6feeb7308da1125143716a28c1524147137a
1 From e6ec3c0d382f57e2c447b1a5dbfc4f58fc0ecfef 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/6] 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 | 14 ++++++++++++--
10 snes/controller/mouse/mouse.hpp | 2 ++
11 2 files changed, 14 insertions(+), 2 deletions(-)
13 diff --git a/snes/controller/mouse/mouse.cpp b/snes/controller/mouse/mouse.cpp
14 index 6b26fae..1a066b9 100755
15 --- a/snes/controller/mouse/mouse.cpp
16 +++ b/snes/controller/mouse/mouse.cpp
17 @@ -3,9 +3,13 @@
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 + int position_x = _position_x;
29 + int position_y = _position_y;
30 bool direction_x = position_x < 0; //0 = right, 1 = left
31 bool direction_y = position_y < 0; //0 = down, 1 = up
33 @@ -67,10 +71,16 @@ void Mouse::serialize(serializer& s) {
34 unsigned char block[Controller::SaveSize] = {0};
35 block[0] = latched ? 1 : 0;
36 block[1] = counter;
37 + block[2] = (unsigned short)_position_x >> 8;
38 + block[3] = (unsigned short)_position_x;
39 + block[4] = (unsigned short)_position_y >> 8;
40 + block[5] = (unsigned short)_position_y;
41 s.array(block, Controller::SaveSize);
42 if(s.mode() == nall::serializer::Load) {
43 latched = (block[0] != 0);
44 counter = block[1];
45 + _position_x = (short)(((unsigned short)block[2] << 8) | (unsigned short)block[3]);
46 + _position_y = (short)(((unsigned short)block[4] << 8) | (unsigned short)block[5]);
50 diff --git a/snes/controller/mouse/mouse.hpp b/snes/controller/mouse/mouse.hpp
51 index b66ea51..b07c8ab 100755
52 --- a/snes/controller/mouse/mouse.hpp
53 +++ b/snes/controller/mouse/mouse.hpp
54 @@ -6,4 +6,6 @@ struct Mouse : Controller {
55 private:
56 bool latched;
57 unsigned counter;
58 + int _position_x;
59 + int _position_y;
61 --
62 1.7.9.48.g85da4d