Added the hint SDL_HINT_JOYSTICK_WGI to control whether to use Windows.Gaming.Input for controllers (cherry picked from commit a6228e7aafb66075fe8f4aaf411314fc92340499)
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
diff --git a/WhatsNew.txt b/WhatsNew.txt
index a5636ed..1d7c27e 100644
--- a/WhatsNew.txt
+++ b/WhatsNew.txt
@@ -2,6 +2,13 @@
This is a list of major changes in SDL's version history.
---------------------------------------------------------------------------
+2.28.2:
+---------------------------------------------------------------------------
+General:
+* Added the hint SDL_HINT_JOYSTICK_WGI to control whether to use Windows.Gaming.Input for controllers
+
+
+---------------------------------------------------------------------------
2.28.0:
---------------------------------------------------------------------------
diff --git a/include/SDL_hints.h b/include/SDL_hints.h
index ad3b403..c808a60 100644
--- a/include/SDL_hints.h
+++ b/include/SDL_hints.h
@@ -1008,6 +1008,15 @@ extern "C" {
#define SDL_HINT_JOYSTICK_THREAD "SDL_JOYSTICK_THREAD"
/**
+ * \brief A variable controlling whether Windows.Gaming.Input should be used for controller handling.
+ *
+ * This variable can be set to the following values:
+ * "0" - WGI is not used
+ * "1" - WGI is used (the default)
+ */
+#define SDL_HINT_JOYSTICK_WGI "SDL_JOYSTICK_WGI"
+
+/**
* \brief Determines whether SDL enforces that DRM master is required in order
* to initialize the KMSDRM video backend.
*
diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c
index 9aa264f..b6f8a5e 100644
--- a/src/joystick/windows/SDL_rawinputjoystick.c
+++ b/src/joystick/windows/SDL_rawinputjoystick.c
@@ -564,6 +564,10 @@ static void RAWINPUT_UpdateWindowsGamingInput()
}
static void RAWINPUT_InitWindowsGamingInput(RAWINPUT_DeviceContext *ctx)
{
+ if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_WGI, SDL_TRUE)) {
+ return;
+ }
+
wgi_state.need_device_list_update = SDL_TRUE;
wgi_state.ref_count++;
if (!wgi_state.initialized) {
@@ -879,12 +883,12 @@ static int RAWINPUT_JoystickInit(void)
{
SDL_assert(!SDL_RAWINPUT_inited);
- if (!WIN_IsWindowsVistaOrGreater()) {
- /* According to bug 6400, this doesn't work on Windows XP */
- return -1;
+ if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_RAWINPUT, SDL_TRUE)) {
+ return 0;
}
- if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_RAWINPUT, SDL_TRUE)) {
+ if (!WIN_IsWindowsVistaOrGreater()) {
+ /* According to bug 6400, this doesn't work on Windows XP */
return -1;
}
diff --git a/src/joystick/windows/SDL_windows_gaming_input.c b/src/joystick/windows/SDL_windows_gaming_input.c
index f9e7e42..218c0fb 100644
--- a/src/joystick/windows/SDL_windows_gaming_input.c
+++ b/src/joystick/windows/SDL_windows_gaming_input.c
@@ -483,6 +483,10 @@ static int WGI_JoystickInit(void)
RoGetActivationFactory_t RoGetActivationFactoryFunc = NULL;
HRESULT hr;
+ if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_WGI, SDL_TRUE)) {
+ return 0;
+ }
+
if (FAILED(WIN_RoInitialize())) {
return SDL_SetError("RoInitialize() failed");
}