SDL: attempt to fix uwp build

From 312c899f4f5004ef0df79242cd79137f7792c509 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sat, 2 Apr 2022 03:32:10 +0300
Subject: [PATCH] attempt to fix uwp build

---
 src/core/windows/SDL_windows.c              | 2 ++
 src/core/windows/SDL_windows.h              | 2 ++
 src/joystick/windows/SDL_rawinputjoystick.c | 6 ++++++
 3 files changed, 10 insertions(+)

diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c
index b48feb15ebe..bf0dfb9838a 100644
--- a/src/core/windows/SDL_windows.c
+++ b/src/core/windows/SDL_windows.c
@@ -120,6 +120,7 @@ WIN_CoUninitialize(void)
 #endif
 }
 
+#ifndef __WINRT__
 void *
 WIN_LoadComBaseFunction(const char *name)
 {
@@ -136,6 +137,7 @@ WIN_LoadComBaseFunction(const char *name)
         return NULL;
     }
 }
+#endif
 
 HRESULT
 WIN_RoInitialize(void)
diff --git a/src/core/windows/SDL_windows.h b/src/core/windows/SDL_windows.h
index 640769da13c..917a8256f41 100644
--- a/src/core/windows/SDL_windows.h
+++ b/src/core/windows/SDL_windows.h
@@ -63,8 +63,10 @@ extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr);
 /* Sets an error message based on GetLastError(). Always return -1. */
 extern int WIN_SetError(const char *prefix);
 
+#if !defined(__WINRT__)
 /* Load a function from combase.dll */
 void *WIN_LoadComBaseFunction(const char *name);
+#endif
 
 /* Wrap up the oddities of CoInitialize() into a common function. */
 extern HRESULT WIN_CoInitialize(void);
diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c
index 8c96ae63676..562be9b003c 100644
--- a/src/joystick/windows/SDL_rawinputjoystick.c
+++ b/src/joystick/windows/SDL_rawinputjoystick.c
@@ -62,6 +62,7 @@ typedef struct WindowsGamingInputGamepadState WindowsGamingInputGamepadState;
 #define GamepadButtons_GUIDE 0x40000000
 #define COBJMACROS
 #include "windows.gaming.input.h"
+#include <roapi.h>
 #endif
 
 #if defined(SDL_JOYSTICK_RAWINPUT_XINPUT) || defined(SDL_JOYSTICK_RAWINPUT_WGI)
@@ -576,8 +577,13 @@ RAWINPUT_InitWindowsGamingInput(RAWINPUT_DeviceContext *ctx)
             typedef HRESULT (WINAPI *WindowsCreateStringReference_t)(PCWSTR sourceString, UINT32 length, HSTRING_HEADER *hstringHeader, HSTRING* string);
             typedef HRESULT (WINAPI *RoGetActivationFactory_t)(HSTRING activatableClassId, REFIID iid, void** factory);
 
+#ifdef __WINRT__
+            WindowsCreateStringReference_t WindowsCreateStringReferenceFunc = WindowsCreateStringReference;
+            RoGetActivationFactory_t RoGetActivationFactoryFunc = RoGetActivationFactory;
+#else
             WindowsCreateStringReference_t WindowsCreateStringReferenceFunc = (WindowsCreateStringReference_t)WIN_LoadComBaseFunction("WindowsCreateStringReference");
             RoGetActivationFactory_t RoGetActivationFactoryFunc = (RoGetActivationFactory_t)WIN_LoadComBaseFunction("RoGetActivationFactory");
+#endif
             if (WindowsCreateStringReferenceFunc && RoGetActivationFactoryFunc) {
                 PCWSTR pNamespace = L"Windows.Gaming.Input.Gamepad";
                 HSTRING_HEADER hNamespaceStringHeader;