Fixed build error on Linux if HAVE_INOTIFY isn't defined Fixes https://github.com/libsdl-org/SDL/issues/5682
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c
index 92483b3..307dd56 100644
--- a/src/joystick/linux/SDL_sysjoystick.c
+++ b/src/joystick/linux/SDL_sysjoystick.c
@@ -497,21 +497,6 @@ static void SteamControllerDisconnectedCallback(int device_instance)
}
}
-#ifdef HAVE_INOTIFY
-#ifdef HAVE_INOTIFY_INIT1
-static int SDL_inotify_init1(void) {
- return inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
-}
-#else
-static int SDL_inotify_init1(void) {
- int fd = inotify_init();
- if (fd < 0) return -1;
- fcntl(fd, F_SETFL, O_NONBLOCK);
- fcntl(fd, F_SETFD, FD_CLOEXEC);
- return fd;
-}
-#endif
-
static int
StrHasPrefix(const char *string, const char *prefix)
{
@@ -566,6 +551,21 @@ IsJoystickDeviceNode(const char *node)
}
}
+#ifdef HAVE_INOTIFY
+#ifdef HAVE_INOTIFY_INIT1
+static int SDL_inotify_init1(void) {
+ return inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
+}
+#else
+static int SDL_inotify_init1(void) {
+ int fd = inotify_init();
+ if (fd < 0) return -1;
+ fcntl(fd, F_SETFL, O_NONBLOCK);
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
+ return fd;
+}
+#endif
+
static void
LINUX_InotifyJoystickDetect(void)
{