Disable libusb by default, as it breaks on Linux when trying to use it with non-root permissions on some distributions

This commit is contained in:
Sam Lantinga 2020-11-21 12:55:56 -08:00
parent 870841c414
commit 5e0644c15a
2 changed files with 58 additions and 55 deletions

59
configure vendored
View File

@ -895,6 +895,7 @@ enable_directx
enable_wasapi enable_wasapi
enable_sdl_dlopen enable_sdl_dlopen
enable_hidapi enable_hidapi
enable_hidapi_libusb
enable_clock_gettime enable_clock_gettime
enable_rpath enable_rpath
enable_backgrounding_signal enable_backgrounding_signal
@ -1691,7 +1692,9 @@ Optional Features:
--enable-wasapi use the Windows WASAPI audio driver [[default=yes]] --enable-wasapi use the Windows WASAPI audio driver [[default=yes]]
--enable-sdl-dlopen use dlopen for shared object loading [[default=yes]] --enable-sdl-dlopen use dlopen for shared object loading [[default=yes]]
--enable-hidapi use HIDAPI for low level joystick drivers --enable-hidapi use HIDAPI for low level joystick drivers
[[default=no]] [[default=yes]]
--enable-hidapi-libusb use libusb for low level joystick drivers
[[default=maybe]]
--enable-clock_gettime use clock_gettime() instead of gettimeofday() on --enable-clock_gettime use clock_gettime() instead of gettimeofday() on
UNIX [[default=yes]] UNIX [[default=yes]]
--enable-rpath use an rpath when linking SDL [[default=yes]] --enable-rpath use an rpath when linking SDL [[default=yes]]
@ -24291,23 +24294,6 @@ $as_echo "#define SDL_JOYSTICK_USBHID 1" >>confdefs.h
CheckHIDAPI() CheckHIDAPI()
{ {
# The hidraw support doesn't catch Xbox, PS4 and Nintendo controllers,
# so we'll just use libusb when it's available.
case "$host" in
# libusb does not support iOS
*-ios-* )
skiplibusb=yes
;;
# On the other hand, *BSD specifically uses libusb only
*-*-*bsd* )
onlylibusb=yes
;;
# RAWINPUT is only available on Win32, but can be enabled if HIDAPI is
*-*-cygwin* | *-*-mingw32*)
userawinput=yes
;;
esac
# Check whether --enable-hidapi was given. # Check whether --enable-hidapi was given.
if test "${enable_hidapi+set}" = set; then : if test "${enable_hidapi+set}" = set; then :
enableval=$enable_hidapi; enableval=$enable_hidapi;
@ -24315,10 +24301,33 @@ else
enable_hidapi=yes enable_hidapi=yes
fi fi
# Check whether --enable-hidapi-libusb was given.
if test "${enable_hidapi_libusb+set}" = set; then :
enableval=$enable_hidapi_libusb;
else
enable_hidapi_libusb=maybe
fi
if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then
if test x$skiplibusb = xyes; then case "$host" in
# libusb does not support iOS
*-ios-* )
enable_hidapi_libusb=no
;;
# On the other hand, *BSD specifically uses libusb only
*-*-*bsd* )
enable_hidapi_libusb=yes
require_hidapi_libusb=yes
;;
# RAWINPUT is only available on Win32, but can be enabled if HIDAPI is
*-*-cygwin* | *-*-mingw32*)
enable_joystick_rawinput=yes
;;
esac
hidapi_support=yes hidapi_support=yes
else if test x$enable_hidapi_libusb = xyes; then
pkg_failed=no pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBUSB" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBUSB" >&5
@ -24397,12 +24406,8 @@ fi
CFLAGS="$save_CFLAGS" CFLAGS="$save_CFLAGS"
if test x$have_libusb_h = xyes; then if test x$have_libusb_h = xno && test x$require_hidapi_libusb = xyes; then
hidapi_support=yes
elif test x$onlylibusb = xyes; then
hidapi_support=no hidapi_support=no
else
hidapi_support=yes
fi fi
fi fi
@ -24410,7 +24415,7 @@ fi
$as_echo "#define SDL_JOYSTICK_HIDAPI 1" >>confdefs.h $as_echo "#define SDL_JOYSTICK_HIDAPI 1" >>confdefs.h
if test x$userawinput = xyes; then if test x$enable_joystick_rawinput = xyes; then
$as_echo "#define SDL_JOYSTICK_RAWINPUT 1" >>confdefs.h $as_echo "#define SDL_JOYSTICK_RAWINPUT 1" >>confdefs.h
@ -24421,7 +24426,7 @@ $as_echo "#define SDL_JOYSTICK_RAWINPUT 1" >>confdefs.h
if test x$have_libusb_h = xyes; then if test x$have_libusb_h = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
if test x$onlylibusb = xyes; then if test x$require_hidapi_libusb = xyes; then
SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c" SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS" EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
else else

