Plan for control remapping

From OHRRPGCE-Wiki
Jump to navigation Jump to search
Revise.png
This article or section is not complete. If you wish, you may finish it, and remove this tag when you are done.

Existing Gamepad settings (for Android)[edit]

Awkwardly, there are "Gamepad Buttons (Android only)" settings (under "Platform Options") which map gamepad buttons to keyboard keys, which only work on Android, and "Multiplayer Gamepad Options" for gamepads 2-4 specific to Ouya gamepads (apparently they don't work on other Android-based consoles like Fire TV). Joy-to-key mapping would be useful everywhere (see also Plan for a joystick config menu‎) but maybe we should deprecate and hide the existing settings.

libsdl-android port[edit]

The reason these are Android-only is that the libsdl-android (pelya/commandergenius) port doesn't report joystick/gamepad buttons at all, it only supports mapping them to keyboard keys. (pelya wrote "Mapping gamepad buttons to keypresses just makes it easier to port [Linux games]. I did plan to provide API through SDL_JoyButtonEvent, but did not implement it yet." It does support joystick axes (only if you uses SDL_OpenJoystick to open JOY_GAMEPAD1 which is joystick 2; this also disables reporting axes as keyboard buttons, and disables our support for multiple Ouya gamepads. (See DemoGLSurfaceView_nativeGamepadAnalogJoystickInput.)

In our libsdl-android fork, distinct input multiple gamepads are supported only on Ouya, otherwise they all share the "Gamepad Buttons" mapping. Upstream commander-genius has since added support for up to 4 gamepads instead of just one. These are numbered, starting from 2, in the order that events are received from them. Still no support for true gamepad buttons.

In upstream pelya/commandergenius, SDL_ANDROID_set_java_gamepad_keymap was renamed to SDL_ANDROID_SetGamepadKeymap, and SDL_ANDROID_SetIndividualGamepadKeymap was added which is a replacement for our SDL_ANDROID_set_ouya_gamepad_keymap.

It could be possible to get real gamepad buttons by mapping those buttons to unused SDL key codes (this can only be done using the C SDL_ANDROID_* API, not a .cfg file), and translate these into buttons in gfx_sdl. But it would be a better idea to implement joystick button events in libsdl-android, the way it works in SDL2 and on other OSes.

gamepad_virtual_keyboard[edit]

"Gamepad Buttons (Android only)" and "Multiplayer Gamepad Options" also used on non-Ouya consoles for gamepad_virtual_keyboard, which is used for hero renaming and "input string with virtual keyboard".

gamepad_virtual_keyboard should be modified to read multiplayer controls using keyval instead of loading the Android-specific button-keyboard mapping into an ArrowSet, a UDT used nowhere else.