diff options
author | Filippos Karapetis | 2015-12-24 18:25:16 +0200 |
---|---|---|
committer | Filippos Karapetis | 2015-12-24 18:25:16 +0200 |
commit | b2fad340b5f6cf2c54cb64241003867f5a5a893c (patch) | |
tree | b2b0c962b88a0014c6064f248dfcf619b7dc48d6 /engines | |
parent | 9c749c7d2e9c60b30274ba63fac44f886574e668 (diff) | |
download | scummvm-rg350-b2fad340b5f6cf2c54cb64241003867f5a5a893c.tar.gz scummvm-rg350-b2fad340b5f6cf2c54cb64241003867f5a5a893c.tar.bz2 scummvm-rg350-b2fad340b5f6cf2c54cb64241003867f5a5a893c.zip |
LAB: More cleanup of the keyboard handling code
Diffstat (limited to 'engines')
-rw-r--r-- | engines/lab/eventman.cpp | 51 | ||||
-rw-r--r-- | engines/lab/eventman.h | 6 | ||||
-rw-r--r-- | engines/lab/interface.cpp | 9 |
3 files changed, 19 insertions, 47 deletions
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp index 5dbe60f946..83c50b9771 100644 --- a/engines/lab/eventman.cpp +++ b/engines/lab/eventman.cpp @@ -59,6 +59,17 @@ static const byte mouseData[] = { #define MOUSE_WIDTH 10 #define MOUSE_HEIGHT 15 +EventManager::EventManager(LabEngine *vm) : _vm(vm) { + _leftClick = false; + _rightClick = false; + + _lastButtonHit = nullptr; + _screenButtonList = nullptr; + _hitButton = nullptr; + _mousePos = Common::Point(0, 0); + _keyPressed = Common::KEYCODE_INVALID; +} + Button *EventManager::checkButtonHit(ButtonList *buttonList, Common::Point pos) { for (ButtonList::iterator buttonItr = buttonList->begin(); buttonItr != buttonList->end(); ++buttonItr) { Button *button = *buttonItr; @@ -104,23 +115,6 @@ Button *EventManager::getButton(uint16 id) { return nullptr; } -EventManager::EventManager(LabEngine *vm) : _vm(vm) { - _leftClick = false; - _rightClick = false; - - _lastButtonHit = nullptr; - _screenButtonList = nullptr; - _hitButton = nullptr; - _mousePos = Common::Point(0, 0); - - _nextKeyIn = 0; - _nextKeyOut = 0; - - for (int i = 0; i < 64; i++) - _keyBuf[i] = Common::KEYCODE_INVALID; - -} - void EventManager::updateMouse() { if (!_hitButton) return; @@ -168,19 +162,6 @@ void EventManager::setMousePos(Common::Point pos) { _vm->_system->warpMouse(pos.x * 2, pos.y); } -Common::KeyCode EventManager::keyPress() { - Common::KeyCode key = Common::KEYCODE_INVALID; - - processInput(); - - if (_nextKeyIn != _nextKeyOut) { - key = _keyBuf[_nextKeyOut]; - _nextKeyOut = (_nextKeyOut + 1) % 64; - } - - return key; -} - void EventManager::processInput() { Common::Event event; Button *curButton = nullptr; @@ -220,13 +201,9 @@ void EventManager::processInput() { continue; } // Intentional fall through - default: { - int n = (_nextKeyIn + 1) % 64; - if (n != _nextKeyOut) { - _keyBuf[_nextKeyIn] = event.kbd.keycode; - _nextKeyIn = n; - } - } + default: + _keyPressed = event.kbd; + break; } break; case Common::EVENT_QUIT: diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h index a5f0e9484f..f0e04fcb55 100644 --- a/engines/lab/eventman.h +++ b/engines/lab/eventman.h @@ -77,7 +77,6 @@ private: uint16 _nextKeyIn; uint16 _nextKeyOut; - Common::KeyCode _keyBuf[64]; Button *_hitButton; Button *_lastButtonHit; @@ -93,11 +92,6 @@ private: Button *checkButtonHit(ButtonList *buttonList, Common::Point pos); /** - * Checks whether or not a key has been pressed. - */ - Common::KeyCode keyPress(); - - /** * Checks whether or not the coords fall within one of the buttons in a list * of buttons. */ diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp index af52a6a2f3..6f0156234a 100644 --- a/engines/lab/interface.cpp +++ b/engines/lab/interface.cpp @@ -117,8 +117,7 @@ IntuiMessage *EventManager::getMsg() { static IntuiMessage message; updateMouse(); - - Common::KeyCode curKey = keyPress(); + processInput(); if (_lastButtonHit) { updateMouse(); @@ -135,8 +134,10 @@ IntuiMessage *EventManager::getMsg() { message._mouse.x /= 2; _leftClick = _rightClick = false; return &message; - } else if (curKey != Common::KEYCODE_INVALID) { - message._code = curKey; + } else if (_keyPressed.keycode != Common::KEYCODE_INVALID) { + message._code = _keyPressed.keycode; + _keyPressed.keycode = Common::KEYCODE_INVALID; + Button *curButton = checkNumButtonHit(_screenButtonList, message._code); if (curButton) { |