added --enable-xinput switch for windows builds

This commit is contained in:
Ozkan Sezer 2021-01-29 23:11:13 +03:00
parent d6a6662fa1
commit 091a4649e8
4 changed files with 57 additions and 27 deletions

View File

@ -386,6 +386,7 @@ foreach(_SUB ${SDL_X11_OPTIONS})
endforeach()
set_option(VIDEO_COCOA "Use Cocoa video driver" ${APPLE})
set_option(DIRECTX "Use DirectX for Windows audio/video" ${WINDOWS})
set_option(XINPUT "Use Xinput for Windows" ${WINDOWS})
set_option(WASAPI "Use the Windows WASAPI audio driver" ${WINDOWS})
set_option(RENDER_D3D "Enable the Direct3D render driver" ${WINDOWS})
set_option(RENDER_METAL "Enable the Metal render driver" ${APPLE})
@ -1453,7 +1454,7 @@ elseif(WINDOWS)
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
endif()
if(HAVE_WIN32_CC)
if(XINPUT)
# xinput.h may need windows.h, but does not include it itself.
check_c_source_compiles("
#include <windows.h>
@ -1469,8 +1470,6 @@ elseif(WINDOWS)
#include <xinput.h>
XINPUT_STATE_EX s1;
int main(int argc, char **argv) { }" HAVE_XINPUT_STATE_EX)
else()
check_include_file(xinput.h HAVE_XINPUT_H)
endif()
# headers needed elsewhere

View File

@ -400,7 +400,7 @@ macro(CheckX11)
check_include_file(X11/Xcursor/Xcursor.h HAVE_XCURSOR_H)
check_include_file(X11/extensions/Xinerama.h HAVE_XINERAMA_H)
check_include_file(X11/extensions/XInput2.h HAVE_XINPUT_H)
check_include_file(X11/extensions/XInput2.h HAVE_XINPUT2_H)
check_include_file(X11/extensions/Xrandr.h HAVE_XRANDR_H)
check_include_file(X11/extensions/Xrender.h HAVE_XRENDER_H)
check_include_file(X11/extensions/scrnsaver.h HAVE_XSS_H)
@ -498,7 +498,7 @@ macro(CheckX11)
set(SDL_VIDEO_DRIVER_X11_XINERAMA 1)
endif()
if(VIDEO_X11_XINPUT AND HAVE_XINPUT_H)
if(VIDEO_X11_XINPUT AND HAVE_XINPUT2_H)
set(HAVE_VIDEO_X11_XINPUT TRUE)
if(HAVE_X11_SHARED AND XI_LIB)
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "\"${XI_LIB_SONAME}\"")

35
configure vendored
View File

