We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4436 - [OpenBSD] fix D-pad
Summary: [OpenBSD] fix D-pad
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: joystick (show other bugs)
Version: HG 2.0
Hardware: x86_64 OpenBSD
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.10
Depends on:
Blocks:
 
Reported: 2018-12-28 17:05 UTC by Thomas Frohwein
Modified: 2019-07-01 05:48 UTC (History)
1 user (show)

See Also:


Attachments
diff to implement dpad for gamepads on OpenBSD (3.39 KB, patch)
2018-12-28 17:05 UTC, Thomas Frohwein
Details | Diff
Fix logic of dpad events (1.82 KB, patch)
2019-06-23 02:22 UTC, JvsqfI8ZY2hr
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Frohwein 2018-12-28 17:05:04 UTC
Created attachment 3555 [details]
diff to implement dpad for gamepads on OpenBSD

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
Comment 1 Ryan C. Gordon 2019-05-18 18:48:55 UTC
Tagging a bunch of bugs with "target-2.0.10" so we have a clear list of things to address before a 2.0.10 release.

Please note that "addressing" one of these bugs might mean deciding to defer on it until after 2.0.10, or resolving it as WONTFIX, etc. This is just here to tell us we should look at it carefully, and soon.

If you have new information or feedback on this issue, this is a good time to add it to the conversation, as we're likely to be paying attention to this specific report in the next few days/weeks.

Thanks!

--ryan.
Comment 2 Sam Lantinga 2019-05-19 18:56:42 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/64dabb27041d
Comment 3 JvsqfI8ZY2hr 2019-06-23 02:21:12 UTC
Hi, this patch breaks dpad/hat input on my PS4 controller.  The attached patch restores functionality.  Calling SDL_PrivateJoystickHat() at the end of BSD_JoystickUpdate was setting the hat state to zero on every kind of input, instead of just the HUG_DPAD events.
Comment 4 JvsqfI8ZY2hr 2019-06-23 02:22:44 UTC
Created attachment 3840 [details]
Fix logic of dpad events
Comment 5 Thomas Frohwein 2019-06-23 04:42:11 UTC
(In reply to daniel.c.sinclair from comment #4)
> Created attachment 3840 [details]
> Fix logic of dpad events

Thanks for reporting this unintended regression! Tested your diff with the Xbox 360 controller and it still works. While I can't reproduce the breakage and fix with the gamepads that I possess, this diff has my endorsement over the original one given that it reportedly fixes at least the PS4 controller, maybe others too...
Comment 6 Sam Lantinga 2019-07-01 05:48:35 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/0c19a7239a95