Fixed building without linux/input.h

https://github.com/libsdl-org/SDL/issues/6169
This commit is contained in:
Sam Lantinga 2022-11-11 10:24:17 -08:00
parent b7e65a81f1
commit 9f8b68a278
12 changed files with 39 additions and 19 deletions

View File

@ -1010,6 +1010,7 @@ if(SDL_LIBC)
string(REPLACE "." "_" _HAVE_H ${_UPPER}) string(REPLACE "." "_" _HAVE_H ${_UPPER})
check_include_file("${_HEADER}" ${_HAVE_H}) check_include_file("${_HEADER}" ${_HAVE_H})
endforeach() endforeach()
check_include_file(linux/input.h HAVE_LINUX_INPUT_H)
set(STDC_HEADER_NAMES "stddef.h;stdarg.h;stdlib.h;string.h;stdio.h;wchar.h;float.h") set(STDC_HEADER_NAMES "stddef.h;stdarg.h;stdlib.h;string.h;stdio.h;wchar.h;float.h")
check_include_files("${STDC_HEADER_NAMES}" STDC_HEADERS) check_include_files("${STDC_HEADER_NAMES}" STDC_HEADERS)
@ -1579,7 +1580,7 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
if(FREEBSD OR NETBSD OR OPENBSD OR BSDI) if(FREEBSD OR NETBSD OR OPENBSD OR BSDI)
CheckUSBHID() CheckUSBHID()
endif() endif()
if(LINUX AND NOT ANDROID) if(LINUX AND HAVE_LINUX_INPUT_H AND NOT ANDROID)
set(SDL_JOYSTICK_LINUX 1) set(SDL_JOYSTICK_LINUX 1)
file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/linux/*.c ${SDL2_SOURCE_DIR}/src/joystick/steam/*.c) file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/linux/*.c ${SDL2_SOURCE_DIR}/src/joystick/steam/*.c)
list(APPEND SOURCE_FILES ${JOYSTICK_SOURCES}) list(APPEND SOURCE_FILES ${JOYSTICK_SOURCES})

16
configure vendored
View File

@ -18816,6 +18816,12 @@ if test "x$ac_cv_header_signal_h" = xyes
then : then :
printf "%s\n" "#define HAVE_SIGNAL_H 1" >>confdefs.h printf "%s\n" "#define HAVE_SIGNAL_H 1" >>confdefs.h
fi
ac_fn_c_check_header_compile "$LINENO" "linux/input.h" "ac_cv_header_linux_input_h" "$ac_includes_default"
if test "x$ac_cv_header_linux_input_h" = xyes
then :
printf "%s\n" "#define HAVE_LINUX_INPUT_H 1" >>confdefs.h
fi fi
@ -28492,15 +28498,17 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_AAUDIO 1" >>confdefs.h
if test x$enable_joystick = xyes; then if test x$enable_joystick = xyes; then
case $ARCH in case $ARCH in
linux) linux)
if test "x$ac_cv_header_linux_input_h" = xyes; then
printf "%s\n" "#define SDL_JOYSTICK_LINUX 1" >>confdefs.h printf "%s\n" "#define SDL_JOYSTICK_LINUX 1" >>confdefs.h
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
fi
;; ;;
freebsd) freebsd)
if test x$use_input_events = xyes; then if test x$use_input_events = xyes -a x$ac_cv_header_linux_input_h = xyes; then
printf "%s\n" "#define SDL_JOYSTICK_LINUX 1" >>confdefs.h printf "%s\n" "#define SDL_JOYSTICK_LINUX 1" >>confdefs.h

View File

@ -329,7 +329,7 @@ if test x$enable_libc = xyes; then
dnl Check for C library headers dnl Check for C library headers
dnl AC_CHECK_INCLUDES_DEFAULT is an autoconf-2.7x thing where AC_HEADER_STDC is deprecated. dnl AC_CHECK_INCLUDES_DEFAULT is an autoconf-2.7x thing where AC_HEADER_STDC is deprecated.
m4_ifdef([AC_CHECK_INCLUDES_DEFAULT], [AC_CHECK_INCLUDES_DEFAULT], [AC_HEADER_STDC]) m4_ifdef([AC_CHECK_INCLUDES_DEFAULT], [AC_CHECK_INCLUDES_DEFAULT], [AC_HEADER_STDC])
AC_CHECK_HEADERS(sys/types.h stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h strings.h wchar.h inttypes.h stdint.h limits.h ctype.h math.h float.h iconv.h signal.h) AC_CHECK_HEADERS(sys/types.h stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h strings.h wchar.h inttypes.h stdint.h limits.h ctype.h math.h float.h iconv.h signal.h linux/input.h)
dnl Check for typedefs, structures, etc. dnl Check for typedefs, structures, etc.
AC_TYPE_SIZE_T AC_TYPE_SIZE_T
@ -3900,13 +3900,15 @@ case "$host" in
if test x$enable_joystick = xyes; then if test x$enable_joystick = xyes; then
case $ARCH in case $ARCH in
linux) linux)
AC_DEFINE(SDL_JOYSTICK_LINUX, 1, [ ]) if test "x$ac_cv_header_linux_input_h" = xyes; then
SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c" AC_DEFINE(SDL_JOYSTICK_LINUX, 1, [ ])
SOURCES="$SOURCES $srcdir/src/joystick/steam/*.c" SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
have_joystick=yes SOURCES="$SOURCES $srcdir/src/joystick/steam/*.c"
have_joystick=yes
fi
;; ;;
freebsd) freebsd)
if test x$use_input_events = xyes; then if test x$use_input_events = xyes -a x$ac_cv_header_linux_input_h = xyes; then
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"

View File

@ -72,6 +72,7 @@
#cmakedefine HAVE_STRING_H 1 #cmakedefine HAVE_STRING_H 1
#cmakedefine HAVE_SYS_TYPES_H 1 #cmakedefine HAVE_SYS_TYPES_H 1
#cmakedefine HAVE_WCHAR_H 1 #cmakedefine HAVE_WCHAR_H 1
#cmakedefine HAVE_LINUX_INPUT_H 1
#cmakedefine HAVE_PTHREAD_NP_H 1 #cmakedefine HAVE_PTHREAD_NP_H 1
#cmakedefine HAVE_LIBUNWIND_H 1 #cmakedefine HAVE_LIBUNWIND_H 1

View File

@ -75,6 +75,7 @@
#undef HAVE_STRING_H #undef HAVE_STRING_H
#undef HAVE_SYS_TYPES_H #undef HAVE_SYS_TYPES_H
#undef HAVE_WCHAR_H #undef HAVE_WCHAR_H
#undef HAVE_LINUX_INPUT_H
#undef HAVE_PTHREAD_NP_H #undef HAVE_PTHREAD_NP_H
#undef HAVE_LIBUNWIND_H #undef HAVE_LIBUNWIND_H

View File

@ -19,10 +19,12 @@
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#include "../../SDL_internal.h"
#include "SDL_evdev_capabilities.h" #include "SDL_evdev_capabilities.h"
#if HAVE_LIBUDEV_H || defined(SDL_JOYSTICK_LINUX)
#if HAVE_LINUX_INPUT_H
/* missing defines in older Linux kernel headers */ /* missing defines in older Linux kernel headers */
#ifndef BTN_TRIGGER_HAPPY #ifndef BTN_TRIGGER_HAPPY
@ -142,4 +144,6 @@ SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)],
return devclass; return devclass;
} }
#endif #endif /* HAVE_LINUX_INPUT_H */
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -19,12 +19,13 @@
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#include "../../SDL_internal.h" #include "../../SDL_internal.h"
#ifndef SDL_evdev_capabilities_h_ #ifndef SDL_evdev_capabilities_h_
#define SDL_evdev_capabilities_h_ #define SDL_evdev_capabilities_h_
#if HAVE_LINUX_INPUT_H
#include <linux/input.h> #include <linux/input.h>
/* A device can be any combination of these classes */ /* A device can be any combination of these classes */
@ -51,6 +52,8 @@ extern int SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)],
unsigned long bitmask_key[NBITS(KEY_MAX)], unsigned long bitmask_key[NBITS(KEY_MAX)],
unsigned long bitmask_rel[NBITS(REL_MAX)]); unsigned long bitmask_rel[NBITS(REL_MAX)]);
#endif /* HAVE_LINUX_INPUT_H */
#endif /* SDL_evdev_capabilities_h_ */ #endif /* SDL_evdev_capabilities_h_ */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

