aboutsummaryrefslogtreecommitdiff
path: root/engines/illusions
diff options
context:
space:
mode:
authorjohndoe1232018-05-25 05:27:57 +1000
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commit33ece271fde12033c620660216a678e1c506fd75 (patch)
treef39fdfa8107003402874778cb915a33312a01c74 /engines/illusions
parent65049228a8d4bcfbcedae75d098256bbbdc92baa (diff)
downloadscummvm-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')
-rw-r--r--engines/illusions/input.cpp25
-rw-r--r--engines/illusions/input.h3
2 files changed, 28 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;
}
diff --git a/engines/illusions/input.h b/engines/illusions/input.h
index 3b554bd622..b92cd1d2cf 100644
--- a/engines/illusions/input.h
+++ b/engines/illusions/input.h
@@ -90,6 +90,7 @@ public:
void setCursorPosition(Common::Point mousePos);
Common::Point getCursorDelta();
InputEvent& setInputEvent(uint evt, uint bitMask);
+ bool isCursorMovedByKeyboard() const { return _cursorMovedByKeyboard; }
bool isCheatModeActive();
protected:
uint _cheatCodeIndex;
@@ -98,12 +99,14 @@ protected:
uint _newKeys;
Common::Point _cursorPos, _prevCursorPos;
InputEvent _inputEvents[kEventMax];
+ bool _cursorMovedByKeyboard;
void handleKey(Common::KeyCode key, int mouseButton, bool down);
void handleMouseButton(int mouseButton, bool down);
void discardButtons(uint bitMask);
bool lookButtonStates(uint bitMask);
bool lookNewButtons(uint bitMask);
void setButtonState(uint bitMask);
+ void moveCursorByKeyboard(int deltaX, int deltaY);
};
} // End of namespace Illusions