aboutsummaryrefslogtreecommitdiff
path: root/backends/events/sdl/sdl-events.cpp
diff options
context:
space:
mode:
authorBastien Bouclet2018-01-27 18:20:47 +0100
committerGitHub2018-01-27 18:20:47 +0100
commit1b0ffaf31104e086ae4735447beab78f37626fd8 (patch)
treebd701d678662371c8ea886367a4c0d0904282a7e /backends/events/sdl/sdl-events.cpp
parent949ca448bd4f03d397c4dc467e5447b4c728936d (diff)
parent49a48cedea2c82d2774fdec0f6d55ab8e9b91a4c (diff)
downloadscummvm-rg350-1b0ffaf31104e086ae4735447beab78f37626fd8.tar.gz
scummvm-rg350-1b0ffaf31104e086ae4735447beab78f37626fd8.tar.bz2
scummvm-rg350-1b0ffaf31104e086ae4735447beab78f37626fd8.zip
Merge pull request #1111 from bgK/gamepad-scale-mouse-speed-with-resolution
SDL: Scale the joystick mouse speed with the vertical window size
Diffstat (limited to 'backends/events/sdl/sdl-events.cpp')
-rw-r--r--backends/events/sdl/sdl-events.cpp86
1 files changed, 46 insertions, 40 deletions
diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp
index a3dee67f22..a3c0087b94 100644
--- a/backends/events/sdl/sdl-events.cpp
+++ b/backends/events/sdl/sdl-events.cpp
@@ -212,46 +212,7 @@ bool SdlEventSource::handleKbdMouse(Common::Event &event) {
}
}
- int16 speedFactor = 25;
-
- if (g_system->hasFeature(OSystem::kFeatureKbdMouseSpeed)) {
- switch (ConfMan.getInt("kbdmouse_speed")) {
- // 0.25 keyboard pointer speed
- case 0:
- speedFactor = 100;
- break;
- // 0.5 speed
- case 1:
- speedFactor = 50;
- break;
- // 0.75 speed
- case 2:
- speedFactor = 33;
- break;
- // 1.0 speed
- case 3:
- speedFactor = 25;
- break;
- // 1.25 speed
- case 4:
- speedFactor = 20;
- break;
- // 1.5 speed
- case 5:
- speedFactor = 17;
- break;
- // 1.75 speed
- case 6:
- speedFactor = 14;
- break;
- // 2.0 speed
- case 7:
- speedFactor = 12;
- break;
- default:
- speedFactor = 25;
- }
- }
+ int16 speedFactor = computeJoystickMouseSpeedFactor();
// - The modifier key makes the mouse movement slower
// - The extra factor "delay/speedFactor" ensures velocities
@@ -300,6 +261,51 @@ bool SdlEventSource::handleKbdMouse(Common::Event &event) {
return false;
}
+int16 SdlEventSource::computeJoystickMouseSpeedFactor() const {
+ int16 speedFactor;
+
+ switch (ConfMan.getInt("kbdmouse_speed")) {
+ // 0.25 keyboard pointer speed
+ case 0:
+ speedFactor = 100;
+ break;
+ // 0.5 speed
+ case 1:
+ speedFactor = 50;
+ break;
+ // 0.75 speed
+ case 2:
+ speedFactor = 33;
+ break;
+ // 1.0 speed
+ case 3:
+ speedFactor = 25;
+ break;
+ // 1.25 speed
+ case 4:
+ speedFactor = 20;
+ break;
+ // 1.5 speed
+ case 5:
+ speedFactor = 17;
+ break;
+ // 1.75 speed
+ case 6:
+ speedFactor = 14;
+ break;
+ // 2.0 speed
+ case 7:
+ speedFactor = 12;
+ break;
+ default:
+ speedFactor = 25;
+ }
+
+ // Scale the mouse cursor speed with the display size so moving across
+ // the screen takes a reasonable amount of time at higher resolutions.
+ return speedFactor * 480 / _km.y_max;
+}
+
void SdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) {
event.kbd.flags = 0;