aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsn88872017-02-10 11:20:59 -0600
committerThierry Crozat2017-02-14 23:05:34 +0000
commitfb50d5934d982d5670233d0455f76cb73ccdaa27 (patch)
tree056e07ce9f692f13fef3aafc602c57c5b79f6578
parent8c13a263aef01e191ab4b031210186553025cf53 (diff)
downloadscummvm-rg350-fb50d5934d982d5670233d0455f76cb73ccdaa27.tar.gz
scummvm-rg350-fb50d5934d982d5670233d0455f76cb73ccdaa27.tar.bz2
scummvm-rg350-fb50d5934d982d5670233d0455f76cb73ccdaa27.zip
SDL: Fix jerky/laggy analog joystick mouse control
This fixes bug 6996: Android: Mouse pointer control with analog joystick is unusable
-rw-r--r--backends/events/sdl/sdl-events.cpp15
-rw-r--r--backends/events/sdl/sdl-events.h2
-rw-r--r--backends/events/wincesdl/wincesdl-events.cpp2
3 files changed, 15 insertions, 4 deletions
diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp
index 5fb66a7ec4..832fa36153 100644
--- a/backends/events/sdl/sdl-events.cpp
+++ b/backends/events/sdl/sdl-events.cpp
@@ -179,11 +179,16 @@ void SdlEventSource::processMouseEvent(Common::Event &event, int x, int y) {
_km.y = y;
}
-void SdlEventSource::handleKbdMouse() {
+void SdlEventSource::handleKbdMouse(Common::Event &event) {
+
// Skip recording of these events
uint32 curTime = g_system->getMillis(true);
if (curTime >= _km.last_time + _km.delay_time) {
+
+ int16 oldKmX = _km.x;
+ int16 oldKmY = _km.y;
+
_km.last_time = curTime;
if (_km.x_down_count == 1) {
_km.x_down_time = curTime;
@@ -248,6 +253,11 @@ void SdlEventSource::handleKbdMouse() {
if (_graphicsManager) {
_graphicsManager->getWindow()->warpMouseInWindow((Uint16)_km.x, (Uint16)_km.y);
}
+
+ if (_km.x != oldKmX || _km.y != oldKmY) {
+ event.type = Common::EVENT_MOUSEMOVE;
+ processMouseEvent(event, _km.x, _km.y);
+ }
}
}
}
@@ -425,7 +435,8 @@ Common::KeyCode SdlEventSource::SDLToOSystemKeycode(const SDLKey key) {
}
bool SdlEventSource::pollEvent(Common::Event &event) {
- handleKbdMouse();
+ handleKbdMouse(event);
+
#if SDL_VERSION_ATLEAST(2, 0, 0)
// In case we still need to send a key up event for a key down from a
diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h
index c43699420b..032ad723eb 100644
--- a/backends/events/sdl/sdl-events.h
+++ b/backends/events/sdl/sdl-events.h
@@ -106,7 +106,7 @@ protected:
virtual bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event);
virtual bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event);
virtual bool handleJoyAxisMotion(SDL_Event &ev, Common::Event &event);
- virtual void handleKbdMouse();
+ virtual void handleKbdMouse(Common::Event &event);
//@}
diff --git a/backends/events/wincesdl/wincesdl-events.cpp b/backends/events/wincesdl/wincesdl-events.cpp
index d3141ee50c..2fcd79490c 100644
--- a/backends/events/wincesdl/wincesdl-events.cpp
+++ b/backends/events/wincesdl/wincesdl-events.cpp
@@ -69,7 +69,7 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
memset(&event, 0, sizeof(Common::Event));
- handleKbdMouse();
+ handleKbdMouse(event);
// If the screen changed, send an Common::EVENT_SCREEN_CHANGED
int screenID = _graphicsMan->getScreenChangeID();