[Scummvm-git-logs] scummvm master -> 7d6a1fcbaa97ca9d282af7ca54113339c91c3d28
antoniou79
noreply at scummvm.org
Fri Mar 31 20:13:26 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
7d6a1fcbaa ANDROID: Treat DPAD keypresses as JOYSTICK_DPAD
Commit: 7d6a1fcbaa97ca9d282af7ca54113339c91c3d28
https://github.com/scummvm/scummvm/commit/7d6a1fcbaa97ca9d282af7ca54113339c91c3d28
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2023-03-31T23:13:16+03:00
Commit Message:
ANDROID: Treat DPAD keypresses as JOYSTICK_DPAD
Mapped by default to virtual mouse movement
Changed paths:
backends/platform/android/android.cpp
backends/platform/android/events.cpp
backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 77c5b5a9b58..850da09f8c4 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -713,8 +713,8 @@ Common::KeymapperDefaultBindings *OSystem_Android::getKeymapperDefaultBindings()
// By default DPAD directions will be used for virtual mouse in GUI context
// If the user wants to remap them, they will be able to navigate to Global Options -> Keymaps and do so.
- // In some devices (eg. Android TV) with only the remote control as input, it is impossible to navigate the launcher GUI,
- // if the DPAD actions are mapped to "up", "down", "left", "right" directions.
+ // In some devices (eg. Android TV) with only the remote control as DPAD input, it is impossible to navigate the launcher GUI,
+ // if the DPAD actions are mapped to "UP", "DOWN", "LEFT", "RIGHT" directions (GUI context) and not mouse cursor movement.
// TODO If/when full key-based (ie. non-mouse) navigation of the ScummVM GUI is implemented,
// we can revert back to the core behavior of DPAD being mapped to "up", "down", "left", "right" directions.
keymapperDefaultBindings->addDefaultBinding(Common::kGlobalKeymapName, "VMOUSEUP", "JOY_LEFT_STICK_Y-");
@@ -725,13 +725,16 @@ Common::KeymapperDefaultBindings *OSystem_Android::getKeymapperDefaultBindings()
keymapperDefaultBindings->addDefaultBinding(Common::kGlobalKeymapName, "VMOUSELEFT", "JOY_LEFT");
keymapperDefaultBindings->addDefaultBinding(Common::kGlobalKeymapName, "VMOUSERIGHT", "JOY_LEFT_STICK_X+");
keymapperDefaultBindings->addDefaultBinding(Common::kGlobalKeymapName, "VMOUSERIGHT", "JOY_RIGHT");
+ keymapperDefaultBindings->addDefaultBinding(Common::kGlobalKeymapName, "VMOUSESLOW", "JOY_RIGHT_SHOULDER");
+ keymapperDefaultBindings->addDefaultBinding(Common::kGlobalKeymapName, "VMOUSESLOW", "AUDIOPLAYPAUSE");
keymapperDefaultBindings->addDefaultBinding(Common::kGuiKeymapName, Common::kStandardActionInteract, "JOY_A");
- // TODO Needs JOY_CENTER to be defined
- //keymapperDefaultBindings->addDefaultBinding(Common::kGuiKeymapName, Common::kStandardActionInteract, "JOY_CENTER");
- keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, Common::kStandardActionMoveUp, nullptr);
- keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, Common::kStandardActionMoveDown, nullptr);
- keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, Common::kStandardActionMoveLeft, nullptr);
- keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, Common::kStandardActionMoveRight, nullptr);
+ keymapperDefaultBindings->addDefaultBinding(Common::kGuiKeymapName, Common::kStandardActionInteract, "JOY_CENTER");
+ keymapperDefaultBindings->addDefaultBinding(Common::kGuiKeymapName, Common::kStandardActionInteract, "SELECT");
+ // NOTE using nullptr as the third argument clears the bindings for the action.
+ keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, Common::kStandardActionMoveUp, "UP");
+ keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, Common::kStandardActionMoveDown, "DOWN");
+ keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, Common::kStandardActionMoveLeft, "LEFT");
+ keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, Common::kStandardActionMoveRight, "RIGHT");
return keymapperDefaultBindings;
}
diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp
index 9d3a64ead7d..bed36bbc2b8 100644
--- a/backends/platform/android/events.cpp
+++ b/backends/platform/android/events.cpp
@@ -544,6 +544,8 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
return;
case JE_DPAD:
+ // For now, this behavior, emulating mouse movement and left mouse clicking here for DPAD button presses,
+ // is no longer used.
switch (arg2) {
case AKEYCODE_DPAD_UP:
// fall through
@@ -1198,7 +1200,19 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
case AKEYCODE_BUTTON_R1:
e.joystick.button = Common::JOYSTICK_BUTTON_RIGHT_SHOULDER;
break;
-
+// // NOTE As of yet JOYSTICK_BUTTON_LEFT_TRIGGER, JOYSTICK_BUTTON_RIGHT_TRIGGER are missing as "buttons" from the hardware-input source code
+// // There are controllers like PS5's DualSense that trigger these buttons presses, albeit for wrong buttons (Create and Menu gamepad buttons)
+// // which could be due to Android OS not fully supporting them.
+// // PS3's DS3 also triggers these button presses but also generates a movement event so perhaps we can capture them that way
+// // (as generic joystick movement, "JOYSTICK_AXIS_LEFT_TRIGGER", "JOYSTICK_AXIS_RIGHT_TRIGGER" hardware-input).
+// case AKEYCODE_BUTTON_L2:
+// e.joystick.button = Common::JOYSTICK_BUTTON_LEFT_TRIGGER;
+// break;
+//
+// case AKEYCODE_BUTTON_R2:
+// e.joystick.button = Common::JOYSTICK_BUTTON_RIGHT_TRIGGER;
+// break;
+//
case AKEYCODE_BUTTON_THUMBL:
e.joystick.button = Common::JOYSTICK_BUTTON_LEFT_STICK;
break;
@@ -1223,10 +1237,9 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
e.joystick.button = Common::JOYSTICK_BUTTON_DPAD_RIGHT;
break;
-// case AKEYCODE_DPAD_CENTER:
-// // TODO This needs to be defined (backends/keymapper/hardware-input.cpp and common/events.h)
-// e.joystick.button = Common::JOYSTICK_BUTTON_DPAD_CENTER;
-// break;
+ case AKEYCODE_DPAD_CENTER:
+ e.joystick.button = Common::JOYSTICK_BUTTON_DPAD_CENTER;
+ break;
default:
LOGW("unmapped gamepad key: %d", arg2);
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
index 669f1d24dae..746264016c1 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
@@ -385,20 +385,17 @@ public class ScummVMEventsBase implements
case KeyEvent.KEYCODE_DPAD_LEFT:
case KeyEvent.KEYCODE_DPAD_RIGHT:
case KeyEvent.KEYCODE_DPAD_CENTER:
- if ((e.getSource() & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) {
- // When interpreted as JE_DPAD it will work as a mouse (translated in Android backend, events.cpp)
- // This is a case for FireTV Stick remote control's DPAD
- // The remote control itself is: InputDevice.SOURCE_DPAD | InputDevice.SOURCE_KEYBOARD
- // since it also has "buttons" for fast-forward, play/pause toggle, and rewind.
- // TODO Evaluate merging this case with setting the type as "JE_GAMEPAD"
- // and delegating the key mapping to ScummVM's keymapper
- type = JE_DPAD;
- } else {
- // When interpreted as JE_GAMEPAD it will be forwarded to ScummVM's keymapper
- type = JE_GAMEPAD;
- }
- break;
-
+ // NOTE 1 For now, we're handling DPAD keys as JE_GAMEPAD events, regardless the source InputDevice
+ // We delegate these keypresses to ScummVM's keymapper as JOYSTICK_BUTTON_DPAD presses.
+ // (JOYSTICK_BUTTON_DPAD_UP, JOYSTICK_BUTTON_DPAD_DOWN, JOYSTICK_BUTTON_DPAD_LEFT, JOYSTICK_BUTTON_DPAD_RIGHT and JOYSTICK_BUTTON_DPAD_CENTER)
+ // By default mapped to virtual mouse (VMOUSE).
+ // As virtual mouse, cursor may be too fast/hard to control, so it's recommended to set and use a VMOUSESLOW binding too.
+ // TODO Maybe add a checkbox in backend to toggle virtual mouse slow/fast, so that the user does not have to press two buttons
+ // at the same time. (Simultaneous button pressing may work on physical TV remote controls, but may not work on apps for remote controls)
+ // NOTE 2 Modern gamepads/ game controllers treat the "DPAD" cross buttons as HATs that produce movement events
+ // and *not* DPAD_UP/DOWN/LEFT/RIGHT button press events. Hence, for those controllers these DPAD key events won't be triggered.
+ //
+ // fall-through
case KeyEvent.KEYCODE_BUTTON_A:
case KeyEvent.KEYCODE_BUTTON_B:
case KeyEvent.KEYCODE_BUTTON_C:
@@ -422,6 +419,7 @@ public class ScummVMEventsBase implements
case KeyEvent.KEYCODE_BUTTON_3:
case KeyEvent.KEYCODE_BUTTON_4:
// These are oddly detected with SOURCE_KEYBOARD for joystick so don't bother checking the e.getSource()
+ // Tested on a Saitek ST200 USB Control Stick & Throttle
type = JE_JOYSTICK;
break;
More information about the Scummvm-git-logs
mailing list