1 From 863bde899b53ae31e854096ac5258208c848a293 Mon Sep 17 00:00:00 2001
2 From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
3 Date: Thu, 6 Mar 2014 21:07:54 +0200
4 Subject: [PATCH 15/23] Fix mouse speed support
7 snes/config/config.cpp | 1 +
8 snes/config/config.hpp | 3 +++
9 snes/controller/mouse/mouse.cpp | 11 +++++++++--
10 snes/controller/mouse/mouse.hpp | 1 +
11 4 files changed, 14 insertions(+), 2 deletions(-)
13 diff --git a/snes/config/config.cpp b/snes/config/config.cpp
14 index 206daae..1983137 100755
15 --- a/snes/config/config.cpp
16 +++ b/snes/config/config.cpp
17 @@ -8,6 +8,7 @@ Configuration::Configuration() {
18 expansion_port = System::ExpansionPortDevice::BSX;
19 region = System::Region::Autodetect;
21 + mouse_speed_fix = false;
24 cpu.ntsc_frequency = 21477272; //315 / 88 * 6000000
25 diff --git a/snes/config/config.hpp b/snes/config/config.hpp
26 index dabde59..68fe0bd 100755
27 --- a/snes/config/config.hpp
28 +++ b/snes/config/config.hpp
30 +#define BSNES_SUPPORTS_MOUSE_SPEED_FIX
32 struct Configuration {
33 Input::Device controller_port1;
34 Input::Device controller_port2;
35 System::ExpansionPortDevice expansion_port;
36 System::Region region;
38 + bool mouse_speed_fix;
42 diff --git a/snes/controller/mouse/mouse.cpp b/snes/controller/mouse/mouse.cpp
43 index 1a066b9..caa7a35 100755
44 --- a/snes/controller/mouse/mouse.cpp
45 +++ b/snes/controller/mouse/mouse.cpp
50 + if(config.mouse_speed_fix && latched) {
51 + speed = (speed + 1) % 3;
54 if(counter >= 32) return 1;
57 @@ -31,8 +35,8 @@ uint2 Mouse::data() {
59 case 8: return interface->inputPoll(port, Input::Device::Mouse, 0, (unsigned)Input::MouseID::Right);
60 case 9: return interface->inputPoll(port, Input::Device::Mouse, 0, (unsigned)Input::MouseID::Left);
61 - case 10: return 0; //speed (0 = slow, 1 = normal, 2 = fast, 3 = unused)
62 - case 11: return 0; // ||
63 + case 10: return speed >> 1; //speed (0 = slow, 1 = normal, 2 = fast, 3 = unused)
64 + case 11: return speed & 1; // ||
66 case 12: return 0; //signature
67 case 13: return 0; // ||
68 @@ -75,10 +79,12 @@ void Mouse::serialize(serializer& s) {
69 block[3] = (unsigned short)_position_x;
70 block[4] = (unsigned short)_position_y >> 8;
71 block[5] = (unsigned short)_position_y;
73 s.array(block, Controller::SaveSize);
74 if(s.mode() == nall::serializer::Load) {
75 latched = (block[0] != 0);
78 _position_x = (short)(((unsigned short)block[2] << 8) | (unsigned short)block[3]);
79 _position_y = (short)(((unsigned short)block[4] << 8) | (unsigned short)block[5]);
81 @@ -87,6 +93,7 @@ void Mouse::serialize(serializer& s) {
82 Mouse::Mouse(bool port) : Controller(port) {
89 diff --git a/snes/controller/mouse/mouse.hpp b/snes/controller/mouse/mouse.hpp
90 index b07c8ab..13a9313 100755
91 --- a/snes/controller/mouse/mouse.hpp
92 +++ b/snes/controller/mouse/mouse.hpp
93 @@ -6,6 +6,7 @@ struct Mouse : Controller {