diff options
author | johndoe123 | 2018-05-25 05:27:57 +1000 |
---|---|---|
committer | Eugene Sandulenko | 2018-07-20 06:43:33 +0000 |
commit | 33ece271fde12033c620660216a678e1c506fd75 (patch) | |
tree | f39fdfa8107003402874778cb915a33312a01c74 /engines/illusions/input.cpp | |
parent | 65049228a8d4bcfbcedae75d098256bbbdc92baa (diff) | |
download | scummvm-rg350-33ece271fde12033c620660216a678e1c506fd75.tar.gz scummvm-rg350-33ece271fde12033c620660216a678e1c506fd75.tar.bz2 scummvm-rg350-33ece271fde12033c620660216a678e1c506fd75.zip |
ILLUSIONS: Implement cursor movement via arrow keys
(cherry picked from commit 12e33c6)
Diffstat (limited to 'engines/illusions/input.cpp')
-rw-r--r-- | engines/illusions/input.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/engines/illusions/input.cpp b/engines/illusions/input.cpp index 1374e44ce3..6af6cd5c00 100644 --- a/engines/illusions/input.cpp +++ b/engines/illusions/input.cpp @@ -21,6 +21,7 @@ */ #include "illusions/input.h" +#include "common/system.h" namespace Illusions { @@ -93,6 +94,7 @@ Input::Input() { _cursorPos.y = 0; _prevCursorPos.x = 0; _prevCursorPos.y = 0; + _cursorMovedByKeyboard = false; _cheatCodeIndex = 0; } @@ -105,6 +107,7 @@ void Input::processEvent(Common::Event event) { handleKey(event.kbd.keycode, MOUSE_NONE, false); break; case Common::EVENT_MOUSEMOVE: + _cursorMovedByKeyboard = false; _cursorPos.x = event.mouse.x; _cursorPos.y = event.mouse.y; break; @@ -172,6 +175,22 @@ InputEvent& Input::setInputEvent(uint evt, uint bitMask) { } void Input::handleKey(Common::KeyCode key, int mouseButton, bool down) { + switch (key) { + case Common::KEYCODE_UP: + moveCursorByKeyboard(0, -4); + break; + case Common::KEYCODE_DOWN: + moveCursorByKeyboard(0, 4); + break; + case Common::KEYCODE_RIGHT: + moveCursorByKeyboard(4, 0); + break; + case Common::KEYCODE_LEFT: + moveCursorByKeyboard(-4, 0); + break; + default: + break; + } for (uint i = 0; i < kEventMax; ++i) { _newKeys |= _inputEvents[i].handle(key, mouseButton, down); } @@ -221,6 +240,12 @@ void Input::discardButtons(uint bitMask) { _buttonStates &= ~bitMask; } +void Input::moveCursorByKeyboard(int deltaX, int deltaY) { + _cursorMovedByKeyboard = true; + _cursorPos.x = CLIP(_cursorPos.x + deltaX, 0, g_system->getWidth() - 1); + _cursorPos.y = CLIP(_cursorPos.y + deltaY, 0, g_system->getHeight() - 1); +} + bool Input::isCheatModeActive() { return _cheatCodeIndex == 7; } |