fix build with --disable-directx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f749f6f..662658b 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 <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)
diff --git a/configure b/configure
index 39aaee0..49fb94d 100755
--- a/configure
+++ b/configure
@@ -23865,13 +23865,44 @@ if test "x$ac_cv_header_dxgi_h" = xyes; then :
fi
+
+ if test x$have_ddraw = xyes; then
+
+$as_echo "#define HAVE_DDRAW_H 1" >>confdefs.h
+
+ fi
+ if test x$have_dinput = xyes; then
+
+$as_echo "#define HAVE_DINPUT_H 1" >>confdefs.h
+
+ fi
+ if test x$have_dsound = xyes; then
+
+$as_echo "#define HAVE_DSOUND_H 1" >>confdefs.h
+
+ fi
+ if test x$have_dxgi = xyes; then
+
+$as_echo "#define HAVE_DXGI_H 1" >>confdefs.h
+
+ fi
+
+ # FIXME: latest Cygwin finds dinput headers, but we die on other win32 headers.
+ # FIXME: ...so force it off for now.
+ case "$host" in
+ *-*-cygwin*)
+ 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
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <windows.h>
@@ -23890,7 +23921,7 @@ 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
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <windows.h>
@@ -23910,49 +23941,20 @@ if ac_fn_c_try_compile "$LINENO"; then :
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- if test x$have_ddraw = xyes; then
-
-$as_echo "#define HAVE_DDRAW_H 1" >>confdefs.h
-
- fi
- if test x$have_dinput = xyes; then
-
-$as_echo "#define HAVE_DINPUT_H 1" >>confdefs.h
-
- fi
- if test x$have_dsound = xyes; then
-
-$as_echo "#define HAVE_DSOUND_H 1" >>confdefs.h
-
- fi
- if test x$have_dxgi = xyes; then
-
-$as_echo "#define HAVE_DXGI_H 1" >>confdefs.h
-
- fi
- 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
-
- # FIXME: latest Cygwin finds dinput headers, but we die on other win32 headers.
- # FIXME: ...so force it off for now.
- case "$host" in
- *-*-cygwin*)
- have_dinput=false
- ;;
- esac
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 cc2f064..b47c75b 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 <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, [ ])
diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c
index 27c67a8..26ed606 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) {