Skip to content

Commit

Permalink
Fixed bug 5360 - non-libudev joystick detection doesn't see controlle…
Browse files Browse the repository at this point in the history
…rs that were already connected

Simon McVittie

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.
  • Loading branch information
slouken committed Nov 24, 2020
1 parent 8e2746c commit c8c818d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/joystick/linux/SDL_sysjoystick.c
Expand Up @@ -571,6 +571,10 @@ LINUX_InotifyJoystickDetect(void)
}
#endif /* HAVE_INOTIFY_H */

/* Detect devices by reading /dev/input. In the inotify code path we
* have to do this the first time, to detect devices that already existed
* before we started; in the non-inotify code path we do this repeatedly
* (polling). */
static void
LINUX_FallbackJoystickDetect(void)
{
Expand Down Expand Up @@ -615,12 +619,13 @@ LINUX_JoystickDetect(void)
}
else
#endif
if (inotify_fd >= 0) {
#ifdef HAVE_INOTIFY_H
if (inotify_fd >= 0 && last_joy_detect_time != 0) {
LINUX_InotifyJoystickDetect();
#endif
}
else {
else
#endif
{
LINUX_FallbackJoystickDetect();
}

Expand Down

0 comments on commit c8c818d

Please sign in to comment.