From 601e1d486b038f121323e78ed68a154d6763c9f1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 9 Nov 2018 20:27:14 -0800 Subject: GLK: Add GLK timer intervals --- engines/gargoyle/events.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'engines/gargoyle/events.cpp') diff --git a/engines/gargoyle/events.cpp b/engines/gargoyle/events.cpp index bc56407ee8..520b6f22e5 100644 --- a/engines/gargoyle/events.cpp +++ b/engines/gargoyle/events.cpp @@ -53,8 +53,8 @@ const byte ARROW[] = { 4, 2, 5, 5 }; -Events::Events() : _forceClick(false), _currentEvent(nullptr), _timeouts(false), - _priorFrameTime(0), _frameCounter(0), _cursorId(CURSOR_NONE) { +Events::Events() : _forceClick(false), _currentEvent(nullptr), _cursorId(CURSOR_NONE), + _timerMilli(0), _timerTimeExpiry(0), _priorFrameTime(0), _frameCounter(0) { initializeCursors(); } @@ -118,7 +118,7 @@ void Events::getEvent(event_t *event, bool polled) { dispatchEvent(*_currentEvent, polled); if (!polled) { - while (!g_vm->shouldQuit() && _currentEvent->type == evtype_None && !_timeouts) { + while (!g_vm->shouldQuit() && _currentEvent->type == evtype_None && !isTimerExpired()) { pollEvents(); g_system->delayMillis(10); @@ -129,10 +129,11 @@ void Events::getEvent(event_t *event, bool polled) { _currentEvent->type = evtype_Quit; } - if (_currentEvent->type == evtype_None && _timeouts) { + if (_currentEvent->type == evtype_None && isTimerExpired()) { store(evtype_Timer, nullptr, 0, 0); dispatchEvent(*_currentEvent, polled); - _timeouts = false; + + _timerTimeExpiry = g_system->getMillis() + _timerMilli; } _currentEvent = nullptr; @@ -338,4 +339,13 @@ void Events::setCursor(CursorId cursorId) { } } +void Events::setTimerInterval(uint milli) { + _timerMilli = milli; + _timerTimeExpiry = g_system->getMillis() + milli; +} + +bool Events::isTimerExpired() const { + return _timerMilli && g_system->getMillis() >= _timerTimeExpiry; +} + } // End of namespace Gargoyle -- cgit v1.2.3