sdl2_window
sdl2_window copied to clipboard
Xbox One gamepad: dpad doesn't send events
I have a Xbox One gamepad plugged with a USB cable. Using a simple test app in C, I see that everything works fine and is detected by SDL2, including the d-pad. However, when using the sdl2_window backend for piston and printing all input events, I receive events for every part of the gamepad, except the dpad, it's as if it wasn't present at all.
Does the dpad require specific handling? The test app refers to it as a hat, does this mean something?
Thanks!
Joystick support is new, implemented by me, and I didn't know hats were a thing (I just have a SNES controller!) So fairly certain this just needs to be implemented. Unfortunately, I don't have that controller to test. If you're interested in digging in:
- Hat function in
rust-sdl2, suggesting that we should be able to get this to work. - Event handler where we translate SDL2 joystick events to piston events
- Add some debugging here to see what events we're missing - I bet there is a hat related one that just needs to be mapped.
- Joystick related input events that you made need to add to.
Good luck!
Handy example program to test with
and a protip I wish I knew about when I started this stuff: you can setup your .cargo/config file to use local checkouts of all the above projects)