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 4962

Summary: Hats get confused if they're not all used
Product: SDL Reporter: Sjoerd Simons <sjoerd.simons>
Component: joystickAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.1   
Hardware: x86_64   
OS: Linux   
Attachments: Proposed fix

Description Sjoerd Simons 2020-01-28 13:03:46 UTC
Created attachment 4178 [details]
Proposed fix

If only e.g. EV_HAT0X  and EV_HAT2X are used the hat handling code got confused and events for both hats seem to come from hat 0.

A reason for "joysticks" not to have all HATs is because implement the standard linux gamepad event codes (https://www.kernel.org/doc/Documentation/input/gamepad.rst) which defines EV_HAT0 to be for an analog d-pad, EV_HAT1 to the top two shoulder buttons (if analog triggers rather digital) and EV_HAT2 for the bottom two shoulder buttons).
Comment 1 Sam Lantinga 2020-02-04 15:24:12 UTC
Looks good, thanks!
https://hg.libsdl.org/SDL/rev/26fa8708d147