From dc0bfbc7241c0085f5dabb80b051f82b77187952 Mon Sep 17 00:00:00 2001 From: Le Philousophe Date: Tue, 21 May 2019 17:42:55 +0200 Subject: COMMON: Fix button state desynchronization when warping mouse --- backends/events/default/default-events.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index 85cf44c960..86c56eadd2 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -281,15 +281,32 @@ void DefaultEventManager::purgeMouseEvents() { while (!_eventQueue.empty()) { Common::Event event = _eventQueue.pop(); switch (event.type) { - case Common::EVENT_MOUSEMOVE: + // Update button state even when purging events to avoid desynchronisation with real button state case Common::EVENT_LBUTTONDOWN: + _mousePos = event.mouse; + _buttonState |= LBUTTON; + break; + case Common::EVENT_LBUTTONUP: + _mousePos = event.mouse; + _buttonState &= ~LBUTTON; + break; + case Common::EVENT_RBUTTONDOWN: + _mousePos = event.mouse; + _buttonState |= RBUTTON; + break; + case Common::EVENT_RBUTTONUP: + _mousePos = event.mouse; + _buttonState &= ~RBUTTON; + break; + case Common::EVENT_WHEELUP: case Common::EVENT_WHEELDOWN: case Common::EVENT_MBUTTONDOWN: case Common::EVENT_MBUTTONUP: + case Common::EVENT_MOUSEMOVE: // do nothing break; default: -- cgit v1.2.3