fix build with --disable-directx

This commit is contained in:
Ozkan Sezer 2021-01-17 05:00:50 +03:00
parent 2ea393bd83
commit f3835702d3
4 changed files with 107 additions and 101 deletions

View File

@ -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 <windows.h>
#include <xinput.h>
int main(int argc, char **argv) { }" HAVE_XINPUT_H)
check_c_source_compiles("
#include <windows.h>
#include <xinput.h>
XINPUT_GAMEPAD_EX x1;
int main(int argc, char **argv) { }" HAVE_XINPUT_GAMEPAD_EX)
check_c_source_compiles("
#include <windows.h>
#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()
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 <windows.h>
#include <xinput.h>
int main(int argc, char **argv) { }" HAVE_XINPUT_H)
check_c_source_compiles("
#include <windows.h>
#include <xinput.h>
XINPUT_GAMEPAD_EX x1;
int main(int argc, char **argv) { }" HAVE_XINPUT_GAMEPAD_EX)
check_c_source_compiles("
#include <windows.h>
#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
check_include_file(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
check_include_file(audioclient.h HAVE_AUDIOCLIENT_H)

120
configure vendored
View File

@ -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 <windows.h>
#include <xinput.h>
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 <windows.h>
#include <xinput.h>
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 <windows.h>
#include <xinput.h>
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 <windows.h>
#include <xinput.h>
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"

View File

@ -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 <windows.h>
#include <xinput.h>
XINPUT_GAMEPAD_EX x1;
],[],[have_xinput_gamepadex=yes])
AC_TRY_COMPILE([
#include <windows.h>
#include <xinput.h>
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 <windows.h>
#include <xinput.h>
XINPUT_GAMEPAD_EX x1;
],[],[have_xinput_gamepadex=yes])
AC_TRY_COMPILE([
#include <windows.h>
#include <xinput.h>
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, [ ])

View File

@ -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) {