Blame patches/sdl2/win32.patch

d7cf18
diff -ru SDL2-2.0.12.orig/src/video/windows/SDL_windowsvideo.c SDL2-2.0.12/src/video/windows/SDL_windowsvideo.c
d7cf18
--- SDL2-2.0.12.orig/src/video/windows/SDL_windowsvideo.c       2020-03-11 02:36:18.000000000 +0100
d7cf18
+++ SDL2-2.0.12/src/video/windows/SDL_windowsvideo.c    2020-10-07 13:49:51.592298088 +0200
d7cf18
@@ -43,6 +43,10 @@
d7cf18
 SDL_bool g_WindowsEnableMessageLoop = SDL_TRUE;
d7cf18
 SDL_bool g_WindowFrameUsableWhileCursorHidden = SDL_TRUE;
d7cf18
d7cf18
+#ifndef ES_CONTINUOUS
d7cf18
+#define ES_CONTINUOUS ((DWORD)0x80000000)
d7cf18
+#endif
d7cf18
+
d7cf18
 static void SDLCALL
d7cf18
 UpdateWindowsEnableMessageLoop(void *userdata, const char *name, const char *oldValue, const char *newValue)
d7cf18
 {
d7cf18
213fe0
--- SDL2-2.0.8.orig/src/video/windows/SDL_windowsvideo.c	2018-03-01 17:34:42.000000000 +0100
213fe0
+++ SDL2-2.0.8/src/video/windows/SDL_windowsvideo.c	2020-10-05 01:07:51.101894646 +0200
213fe0
@@ -240,13 +240,17 @@
213fe0
     WIN_QuitMouse(_this);
213fe0
 }
213fe0
 
213fe0
-
213fe0
+#ifdef SDL_VIDEO_RENDER_D3D
213fe0
 #define D3D_DEBUG_INFO
213fe0
 #include <d3d9.h>
213fe0
+#endif
213fe0
 
213fe0
 SDL_bool 
213fe0
 D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface)
213fe0
 {
213fe0
+#ifndef SDL_VIDEO_RENDER_D3D
213fe0
+    return SDL_FALSE;
213fe0
+#else
213fe0
     *pD3DDLL = SDL_LoadObject("D3D9.DLL");
213fe0
     if (*pD3DDLL) {
213fe0
         typedef IDirect3D9 *(WINAPI *Direct3DCreate9_t) (UINT SDKVersion);
213fe0
@@ -284,12 +288,16 @@
213fe0
     }
213fe0
     *pDirect3D9Interface = NULL;
213fe0
     return SDL_FALSE;
213fe0
+#endif
213fe0
 }
213fe0
 
213fe0
 
213fe0
 int
213fe0
 SDL_Direct3D9GetAdapterIndex(int displayIndex)
213fe0
 {
213fe0
+#ifndef SDL_VIDEO_RENDER_D3D
213fe0
+    return 0;
213fe0
+#else
213fe0
     void *pD3DDLL;
213fe0
     IDirect3D9 *pD3D;
213fe0
     if (!D3D_LoadDLL(&pD3DDLL, &pD3D)) {
213fe0
@@ -324,6 +332,7 @@
213fe0
 
213fe0
         return adapterIndex;
213fe0
     }
213fe0
+#endif
213fe0
 }
213fe0
 
213fe0
 #if HAVE_DXGI_H
213fe0
--- SDL2-2.0.8.orig/src/video/windows/SDL_windowsevents.c	2018-03-01 17:34:42.000000000 +0100
213fe0
+++ SDL2-2.0.8/src/video/windows/SDL_windowsevents.c	2020-10-05 01:59:14.387146659 +0200
213fe0
@@ -1162,7 +1166,7 @@
213fe0
         }
213fe0
     } else {
213fe0
         /* Use the first icon as a default icon, like in the Explorer */
213fe0
-        GetModuleFileName(SDL_Instance, path, MAX_PATH);
213fe0
+        GetModuleFileNameA(SDL_Instance, path, MAX_PATH);
213fe0
         ExtractIconEx(path, 0, &wcex.hIcon, &wcex.hIconSm, 1);
213fe0
     }
213fe0
 
213fe0
--- SDL2-2.0.8.orig/include/SDL_system.h	2018-03-01 17:34:41.000000000 +0100
213fe0
+++ SDL2-2.0.8/include/SDL_system.h	2020-10-05 00:17:56.683991095 +0200
213fe0
@@ -41,7 +41,7 @@
213fe0
 
213fe0
 
213fe0
 /* Platform specific functions for Windows */
213fe0
-#ifdef __WIN32__
213fe0
+#if defined(__WIN32__) || defined(__midipix__)
213fe0
 	
