mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-01 15:09:47 +00:00
TITANIC: Improve performance of event handling
This commit is contained in:
parent
06e1445fd1
commit
e8e7266214
@ -34,66 +34,76 @@ Events::Events(TitanicEngine *vm): _vm(vm), _frameCounter(1),
|
|||||||
_totalFrames(0), _priorFrameTime(0), _specialButtons(0) {
|
_totalFrames(0), _priorFrameTime(0), _specialButtons(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MOVE_CHECK if (moved) eventTarget()->mouseMove(_mousePos)
|
||||||
|
|
||||||
void Events::pollEvents() {
|
void Events::pollEvents() {
|
||||||
checkForNextFrameCounter();
|
checkForNextFrameCounter();
|
||||||
|
|
||||||
|
bool moved = false;
|
||||||
Common::Event event;
|
Common::Event event;
|
||||||
if (!g_system->getEventManager()->pollEvent(event))
|
while (!_vm->shouldQuit() && g_system->getEventManager()->pollEvent(event)) {
|
||||||
return;
|
if (event.type != Common::EVENT_MOUSEMOVE) {
|
||||||
|
MOVE_CHECK;
|
||||||
|
}
|
||||||
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case Common::EVENT_MOUSEMOVE:
|
case Common::EVENT_MOUSEMOVE:
|
||||||
_mousePos = event.mouse;
|
_mousePos = event.mouse;
|
||||||
eventTarget()->mouseMove(_mousePos);
|
moved = true;
|
||||||
break;
|
break;
|
||||||
case Common::EVENT_LBUTTONDOWN:
|
case Common::EVENT_LBUTTONDOWN:
|
||||||
_specialButtons |= MK_LBUTTON;
|
_specialButtons |= MK_LBUTTON;
|
||||||
_mousePos = event.mouse;
|
_mousePos = event.mouse;
|
||||||
eventTarget()->leftButtonDown(_mousePos);
|
eventTarget()->leftButtonDown(_mousePos);
|
||||||
break;
|
return;
|
||||||
case Common::EVENT_LBUTTONUP:
|
case Common::EVENT_LBUTTONUP:
|
||||||
_specialButtons &= ~MK_LBUTTON;
|
_specialButtons &= ~MK_LBUTTON;
|
||||||
_mousePos = event.mouse;
|
_mousePos = event.mouse;
|
||||||
eventTarget()->leftButtonUp(_mousePos);
|
eventTarget()->leftButtonUp(_mousePos);
|
||||||
break;
|
return;
|
||||||
case Common::EVENT_MBUTTONDOWN:
|
case Common::EVENT_MBUTTONDOWN:
|
||||||
_specialButtons |= MK_MBUTTON;
|
_specialButtons |= MK_MBUTTON;
|
||||||
_mousePos = event.mouse;
|
_mousePos = event.mouse;
|
||||||
eventTarget()->middleButtonDown(_mousePos);
|
eventTarget()->middleButtonDown(_mousePos);
|
||||||
break;
|
return;
|
||||||
case Common::EVENT_MBUTTONUP:
|
case Common::EVENT_MBUTTONUP:
|
||||||
_specialButtons &= ~MK_MBUTTON;
|
_specialButtons &= ~MK_MBUTTON;
|
||||||
_mousePos = event.mouse;
|
_mousePos = event.mouse;
|
||||||
eventTarget()->middleButtonUp(_mousePos);
|
eventTarget()->middleButtonUp(_mousePos);
|
||||||
break;
|
return;
|
||||||
case Common::EVENT_RBUTTONDOWN:
|
case Common::EVENT_RBUTTONDOWN:
|
||||||
_specialButtons |= MK_RBUTTON;
|
_specialButtons |= MK_RBUTTON;
|
||||||
_mousePos = event.mouse;
|
_mousePos = event.mouse;
|
||||||
eventTarget()->rightButtonDown(_mousePos);
|
eventTarget()->rightButtonDown(_mousePos);
|
||||||
break;
|
return;
|
||||||
case Common::EVENT_RBUTTONUP:
|
case Common::EVENT_RBUTTONUP:
|
||||||
_specialButtons &= ~MK_RBUTTON;
|
_specialButtons &= ~MK_RBUTTON;
|
||||||
_mousePos = event.mouse;
|
_mousePos = event.mouse;
|
||||||
eventTarget()->rightButtonUp(_mousePos);
|
eventTarget()->rightButtonUp(_mousePos);
|
||||||
break;
|
return;
|
||||||
case Common::EVENT_WHEELUP:
|
case Common::EVENT_WHEELUP:
|
||||||
case Common::EVENT_WHEELDOWN:
|
case Common::EVENT_WHEELDOWN:
|
||||||
_mousePos = event.mouse;
|
_mousePos = event.mouse;
|
||||||
eventTarget()->mouseWheel(_mousePos, event.type == Common::EVENT_WHEELUP);
|
eventTarget()->mouseWheel(_mousePos, event.type == Common::EVENT_WHEELUP);
|
||||||
break;
|
return;
|
||||||
case Common::EVENT_KEYDOWN:
|
case Common::EVENT_KEYDOWN:
|
||||||
handleKbdSpecial(event.kbd);
|
handleKbdSpecial(event.kbd);
|
||||||
eventTarget()->keyDown(event.kbd);
|
eventTarget()->keyDown(event.kbd);
|
||||||
break;
|
return;
|
||||||
case Common::EVENT_KEYUP:
|
case Common::EVENT_KEYUP:
|
||||||
handleKbdSpecial(event.kbd);
|
handleKbdSpecial(event.kbd);
|
||||||
eventTarget()->keyUp(event.kbd);
|
eventTarget()->keyUp(event.kbd);
|
||||||
break;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MOVE_CHECK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef MOVE_CHECK
|
||||||
|
|
||||||
void Events::pollEventsAndWait() {
|
void Events::pollEventsAndWait() {
|
||||||
pollEvents();
|
pollEvents();
|
||||||
g_system->delayMillis(10);
|
g_system->delayMillis(10);
|
||||||
|
Loading…
Reference in New Issue
Block a user