From f3835702d33dfdb65a835b98fe24aa1586a1bb72 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Sun, 17 Jan 2021 05:00:50 +0300 Subject: [PATCH] fix build with --disable-directx --- CMakeLists.txt | 40 +++---- configure | 120 ++++++++++---------- configure.ac | 43 +++---- src/joystick/windows/SDL_rawinputjoystick.c | 5 +- 4 files changed, 107 insertions(+), 101 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f749f6f3f..662658b3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1421,26 +1421,6 @@ elseif(WINDOWS) set(CMAKE_REQUIRED_FLAGS "/I\"$ENV{DXSDK_DIR}\\Include\"") endif() - if(HAVE_WIN32_CC) - # xinput.h may need windows.h, but doesn't include it itself. - check_c_source_compiles(" - #include - #include - int main(int argc, char **argv) { }" HAVE_XINPUT_H) - check_c_source_compiles(" - #include - #include - XINPUT_GAMEPAD_EX x1; - int main(int argc, char **argv) { }" HAVE_XINPUT_GAMEPAD_EX) - check_c_source_compiles(" - #include - #include - XINPUT_STATE_EX s1; - int main(int argc, char **argv) { }" HAVE_XINPUT_STATE_EX) - else() - check_include_file(xinput.h HAVE_XINPUT_H) - endif() - check_include_file(d3d9.h HAVE_D3D_H) check_include_file(d3d11_1.h HAVE_D3D11_H) check_include_file(ddraw.h HAVE_DDRAW_H) @@ -1461,6 +1441,26 @@ elseif(WINDOWS) set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS}) endif() + if(HAVE_WIN32_CC) + # xinput.h may need windows.h, but does not include it itself. + check_c_source_compiles(" + #include + #include + int main(int argc, char **argv) { }" HAVE_XINPUT_H) + check_c_source_compiles(" + #include + #include + XINPUT_GAMEPAD_EX x1; + int main(int argc, char **argv) { }" HAVE_XINPUT_GAMEPAD_EX) + check_c_source_compiles(" + #include + #include + 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 check_include_file(mmdeviceapi.h HAVE_MMDEVICEAPI_H) check_include_file(audioclient.h HAVE_AUDIOCLIENT_H) diff --git a/configure b/configure index 39aaee015..49fb94dbc 100755 --- a/configure +++ b/configure @@ -23865,50 +23865,6 @@ if test "x$ac_cv_header_dxgi_h" = xyes; then : fi - 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 -/* end confdefs.h. */ - -#include -#include -XINPUT_GAMEPAD_EX x1; - -int -main () -{ - - ; - return 0; -} -_ACEOF -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 -/* end confdefs.h. */ - -#include -#include -XINPUT_STATE_EX s1; - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - have_xinput_stateex=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test x$have_ddraw = xyes; then @@ -23929,21 +23885,6 @@ $as_echo "#define HAVE_DSOUND_H 1" >>confdefs.h $as_echo "#define HAVE_DXGI_H 1" >>confdefs.h - fi - 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 - -$as_echo "#define HAVE_XINPUT_GAMEPAD_EX 1" >>confdefs.h - - fi - if test x$have_xinput_stateex = xyes; then - -$as_echo "#define HAVE_XINPUT_STATE_EX 1" >>confdefs.h - fi # FIXME: latest Cygwin finds dinput headers, but we die on other win32 headers. @@ -23953,6 +23894,67 @@ $as_echo "#define HAVE_XINPUT_STATE_EX 1" >>confdefs.h have_dinput=false ;; esac + fi + + 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 +/* end confdefs.h. */ + +#include +#include +XINPUT_GAMEPAD_EX x1; + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 +/* end confdefs.h. */ + +#include +#include +XINPUT_STATE_EX s1; + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + have_xinput_stateex=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + 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 + +$as_echo "#define HAVE_XINPUT_GAMEPAD_EX 1" >>confdefs.h + + fi + if test x$have_xinput_stateex = xyes; then + +$as_echo "#define HAVE_XINPUT_STATE_EX 1" >>confdefs.h + fi ac_fn_c_check_header_mongrel "$LINENO" "mmdeviceapi.h" "ac_cv_header_mmdeviceapi_h" "$ac_includes_default" diff --git a/configure.ac b/configure.ac index cc2f06474..b47c75b6d 100644 --- a/configure.ac +++ b/configure.ac @@ -3154,17 +3154,6 @@ AS_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[defaul AC_CHECK_HEADER(dsound.h, have_dsound=yes) AC_CHECK_HEADER(dinput.h, have_dinput=yes) AC_CHECK_HEADER(dxgi.h, have_dxgi=yes) - AC_CHECK_HEADER(xinput.h, have_xinput=yes) - AC_TRY_COMPILE([ -#include -#include -XINPUT_GAMEPAD_EX x1; - ],[],[have_xinput_gamepadex=yes]) - AC_TRY_COMPILE([ -#include -#include -XINPUT_STATE_EX s1; - ],[],[have_xinput_stateex=yes]) if test x$have_ddraw = xyes; then AC_DEFINE(HAVE_DDRAW_H, 1, [ ]) @@ -3178,15 +3167,6 @@ XINPUT_STATE_EX s1; if test x$have_dxgi = xyes; then AC_DEFINE(HAVE_DXGI_H, 1, [ ]) fi - 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 # FIXME: latest Cygwin finds dinput headers, but we die on other win32 headers. # FIXME: ...so force it off for now. @@ -3197,6 +3177,29 @@ XINPUT_STATE_EX s1; esac fi + dnl The following are independent of --enable-directx + AC_CHECK_HEADER(xinput.h, have_xinput=yes) + AC_TRY_COMPILE([ +#include +#include +XINPUT_GAMEPAD_EX x1; + ],[],[have_xinput_gamepadex=yes]) + AC_TRY_COMPILE([ +#include +#include +XINPUT_STATE_EX s1; + ],[],[have_xinput_stateex=yes]) + + 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 + AC_CHECK_HEADER(mmdeviceapi.h, have_wasapi=yes) if test x$have_wasapi = xyes; then AC_DEFINE(HAVE_MMDEVICEAPI_H, 1, [ ]) diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c index 27c67a82f..26ed60690 100644 --- a/src/joystick/windows/SDL_rawinputjoystick.c +++ b/src/joystick/windows/SDL_rawinputjoystick.c @@ -44,7 +44,9 @@ #include "../../core/windows/SDL_hid.h" #include "../hidapi/SDL_hidapijoystick_c.h" +#ifdef HAVE_XINPUT_H #define SDL_JOYSTICK_RAWINPUT_XINPUT +#endif #ifdef SDL_WINDOWS10_SDK #define SDL_JOYSTICK_RAWINPUT_WGI #endif @@ -1216,9 +1218,8 @@ RAWINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uin { #if defined(SDL_JOYSTICK_RAWINPUT_WGI) || defined(SDL_JOYSTICK_RAWINPUT_XINPUT) RAWINPUT_DeviceContext *ctx = joystick->hwdata; -#endif - SDL_bool rumbled = SDL_FALSE; +#endif #ifdef SDL_JOYSTICK_RAWINPUT_WGI if (!rumbled && ctx->wgi_correlated) {