Skip to content

Commit 5f5fe5d

Browse files
committed
UWP/WinRT: Fix Compiling on UWP
1 parent 80335b8 commit 5f5fe5d

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/SDL.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969

7070
// Initialization/Cleanup routines
7171
#include "timer/SDL_timer_c.h"
72-
#ifdef SDL_PLATFORM_WINDOWS
72+
#if defined(SDL_PLATFORM_WINDOWS) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
7373
extern bool SDL_HelperWindowCreate(void);
7474
extern void SDL_HelperWindowDestroy(void);
7575
#endif
@@ -323,7 +323,7 @@ bool SDL_InitSubSystem(SDL_InitFlags flags)
323323
SDL_DBus_Init();
324324
#endif
325325

326-
#ifdef SDL_PLATFORM_WINDOWS
326+
#if defined(SDL_PLATFORM_WINDOWS) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
327327
if (flags & (SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK)) {
328328
if (!SDL_HelperWindowCreate()) {
329329
goto quit_and_error;
@@ -659,7 +659,7 @@ void SDL_Quit(void)
659659
SDL_bInMainQuit = true;
660660

661661
// Quit all subsystems
662-
#ifdef SDL_PLATFORM_WINDOWS
662+
#if defined(SDL_PLATFORM_WINDOWS) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
663663
SDL_HelperWindowDestroy();
664664
#endif
665665
SDL_QuitSubSystem(SDL_INIT_EVERYTHING);

src/core/windows/SDL_windows.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ typedef enum RO_INIT_TYPE
4545
#define WC_ERR_INVALID_CHARS 0x00000080
4646
#endif
4747

48+
#if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
4849
// Dark mode support
4950
typedef enum {
5051
UXTHEME_APPMODE_DEFAULT,
@@ -82,7 +83,7 @@ typedef void (WINAPI *RefreshImmersiveColorPolicyState_t)(void);
8283
typedef UxthemePreferredAppMode (WINAPI *SetPreferredAppMode_t)(UxthemePreferredAppMode);
8384
typedef BOOL (WINAPI *SetWindowCompositionAttribute_t)(HWND, const WINDOWCOMPOSITIONATTRIBDATA *);
8485
typedef void (NTAPI *RtlGetVersion_t)(NT_OSVERSIONINFOW *);
85-
86+
#endif
8687
// Fake window to help with DirectInput events.
8788
HWND SDL_HelperWindow = NULL;
8889
static const TCHAR *SDL_HelperWindowClassName = TEXT("SDLHelperWindowInputCatcher");
@@ -154,6 +155,20 @@ void SDL_HelperWindowDestroy(void)
154155
SDL_HelperWindowClass = 0;
155156
}
156157
}
158+
#else
159+
// Stub implementations for UWP/Xbox platforms
160+
HWND SDL_HelperWindow = NULL;
161+
162+
bool SDL_HelperWindowCreate(void)
163+
{
164+
return true; // No-op for UWP/Xbox
165+
}
166+
167+
void SDL_HelperWindowDestroy(void)
168+
{
169+
// No-op for UWP/Xbox
170+
}
171+
#endif
157172

158173
// Sets an error message based on an HRESULT
159174
bool WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)

0 commit comments

Comments
 (0)