Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libsnes/lsnes_patches/0004-Fix-mouse-polling.patch
2 views
1
From 160dedf35571478781737ee35307b9321cfb41bb Mon Sep 17 00:00:00 2001
2
From: Ilari Liusvaara <[email protected]>
3
Date: Wed, 7 Mar 2012 16:57:18 +0200
4
Subject: [PATCH 4/4] Fix mouse polling
5
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(-)
12
13
diff --git a/snes/controller/mouse/mouse.cpp b/snes/controller/mouse/mouse.cpp
14
index 6b26fae..824ecd3 100755
15
--- snes/controller/mouse/mouse.cpp
16
+++ snes/controller/mouse/mouse.cpp
17
@@ -3,8 +3,10 @@
18
uint2 Mouse::data() {
19
if(counter >= 32) return 1;
20
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
+ }
27
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]);
44
}
45
}
46
47
diff --git a/snes/controller/mouse/mouse.hpp b/snes/controller/mouse/mouse.hpp
48
index b66ea51..6074f34 100755
49
--- snes/controller/mouse/mouse.hpp
50
+++ 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;
57
};
58
--
59
1.7.9.48.g85da4d
60
61
62