From 12e226922d3f62ab55bd921f712a0be8f04497c0 Mon Sep 17 00:00:00 2001 From: rsn8887 Date: Wed, 1 Mar 2017 09:55:20 -0600 Subject: SDL: Always use sub-pixel joystick pointer resolution --- backends/events/androidsdl/androidsdl-events.cpp | 3 +++ backends/events/gph/gph-events.cpp | 6 +++++ backends/events/openpandora/op-events.cpp | 6 +++++ backends/events/sdl/sdl-events.cpp | 19 +++++++-------- backends/events/symbiansdl/symbiansdl-events.cpp | 4 ++++ backends/events/webossdl/webossdl-events.cpp | 30 ++++++++++++++++++++++++ backends/events/wincesdl/wincesdl-events.cpp | 11 ++++++++- 7 files changed, 68 insertions(+), 11 deletions(-) diff --git a/backends/events/androidsdl/androidsdl-events.cpp b/backends/events/androidsdl/androidsdl-events.cpp index 125f411289..0282b23a7a 100644 --- a/backends/events/androidsdl/androidsdl-events.cpp +++ b/backends/events/androidsdl/androidsdl-events.cpp @@ -50,6 +50,9 @@ bool AndroidSdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event & return false; processMouseEvent(event, ev.button.x, ev.button.y); + // update KbdMouse + _km.x = ev.button.x * MULTIPLIER; + _km.y = ev.button.y * MULTIPLIER; return true; } diff --git a/backends/events/gph/gph-events.cpp b/backends/events/gph/gph-events.cpp index d59d0bead5..a720ded0f2 100644 --- a/backends/events/gph/gph-events.cpp +++ b/backends/events/gph/gph-events.cpp @@ -191,6 +191,9 @@ bool GPHEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) return false; processMouseEvent(event, ev.button.x, ev.button.y); + // update KbdMouse + _km.x = ev.button.x * MULTIPLIER; + _km.y = ev.button.y * MULTIPLIER; return true; } @@ -217,6 +220,9 @@ bool GPHEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) { return false; processMouseEvent(event, ev.button.x, ev.button.y); + // update KbdMouse + _km.x = ev.button.x * MULTIPLIER; + _km.y = ev.button.y * MULTIPLIER; return true; } diff --git a/backends/events/openpandora/op-events.cpp b/backends/events/openpandora/op-events.cpp index abb1458d66..80fff20bc2 100644 --- a/backends/events/openpandora/op-events.cpp +++ b/backends/events/openpandora/op-events.cpp @@ -84,6 +84,9 @@ bool OPEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) { return false; processMouseEvent(event, ev.button.x, ev.button.y); + // update KbdMouse + _km.x = ev.button.x * MULTIPLIER; + _km.y = ev.button.y * MULTIPLIER; return true; } @@ -112,6 +115,9 @@ bool OPEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) { return false; processMouseEvent(event, ev.button.x, ev.button.y); + // update KbdMouse + _km.x = ev.button.x * MULTIPLIER; + _km.y = ev.button.y * MULTIPLIER; return true; } diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index 9a9d652dce..a1657468a8 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -177,10 +177,6 @@ void SdlEventSource::processMouseEvent(Common::Event &event, int x, int y) { _graphicsManager->notifyMousePos(Common::Point(x, y)); _graphicsManager->transformMouseCoordinates(event.mouse); } - - // Update the "keyboard mouse" coords - _km.x = x * MULTIPLIER; - _km.y = y * MULTIPLIER; } bool SdlEventSource::handleKbdMouse(Common::Event &event) { @@ -311,14 +307,8 @@ bool SdlEventSource::handleKbdMouse(Common::Event &event) { } if (_km.x != oldKmX || _km.y != oldKmY) { - // keep hi-res coordinates since - // processMouseEvent will overwrite them with lo-res numbers - oldKmX = _km.x; - oldKmY = _km.y; event.type = Common::EVENT_MOUSEMOVE; processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); - _km.x = oldKmX; - _km.y = oldKmY; return true; } } @@ -745,6 +735,9 @@ bool SdlEventSource::handleKeyUp(SDL_Event &ev, Common::Event &event) { bool SdlEventSource::handleMouseMotion(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_MOUSEMOVE; processMouseEvent(event, ev.motion.x, ev.motion.y); + // update KbdMouse + _km.x = ev.motion.x * MULTIPLIER; + _km.y = ev.motion.y * MULTIPLIER; return true; } @@ -768,6 +761,9 @@ bool SdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) return false; processMouseEvent(event, ev.button.x, ev.button.y); + // update KbdMouse + _km.x = ev.button.x * MULTIPLIER; + _km.y = ev.button.y * MULTIPLIER; return true; } @@ -784,6 +780,9 @@ bool SdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) { else return false; processMouseEvent(event, ev.button.x, ev.button.y); + // update KbdMouse + _km.x = ev.button.x * MULTIPLIER; + _km.y = ev.button.y * MULTIPLIER; return true; } diff --git a/backends/events/symbiansdl/symbiansdl-events.cpp b/backends/events/symbiansdl/symbiansdl-events.cpp index 9272cbaf9d..4649f9f90a 100644 --- a/backends/events/symbiansdl/symbiansdl-events.cpp +++ b/backends/events/symbiansdl/symbiansdl-events.cpp @@ -133,6 +133,10 @@ bool SymbianSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { _currentZone = 0; event.type = Common::EVENT_MOUSEMOVE; processMouseEvent(event, _mouseXZone[_currentZone], _mouseYZone[_currentZone]); + // update KbdMouse + _km.x = _mouseXZone[_currentZone] * MULTIPLIER; + _km.y = _mouseYZone[_currentZone] * MULTIPLIER; + if (_graphicsManager) { _graphicsManager->getWindow()->warpMouseInWindow(event.mouse.x, event.mouse.y); } diff --git a/backends/events/webossdl/webossdl-events.cpp b/backends/events/webossdl/webossdl-events.cpp index 72106789a5..8f124f2f2d 100644 --- a/backends/events/webossdl/webossdl-events.cpp +++ b/backends/events/webossdl/webossdl-events.cpp @@ -150,6 +150,9 @@ bool WebOSSdlEventSource::handleMouseButtonDown(SDL_Event &ev, _dragging = true; event.type = Common::EVENT_LBUTTONDOWN; processMouseEvent(event, _curX, _curY); + // update KbdMouse + _km.x = _curX * MULTIPLIER; + _km.y = _curY * MULTIPLIER; } // If we're not in trackpad mode, move the cursor to the tap if (!_trackpadMode) { @@ -158,11 +161,17 @@ bool WebOSSdlEventSource::handleMouseButtonDown(SDL_Event &ev, // If we're already clicking, hold it until after the move. if (event.type == Common::EVENT_LBUTTONDOWN) { processMouseEvent(event, _curX, _curY); + // update KbdMouse + _km.x = _curX * MULTIPLIER; + _km.y = _curY * MULTIPLIER; g_system->getEventManager()->pushEvent(event); } // Move the mouse event.type = Common::EVENT_MOUSEMOVE; processMouseEvent(event, _curX, _curY); + // update KbdMouse + _km.x = _curX * MULTIPLIER; + _km.y = _curY * MULTIPLIER; } // Watch for a double-tap-triggered drag _dragStartTime = g_system->getMillis(); @@ -191,6 +200,9 @@ bool WebOSSdlEventSource::handleMouseButtonUp(SDL_Event &ev, if (ev.button.which == 0 && _dragging) { event.type = Common::EVENT_LBUTTONUP; processMouseEvent(event, _curX, _curY); + // update KbdMouse + _km.x = _curX * MULTIPLIER; + _km.y = _curY * MULTIPLIER; _dragging = false; } else { // If it was the first finger and the click hasn't been @@ -199,6 +211,9 @@ bool WebOSSdlEventSource::handleMouseButtonUp(SDL_Event &ev, !_fingerDown[1] && !_fingerDown[2]) { event.type = Common::EVENT_LBUTTONUP; processMouseEvent(event, _curX, _curY); + // update KbdMouse + _km.x = _curX * MULTIPLIER; + _km.y = _curY * MULTIPLIER; g_system->getEventManager()->pushEvent(event); event.type = Common::EVENT_LBUTTONDOWN; if (_queuedDragTime > 0) @@ -209,6 +224,9 @@ bool WebOSSdlEventSource::handleMouseButtonUp(SDL_Event &ev, // right mouse click. event.type = Common::EVENT_RBUTTONDOWN; processMouseEvent(event, _curX, _curY); + // update KbdMouse + _km.x = _curX * MULTIPLIER; + _km.y = _curY * MULTIPLIER; _queuedRUpTime = g_system->getMillis() + QUEUED_RUP_DELAY; } else if (ev.button.which == 2 && _fingerDown[0] && _fingerDown[1]) { @@ -217,6 +235,9 @@ bool WebOSSdlEventSource::handleMouseButtonUp(SDL_Event &ev, // as a right click. event.type = Common::EVENT_MBUTTONUP; processMouseEvent(event, _curX, _curY); + // update KbdMouse + _km.x = _curX * MULTIPLIER; + _km.y = _curY * MULTIPLIER; g_system->getEventManager()->pushEvent(event); event.type = Common::EVENT_MBUTTONDOWN; _fingerDown[1] = false; @@ -263,6 +284,9 @@ bool WebOSSdlEventSource::handleMouseMotion(SDL_Event &ev, } event.type = Common::EVENT_MOUSEMOVE; processMouseEvent(event, _curX, _curY); + // update KbdMouse + _km.x = _curX * MULTIPLIER; + _km.y = _curY * MULTIPLIER; } break; case 1: @@ -407,12 +431,18 @@ bool WebOSSdlEventSource::pollEvent(Common::Event &event) { } else if (_queuedRUpTime != 0 && curTime >= _queuedRUpTime) { event.type = Common::EVENT_RBUTTONUP; processMouseEvent(event, _curX, _curY); + // update KbdMouse + _km.x = _curX * MULTIPLIER; + _km.y = _curY * MULTIPLIER; _queuedRUpTime = 0; return true; } else if (_queuedDragTime != 0 && curTime >= _queuedDragTime) { event.type = Common::EVENT_LBUTTONDOWN; _dragging = true; processMouseEvent(event, _curX, _curY); + // update KbdMouse + _km.x = _curX * MULTIPLIER; + _km.y = _curY * MULTIPLIER; _queuedDragTime = 0; return true; } diff --git a/backends/events/wincesdl/wincesdl-events.cpp b/backends/events/wincesdl/wincesdl-events.cpp index 7001d5fec6..c949d1c41c 100644 --- a/backends/events/wincesdl/wincesdl-events.cpp +++ b/backends/events/wincesdl/wincesdl-events.cpp @@ -156,6 +156,10 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) { case SDL_MOUSEMOTION: event.type = Common::EVENT_MOUSEMOVE; processMouseEvent(event, ev.motion.x, ev.motion.y); + // update KbdMouse + _km.x = ev.motion.x * MULTIPLIER; + _km.y = ev.motion.y * MULTIPLIER; + _graphicsMan->setMousePos(event.mouse.x, event.mouse.y); return true; @@ -168,7 +172,9 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) { else break; processMouseEvent(event, ev.button.x, ev.button.y); - + // update KbdMouse + _km.x = ev.button.x * MULTIPLIER; + _km.y = ev.button.y * MULTIPLIER; if (event.mouse.x > _tapX) deltaX = event.mouse.x - _tapX; @@ -244,6 +250,9 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) { } processMouseEvent(event, ev.button.x, ev.button.y); + // update KbdMouse + _km.x = ev.button.x * MULTIPLIER; + _km.y = ev.button.y * MULTIPLIER; if (freeLookActive && !_closeClick) { _tapX = event.mouse.x; -- cgit v1.2.3