diff --git a/configure.ac b/configure.ac index 7c6f632f0..6698af33e 100644 --- a/configure.ac +++ b/configure.ac @@ -2722,6 +2722,20 @@ AS_HELP_STRING([--enable-ime], [enable IME support [[default=yes]]]), fi } +dnl Check inotify presense +CheckInotify() +{ + AC_CHECK_HEADER(sys/inotify.h, have_inotify_inotify_h_hdr=yes) + if test x$have_inotify_inotify_h_hdr = xyes; then + AC_DEFINE(HAVE_INOTIFY_H, 1, [ ]) + case "$host" in + *-*-freebsd*) + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -linotify" + ;; + esac + fi +} + dnl See if the platform has libibus IME support. CheckIBus() { @@ -2735,9 +2749,6 @@ AS_HELP_STRING([--enable-ibus], [enable IBus support [[default=yes]]]), AC_CHECK_HEADER(ibus-1.0/ibus.h, have_ibus_ibus_h_hdr=yes, have_ibus_ibus_h_hdr=no) - AC_CHECK_HEADER(sys/inotify.h, - have_inotify_inotify_h_hdr=yes, - have_inotify_inotify_h_hdr=no) CFLAGS="$save_CFLAGS" if test x$have_ibus_ibus_h_hdr = xyes; then if test x$enable_ime != xyes; then @@ -3457,7 +3468,6 @@ AS_HELP_STRING([--enable-joystick-virtual], [enable virtual joystick APIs [[defa fi } - dnl Do this on all platforms, before everything else (other things might want to override it). CheckWarnAll CheckNoStrictAliasing @@ -3539,6 +3549,7 @@ case "$host" in CheckLibUDev CheckDBus CheckIME + CheckInotify CheckIBus CheckFcitx case $ARCH in @@ -3599,12 +3610,20 @@ case "$host" in # Set up files for the joystick library if test x$enable_joystick = xyes; then case $ARCH in - linux|freebsd) + linux) AC_DEFINE(SDL_JOYSTICK_LINUX, 1, [ ]) SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c" SOURCES="$SOURCES $srcdir/src/joystick/steam/*.c" have_joystick=yes ;; + freebsd) + if test x$use_input_events = xyes; then + AC_DEFINE(SDL_JOYSTICK_LINUX, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c" + SOURCES="$SOURCES $srcdir/src/joystick/steam/*.c" + have_joystick=yes + fi + ;; android) AC_DEFINE(SDL_JOYSTICK_ANDROID, 1, [ ]) SOURCES="$SOURCES $srcdir/src/joystick/android/*.c" diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 242a3d22e..3526d4c0e 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -207,6 +207,7 @@ #undef HAVE_ALTIVEC_H #undef HAVE_DBUS_DBUS_H #undef HAVE_FCITX +#undef HAVE_INOTIFY_H #undef HAVE_IBUS_IBUS_H #undef HAVE_IMMINTRIN_H #undef HAVE_LIBSAMPLERATE_H diff --git a/src/joystick/bsd/SDL_sysjoystick.c b/src/joystick/bsd/SDL_bsdjoystick.c similarity index 100% rename from src/joystick/bsd/SDL_sysjoystick.c rename to src/joystick/bsd/SDL_bsdjoystick.c diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index 76b83c6e5..0b2d8b370 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -32,7 +32,9 @@ #include /* errno, strerror */ #include #include /* For the definition of PATH_MAX */ +#ifdef HAVE_INOTIFY_H #include +#endif #include #include #include @@ -498,6 +500,7 @@ static void SteamControllerDisconnectedCallback(int device_instance) } } +#ifdef HAVE_INOTIFY_H static int StrHasPrefix(const char *string, const char *prefix) { @@ -566,6 +569,7 @@ LINUX_InotifyJoystickDetect(void) } } } +#endif /* HAVE_INOTIFY_H */ static void LINUX_FallbackJoystickDetect(void) @@ -612,7 +616,9 @@ LINUX_JoystickDetect(void) else #endif if (inotify_fd >= 0) { +#ifdef HAVE_INOTIFY_H LINUX_InotifyJoystickDetect(); +#endif } else { LINUX_FallbackJoystickDetect(); @@ -678,6 +684,7 @@ LINUX_JoystickInit(void) else #endif { +#ifdef HAVE_INOTIFY_H inotify_fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC); if (inotify_fd < 0) { @@ -700,6 +707,7 @@ LINUX_JoystickInit(void) strerror (errno)); } } +#endif /* HAVE_INOTIFY_H */ /* Report all devices currently present */ LINUX_JoystickDetect(); @@ -1320,8 +1328,10 @@ LINUX_JoystickQuit(void) SDL_joylist_item *item = NULL; SDL_joylist_item *next = NULL; - close(inotify_fd); - inotify_fd = -1; + if (inotify_fd != -1) { + close(inotify_fd); + inotify_fd = -1; + } for (item = SDL_joylist; item; item = next) { next = item->next;