View File

@ -18,6 +18,7 @@
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#include "../../SDL_internal.h"
#include "SDL_ime.h" #include "SDL_ime.h"
#include "SDL_ibus.h" #include "SDL_ibus.h"

View File

@ -19,9 +19,8 @@
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#include "../../SDL_internal.h" #include "../../SDL_internal.h"
#include "SDL_sandbox.h" #include "SDL_sandbox.h"
#include <unistd.h> #include <unistd.h>

View File

@ -18,6 +18,7 @@
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#include "../../SDL_internal.h"
/* /*
* To list the properties of a device, try something like: * To list the properties of a device, try something like:

View File

@ -24,7 +24,7 @@
#ifndef SDL_udev_h_ #ifndef SDL_udev_h_
#define SDL_udev_h_ #define SDL_udev_h_
#if HAVE_LIBUDEV_H #if HAVE_LIBUDEV_H && HAVE_LINUX_INPUT_H
#ifndef SDL_USE_LIBUDEV #ifndef SDL_USE_LIBUDEV
#define SDL_USE_LIBUDEV 1 #define SDL_USE_LIBUDEV 1
@ -108,7 +108,7 @@ extern const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void);
extern void SDL_UDEV_ReleaseUdevSyms(void); extern void SDL_UDEV_ReleaseUdevSyms(void);
#endif /* HAVE_LIBUDEV_H */ #endif /* HAVE_LIBUDEV_H && HAVE_LINUX_INPUT_H */
#endif /* SDL_udev_h_ */ #endif /* SDL_udev_h_ */

View File

@ -551,7 +551,6 @@ HIDAPI_ShutdownDiscovery()
#undef HIDAPI_H__ #undef HIDAPI_H__
#if __LINUX__ #if __LINUX__
#include "../core/linux/SDL_udev.h"
#if SDL_USE_LIBUDEV #if SDL_USE_LIBUDEV
static const SDL_UDEV_Symbols *udev_ctx = NULL; static const SDL_UDEV_Symbols *udev_ctx = NULL;