diff options
author | Bastien Bouclet | 2017-12-19 06:18:24 +0100 |
---|---|---|
committer | Bastien Bouclet | 2017-12-26 21:11:04 +0100 |
commit | 1fb748e97480dc64ed27ebe75490c1b938cdbed4 (patch) | |
tree | bcf5ab6212c83878fe8bb92a742a1695de3e5f09 /backends/events | |
parent | 6fb50d562f9716a930ecb4fe3d20047d506e4ed5 (diff) | |
download | scummvm-rg350-1fb748e97480dc64ed27ebe75490c1b938cdbed4.tar.gz scummvm-rg350-1fb748e97480dc64ed27ebe75490c1b938cdbed4.tar.bz2 scummvm-rg350-1fb748e97480dc64ed27ebe75490c1b938cdbed4.zip |
SDL: Move the non analog joystick code to the Symbian port
Symbian was the only user of that code.
Diffstat (limited to 'backends/events')
-rw-r--r-- | backends/events/psp2sdl/psp2sdl-events.cpp | 1 | ||||
-rw-r--r-- | backends/events/sdl/sdl-events.cpp | 38 | ||||
-rw-r--r-- | backends/events/sdl/sdl-events.h | 2 | ||||
-rw-r--r-- | backends/events/symbiansdl/symbiansdl-events.cpp | 36 | ||||
-rw-r--r-- | backends/events/symbiansdl/symbiansdl-events.h | 2 |
5 files changed, 39 insertions, 40 deletions
diff --git a/backends/events/psp2sdl/psp2sdl-events.cpp b/backends/events/psp2sdl/psp2sdl-events.cpp index e58e49d9a8..f5554599d6 100644 --- a/backends/events/psp2sdl/psp2sdl-events.cpp +++ b/backends/events/psp2sdl/psp2sdl-events.cpp @@ -37,7 +37,6 @@ #include "math.h" #define JOY_DEADZONE 2000 -#define JOY_ANALOG #define JOY_XAXIS 0 #define JOY_YAXIS 1 #define JOY_XAXISR 2 diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index 09530675c4..6d48b8d372 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -30,18 +30,10 @@ #include "common/config-manager.h" #include "common/textconsole.h" -#ifdef JOY_ANALOG -#include "math.h" -#endif - // FIXME move joystick defines out and replace with confile file options // we should really allow users to map any key to a joystick button #define JOY_DEADZONE 3200 -#ifndef __SYMBIAN32__ // Symbian wants dialog joystick i.e cursor for movement/selection - #define JOY_ANALOG -#endif - // #define JOY_INVERT_Y #define JOY_XAXIS 0 #define JOY_YAXIS 1 @@ -1023,7 +1015,6 @@ bool SdlEventSource::handleAxisToMouseMotion(int16 xAxis, int16 yAxis) { yAxis = -yAxis; #endif -#ifdef JOY_ANALOG // conversion factor between keyboard mouse and joy axis value int vel_to_axis = (1500 / MULTIPLIER); @@ -1047,35 +1038,6 @@ bool SdlEventSource::handleAxisToMouseMotion(int16 xAxis, int16 yAxis) { _km.x_vel = 0; _km.y_vel = 0; } -#else - if (xAxis > JOY_DEADZONE) { - xAxis -= JOY_DEADZONE; - } else if (xAxis < -JOY_DEADZONE) { - xAxis += JOY_DEADZONE; - } else - xAxis = 0; - if (yAxis > JOY_DEADZONE) { - yAxis -= JOY_DEADZONE; - } else if (yAxis < -JOY_DEADZONE) { - yAxis += JOY_DEADZONE; - } else - yAxis = 0; - - if (xAxis != 0) { - _km.x_vel = (xAxis > 0) ? 1 * MULTIPLIER:-1 * MULTIPLIER; - _km.x_down_count = 1; - } else { - _km.x_vel = 0; - _km.x_down_count = 0; - } - if (yAxis != 0) { - _km.y_vel = (yAxis > 0) ? 1 * MULTIPLIER: -1 * MULTIPLIER; - _km.y_down_count = 1; - } else { - _km.y_vel = 0; - _km.y_down_count = 0; - } -#endif return false; } diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h index cea944fb1a..33d971a605 100644 --- a/backends/events/sdl/sdl-events.h +++ b/backends/events/sdl/sdl-events.h @@ -132,7 +132,7 @@ protected: /** * Update the virtual mouse according to a joystick or game controller axis position change */ - bool handleAxisToMouseMotion(int16 xAxis, int16 yAxis); + virtual bool handleAxisToMouseMotion(int16 xAxis, int16 yAxis); /** * Assigns the mouse coords to the mouse event. Furthermore notify the diff --git a/backends/events/symbiansdl/symbiansdl-events.cpp b/backends/events/symbiansdl/symbiansdl-events.cpp index 4649f9f90a..0ae5824681 100644 --- a/backends/events/symbiansdl/symbiansdl-events.cpp +++ b/backends/events/symbiansdl/symbiansdl-events.cpp @@ -31,6 +31,8 @@ #include <bautils.h> +#define JOY_DEADZONE 3200 + SymbianSdlEventSource::zoneDesc SymbianSdlEventSource::_zones[TOTAL_ZONES] = { { 0, 0, 320, 145 }, { 0, 145, 150, 55 }, @@ -200,4 +202,38 @@ bool SymbianSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { return false; } +bool SymbianSdlEventSource::handleAxisToMouseMotion(int16 xAxis, int16 yAxis) { + // Symbian wants dialog joystick i.e cursor for movement/selection + + if (xAxis > JOY_DEADZONE) { + xAxis -= JOY_DEADZONE; + } else if (xAxis < -JOY_DEADZONE) { + xAxis += JOY_DEADZONE; + } else + xAxis = 0; + if (yAxis > JOY_DEADZONE) { + yAxis -= JOY_DEADZONE; + } else if (yAxis < -JOY_DEADZONE) { + yAxis += JOY_DEADZONE; + } else + yAxis = 0; + + if (xAxis != 0) { + _km.x_vel = (xAxis > 0) ? 1 * MULTIPLIER:-1 * MULTIPLIER; + _km.x_down_count = 1; + } else { + _km.x_vel = 0; + _km.x_down_count = 0; + } + if (yAxis != 0) { + _km.y_vel = (yAxis > 0) ? 1 * MULTIPLIER: -1 * MULTIPLIER; + _km.y_down_count = 1; + } else { + _km.y_vel = 0; + _km.y_down_count = 0; + } + + return false; +} + #endif diff --git a/backends/events/symbiansdl/symbiansdl-events.h b/backends/events/symbiansdl/symbiansdl-events.h index 2664bc267d..0393e398f0 100644 --- a/backends/events/symbiansdl/symbiansdl-events.h +++ b/backends/events/symbiansdl/symbiansdl-events.h @@ -50,6 +50,8 @@ protected: static zoneDesc _zones[TOTAL_ZONES]; virtual bool remapKey(SDL_Event &ev, Common::Event &event); + + virtual bool handleAxisToMouseMotion(int16 xAxis, int16 yAxis); }; #endif |