diff options
Diffstat (limited to 'engines/access/events.cpp')
-rw-r--r-- | engines/access/events.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 87e5d10cc3..60073e6030 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -45,6 +45,7 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) { _mouseCol = _mouseRow = 0; _cursorExitFlag = false; _vbCount = 0; + _keyCode = Common::KEYCODE_INVALID; } EventsManager::~EventsManager() { @@ -141,7 +142,7 @@ void EventsManager::pollEvents(bool skipTimers) { _vm->_debugger->attach(); _vm->_debugger->onFrame(); } else { - _keypresses.push(event.kbd); + keyControl(event.kbd.keycode); } return; case Common::EVENT_KEYUP: @@ -181,6 +182,11 @@ void EventsManager::pollEvents(bool skipTimers) { } } +void EventsManager::keyControl(Common::KeyCode keycode) { + _keyCode = keycode; + // TODO: Keypress handling +} + void EventsManager::pollEventsAndWait() { pollEvents(); g_system->delayMillis(10); @@ -219,18 +225,23 @@ void EventsManager::delay(int time) { } void EventsManager::zeroKeys() { - _keypresses.clear(); + _keyCode = Common::KEYCODE_INVALID; } bool EventsManager::getKey(Common::KeyState &key) { - if (_keypresses.empty()) { + if (_keyCode == Common::KEYCODE_INVALID) { return false; } else { - key = _keypresses.pop(); + key = _keyCode; + _keyCode = Common::KEYCODE_INVALID; return true; } } +bool EventsManager::isKeyPending() const { + return _keyCode != Common::KEYCODE_INVALID; +} + void EventsManager::debounceLeft() { while (_leftButton && !_vm->shouldQuit()) { pollEvents(); @@ -240,17 +251,14 @@ void EventsManager::debounceLeft() { void EventsManager::clearEvents() { _leftButton = _rightButton = false; - _keypresses.clear(); + zeroKeys(); } void EventsManager::waitKeyMouse() { - while (!_vm->shouldQuit() && !_leftButton && _keypresses.size() == 0) { + while (!_vm->shouldQuit() && isKeyMousePressed()) { pollEvents(true); g_system->delayMillis(10); } - - zeroKeys(); - debounceLeft(); } Common::Point EventsManager::calcRawMouse() { @@ -278,7 +286,7 @@ int EventsManager::checkMouseBox1(Common::Array<Common::Rect> &rects) { } bool EventsManager::isKeyMousePressed() { - bool result = _leftButton || _rightButton || _keypresses.size() > 0; + bool result = _leftButton || _rightButton || isKeyPending(); debounceLeft(); zeroKeys(); |