From 2371b247fff6ba48a622f67aaa6d15b9ac54c95a Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 31 Oct 2021 18:27:51 -0500 Subject: [PATCH] windows: improve feature detection consistency between CMake and non-CMake builds --- include/SDL_config.h.cmake | 1 + include/SDL_config_windows.h | 30 ++++++++++----------- src/joystick/windows/SDL_rawinputjoystick.c | 2 +- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index a0784f603..4e6337994 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 9fae43ed3..eab51f73d 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 +#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 -#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 1bcf1564d..2210b192d 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