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 4830

Summary: Incorrect joystick button state after SYN_DROPPED
Product: SDL Reporter: Mathieu Eyraud <meyraud705>
Component: joystickAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: icculus, sezeroz
Version: 2.0.10Keywords: target-2.0.14
Hardware: All   
OS: Linux   

Description Mathieu Eyraud 2019-10-17 15:14:46 UTC
After receiving SYN_DROPPED event from a linux system, axis values are re-read but not the button values.
https://hg.libsdl.org/SDL/file/d1a5e3cd0ae8/src/joystick/linux/SDL_sysjoystick.c#l949
This may cause joystick button values to be in incorrect state and some joystick events to be missing.
Comment 1 Sam Lantinga 2019-10-19 20:05:09 UTC
Good catch. Do you have a patch you've tested that polls button values as well?
Comment 2 Mathieu Eyraud 2019-10-19 21:40:04 UTC
No, I Don't have a patch and I don't know linux's syscall to make one.
Comment 3 Ryan C. Gordon 2020-06-28 20:29:39 UTC
This is fixed in https://hg.libsdl.org/SDL/rev/2173f488608f

Now we poll hats and buttons in addition to axes when we get a SYN_DROPPED, and we also follow the proper evdev procedure of throwing away the rest of the input packet (that is, until we see a SYN_REPORT) after a SYN_DROPPED event.

This can be tested by building the latest testjoystick and pressing the 'L' key to sleep for 3 seconds--and going wild with the joystick in that time--to overwhelm the kernel's event buffer. SDL will now recover and resync with the current joystick state.

--ryan.