From 130b6bebaec4bc9f37c103a69595e8c261f2af49 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 24 Aug 2021 17:01:34 -0700
Subject: [PATCH] Manually scan for Linux joysticks before udev scan runs
This allows us to have joysticks sorted by insert time at startup, fixing https://github.com/libsdl-org/SDL/issues/4688
---
src/joystick/linux/SDL_sysjoystick.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c
index af21d79a9a..a3936e6391 100644
--- a/src/joystick/linux/SDL_sysjoystick.c
+++ b/src/joystick/linux/SDL_sysjoystick.c
@@ -676,6 +676,9 @@ LINUX_JoystickInit(void)
last_joy_detect_time = 0;
last_input_dir_mtime = 0;
+ /* Manually scan first, since we sort by device number and udev doesn't */
+ LINUX_JoystickDetect();
+
#if SDL_USE_LIBUDEV
if (enumeration_method == ENUMERATION_LIBUDEV) {
if (SDL_UDEV_Init() < 0) {
@@ -717,9 +720,6 @@ LINUX_JoystickInit(void)
}
}
#endif /* HAVE_INOTIFY */
-
- /* Report all devices currently present */
- LINUX_JoystickDetect();
}
return 0;