configure: Windows and macOS now respect --enable-hidapi. (and it defaults to "yes" on those platforms. Other places, which use libusb, still default to no because they probably need root permissions to work.)
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
diff --git a/configure b/configure
index fb7d422..ab7b658 100755
--- a/configure
+++ b/configure
@@ -1675,7 +1675,7 @@ Optional Features:
--enable-wasapi use the Windows WASAPI audio driver [[default=yes]]
--enable-sdl-dlopen use dlopen for shared object loading [[default=yes]]
--enable-hidapi use HIDAPI for low level joystick drivers
- [[default=no]]
+ [[default=maybe]]
--enable-clock_gettime use clock_gettime() instead of gettimeofday() on
UNIX [[default=yes]]
--enable-rpath use an rpath when linking SDL [[default=yes]]
@@ -24107,14 +24107,32 @@ CheckHIDAPI()
# so we'll just use libusb when it's available.
#
# Except that libusb requires root permissions to open devices, so that's not generally useful, and we'll disable this by default.
+ #
+ # On macOS and Windows, where you don't need libusb or root, we default to yes.
+ skiplibusb=no
+ case "$host" in
+ *-*-cygwin* | *-*-mingw32* | *-*-darwin* )
+ skiplibusb=yes
+ ;;
+ esac
+
# Check whether --enable-hidapi was given.
if test "${enable_hidapi+set}" = set; then :
enableval=$enable_hidapi;
else
- enable_hidapi=no
+ enable_hidapi=maybe
fi
+ hidapi_support=no
+
+ if test x$enable_hidapi = xmaybe; then
+ enable_hidapi=$skiplibusb
+ fi
+
if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then
+ if test x$skiplibusb = xyes; then
+ hidapi_support=yes
+ else
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBUSB" >&5
@@ -24184,28 +24202,34 @@ else
$as_echo "yes" >&6; }
have_libusb=yes
fi
- hidapi_support=no
- save_CFLAGS="$CFLAGS"
- CFLAGS="$save_CFLAGS $LIBUSB_CFLAGS"
- ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default"
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$save_CFLAGS $LIBUSB_CFLAGS"
+ ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default"
if test "x$ac_cv_header_libusb_h" = xyes; then :
have_libusb_h=yes
fi
- CFLAGS="$save_CFLAGS"
+ CFLAGS="$save_CFLAGS"
+ if test x$have_libusb_h = xyes; then
+ hidapi_support=yes
+ fi
+ fi
- if test x$have_libusb_h = xyes; then
- hidapi_support=yes
+ if test x$hidapi_support = xyes; then
$as_echo "#define SDL_JOYSTICK_HIDAPI 1" >>confdefs.h
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
- SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
- EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
- EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
+
+ if test x$skiplibusb = xno; then
+ SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
+ EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
+ fi
fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for hidapi support" >&5
$as_echo_n "checking for hidapi support... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hidapi_support" >&5
@@ -24632,6 +24656,7 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
CheckWINDOWSGLES
CheckVulkan
CheckDIRECTX
+ CheckHIDAPI
# Set up the core platform files
SOURCES="$SOURCES $srcdir/src/core/windows/*.c"
@@ -24705,14 +24730,11 @@ $as_echo "#define SDL_JOYSTICK_DINPUT 1" >>confdefs.h
$as_echo "#define SDL_JOYSTICK_WINMM 1" >>confdefs.h
fi
-
-$as_echo "#define SDL_JOYSTICK_HIDAPI 1" >>confdefs.h
-
SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c"
- SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
- SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
- EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
have_joystick=yes
+ if test x$hidapi_support = xyes; then
+ SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
+ fi
fi
if test x$enable_haptic = xyes; then
if test x$have_dinput = xyes -o x$have_xinput = xyes; then
@@ -25036,6 +25058,7 @@ $as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h
CheckOpenGLX11
CheckVulkan
CheckPTHREAD
+ CheckHIDAPI
# Set up files for the audio library
if test x$enable_audio = xyes; then
@@ -25052,14 +25075,11 @@ $as_echo "#define SDL_AUDIO_DRIVER_COREAUDIO 1" >>confdefs.h
$as_echo "#define SDL_JOYSTICK_IOKIT 1" >>confdefs.h
-
-$as_echo "#define SDL_JOYSTICK_HIDAPI 1" >>confdefs.h
-
SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
- SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
- SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
- EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
have_joystick=yes
+ if test x$hidapi_support = xyes; then
+ SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
+ fi
fi
# Set up files for the haptic library
if test x$enable_haptic = xyes; then
diff --git a/configure.ac b/configure.ac
index 13eb448..9e782c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3199,26 +3199,50 @@ CheckHIDAPI()
# so we'll just use libusb when it's available.
#
# Except that libusb requires root permissions to open devices, so that's not generally useful, and we'll disable this by default.
+ #
+ # On macOS and Windows, where you don't need libusb or root, we default to yes.
+ skiplibusb=no
+ case "$host" in
+ *-*-cygwin* | *-*-mingw32* | *-*-darwin* )
+ skiplibusb=yes
+ ;;
+ esac
+
AC_ARG_ENABLE(hidapi,
-AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[default=no]]]),
- , enable_hidapi=no)
- if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then
- PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], have_libusb=yes, have_libusb=no)
- hidapi_support=no
- save_CFLAGS="$CFLAGS"
- CFLAGS="$save_CFLAGS $LIBUSB_CFLAGS"
- AC_CHECK_HEADER(libusb.h, have_libusb_h=yes)
- CFLAGS="$save_CFLAGS"
+AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[default=maybe]]]),
+ , enable_hidapi=maybe)
+ hidapi_support=no
- if test x$have_libusb_h = xyes; then
+ if test x$enable_hidapi = xmaybe; then
+ enable_hidapi=$skiplibusb
+ fi
+
+ if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then
+ if test x$skiplibusb = xyes; then
hidapi_support=yes
+ else
+ PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], have_libusb=yes, have_libusb=no)
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$save_CFLAGS $LIBUSB_CFLAGS"
+ AC_CHECK_HEADER(libusb.h, have_libusb_h=yes)
+ CFLAGS="$save_CFLAGS"
+ if test x$have_libusb_h = xyes; then
+ hidapi_support=yes
+ fi
+ fi
+
+ if test x$hidapi_support = xyes; then
AC_DEFINE(SDL_JOYSTICK_HIDAPI, 1, [ ])
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
- SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
- EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
- EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
+
+ if test x$skiplibusb = xno; then
+ SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
+ EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
+ fi
fi
+
AC_MSG_CHECKING(for hidapi support)
AC_MSG_RESULT($hidapi_support)
fi
@@ -3521,6 +3545,7 @@ case "$host" in
CheckWINDOWSGLES
CheckVulkan
CheckDIRECTX
+ CheckHIDAPI
# Set up the core platform files
SOURCES="$SOURCES $srcdir/src/core/windows/*.c"
@@ -3572,12 +3597,11 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
else
AC_DEFINE(SDL_JOYSTICK_WINMM, 1, [ ])
fi
- AC_DEFINE(SDL_JOYSTICK_HIDAPI, 1, [ ])
SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c"
- SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
- SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
- EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
have_joystick=yes
+ if test x$hidapi_support = xyes; then
+ SOURCES="$SOURCES $srcdir/src/hidapi/windows/hid.c"
+ fi
fi
if test x$enable_haptic = xyes; then
if test x$have_dinput = xyes -o x$have_xinput = xyes; then
@@ -3803,6 +3827,7 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
CheckOpenGLX11
CheckVulkan
CheckPTHREAD
+ CheckHIDAPI
# Set up files for the audio library
if test x$enable_audio = xyes; then
@@ -3815,12 +3840,11 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
# Set up files for the joystick library
if test x$enable_joystick = xyes; then
AC_DEFINE(SDL_JOYSTICK_IOKIT, 1, [ ])
- AC_DEFINE(SDL_JOYSTICK_HIDAPI, 1, [ ])
SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
- SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
- SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
- EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
have_joystick=yes
+ if test x$hidapi_support = xyes; then
+ SOURCES="$SOURCES $srcdir/src/hidapi/mac/hid.c"
+ fi
fi
# Set up files for the haptic library
if test x$enable_haptic = xyes; then