Re-added WinRT support until we're sure that it's no longer being used

This commit is contained in:
Sam Lantinga
2022-11-23 10:41:43 -08:00
parent d5572559a5
commit a635a485bc
92 changed files with 8410 additions and 164 deletions

View File

@@ -20,6 +20,8 @@
*/
#include "../../SDL_internal.h"
#ifndef __WINRT__
#include "SDL_hid.h"
@@ -83,4 +85,6 @@ WIN_UnloadHIDDLL(void)
}
}
#endif /* !__WINRT__ */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -25,6 +25,8 @@
#include "SDL_windows.h"
#ifndef __WINRT__
typedef LONG NTSTATUS;
typedef USHORT USAGE;
typedef struct _HIDP_PREPARSED_DATA *PHIDP_PREPARSED_DATA;
@@ -195,6 +197,8 @@ extern HidP_GetValueCaps_t SDL_HidP_GetValueCaps;
extern HidP_MaxDataListLength_t SDL_HidP_MaxDataListLength;
extern HidP_GetData_t SDL_HidP_GetData;
#endif /* !__WINRT__ */
#endif /* SDL_hid_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if defined(__WIN32__) || defined(__GDK__)
#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__)
#include "SDL_windows.h"
#include "SDL_error.h"
@@ -89,7 +89,14 @@ WIN_CoInitialize(void)
If you need multi-threaded mode, call CoInitializeEx() before SDL_Init()
*/
#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
#ifdef __WINRT__
/* DLudwig: On WinRT, it is assumed that COM was initialized in main().
CoInitializeEx is available (not CoInitialize though), however
on WinRT, main() is typically declared with the [MTAThread]
attribute, which, AFAIK, should initialize COM.
*/
return S_OK;
#elif defined(__XBOXONE__) || defined(__XBOXSERIES__)
/* On Xbox, there's no need to call CoInitializeEx (and it's not implemented) */
return S_OK;
#else
@@ -111,9 +118,12 @@ WIN_CoInitialize(void)
void
WIN_CoUninitialize(void)
{
#ifndef __WINRT__
CoUninitialize();
#endif
}
#ifndef __WINRT__
void *
WIN_LoadComBaseFunction(const char *name)
{
@@ -130,10 +140,14 @@ WIN_LoadComBaseFunction(const char *name)
return NULL;
}
}
#endif
HRESULT
WIN_RoInitialize(void)
{
#ifdef __WINRT__
return S_OK;
#else
typedef HRESULT (WINAPI *RoInitialize_t)(RO_INIT_TYPE initType);
RoInitialize_t RoInitializeFunc = (RoInitialize_t)WIN_LoadComBaseFunction("RoInitialize");
if (RoInitializeFunc) {
@@ -153,19 +167,22 @@ WIN_RoInitialize(void)
} else {
return E_NOINTERFACE;
}
#endif
}
void
WIN_RoUninitialize(void)
{
#ifndef __WINRT__
typedef void (WINAPI *RoUninitialize_t)(void);
RoUninitialize_t RoUninitializeFunc = (RoUninitialize_t)WIN_LoadComBaseFunction("RoUninitialize");
if (RoUninitializeFunc) {
RoUninitializeFunc();
}
#endif
}
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
#if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
static BOOL
IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
{
@@ -189,7 +206,7 @@ IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServiceP
BOOL WIN_IsWindowsVistaOrGreater(void)
{
#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
#if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__)
return TRUE;
#else
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0);
@@ -198,7 +215,7 @@ BOOL WIN_IsWindowsVistaOrGreater(void)
BOOL WIN_IsWindows7OrGreater(void)
{
#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
#if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__)
return TRUE;
#else
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 0);
@@ -207,7 +224,7 @@ BOOL WIN_IsWindows7OrGreater(void)
BOOL WIN_IsWindows8OrGreater(void)
{
#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
#if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__)
return TRUE;
#else
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0);
@@ -238,8 +255,8 @@ WASAPI doesn't need this. This is just for DirectSound/WinMM.
char *
WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
{
#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
return WIN_StringToUTF8(name); /* No registry access on Xbox, go with what we've got. */
#if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__)
return WIN_StringToUTF8(name); /* No registry access on WinRT/UWP and Xbox, go with what we've got. */
#else
static const GUID nullguid = { 0 };
const unsigned char *ptr;
@@ -291,7 +308,7 @@ WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
retval = WIN_StringToUTF8(strw);
SDL_free(strw);
return retval ? retval : WIN_StringToUTF8(name);
#endif /**/
#endif /* if __WINRT__ / else */
}
BOOL
@@ -324,6 +341,6 @@ WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect)
winrect->bottom = sdlrect->y + sdlrect->h - 1;
}
#endif /* defined(__WIN32__) || defined(__GDK__) */
#endif /* defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -120,8 +120,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);

View File

@@ -37,7 +37,7 @@ static HANDLE s_pXInputDLL = 0;
static int s_XInputDLLRefCount = 0;
#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
#if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__)
int
WIN_LoadXInputDLL(void)
@@ -70,7 +70,7 @@ WIN_UnloadXInputDLL(void)
{
}
#else /* !(defined(__XBOXONE__) || defined(__XBOXSERIES__)) */
#else /* !(defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__)) */
int
WIN_LoadXInputDLL(void)
@@ -138,7 +138,7 @@ WIN_UnloadXInputDLL(void)
}
}
#endif /**/
#endif /* __WINRT__ */
/* Ends C function definitions when using C++ */
#ifdef __cplusplus