-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add gamepad support #539
base: main
Are you sure you want to change the base?
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) |
@@ -150,10 +160,24 @@ export default class Game extends Component<Props, State> { | |||
# | |||
</span> | |||
)}{" "} | |||
{isGamepadConnected ? ( | |||
<span class={[gamepadButton, gamepadButtonA].join(" ")}> | |||
A |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to be very specific to particular gamepads, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm ok, I'll need to address that in some way before landing this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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