213fe0
 /**
213fe0
    \brief Set a function that is called for every windows message, before TranslateMessage()
213fe0
--- SDL2-2.0.8.orig/src/core/unix/SDL_windows.c	1970-01-01 01:00:00.000000000 +0100
213fe0
+++ SDL2-2.0.8/src/core/unix/SDL_windows.c	2020-10-05 01:45:58.660207506 +0200
213fe0
@@ -0,0 +1,54 @@
213fe0
+/*
213fe0
+  Simple DirectMedia Layer
213fe0
+  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
213fe0
+
213fe0
+  This software is provided 'as-is', without any express or implied
213fe0
+  warranty.  In no event will the authors be held liable for any damages
213fe0
+  arising from the use of this software.
213fe0
+
213fe0
+  Permission is granted to anyone to use this software for any purpose,
213fe0
+  including commercial applications, and to alter it and redistribute it
213fe0
+  freely, subject to the following restrictions:
213fe0
+
213fe0
+  1. The origin of this software must not be misrepresented; you must not
213fe0
+     claim that you wrote the original software. If you use this software
213fe0
+     in a product, an acknowledgment in the product documentation would be
213fe0
+     appreciated but is not required.
213fe0
+  2. Altered source versions must be plainly marked as such, and must not be
213fe0
+     misrepresented as being the original software.
213fe0
+  3. This notice may not be removed or altered from any source distribution.
213fe0
+*/
213fe0
+#include "../../SDL_internal.h"
213fe0
+
213fe0
+#if defined(__WIN32__) || defined(__WINRT__) || defined(__midipix__)
213fe0
+
213fe0
+#include "SDL_windows.h"
213fe0
+#include "SDL_error.h"
213fe0
+#include "SDL_assert.h"
213fe0
+
213fe0
+#ifndef _WIN32_WINNT_VISTA
213fe0
+#define _WIN32_WINNT_VISTA  0x0600
213fe0
+#endif
213fe0
+
213fe0
+
213fe0
+/* Sets an error message based on an HRESULT */
213fe0
+int
213fe0
+WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
213fe0
+{
213fe0
+    TCHAR buffer[1024];
213fe0
+    char *message;
213fe0
+    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, 0,
213fe0
+                  buffer, SDL_arraysize(buffer), NULL);
213fe0
+    message = WIN_StringToUTF8(buffer);
213fe0
+    SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
213fe0
+    SDL_free(message);
213fe0
+    return -1;
213fe0
+}
213fe0
+
213fe0
+/* Sets an error message based on GetLastError() */
213fe0
+int
213fe0
+WIN_SetError(const char *prefix)
213fe0
+{
213fe0
+    return WIN_SetErrorFromHRESULT(prefix, GetLastError());
213fe0
+}
213fe0
+#endif
213fe0
--- SDL2-2.0.8.orig/src/core/unix/SDL_windows.h	1970-01-01 01:00:00.000000000 +0100
213fe0
+++ SDL2-2.0.8/src/core/unix/SDL_windows.h	2020-10-05 01:36:40.827047116 +0200
213fe0
@@ -0,0 +1,75 @@
213fe0
+/*
213fe0
+  Simple DirectMedia Layer
213fe0
+  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
213fe0
+
213fe0
+  This software is provided 'as-is', without any express or implied
213fe0
+  warranty.  In no event will the authors be held liable for any damages
213fe0
+  arising from the use of this software.
213fe0
+
213fe0
+  Permission is granted to anyone to use this software for any purpose,
213fe0
+  including commercial applications, and to alter it and redistribute it
213fe0
+  freely, subject to the following restrictions:
213fe0
+
213fe0
+  1. The origin of this software must not be misrepresented; you must not
213fe0
+     claim that you wrote the original software. If you use this software
213fe0
+     in a product, an acknowledgment in the product documentation would be
213fe0
+     appreciated but is not required.
213fe0
+  2. Altered source versions must be plainly marked as such, and must not be
213fe0
+     misrepresented as being the original software.
213fe0
+  3. This notice may not be removed or altered from any source distribution.
213fe0
+*/
213fe0
+
213fe0
+/* This is an include file for windows.h with the SDL build settings */
213fe0
+
213fe0
+#ifndef _INCLUDED_WINDOWS_H
213fe0
+#define _INCLUDED_WINDOWS_H
213fe0
+
213fe0
+#if defined(__WIN32__)
213fe0
+#define WIN32_LEAN_AND_MEAN
213fe0
+#define STRICT
213fe0
+#ifndef UNICODE
213fe0
+#define UNICODE 1
213fe0
+#endif
213fe0
+#undef _WIN32_WINNT
213fe0
+#define _WIN32_WINNT  0x501   /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */
213fe0
+#endif
213fe0
+
213fe0
+#include <windows.h>
213fe0
+#include <basetyps.h>   /* for REFIID with broken mingw.org headers */
213fe0
+
213fe0
+/* Routines to convert from UTF8 to native Windows text */
213fe0
+#if UNICODE
213fe0
+#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR))
213fe0
+#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (char *)(S), SDL_strlen(S)+1)
213fe0
+#else
213fe0
+/* !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. */
213fe0
+#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)(S), (SDL_strlen(S)+1))
213fe0
+#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1)
213fe0
+#endif
213fe0
+
213fe0
+/* Sets an error message based on a given HRESULT */
213fe0
+extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr);
213fe0
+
213fe0
+/* Sets an error message based on GetLastError(). Always return -1. */
213fe0
+extern int WIN_SetError(const char *prefix);
213fe0
+
213fe0
+/* Wrap up the oddities of CoInitialize() into a common function. */
213fe0
+extern HRESULT WIN_CoInitialize(void);
213fe0
+extern void WIN_CoUninitialize(void);
213fe0
+
213fe0
+/* Returns SDL_TRUE if we're running on Windows Vista and newer */
213fe0
+extern BOOL WIN_IsWindowsVistaOrGreater(void);
213fe0
+
213fe0
+/* Returns SDL_TRUE if we're running on Windows 7 and newer */
213fe0
+extern BOOL WIN_IsWindows7OrGreater(void);
213fe0
+
213fe0
+/* You need to SDL_free() the result of this call. */
213fe0
+extern char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid);
213fe0
+
213fe0
+/* Checks to see if two GUID are the same. */
213fe0
+extern BOOL WIN_IsEqualGUID(const GUID * a, const GUID * b);
213fe0
+extern BOOL WIN_IsEqualIID(REFIID a, REFIID b);
213fe0
+
213fe0
+#endif /* _INCLUDED_WINDOWS_H */
213fe0
+
213fe0
+/* vi: set ts=4 sw=4 expandtab: */