626ff5e200
Additionally, fix the mouse input craziness.
60 lines
2.4 KiB
Diff
60 lines
2.4 KiB
Diff
From 160dedf35571478781737ee35307b9321cfb41bb Mon Sep 17 00:00:00 2001
|
|
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
|
|
Date: Wed, 7 Mar 2012 16:57:18 +0200
|
|
Subject: [PATCH 4/4] Fix mouse polling
|
|
|
|
Don't poll for mouse motion excessive number of times (no need to poll it for
|
|
each bit!)
|
|
---
|
|
snes/controller/mouse/mouse.cpp | 12 ++++++++++--
|
|
snes/controller/mouse/mouse.hpp | 2 ++
|
|
2 files changed, 12 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/snes/controller/mouse/mouse.cpp b/snes/controller/mouse/mouse.cpp
|
|
index 6b26fae..824ecd3 100755
|
|
--- a/snes/controller/mouse/mouse.cpp
|
|
+++ b/snes/controller/mouse/mouse.cpp
|
|
@@ -3,8 +3,10 @@
|
|
uint2 Mouse::data() {
|
|
if(counter >= 32) return 1;
|
|
|
|
- int position_x = interface->inputPoll(port, Input::Device::Mouse, 0, (unsigned)Input::MouseID::X); //-n = left, 0 = center, +n = right
|
|
- int position_y = interface->inputPoll(port, Input::Device::Mouse, 0, (unsigned)Input::MouseID::Y); //-n = up, 0 = center, +n = down
|
|
+ if(counter == 0) {
|
|
+ position_x = interface->inputPoll(port, Input::Device::Mouse, 0, (unsigned)Input::MouseID::X); //-n = left, 0 = center, +n = right
|
|
+ position_y = interface->inputPoll(port, Input::Device::Mouse, 0, (unsigned)Input::MouseID::Y); //-n = up, 0 = center, +n = down
|
|
+ }
|
|
|
|
bool direction_x = position_x < 0; //0 = right, 1 = left
|
|
bool direction_y = position_y < 0; //0 = down, 1 = up
|
|
@@ -67,10 +69,16 @@ void Mouse::serialize(serializer& s) {
|
|
unsigned char block[Controller::SaveSize] = {0};
|
|
block[0] = latched ? 1 : 0;
|
|
block[1] = counter;
|
|
+ block[2] = (unsigned short)position_x >> 8;
|
|
+ block[3] = (unsigned short)position_x;
|
|
+ block[4] = (unsigned short)position_y >> 8;
|
|
+ block[5] = (unsigned short)position_y;
|
|
s.array(block, Controller::SaveSize);
|
|
if(s.mode() == nall::serializer::Load) {
|
|
latched = (block[0] != 0);
|
|
counter = block[1];
|
|
+ position_x = (short)(((unsigned short)block[2] << 8) | (unsigned short)block[3]);
|
|
+ position_y = (short)(((unsigned short)block[4] << 8) | (unsigned short)block[5]);
|
|
}
|
|
}
|
|
|
|
diff --git a/snes/controller/mouse/mouse.hpp b/snes/controller/mouse/mouse.hpp
|
|
index b66ea51..6074f34 100755
|
|
--- a/snes/controller/mouse/mouse.hpp
|
|
+++ b/snes/controller/mouse/mouse.hpp
|
|
@@ -6,4 +6,6 @@ struct Mouse : Controller {
|
|
private:
|
|
bool latched;
|
|
unsigned counter;
|
|
+ int position_x;
|
|
+ int position_y;
|
|
};
|
|
--
|
|
1.7.9.48.g85da4d
|
|
|