aboutsummaryrefslogtreecommitdiff
path: root/engines/pegasus/input.cpp
diff options
context:
space:
mode:
authorCameron Cawley2019-06-16 23:29:12 +0100
committerFilippos Karapetis2019-07-08 01:24:55 +0300
commitcf107e7f905c55d7c4b2383cd86eb23e2d8dcc88 (patch)
treeece57aa1b7b29985c0d7bff30b6e127bbf769275 /engines/pegasus/input.cpp
parent30109816fe3a0dae80795483ff28e9a50e6009a4 (diff)
downloadscummvm-rg350-cf107e7f905c55d7c4b2383cd86eb23e2d8dcc88.tar.gz
scummvm-rg350-cf107e7f905c55d7c4b2383cd86eb23e2d8dcc88.tar.bz2
scummvm-rg350-cf107e7f905c55d7c4b2383cd86eb23e2d8dcc88.zip
PEGASUS: Implement joystick support
Diffstat (limited to 'engines/pegasus/input.cpp')
-rw-r--r--engines/pegasus/input.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index 36a84dbd3c..50267ae767 100644
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -175,6 +175,35 @@ void InputDeviceManager::waitInput(const InputBits filter) {
}
}
+uint InputDeviceManager::convertJoystickToKey(uint joybutton) {
+ switch (joybutton) {
+ case Common::JOYSTICK_BUTTON_A:
+ return Common::KEYCODE_RETURN; // Action
+ case Common::JOYSTICK_BUTTON_B:
+ // nothing
+ break;
+ case Common::JOYSTICK_BUTTON_X:
+ return Common::KEYCODE_i; // Display Object Info
+ case Common::JOYSTICK_BUTTON_Y:
+ return Common::KEYCODE_t; // Toggle Data Display
+ case Common::JOYSTICK_BUTTON_LEFT_SHOULDER:
+ return Common::KEYCODE_TILDE; // Open Inventory Panel
+ case Common::JOYSTICK_BUTTON_RIGHT_SHOULDER:
+ return Common::KEYCODE_KP_MULTIPLY; // Open Biochip Panel
+ case Common::JOYSTICK_BUTTON_START:
+ return Common::KEYCODE_p; // Pause
+ case Common::JOYSTICK_BUTTON_DPAD_UP:
+ return Common::KEYCODE_UP;
+ case Common::JOYSTICK_BUTTON_DPAD_DOWN:
+ return Common::KEYCODE_DOWN;
+ case Common::JOYSTICK_BUTTON_DPAD_LEFT:
+ return Common::KEYCODE_LEFT;
+ case Common::JOYSTICK_BUTTON_DPAD_RIGHT:
+ return Common::KEYCODE_RIGHT;
+ }
+ return 0;
+}
+
bool InputDeviceManager::notifyEvent(const Common::Event &event) {
if (GUI::GuiManager::instance().isActive()) {
// For some reason, the engine hooks in the event system using an EventObserver.
@@ -215,6 +244,16 @@ bool InputDeviceManager::notifyEvent(const Common::Event &event) {
if (_keyMap.contains(event.kbd.keycode))
_keyMap[event.kbd.keycode] = false;
break;
+ case Common::EVENT_JOYAXIS_MOTION:
+ break;
+ case Common::EVENT_JOYBUTTON_DOWN:
+ if (_keyMap.contains(convertJoystickToKey(event.joystick.button)))
+ _keyMap[convertJoystickToKey(event.joystick.button)] = true;
+ break;
+ case Common::EVENT_JOYBUTTON_UP:
+ if (_keyMap.contains(convertJoystickToKey(event.joystick.button)))
+ _keyMap[convertJoystickToKey(event.joystick.button)] = false;
+ break;
default:
break;
}