@ -892,6 +892,7 @@ enable_joystick_mfi
enable_pthreads
enable_pthread_sem
enable_directx
enable_xinput
enable_wasapi
enable_sdl_dlopen
enable_hidapi
@ -1677,6 +1678,7 @@ Optional Features:
[[default=yes]]
--enable-pthread-sem use pthread semaphores [[default=yes]]
--enable-directx use DirectX for Windows audio/video [[default=yes]]
--enable-xinput use Xinput for Windows [[default=yes]]
--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
@ -23896,13 +23898,25 @@ $as_echo "#define HAVE_DXGI_H 1" >>confdefs.h
esac
fi
# Check whether --enable-xinput was given.
if test "${enable_xinput+set}" = set; then :
enableval=$enable_xinput;
else
enable_xinput=yes
fi
if test x$enable_xinput = xyes; then
have_xinput_gamepadex=no
have_xinput_stateex=no
ac_fn_c_check_header_mongrel "$LINENO" "xinput.h" "ac_cv_header_xinput_h" "$ac_includes_default"
if test "x$ac_cv_header_xinput_h" = xyes; then :
have_xinput=yes
fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct XINPUT_GAMEPAD_EX" >&5
$as_echo_n "checking for struct XINPUT_GAMEPAD_EX... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <windows.h>
@ -23921,7 +23935,11 @@ if ac_fn_c_try_compile "$LINENO"; then :
have_xinput_gamepadex=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_xinput_gamepadex" >&5
$as_echo "$have_xinput_gamepadex" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct XINPUT_STATE_EX" >&5
$as_echo_n "checking for struct XINPUT_STATE_EX... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <windows.h>
@ -23940,21 +23958,24 @@ if ac_fn_c_try_compile "$LINENO"; then :
have_xinput_stateex=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_xinput_stateex" >&5
$as_echo "$have_xinput_stateex" >&6; }
if test x$have_xinput = xyes; then
if test x$have_xinput = xyes; then
$as_echo "#define HAVE_XINPUT_H 1" >>confdefs.h
fi
if test x$have_xinput_gamepadex = xyes; then
fi
if test x$have_xinput_gamepadex = xyes; then
$as_echo "#define HAVE_XINPUT_GAMEPAD_EX 1" >>confdefs.h
fi
if test x$have_xinput_stateex = xyes; then
fi
if test x$have_xinput_stateex = xyes; then
$as_echo "#define HAVE_XINPUT_STATE_EX 1" >>confdefs.h
fi
fi
ac_fn_c_check_header_mongrel "$LINENO" "mmdeviceapi.h" "ac_cv_header_mmdeviceapi_h" "$ac_includes_default"

View File

@ -3146,7 +3146,7 @@ CheckDIRECTX()
{
AC_ARG_ENABLE(directx,
AS_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[default=yes]]]),
, enable_directx=yes)
, enable_directx=yes)
if test x$enable_directx = xyes; then
AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
AC_CHECK_HEADER(d3d11_1.h, have_d3d11=yes)
@ -3177,27 +3177,37 @@ AS_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[defaul
esac
fi
dnl The following are independent of --enable-directx
AC_CHECK_HEADER(xinput.h, have_xinput=yes)
AC_TRY_COMPILE([
AC_ARG_ENABLE(xinput,
AS_HELP_STRING([--enable-xinput], [use Xinput for Windows [[default=yes]]]),
, enable_xinput=yes)
if test x$enable_xinput = xyes; then
have_xinput_gamepadex=no
have_xinput_stateex=no
AC_CHECK_HEADER(xinput.h, have_xinput=yes)
AC_MSG_CHECKING(for struct XINPUT_GAMEPAD_EX)
AC_TRY_COMPILE([
#include <windows.h>
#include <xinput.h>
XINPUT_GAMEPAD_EX x1;
],[],[have_xinput_gamepadex=yes])
AC_TRY_COMPILE([
],[],[have_xinput_gamepadex=yes])
AC_MSG_RESULT($have_xinput_gamepadex)
AC_MSG_CHECKING(for struct XINPUT_STATE_EX)
AC_TRY_COMPILE([
#include <windows.h>
#include <xinput.h>
XINPUT_STATE_EX s1;
],[],[have_xinput_stateex=yes])
],[],[have_xinput_stateex=yes])
AC_MSG_RESULT($have_xinput_stateex)
if test x$have_xinput = xyes; then
AC_DEFINE(HAVE_XINPUT_H, 1, [ ])
fi
if test x$have_xinput_gamepadex = xyes; then
AC_DEFINE(HAVE_XINPUT_GAMEPAD_EX, 1, [ ])
fi
if test x$have_xinput_stateex = xyes; then
AC_DEFINE(HAVE_XINPUT_STATE_EX, 1, [ ])
if test x$have_xinput = xyes; then
AC_DEFINE(HAVE_XINPUT_H, 1, [ ])
fi
if test x$have_xinput_gamepadex = xyes; then
AC_DEFINE(HAVE_XINPUT_GAMEPAD_EX, 1, [ ])
fi
if test x$have_xinput_stateex = xyes; then
AC_DEFINE(HAVE_XINPUT_STATE_EX, 1, [ ])
fi
fi
AC_CHECK_HEADER(mmdeviceapi.h, have_wasapi=yes)