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 5360

Summary: [PATCH] non-libudev joystick detection doesn't see controllers that were already connected
Product: SDL Reporter: Simon McVittie <smcv>
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: joystick: Fix initial detection when not using udev

Description Simon McVittie 2020-11-19 17:27:07 UTC
This is a follow-up for Bug #5337.

Steps to reproduce:

* Have a USB game controller plugged in
* export SDL_JOYSTICK_DISABLE_UDEV=1
* Run a program that monitors joysticks (like testjoystick)
* Unplug and re-plug the game controller

Expected result:

* Controller is detected as present on startup
* Unplug is detected
* Re-plug is detected

Actual result:

* Controller does not appear to be present initially
* Unplug is not detected either
* Re-plug is detected successfully
Comment 1 Simon McVittie 2020-11-19 17:29:44 UTC
Created attachment 4529 [details]
joystick: Fix initial detection when not using udev


When watching for hotplug events we can poll the inotify fd, but we
still need to scan /dev/input once per process, otherwise we'll fail
to detect devices that were already connected.
Comment 2 Sam Lantinga 2020-11-24 05:15:08 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/9efc5e1acdcc