aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCameron Cawley2019-06-16 23:29:12 +0100
committerFilippos Karapetis2019-07-08 01:24:55 +0300
commitcf107e7f905c55d7c4b2383cd86eb23e2d8dcc88 (patch)
treeece57aa1b7b29985c0d7bff30b6e127bbf769275
parent30109816fe3a0dae80795483ff28e9a50e6009a4 (diff)
downloadscummvm-rg350-cf107e7f905c55d7c4b2383cd86eb23e2d8dcc88.tar.gz
scummvm-rg350-cf107e7f905c55d7c4b2383cd86eb23e2d8dcc88.tar.bz2
scummvm-rg350-cf107e7f905c55d7c4b2383cd86eb23e2d8dcc88.zip
PEGASUS: Implement joystick support
-rw-r--r--engines/pegasus/detection.cpp3
-rw-r--r--engines/pegasus/input.cpp39
-rw-r--r--engines/pegasus/input.h2
-rw-r--r--engines/pegasus/pegasus.cpp1
4 files changed, 44 insertions, 1 deletions
diff --git a/engines/pegasus/detection.cpp b/engines/pegasus/detection.cpp
index 01a3113f2a..74867c1977 100644
--- a/engines/pegasus/detection.cpp
+++ b/engines/pegasus/detection.cpp
@@ -43,7 +43,8 @@ bool PegasusEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsRTL)
|| (f == kSupportsLoadingDuringRuntime)
- || (f == kSupportsSavingDuringRuntime);
+ || (f == kSupportsSavingDuringRuntime)
+ || (f == kSupportsJoystick);
}
bool PegasusEngine::isDemo() const {
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;
}
diff --git a/engines/pegasus/input.h b/engines/pegasus/input.h
index 4259076932..3b06b154ef 100644
--- a/engines/pegasus/input.h
+++ b/engines/pegasus/input.h
@@ -52,6 +52,8 @@ public:
void pumpEvents();
+ uint convertJoystickToKey(uint joybutton);
+
protected:
friend class Common::Singleton<SingletonBaseType>;
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index f2c0afba5c..043fddc03c 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -1279,6 +1279,7 @@ void PegasusEngine::showTempScreen(const Common::String &fileName) {
case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONUP:
case Common::EVENT_KEYDOWN:
+ case Common::EVENT_JOYBUTTON_DOWN:
done = true;
break;
default: