diff options
author | Le Philousophe | 2019-06-01 17:52:50 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2019-06-01 22:43:48 +0200 |
commit | 475f9ea293331537c84cbc4d6f57647ba1820378 (patch) | |
tree | f7542fbe275a21aa34bb7a248fd9d071055945a5 /engines/cryomni3d | |
parent | e707e312da9979664c9a853457269c39e04e0aca (diff) | |
download | scummvm-rg350-475f9ea293331537c84cbc4d6f57647ba1820378.tar.gz scummvm-rg350-475f9ea293331537c84cbc4d6f57647ba1820378.tar.bz2 scummvm-rg350-475f9ea293331537c84cbc4d6f57647ba1820378.zip |
CRYOMNI3D: Fix missed clicks when occuring beteen two pollEvent
Diffstat (limited to 'engines/cryomni3d')
-rw-r--r-- | engines/cryomni3d/cryomni3d.cpp | 42 | ||||
-rw-r--r-- | engines/cryomni3d/cryomni3d.h | 3 |
2 files changed, 31 insertions, 14 deletions
diff --git a/engines/cryomni3d/cryomni3d.cpp b/engines/cryomni3d/cryomni3d.cpp index 9cabf543cb..b7d3a9d528 100644 --- a/engines/cryomni3d/cryomni3d.cpp +++ b/engines/cryomni3d/cryomni3d.cpp @@ -234,17 +234,44 @@ void CryOmni3DEngine::setCursor(uint cursorId) const { bool CryOmni3DEngine::pollEvents() { Common::Event event; + int buttonMask; bool hasEvents = false; - uint oldMouseButton = getCurrentMouseButton(); + // Don't take into transitional clicks for the drag + buttonMask = g_system->getEventManager()->getButtonState(); + uint oldMouseButton; + if (buttonMask & 0x1) { + oldMouseButton = 1; + } else if (buttonMask & 0x2) { + oldMouseButton = 2; + } else { + oldMouseButton = 0; + } + int transitionalMask = 0; while (g_system->getEventManager()->pollEvent(event)) { if (event.type == Common::EVENT_KEYDOWN) { _keysPressed.push(event.kbd); + } else if (event.type == Common::EVENT_LBUTTONDOWN) { + transitionalMask |= Common::EventManager::LBUTTON; + } else if (event.type == Common::EVENT_RBUTTONDOWN) { + transitionalMask |= Common::EventManager::RBUTTON; } hasEvents = true; } + // Merge current button state with any buttons pressed since last poll + // That's to avoid missed clicks + buttonMask = g_system->getEventManager()->getButtonState() | + transitionalMask; + if (buttonMask & 0x1) { + _lastMouseButton = 1; + } else if (buttonMask & 0x2) { + _lastMouseButton = 2; + } else { + _lastMouseButton = 0; + } + _dragStatus = kDragStatus_NoDrag; uint currentMouseButton = getCurrentMouseButton(); if (!oldMouseButton && currentMouseButton == 1) { @@ -281,19 +308,8 @@ void CryOmni3DEngine::setAutoRepeatClick(uint millis) { _autoRepeatNextEvent = g_system->getMillis() + millis; } -uint CryOmni3DEngine::getCurrentMouseButton() { - int mask = g_system->getEventManager()->getButtonState(); - if (mask & 0x1) { - return 1; - } else if (mask & 0x2) { - return 2; - } else { - return 0; - } -} - void CryOmni3DEngine::waitMouseRelease() { - while (g_system->getEventManager()->getButtonState() != 0 && !g_engine->shouldQuit()) { + while (getCurrentMouseButton() != 0 && !g_engine->shouldQuit()) { pollEvents(); g_system->updateScreen(); g_system->delayMillis(10); diff --git a/engines/cryomni3d/cryomni3d.h b/engines/cryomni3d/cryomni3d.h index 6d6faffda8..003d5080b0 100644 --- a/engines/cryomni3d/cryomni3d.h +++ b/engines/cryomni3d/cryomni3d.h @@ -117,7 +117,7 @@ public: bool pollEvents(); Common::Point getMousePos(); void setMousePos(const Common::Point &point); - uint getCurrentMouseButton(); + uint getCurrentMouseButton() { return _lastMouseButton; } Common::KeyState getNextKey(); bool checkKeysPressed(); bool checkKeysPressed(uint numKeys, ...); @@ -161,6 +161,7 @@ protected: DragStatus _dragStatus; Common::Point _dragStart; + uint _lastMouseButton; uint _autoRepeatNextEvent; private: |