From 6873082c3450fc762e96405000de91e6ceae67a8 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 29 Nov 2022 09:26:29 -0800
Subject: [PATCH] Fixed building on Windows with SDL_VIDEO=OFF
Fixes https://github.com/libsdl-org/SDL/issues/6562
---
src/core/windows/SDL_windows.c | 50 +++++++++++++++++++++++
src/haptic/windows/SDL_dinputhaptic.c | 4 ++
src/joystick/windows/SDL_dinputjoystick.c | 4 ++
3 files changed, 58 insertions(+)
diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c
index 9cc0c2b02a52..bed59856b8a6 100644
--- a/src/core/windows/SDL_windows.c
+++ b/src/core/windows/SDL_windows.c
@@ -342,4 +342,54 @@ WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect)
#endif /* defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) */
+
+/*
+ * Public APIs
+ */
+#if !defined(SDL_VIDEO_DRIVER_WINDOWS)
+
+#if defined(__WIN32__) || defined(__GDK__)
+int
+SDL_RegisterApp(const char *name, Uint32 style, void *hInst)
+{
+ (void) name;
+ (void) style;
+ (void) hInst;
+ return 0;
+}
+
+void
+SDL_UnregisterApp(void)
+{
+}
+
+void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata)
+{
+}
+#endif /* __WIN32__ || __GDK__ */
+
+#if defined(__WIN32__) || defined(__WINGDK__)
+int
+SDL_Direct3D9GetAdapterIndex(int displayIndex)
+{
+ (void) displayIndex;
+ return 0; /* D3DADAPTER_DEFAULT */
+}
+
+SDL_bool
+SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputIndex)
+{
+ (void) displayIndex;
+ if (adapterIndex) {
+ *adapterIndex = -1;
+ }
+ if (outputIndex) {
+ *outputIndex = -1;
+ }
+ return SDL_FALSE;
+}
+#endif /* __WIN32__ || __WINGDK__ */
+
+#endif /* !SDL_VIDEO_DRIVER_WINDOWS */
+
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/haptic/windows/SDL_dinputhaptic.c b/src/haptic/windows/SDL_dinputhaptic.c
index fb276b329587..6aaef8b7e656 100644
--- a/src/haptic/windows/SDL_dinputhaptic.c
+++ b/src/haptic/windows/SDL_dinputhaptic.c
@@ -31,7 +31,11 @@
/*
* External stuff.
*/
+#ifdef SDL_VIDEO_DRIVER_WINDOWS
extern HWND SDL_HelperWindow;
+#else
+static const HWND SDL_HelperWindow = NULL;
+#endif
/*
diff --git a/src/joystick/windows/SDL_dinputjoystick.c b/src/joystick/windows/SDL_dinputjoystick.c
index 54215b1993f2..5b72b54c0bd8 100644
--- a/src/joystick/windows/SDL_dinputjoystick.c
+++ b/src/joystick/windows/SDL_dinputjoystick.c
@@ -40,7 +40,11 @@
#define CONVERT_MAGNITUDE(x) (((x)*10000) / 0x7FFF)
/* external variables referenced. */
+#ifdef SDL_VIDEO_DRIVER_WINDOWS
extern HWND SDL_HelperWindow;
+#else
+static const HWND SDL_HelperWindow = NULL;
+#endif
/* local variables */
static SDL_bool coinitialized = SDL_FALSE;