windows: improve feature detection consistency between CMake and non-CMake builds
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
diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake
index a0784f6..4e63379 100644
--- a/include/SDL_config.h.cmake
+++ b/include/SDL_config.h.cmake
@@ -245,6 +245,7 @@
#cmakedefine HAVE_DSOUND_H @HAVE_DSOUND_H@
#cmakedefine HAVE_DINPUT_H @HAVE_DINPUT_H@
#cmakedefine HAVE_XINPUT_H @HAVE_XINPUT_H@
+#cmakedefine HAVE_WINDOWS_GAMING_INPUT_H @HAVE_WINDOWS_GAMING_INPUT_H@
#cmakedefine HAVE_DXGI_H @HAVE_DXGI_H@
#cmakedefine HAVE_MMDEVICEAPI_H @HAVE_MMDEVICEAPI_H@
diff --git a/include/SDL_config_windows.h b/include/SDL_config_windows.h
index 9fae43e..eab51f7 100644
--- a/include/SDL_config_windows.h
+++ b/include/SDL_config_windows.h
@@ -25,6 +25,12 @@
#include "SDL_platform.h"
+/* winsdkver.h defines _WIN32_MAXVER for SDK version detection. It is present since at least the Windows 7 SDK.
+ * Define NO_WINSDKVER_H if your SDK version doesn't provide this, or use CMake which can detect it automatically. */
+#ifndef NO_WINSDKVER_H
+#include <winsdkver.h>
+#endif
+
/* This is a set of defines to configure the SDL features */
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
@@ -82,6 +88,12 @@ typedef unsigned int uintptr_t;
#define HAVE_DSOUND_H 1
#define HAVE_DXGI_H 1
#define HAVE_XINPUT_H 1
+#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0A00 /* Windows 10 SDK */
+#define HAVE_WINDOWS_GAMING_INPUT_H 1
+#endif
+#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0601 /* Windows 7 SDK */
+#define HAVE_D3D11_H 1
+#endif
#define HAVE_MMDEVICEAPI_H 1
#define HAVE_AUDIOCLIENT_H 1
#define HAVE_SENSORSAPI_H 1
@@ -201,20 +213,6 @@ typedef unsigned int uintptr_t;
#define HAVE_STDDEF_H 1
#endif
-/* Check to see if we have Windows 10 build environment */
-#if defined(_MSC_VER) && (_MSC_VER >= 1911) /* Visual Studio 15.3 */
-#include <sdkddkver.h>
-#if _WIN32_WINNT >= 0x0601 /* Windows 7 */
-#define SDL_WINDOWS7_SDK
-#endif
-#if _WIN32_WINNT >= 0x0602 /* Windows 8 */
-#define SDL_WINDOWS8_SDK
-#endif
-#if _WIN32_WINNT >= 0x0A00 /* Windows 10 */
-#define SDL_WINDOWS10_SDK
-#endif
-#endif /* _MSC_VER >= 1911 */
-
/* Enable various audio drivers */
#define SDL_AUDIO_DRIVER_WASAPI 1
#define SDL_AUDIO_DRIVER_DSOUND 1
@@ -229,7 +227,7 @@ typedef unsigned int uintptr_t;
#define SDL_JOYSTICK_RAWINPUT 1
#endif
#define SDL_JOYSTICK_VIRTUAL 1
-#ifdef SDL_WINDOWS10_SDK
+#ifdef HAVE_WINDOWS_GAMING_INPUT_H
#define SDL_JOYSTICK_WGI 1
#endif
#define SDL_JOYSTICK_XINPUT 1
@@ -256,7 +254,7 @@ typedef unsigned int uintptr_t;
#ifndef SDL_VIDEO_RENDER_D3D
#define SDL_VIDEO_RENDER_D3D 1
#endif
-#ifdef SDL_WINDOWS7_SDK
+#if !defined(SDL_VIDEO_RENDER_D3D11) && defined(HAVE_D3D11_H)
#define SDL_VIDEO_RENDER_D3D11 1
#endif
diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c
index 1bcf156..2210b19 100644
--- a/src/joystick/windows/SDL_rawinputjoystick.c
+++ b/src/joystick/windows/SDL_rawinputjoystick.c
@@ -47,7 +47,7 @@
#ifdef HAVE_XINPUT_H
#define SDL_JOYSTICK_RAWINPUT_XINPUT
#endif
-#ifdef SDL_WINDOWS10_SDK
+#ifdef HAVE_WINDOWS_GAMING_INPUT_H
#define SDL_JOYSTICK_RAWINPUT_WGI
#endif