From 834a84fabb974935e1f38b24c305fe19ef396c40 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Tue, 3 Aug 2021 05:02:32 -0400
Subject: [PATCH] winrt: Don't use LoadLibraryA on WinRT.
This removes the CM_Register_Notification code on WinRT. Note
that this API _is_ available to UWP apps as of Windows 10.0.17763
(version 1809, released October 2018), according to:
https://docs.microsoft.com/en-us/uwp/win32-and-com/win32-apis#apis-from-api-ms-win-devices-config-l1-1-1dll
So it might be worth readding with some sort of preprocessor check
for minimum targeted version, or whatever is appropriate for WinRT
development.
---
src/joystick/windows/SDL_windowsjoystick.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/joystick/windows/SDL_windowsjoystick.c b/src/joystick/windows/SDL_windowsjoystick.c
index 65d02808ee..a3c3aff7e6 100644
--- a/src/joystick/windows/SDL_windowsjoystick.c
+++ b/src/joystick/windows/SDL_windowsjoystick.c
@@ -141,7 +141,7 @@ static GUID GUID_DEVINTERFACE_HID = { 0x4D1E55B2L, 0xF16F, 0x11CF, { 0x88, 0xCB,
JoyStick_DeviceData *SYS_Joystick; /* array to hold joystick ID values */
-
+#ifndef __WINRT__
static HMODULE cfgmgr32_lib_handle;
static CM_Register_NotificationFunc CM_Register_Notification;
static CM_Unregister_NotificationFunc CM_Unregister_Notification;
@@ -195,8 +195,6 @@ SDL_CreateDeviceNotificationFunc(void)
return SDL_FALSE;
}
-#ifndef __WINRT__
-
typedef struct
{
HRESULT coinitialized;
@@ -455,9 +453,9 @@ WINDOWS_JoystickInit(void)
WINDOWS_JoystickDetect();
+#ifndef __WINRT__
SDL_CreateDeviceNotificationFunc();
-#ifndef __WINRT__
s_bJoystickThread = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_THREAD, SDL_FALSE);
if (s_bJoystickThread) {
if (SDL_StartJoystickThread() < 0) {
@@ -731,9 +729,9 @@ WINDOWS_JoystickQuit(void)
} else {
SDL_CleanupDeviceNotification(&s_notification_data);
}
-#endif
SDL_CleanupDeviceNotificationFunc();
+#endif
SDL_DINPUT_JoystickQuit();
SDL_XINPUT_JoystickQuit();