Browse Source

virtual joysticks: add autotools-build support (Bug 5028)

Autotools support for virtual-joysticks turns it OFF by default.  To turn it
on, pass the following into configure: --enable-joystick-virtual
David Ludwig 5 years ago
parent
commit
cc37ee8a0c
3 changed files with 50 additions and 0 deletions
  1. 28 0
      configure
  2. 21 0
      configure.ac
  3. 1 0
      include/SDL_config.h.in

+ 28 - 0
configure

@@ -899,6 +899,7 @@ enable_clock_gettime
 enable_rpath
 enable_rpath
 enable_backgrounding_signal
 enable_backgrounding_signal
 enable_foregrounding_signal
 enable_foregrounding_signal
+enable_joystick_virtual
 enable_render_d3d
 enable_render_d3d
 enable_sdl2_config
 enable_sdl2_config
 '
 '
@@ -1691,6 +1692,8 @@ Optional Features:
   --enable-foregrounding-signal
   --enable-foregrounding-signal
                           number to use for magic foregrounding signal or 'no'
                           number to use for magic foregrounding signal or 'no'
                           [[default=no]]
                           [[default=no]]
+  --enable-joystick-virtual
+                          enable virtual joystick APIs [[default=no]]
   --enable-render-d3d     enable the Direct3D render driver [[default=yes]]
   --enable-render-d3d     enable the Direct3D render driver [[default=yes]]
   --enable-sdl2-config    Install sdl2-config [default=yes]
   --enable-sdl2-config    Install sdl2-config [default=yes]
 
 
@@ -24531,6 +24534,24 @@ fi
     fi
     fi
 }
 }
 
 
+CheckVirtualJoystick()
+{
+    # Check whether --enable-joystick-virtual was given.
+if test "${enable_joystick_virtual+set}" = set; then :
+  enableval=$enable_joystick_virtual;
+else
+  enable_joystick_virtual=no
+fi
+
+    if test x$enable_joystick = xyes -a x$enable_joystick_virtual = xyes; then
+
+$as_echo "#define SDL_JOYSTICK_VIRTUAL 1" >>confdefs.h
+
+        SOURCES="$SOURCES $srcdir/src/joystick/virtual/*.c"
+        have_joystick_virtual=yes
+    fi
+}
+
 
 
 
 
 CheckWarnAll
 CheckWarnAll
@@ -25390,6 +25411,8 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
         ;;
         ;;
 esac
 esac
 
 
+CheckVirtualJoystick
+
 # Check whether to install sdl2-config
 # Check whether to install sdl2-config
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to install sdl2-config" >&5
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to install sdl2-config" >&5
 $as_echo_n "checking whether to install sdl2-config... " >&6; }
 $as_echo_n "checking whether to install sdl2-config... " >&6; }
@@ -25650,6 +25673,11 @@ if test x$have_x = xyes; then
     SUMMARY="${SUMMARY}X11 libraries   :${SUMMARY_video_x11}\n"
     SUMMARY="${SUMMARY}X11 libraries   :${SUMMARY_video_x11}\n"
 fi
 fi
 SUMMARY="${SUMMARY}Input drivers   :${SUMMARY_input}\n"
 SUMMARY="${SUMMARY}Input drivers   :${SUMMARY_input}\n"
+if test x$have_joystick_virtual = xyes; then
+    SUMMARY="${SUMMARY}Enable virtual joystick APIs : YES\n"
+else
+    SUMMARY="${SUMMARY}Enable virtual joystick APIs : NO\n"
+fi
 if test x$have_samplerate_h_hdr = xyes; then
 if test x$have_samplerate_h_hdr = xyes; then
     SUMMARY="${SUMMARY}Using libsamplerate : YES\n"
     SUMMARY="${SUMMARY}Using libsamplerate : YES\n"
 else
 else

+ 21 - 0
configure.ac

@@ -3410,6 +3410,19 @@ AS_HELP_STRING([--enable-foregrounding-signal], [number to use for magic foregro
     fi
     fi
 }
 }
 
 
+dnl Set up the Virtual joystick driver.
+CheckVirtualJoystick()
+{
+    AC_ARG_ENABLE(joystick-virtual,
+AS_HELP_STRING([--enable-joystick-virtual], [enable virtual joystick APIs [[default=no]]]),
+                  , enable_joystick_virtual=no)
+    if test x$enable_joystick = xyes -a x$enable_joystick_virtual = xyes; then
+        AC_DEFINE(SDL_JOYSTICK_VIRTUAL, 1, [ ])
+        SOURCES="$SOURCES $srcdir/src/joystick/virtual/*.c"
+        have_joystick_virtual=yes
+    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).
@@ -4092,6 +4105,9 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
         ;;
         ;;
 esac
 esac
 
 
+dnl Permit use of virtual joystick APIs on any platform (subject to configure options)
+CheckVirtualJoystick
+
 # Check whether to install sdl2-config
 # Check whether to install sdl2-config
 AC_MSG_CHECKING(whether to install sdl2-config)
 AC_MSG_CHECKING(whether to install sdl2-config)
 AC_ARG_ENABLE([sdl2-config],
 AC_ARG_ENABLE([sdl2-config],
@@ -4315,6 +4331,11 @@ if test x$have_x = xyes; then
     SUMMARY="${SUMMARY}X11 libraries   :${SUMMARY_video_x11}\n"
     SUMMARY="${SUMMARY}X11 libraries   :${SUMMARY_video_x11}\n"
 fi
 fi
 SUMMARY="${SUMMARY}Input drivers   :${SUMMARY_input}\n"
 SUMMARY="${SUMMARY}Input drivers   :${SUMMARY_input}\n"
+if test x$have_joystick_virtual = xyes; then
+    SUMMARY="${SUMMARY}Enable virtual joystick APIs : YES\n"
+else
+    SUMMARY="${SUMMARY}Enable virtual joystick APIs : NO\n"
+fi
 if test x$have_samplerate_h_hdr = xyes; then
 if test x$have_samplerate_h_hdr = xyes; then
     SUMMARY="${SUMMARY}Using libsamplerate : YES\n"
     SUMMARY="${SUMMARY}Using libsamplerate : YES\n"
 else
 else

+ 1 - 0
include/SDL_config.h.in

@@ -290,6 +290,7 @@
 #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
 #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
 #undef SDL_JOYSTICK_HIDAPI
 #undef SDL_JOYSTICK_HIDAPI
 #undef SDL_JOYSTICK_EMSCRIPTEN
 #undef SDL_JOYSTICK_EMSCRIPTEN
+#undef SDL_JOYSTICK_VIRTUAL
 #undef SDL_HAPTIC_DUMMY
 #undef SDL_HAPTIC_DUMMY
 #undef SDL_HAPTIC_ANDROID
 #undef SDL_HAPTIC_ANDROID
 #undef SDL_HAPTIC_LINUX
 #undef SDL_HAPTIC_LINUX