SDL/src/joystick
Sam Lantinga c377de5440 Fixed bug 4436 - [OpenBSD] fix D-pad
Thomas Frohwein

Hi,

If a gamepad lists the Dpad as 4 buttons (Dpad Up,Down, Left, Right) like with the Xbox 360 gamepad / XInput report descriptor used by OpenBSD (https://github.com/openbsd/src/blob/master/sys/dev/usb/uhid_rdesc.h#L184), this is not recognized by the SDL BSD backend and no hat or any other listing for the D-pad exists, e.g. in sdl2-jstest (https://gitlab.com/sdl-jstest/sdl-jstest).

The attached diff fixes this and makes the D-pad on my Xbox 360 and Logitech F310 controllers usable. It adds a hat to nhats when usage HUG_DPAD_UP is found, reads the state of the D-pad buttons into array dpad[], and turns the value of dpad[] into an SDL hat direction (dpad_to_sdl()).

Tested and works with Xbox 360 controller and Logitech F310 in XInput mode. Software-side tested with sdl2-jstest and Owlboy where this worked without problems or regressions.

I don't know if this would be applicable to other *BSDs and don't have an install to test it with, therefore wrapped it in __OpenBSD__ ifdefs.

Thanks,

thfr
2019-05-19 11:56:26 -07:00
..
android Updated copyright for 2019 2019-01-04 22:01:14 -08:00
bsd Fixed bug 4436 - [OpenBSD] fix D-pad 2019-05-19 11:56:26 -07:00
darwin Updated copyright for 2019 2019-01-04 22:01:14 -08:00
dummy Updated copyright for 2019 2019-01-04 22:01:14 -08:00
emscripten Emscripten: call emscripten_sample_gamepad_data 2019-01-29 12:19:00 +00:00
haiku Updated copyright for 2019 2019-01-04 22:01:14 -08:00
hidapi hidapi: Add GCN L/R buttons, just in case someone wants them... 2019-03-17 12:36:40 -04:00
iphoneos iOS/tvOS: fix support for SDL_GameControllerGetButton(controller, GUIDE) with MFi controllers (thanks Caleb!) 2019-01-31 19:52:47 -04:00
linux Updated copyright for 2019 2019-01-04 22:01:14 -08:00
psp Updated copyright for 2019 2019-01-04 22:01:14 -08:00
steam Updated copyright for 2019 2019-01-04 22:01:14 -08:00
windows Updated copyright for 2019 2019-01-04 22:01:14 -08:00
controller_type.h hidapi: Add support for Wii U/Switch USB GameCube controller adapter. 2019-03-12 20:27:54 -04:00
SDL_gamecontroller.c Fix polling left trigger reporting right trigger's values. 2019-03-16 18:12:26 -07:00
SDL_gamecontrollerdb.h Fixed bug 4511 - SDL_gamecontrollerdb Mapping for Sony Playstation USB controller 2019-03-16 19:03:13 -07:00
SDL_joystick.c Handle potentially calling SDL_JoystickUpdate() and SDL_JoystickQuit() at the same time. 2019-03-27 08:17:05 -07:00
SDL_joystick_c.h hidapi: Add support for Wii U/Switch USB GameCube controller adapter. 2019-03-12 20:27:54 -04:00
SDL_sysjoystick.h hidapi: Add support for Wii U/Switch USB GameCube controller adapter. 2019-03-12 20:27:54 -04:00
sort_controllers.py Revert SDL_gamecontrollerdb.h and sort_controllers.py from bug 4024 2019-01-21 20:49:08 +01:00