From 189b3434601a9d080a6c7f4cc2ce7d85901890fb Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Thu, 14 May 2026 21:55:55 +0300 Subject: [PATCH] fix build after commit 2c4e6ed3585ec63adee2e9a680de3c52b4db3c0c: move SDL_UsingGameInputForXInputControllers() to core/windows/SDL_gameinput.cpp because joystick/gdk/SDL_gameinputjoystick.cpp isn't always added to build. --- src/core/windows/SDL_gameinput.cpp | 20 +++++++++-- src/core/windows/SDL_gameinput.h | 17 ++++++++++ src/joystick/gdk/SDL_gameinputjoystick.cpp | 26 --------------- src/joystick/gdk/SDL_gameinputjoystick_c.h | 33 ------------------- src/joystick/windows/SDL_dinputjoystick.c | 2 +- src/joystick/windows/SDL_rawinputjoystick.c | 2 +- .../windows/SDL_windows_gaming_input.c | 2 +- src/joystick/windows/SDL_xinputjoystick.c | 7 ++-- 8 files changed, 41 insertions(+), 68 deletions(-) delete mode 100644 src/joystick/gdk/SDL_gameinputjoystick_c.h diff --git a/src/core/windows/SDL_gameinput.cpp b/src/core/windows/SDL_gameinput.cpp index 7139a4c36d225..f9996916a573a 100644 --- a/src/core/windows/SDL_gameinput.cpp +++ b/src/core/windows/SDL_gameinput.cpp @@ -20,11 +20,11 @@ */ #include "SDL_internal.h" -#ifdef HAVE_GAMEINPUT_H - #include "SDL_windows.h" #include "SDL_gameinput.h" +#ifdef HAVE_GAMEINPUT_H + static SDL_SharedObject *g_hGameInputDLL; static IGameInput *g_pGameInput; static int g_nGameInputRefCount; @@ -99,4 +99,20 @@ void SDL_QuitGameInput(void) } } +bool SDL_UsingGameInputForXInputControllers(void) +{ + if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_GAMEINPUT, SDL_GAMEINPUT_DEFAULT) && + SDL_GameInputReady()) { + return true; + } + return false; +} + +#else + +bool SDL_UsingGameInputForXInputControllers(void) +{ + return false; +} + #endif // HAVE_GAMEINPUT_H diff --git a/src/core/windows/SDL_gameinput.h b/src/core/windows/SDL_gameinput.h index cf8a978a576be..6969ad0dd28fd 100644 --- a/src/core/windows/SDL_gameinput.h +++ b/src/core/windows/SDL_gameinput.h @@ -48,10 +48,27 @@ using namespace GameInput::v2; using namespace GameInput::v1; #endif +// Default value for SDL_HINT_JOYSTICK_GAMEINPUT +#if defined(SDL_PLATFORM_GDK) || (GAMEINPUT_API_VERSION >= 3) +#define SDL_GAMEINPUT_DEFAULT true +#else +#define SDL_GAMEINPUT_DEFAULT false +#endif + extern bool SDL_InitGameInput(IGameInput **ppGameInput); extern bool SDL_GameInputReady(void); extern void SDL_QuitGameInput(void); #endif // HAVE_GAMEINPUT_H +#ifdef __cplusplus +extern "C" { +#endif + +extern bool SDL_UsingGameInputForXInputControllers(void); + +#ifdef __cplusplus +} +#endif + #endif // SDL_gameinput_h_ diff --git a/src/joystick/gdk/SDL_gameinputjoystick.cpp b/src/joystick/gdk/SDL_gameinputjoystick.cpp index 7456190615bc0..0c04592ac564e 100644 --- a/src/joystick/gdk/SDL_gameinputjoystick.cpp +++ b/src/joystick/gdk/SDL_gameinputjoystick.cpp @@ -20,8 +20,6 @@ */ #include "SDL_internal.h" -#include "SDL_gameinputjoystick_c.h" - #ifdef SDL_JOYSTICK_GAMEINPUT #include "../SDL_sysjoystick.h" @@ -29,13 +27,6 @@ #include "../../core/windows/SDL_windows.h" #include "../../core/windows/SDL_gameinput.h" -// Default value for SDL_HINT_JOYSTICK_GAMEINPUT -#if defined(SDL_PLATFORM_GDK) || (GAMEINPUT_API_VERSION >= 3) -#define SDL_GAMEINPUT_DEFAULT true -#else -#define SDL_GAMEINPUT_DEFAULT false -#endif - enum { SDL_GAMEPAD_BUTTON_GAMEINPUT_SHARE = 11 @@ -1053,15 +1044,6 @@ static bool GAMEINPUT_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap return true; } -bool SDL_UsingGameInputForXInputControllers(void) -{ - if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_GAMEINPUT, SDL_GAMEINPUT_DEFAULT) && - SDL_GameInputReady()) { - return true; - } - return false; -} - SDL_JoystickDriver SDL_GAMEINPUT_JoystickDriver = { @@ -1088,12 +1070,4 @@ SDL_JoystickDriver SDL_GAMEINPUT_JoystickDriver = GAMEINPUT_JoystickGetGamepadMapping }; - -#else - -bool SDL_UsingGameInputForXInputControllers(void) -{ - return false; -} - #endif // SDL_JOYSTICK_GAMEINPUT diff --git a/src/joystick/gdk/SDL_gameinputjoystick_c.h b/src/joystick/gdk/SDL_gameinputjoystick_c.h deleted file mode 100644 index 814166b63f704..0000000000000 --- a/src/joystick/gdk/SDL_gameinputjoystick_c.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2026 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_internal.h" - -// Set up for C function definitions, even when using C++ -#ifdef __cplusplus -extern "C" { -#endif - -extern bool SDL_UsingGameInputForXInputControllers(void); - -// Ends C function definitions when using C++ -#ifdef __cplusplus -} -#endif diff --git a/src/joystick/windows/SDL_dinputjoystick.c b/src/joystick/windows/SDL_dinputjoystick.c index e9c818aa0063e..b720288ef34e6 100644 --- a/src/joystick/windows/SDL_dinputjoystick.c +++ b/src/joystick/windows/SDL_dinputjoystick.c @@ -28,8 +28,8 @@ #include "SDL_dinputjoystick_c.h" #include "SDL_rawinputjoystick_c.h" #include "SDL_xinputjoystick_c.h" +#include "../../core/windows/SDL_gameinput.h" #include "../hidapi/SDL_hidapijoystick_c.h" -#include "../gdk/SDL_gameinputjoystick_c.h" #ifndef DIDFT_OPTIONAL #define DIDFT_OPTIONAL 0x80000000 diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c index 92c9e026a5c8e..da557c5e86802 100644 --- a/src/joystick/windows/SDL_rawinputjoystick.c +++ b/src/joystick/windows/SDL_rawinputjoystick.c @@ -37,8 +37,8 @@ #include "../SDL_sysjoystick.h" #include "../../core/windows/SDL_windows.h" #include "../../core/windows/SDL_hid.h" +#include "../../core/windows/SDL_gameinput.h" #include "../hidapi/SDL_hidapijoystick_c.h" -#include "../gdk/SDL_gameinputjoystick_c.h" /* SDL_JOYSTICK_RAWINPUT_XINPUT is disabled because using XInput at the same time as raw input will turn off the Xbox Series X controller when it is connected via the diff --git a/src/joystick/windows/SDL_windows_gaming_input.c b/src/joystick/windows/SDL_windows_gaming_input.c index f8840ac2304d8..e08f568d91053 100644 --- a/src/joystick/windows/SDL_windows_gaming_input.c +++ b/src/joystick/windows/SDL_windows_gaming_input.c @@ -24,7 +24,7 @@ #include "../SDL_sysjoystick.h" #include "../hidapi/SDL_hidapijoystick_c.h" -#include "../gdk/SDL_gameinputjoystick_c.h" +#include "../../core/windows/SDL_gameinput.h" #include "SDL_rawinputjoystick_c.h" #include "../../core/windows/SDL_windows.h" diff --git a/src/joystick/windows/SDL_xinputjoystick.c b/src/joystick/windows/SDL_xinputjoystick.c index 377defb07d3b2..32876fbfad20b 100644 --- a/src/joystick/windows/SDL_xinputjoystick.c +++ b/src/joystick/windows/SDL_xinputjoystick.c @@ -27,17 +27,16 @@ #include "SDL_windowsjoystick_c.h" #include "SDL_xinputjoystick_c.h" #include "SDL_rawinputjoystick_c.h" +#include "../../core/windows/SDL_gameinput.h" #include "../hidapi/SDL_hidapijoystick_c.h" -#include "../gdk/SDL_gameinputjoystick_c.h" // Set up for C function definitions, even when using C++ #ifdef __cplusplus extern "C" { #endif -/* - * Internal stuff. - */ +// Internal stuff + static bool s_bXInputEnabled = false; bool SDL_XINPUT_Enabled(void)