View File

@ -3309,47 +3309,45 @@ CheckUSBHID()
dnl Check for HIDAPI joystick drivers dnl Check for HIDAPI joystick drivers
CheckHIDAPI() CheckHIDAPI()
{ {
# The hidraw support doesn't catch Xbox, PS4 and Nintendo controllers,
# so we'll just use libusb when it's available.
case "$host" in
# libusb does not support iOS
*-ios-* )
skiplibusb=yes
;;
# On the other hand, *BSD specifically uses libusb only
*-*-*bsd* )
onlylibusb=yes
;;
# RAWINPUT is only available on Win32, but can be enabled if HIDAPI is
*-*-cygwin* | *-*-mingw32*)
userawinput=yes
;;
esac
AC_ARG_ENABLE(hidapi, AC_ARG_ENABLE(hidapi,
AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[default=yes]]]), AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[default=yes]]]),
, enable_hidapi=yes) , enable_hidapi=yes)
AC_ARG_ENABLE(hidapi-libusb,
AS_HELP_STRING([--enable-hidapi-libusb], [use libusb for low level joystick drivers [[default=maybe]]]),
, enable_hidapi_libusb=maybe)
if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then
if test x$skiplibusb = xyes; then case "$host" in
# libusb does not support iOS
*-ios-* )
enable_hidapi_libusb=no
;;
# On the other hand, *BSD specifically uses libusb only
*-*-*bsd* )
enable_hidapi_libusb=yes
require_hidapi_libusb=yes
;;
# RAWINPUT is only available on Win32, but can be enabled if HIDAPI is
*-*-cygwin* | *-*-mingw32*)
enable_joystick_rawinput=yes
;;
esac
hidapi_support=yes hidapi_support=yes
else if test x$enable_hidapi_libusb = xyes; then
PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], have_libusb=yes, have_libusb=no) PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], have_libusb=yes, have_libusb=no)
save_CFLAGS="$CFLAGS" save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS $LIBUSB_CFLAGS" CFLAGS="$save_CFLAGS $LIBUSB_CFLAGS"
AC_CHECK_HEADER(libusb.h, have_libusb_h=yes) AC_CHECK_HEADER(libusb.h, have_libusb_h=yes)
CFLAGS="$save_CFLAGS" CFLAGS="$save_CFLAGS"
if test x$have_libusb_h = xyes; then if test x$have_libusb_h = xno && test x$require_hidapi_libusb = xyes; then
hidapi_support=yes
elif test x$onlylibusb = xyes; then
hidapi_support=no hidapi_support=no
else
hidapi_support=yes
fi fi
fi fi
if test x$hidapi_support = xyes; then if test x$hidapi_support = xyes; then
AC_DEFINE(SDL_JOYSTICK_HIDAPI, 1, [ ]) AC_DEFINE(SDL_JOYSTICK_HIDAPI, 1, [ ])
if test x$userawinput = xyes; then if test x$enable_joystick_rawinput = xyes; then
AC_DEFINE(SDL_JOYSTICK_RAWINPUT, 1, [ ]) AC_DEFINE(SDL_JOYSTICK_RAWINPUT, 1, [ ])
fi fi
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi" EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
@ -3358,7 +3356,7 @@ AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[d
if test x$have_libusb_h = xyes; then if test x$have_libusb_h = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
if test x$onlylibusb = xyes; then if test x$require_hidapi_libusb = xyes; then
SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c" SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS" EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
else else