aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2014-12-06 15:21:35 -0500
committerPaul Gilbert2014-12-12 23:01:46 -0500
commit7cd7bb9b54266f952c4049875532e587b0278415 (patch)
tree86efe5e048e0c23b84ea96a894e827083f232370
parent67b3304f710a6888943e8b029237b246377d4026 (diff)
downloadscummvm-rg350-7cd7bb9b54266f952c4049875532e587b0278415.tar.gz
scummvm-rg350-7cd7bb9b54266f952c4049875532e587b0278415.tar.bz2
scummvm-rg350-7cd7bb9b54266f952c4049875532e587b0278415.zip
ACCESS: Implement player keyboard movement
-rw-r--r--engines/access/events.cpp50
-rw-r--r--engines/access/events.h2
2 files changed, 48 insertions, 4 deletions
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 60073e6030..a1be7ffa5b 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -27,6 +27,7 @@
#include "engines/util.h"
#include "access/access.h"
#include "access/events.h"
+#include "access/player.h"
#include "access/amazon/amazon_resources.h"
#define CURSOR_WIDTH 16
@@ -142,10 +143,11 @@ void EventsManager::pollEvents(bool skipTimers) {
_vm->_debugger->attach();
_vm->_debugger->onFrame();
} else {
- keyControl(event.kbd.keycode);
+ keyControl(event.kbd.keycode, true);
}
return;
case Common::EVENT_KEYUP:
+ keyControl(event.kbd.keycode, false);
return;
case Common::EVENT_MOUSEMOVE:
_mousePos = event.mouse;
@@ -182,9 +184,51 @@ void EventsManager::pollEvents(bool skipTimers) {
}
}
-void EventsManager::keyControl(Common::KeyCode keycode) {
+void EventsManager::keyControl(Common::KeyCode keycode, bool isKeyDown) {
+ Player &player = *_vm->_player;
+
+ if (!isKeyDown) {
+ if (player._move != NONE) {
+ _keyCode = Common::KEYCODE_INVALID;
+ player._move = NONE;
+ }
+ return;
+ }
+
_keyCode = keycode;
- // TODO: Keypress handling
+
+ switch (keycode) {
+ case Common::KEYCODE_UP:
+ case Common::KEYCODE_KP8:
+ player._move = UP;
+ break;
+ case Common::KEYCODE_DOWN:
+ case Common::KEYCODE_KP2:
+ player._move = DOWN;
+ break;
+ case Common::KEYCODE_LEFT:
+ case Common::KEYCODE_KP4:
+ player._move = LEFT;
+ break;
+ case Common::KEYCODE_RIGHT:
+ case Common::KEYCODE_KP6:
+ player._move = RIGHT;
+ break;
+ case Common::KEYCODE_KP7:
+ player._move = UPLEFT;
+ break;
+ case Common::KEYCODE_KP9:
+ player._move = UPRIGHT;
+ break;
+ case Common::KEYCODE_KP1:
+ player._move = DOWNLEFT;
+ break;
+ case Common::KEYCODE_KP3:
+ player._move = DOWNRIGHT;
+ break;
+ default:
+ break;
+ }
}
void EventsManager::pollEventsAndWait() {
diff --git a/engines/access/events.h b/engines/access/events.h
index ffb0dbab3f..04edd2bdf3 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -50,7 +50,7 @@ private:
Graphics::Surface _invCursor;
void nextFrame(bool skipTimers);
- void keyControl(Common::KeyCode keycode);
+ void keyControl(Common::KeyCode keycode, bool isKeyDown);
public:
CursorType _cursorId;
CursorType _normalMouse;