Configurable game controller/joystick/gamepad buttons
RPG_RT supports joystick/gamepad gameplay. Player also supports this feature. However, it could be nice to support configurable mappings to customize button mappings, i.e. add lesser common used buttons, e.g. Shift or key numbers to unused game controller buttons.
This issue relies on #666 configuration. Per-game mappings (if implemented) could be saved into a global configuration section to reduce folder writing permissions issues on some platforms.
Ah nice idea, you could add an item in the default menu system and/or the title screen.
Maybe also a good moment to move our api to SDL_GameController which is for using controllers that are like Xbox controllers.
Can also rename the constants from JOY_1 to JOY_20 with something better then:
https://github.com/libsdl-org/SDL/blob/d81fee76235a1f13123818815ecebcb27764595d/include/SDL_gamecontroller.h#L657
The SDL2 support for game controllers is still kinda broken on the web. Don't think we can do much here, SDL2 must fix the mapping (or the HTML5 Api must improve?).
With my Xbox360 controller it reports (A, B, X, Y and left analog stick work fine):
Firefox (reported as "Standard Gamepad"):
- D-Pad: Not working at all
- Right stick Up: Nothing
- Right stick Down: Nothing
- Right stick Left: Right Stick up
- Right stick Right: Right Stick down
- Left Shoulder: OK
- Right Shoulder: OK
- Left Trigger: Right Stick Left
- Right Trigger: Nothing
- Left Stick pressed: Start
- Right Stick pressed: Left stick pressed
- Back: Left stick pressed
- Start: Right Trigger
- Guide (XBox Button): Back
Chromium (reported as "©Microsoft Corporation Controller (STANDARD GAMEPAD)")
- D-Pad: Not working at all
- Right stick Up: OK
- Right stick Down: OK
- Right stick Left: OK
- Right stick Right: OK
- Left Shoulder: OK
- Right Shoulder: OK
- Left Trigger: Back
- Right Trigger: Start
- Left Stick pressed: Guide (Xbox button)
- Right Stick pressed: Nothing
- Back: Left stick pressed
- Start: Right stick pressed
- Guide (XBox Button): Nothing
That test above was on Linux. In Windows the Web Gamepad API works excellent. Everything works as expected.
But this is probably thanks to Microsoft because the gamepad is required to provide a proper mapping for the XInput API. So they solved this on the operating system level.
What do you get in https://gamepad-tester.com/ in Linux?
I suspect it's a browser issue and not an SDL mapping one, since gamepad mapping is very well defined in the web spec.
As you mention, it's super trivial for browser vendors to implement it via XInput on Windows due to the guarantees of that API and how 1:1 the mapping is between XInput and the web "standard gamepad".