mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-15 08:39:45 +00:00
CRYOMNI3D: Fix missed clicks when occuring beteen two pollEvent
This commit is contained in:
parent
e707e312da
commit
475f9ea293
@ -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);
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user