Browse Source

Fixed bug 5335 - enable joystick/haptic/evdev support by default on FreeBSD

Alex S

Evdev headers aren't actually included in the base system (well, it has a private copy), they are available through the devel/evdev-proto port instead. We also have devel/libinotify and devel/libudev-devd shims, I didn't verify whether they work with SDL.
Sam Lantinga 4 years ago
parent
commit
e9869e07bf
3 changed files with 33 additions and 5 deletions
  1. 24 5
      configure.ac
  2. 1 0
      include/SDL_config.h.in
  3. 8 0
      src/joystick/linux/SDL_sysjoystick.c

+ 24 - 5
configure.ac

@@ -2738,6 +2738,20 @@ AS_HELP_STRING([--enable-ime], [enable IME support [[default=yes]]]),
     fi
     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.
 dnl See if the platform has libibus IME support.
 CheckIBus()
 CheckIBus()
 {
 {
@@ -2751,9 +2765,6 @@ AS_HELP_STRING([--enable-ibus], [enable IBus support [[default=yes]]]),
         AC_CHECK_HEADER(ibus-1.0/ibus.h,
         AC_CHECK_HEADER(ibus-1.0/ibus.h,
                         have_ibus_ibus_h_hdr=yes,
                         have_ibus_ibus_h_hdr=yes,
                         have_ibus_ibus_h_hdr=no)
                         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"
         CFLAGS="$save_CFLAGS"
         if test x$have_ibus_ibus_h_hdr = xyes; then
         if test x$have_ibus_ibus_h_hdr = xyes; then
             if test x$enable_ime != xyes; then
             if test x$enable_ime != xyes; then
@@ -3449,7 +3460,6 @@ AS_HELP_STRING([--enable-joystick-virtual], [enable virtual joystick APIs [[defa
     fi
     fi
 }
 }
 
 
-
 dnl Do this on all platforms, before everything else (other things might want to override it).
 dnl Do this on all platforms, before everything else (other things might want to override it).
 CheckWarnAll
 CheckWarnAll
 CheckNoStrictAliasing
 CheckNoStrictAliasing
@@ -3531,6 +3541,7 @@ case "$host" in
         CheckLibUDev
         CheckLibUDev
         CheckDBus
         CheckDBus
         CheckIME
         CheckIME
+        CheckInotify
         CheckIBus
         CheckIBus
         CheckFcitx
         CheckFcitx
         case $ARCH in
         case $ARCH in
@@ -3590,12 +3601,20 @@ case "$host" in
         # Set up files for the joystick library
         # Set up files for the joystick library
         if test x$enable_joystick = xyes; then
         if test x$enable_joystick = xyes; then
           case $ARCH in
           case $ARCH in
-            linux|freebsd)
+            linux)
                 AC_DEFINE(SDL_JOYSTICK_LINUX, 1, [ ])
                 AC_DEFINE(SDL_JOYSTICK_LINUX, 1, [ ])
                 SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
                 SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
                 SOURCES="$SOURCES $srcdir/src/joystick/steam/*.c"
                 SOURCES="$SOURCES $srcdir/src/joystick/steam/*.c"
                 have_joystick=yes
                 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)
             android)
                 AC_DEFINE(SDL_JOYSTICK_ANDROID, 1, [ ])
                 AC_DEFINE(SDL_JOYSTICK_ANDROID, 1, [ ])
                 SOURCES="$SOURCES $srcdir/src/joystick/android/*.c"
                 SOURCES="$SOURCES $srcdir/src/joystick/android/*.c"

+ 1 - 0
include/SDL_config.h.in

@@ -207,6 +207,7 @@
 #undef HAVE_ALTIVEC_H
 #undef HAVE_ALTIVEC_H
 #undef HAVE_DBUS_DBUS_H
 #undef HAVE_DBUS_DBUS_H
 #undef HAVE_FCITX
 #undef HAVE_FCITX
+#undef HAVE_INOTIFY_H
 #undef HAVE_IBUS_IBUS_H
 #undef HAVE_IBUS_IBUS_H
 #undef HAVE_IMMINTRIN_H
 #undef HAVE_IMMINTRIN_H
 #undef HAVE_LIBSAMPLERATE_H
 #undef HAVE_LIBSAMPLERATE_H

+ 8 - 0
src/joystick/linux/SDL_sysjoystick.c

@@ -32,7 +32,9 @@
 #include <errno.h>              /* errno, strerror */
 #include <errno.h>              /* errno, strerror */
 #include <fcntl.h>
 #include <fcntl.h>
 #include <limits.h>             /* For the definition of PATH_MAX */
 #include <limits.h>             /* For the definition of PATH_MAX */
+#ifdef HAVE_INOTIFY_H
 #include <sys/inotify.h>
 #include <sys/inotify.h>
+#endif
 #include <sys/ioctl.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <dirent.h>
 #include <dirent.h>
@@ -498,6 +500,7 @@ static void SteamControllerDisconnectedCallback(int device_instance)
     }
     }
 }
 }
 
 
+#ifdef HAVE_INOTIFY_H
 static int
 static int
 StrHasPrefix(const char *string, const char *prefix)
 StrHasPrefix(const char *string, const char *prefix)
 {
 {
@@ -566,6 +569,7 @@ LINUX_InotifyJoystickDetect(void)
         }
         }
     }
     }
 }
 }
+#endif /* HAVE_INOTIFY_H */
 
 
 static void
 static void
 LINUX_FallbackJoystickDetect(void)
 LINUX_FallbackJoystickDetect(void)
@@ -612,7 +616,9 @@ LINUX_JoystickDetect(void)
     else
     else
 #endif
 #endif
     if (inotify_fd >= 0) {
     if (inotify_fd >= 0) {
+#ifdef HAVE_INOTIFY_H
         LINUX_InotifyJoystickDetect();
         LINUX_InotifyJoystickDetect();
+#endif
     }
     }
     else {
     else {
         LINUX_FallbackJoystickDetect();
         LINUX_FallbackJoystickDetect();
@@ -678,6 +684,7 @@ LINUX_JoystickInit(void)
     else
     else
 #endif
 #endif
     {
     {
+#ifdef HAVE_INOTIFY_H
         inotify_fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
         inotify_fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
 
 
         if (inotify_fd < 0) {
         if (inotify_fd < 0) {
@@ -700,6 +707,7 @@ LINUX_JoystickInit(void)
                             strerror (errno));
                             strerror (errno));
             }
             }
         }
         }
+#endif /* HAVE_INOTIFY_H */
 
 
         /* Report all devices currently present */
         /* Report all devices currently present */
         LINUX_JoystickDetect();
         LINUX_JoystickDetect();