diff options
author | Paul Gilbert | 2014-12-06 15:01:52 -0500 |
---|---|---|
committer | Paul Gilbert | 2014-12-12 23:01:37 -0500 |
commit | 67b3304f710a6888943e8b029237b246377d4026 (patch) | |
tree | 67a02a3d384aab6ee682252e448a91351f83bb1d /engines/access | |
parent | 84d77b7daf8473cd25196ae9445015ed3656797a (diff) | |
download | scummvm-rg350-67b3304f710a6888943e8b029237b246377d4026.tar.gz scummvm-rg350-67b3304f710a6888943e8b029237b246377d4026.tar.bz2 scummvm-rg350-67b3304f710a6888943e8b029237b246377d4026.zip |
ACCESS: Clean up keyboard control
Diffstat (limited to 'engines/access')
-rw-r--r-- | engines/access/access.cpp | 4 | ||||
-rw-r--r-- | engines/access/amazon/amazon_game.cpp | 6 | ||||
-rw-r--r-- | engines/access/amazon/amazon_logic.cpp | 5 | ||||
-rw-r--r-- | engines/access/events.cpp | 28 | ||||
-rw-r--r-- | engines/access/events.h | 6 | ||||
-rw-r--r-- | engines/access/scripts.cpp | 7 |
6 files changed, 31 insertions, 25 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 2153f594b1..55fe2514ed 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -229,7 +229,7 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { _events->debounceLeft(); _sndSubFile += soundsLeft; break; - } else if (_events->_keypresses.size() != 0) { + } else if (_events->isKeyPending()) { _sndSubFile += soundsLeft; break; } else { @@ -272,7 +272,7 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { _events->debounceLeft(); _sndSubFile += soundsLeft; break; - } else if (_events->_keypresses.size() != 0) { + } else if (_events->isKeyPending()) { _sndSubFile += soundsLeft; break; } else { diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 3252754239..902cfcd38a 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -489,8 +489,7 @@ void AmazonEngine::startChapter(int chapter) { _sound->freeSounds(); // Wait loop - while (!shouldQuit() && !_events->_leftButton && !_events->_rightButton - && _events->_keypresses.size() == 0 && _timers[20]._flag) { + while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) { _events->pollEvents(); g_system->delayMillis(10); } @@ -531,8 +530,7 @@ void AmazonEngine::startChapter(int chapter) { _timers[20]._flag++; // Wait loop - while (!shouldQuit() && !_events->_leftButton && !_events->_rightButton - && _events->_keypresses.size() == 0 && _timers[20]._flag) { + while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) { _events->pollEvents(); g_system->delayMillis(10); } diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index a7ee432183..5def4815e2 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -158,12 +158,9 @@ void CampScene::mWhileDoOpen() { events.pollEventsAndWait(); - if (events._leftButton || events._rightButton || events._keypresses.size() > 0) { + if (_vm->_events->isKeyMousePressed()) { _skipStart = true; _vm->_midi->newMusic(10, 1); - - events.debounceLeft(); - events.zeroKeys(); break; } 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(); diff --git a/engines/access/events.h b/engines/access/events.h index 965e8e7fd6..ffb0dbab3f 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -46,8 +46,11 @@ private: AccessEngine *_vm; uint32 _frameCounter; uint32 _priorFrameTime; + Common::KeyCode _keyCode; + Graphics::Surface _invCursor; void nextFrame(bool skipTimers); + void keyControl(Common::KeyCode keycode); public: CursorType _cursorId; CursorType _normalMouse; @@ -58,7 +61,6 @@ public: int _mouseCol, _mouseRow; bool _cursorExitFlag; int _vbCount; - Common::FixedStack<Common::KeyState> _keypresses; public: /** * Constructor @@ -113,6 +115,8 @@ public: bool getKey(Common::KeyState &key); + bool isKeyPending() const; + void delay(int time); void debounceLeft(); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index ec41f37d8c..728421c6d9 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -443,7 +443,7 @@ void Scripts::cmdCheckTimer() { if (_endFlag) return; - if ((idx == 9) && (_vm->_events->_keypresses.size() > 0)) { + if ((idx == 9) && _vm->_events->isKeyPending()) { _vm->_events->zeroKeys(); _vm->_timers[9]._timer = 0; _vm->_timers[9]._flag = 0; @@ -724,10 +724,9 @@ void Scripts::cmdWait() { _vm->_timers[3]._timer = time; _vm->_timers[3]._initTm = time; _vm->_timers[3]._flag++; - _vm->_events->_keypresses.clear(); + _vm->_events->zeroKeys(); - while (!_vm->shouldQuit() && _vm->_events->_keypresses.empty() && - !_vm->_events->_leftButton && !_vm->_events->_rightButton && + while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && _vm->_timers[3]._flag) { _vm->_midi->midiRepeat(); charLoop(); |