Add gamepad support#539
Conversation
0cc2a8c to
b906a6e
Compare
This commit adds support for playing PROXX with a gamepad. The gamepad can be used both on the game board, and in the menus. On the game board it can be used to clear (A or LB) or flag (X or RB) tiles, navigate the board using the D-Pad, and switch into alt mode (B). On the menu, A can be used to confirm (Start or Restart) and B can be used to go back or cancel. I tried to keep this relatively light-weight, but it does add a bit of extra code to the initial bundle (the Gamepad handling specifically). If the user does not use a game pad, the code will not cause any extra CPU usage.
b906a6e to
58202ed
Compare
|
Thanks for getting this together! I'll review and merge when I get a bit of free time (next week hopefully) |
| )}{" "} | ||
| {isGamepadConnected ? ( | ||
| <span class={[gamepadButton, gamepadButtonA].join(" ")}> | ||
| A |
There was a problem hiding this comment.
This is going to be very specific to particular gamepads, right?
There was a problem hiding this comment.
Yeah. This is the key mapping for most Xbox derived gamepads, but will not match for JoyCons or Playstation controllers. I don't think the Gamepad API provides functionality to get the labels for each button, so this would have to be hardcoded based on gamepad vendor id / name most likely.
There was a problem hiding this comment.
hmm ok, I'll need to address that in some way before landing this
There was a problem hiding this comment.
Sounds good. Just to clarify though: while the labels will not match (A on Xbox is X on PS), the actual input handling is correct. Pressing "X" on the PS controller will start a game etc.
There was a problem hiding this comment.
It’s gonna be hard to find a perfect solution. We could add a map that maps from gamepad name to button config, and one fallback config...
This commit adds support for playing PROXX with a gamepad. The gamepad
can be used both on the game board, and in the menus. On the game board
it can be used to clear (A or LB) or flag (X or RB) tiles, navigate the
board using the D-Pad, and switch into alt mode (B). On the menu, A can
be used to confirm (Start or Restart) and B can be used to go back or
cancel.
I tried to keep this relatively light-weight, but it does add a bit of
extra code to the initial bundle (the Gamepad handling specifically). If
the user does not use a game pad, the code will not cause any extra CPU
usage.
I have tested this on a Steamdeck, and on a Linux machine using an Xbox
One controller.
See me trying it out on my Steamdeck here: https://www.youtube.com/watch?v=094whsi4pdw