diff options
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: |