mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 06:08:35 +00:00
PEGASUS: Implement joystick support
This commit is contained in:
parent
30109816fe
commit
cf107e7f90
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -52,6 +52,8 @@ public:
|
||||
|
||||
void pumpEvents();
|
||||
|
||||
uint convertJoystickToKey(uint joybutton);
|
||||
|
||||
protected:
|
||||
friend class Common::Singleton<SingletonBaseType>;
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user