Windows GDK Support (#5830)

* Added GDK

* Simplfied checks in SDL_config_wingdk.h

* Added testgdk sample

* Added GDK readme

* Fixed error in merge of SDL_windows.h

* Additional GDK fixes

* OpenWatcom should not export _SDL_GDKGetTaskQueue

* Formatting fixes

* Moved initialization code into SDL_GDKRunApp
This commit is contained in:
chalonverse
2022-06-27 17:19:39 +00:00
committed by GitHub
parent 314bb5a1ed
commit 3b191580c3
68 changed files with 4150 additions and 93 deletions

View File

@@ -20,7 +20,7 @@
*/
#include "./SDL_internal.h"
#if defined(__WIN32__)
#if defined(__WIN32__) || defined(__GDK__)
#include "core/windows/SDL_windows.h"
#elif defined(__OS2__)
#include <stdlib.h> /* _exit() */
@@ -89,7 +89,7 @@ SDL_COMPILE_TIME_ASSERT(SDL_PATCHLEVEL_max, SDL_PATCHLEVEL <= 99);
extern SDL_NORETURN void SDL_ExitProcess(int exitcode);
SDL_NORETURN void SDL_ExitProcess(int exitcode)
{
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__GDK__)
/* "if you do not know the state of all threads in your process, it is
better to call TerminateProcess than ExitProcess"
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx */
@@ -579,6 +579,8 @@ SDL_GetPlatform(void)
return "Windows";
#elif __WINRT__
return "WinRT";
#elif __WINGDK__
return "WinGDK";
#elif __TVOS__
return "tvOS";
#elif __IPHONEOS__
@@ -630,6 +632,6 @@ _DllMainCRTStartup(HANDLE hModule,
}
#endif /* Building DLL */
#endif /* __WIN32__ */
#endif /* defined(__WIN32__) || defined(__GDK__) */
/* vi: set sts=4 ts=4 sw=4 expandtab: */

View File

@@ -20,7 +20,7 @@
*/
#include "./SDL_internal.h"
#if defined(__WIN32__)
#if defined(__WIN32__) || defined(__GDK__)
#include "core/windows/SDL_windows.h"
#endif
@@ -32,7 +32,7 @@
#include "SDL_assert_c.h"
#include "video/SDL_sysvideo.h"
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__GDK__)
#ifndef WS_OVERLAPPEDWINDOW
#define WS_OVERLAPPEDWINDOW 0
#endif
@@ -90,7 +90,7 @@ static void SDL_AddAssertionToReport(SDL_assert_data *data)
}
}
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__GDK__)
#define ENDLINE "\r\n"
#else
#define ENDLINE "\n"

View File

@@ -20,7 +20,7 @@
*/
#include "./SDL_internal.h"
#if defined(__WIN32__) || defined(__WINRT__)
#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__)
#include "core/windows/SDL_windows.h"
#endif
@@ -362,7 +362,7 @@ SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list
}
}
#if defined(__WIN32__) && !defined(HAVE_STDIO_H) && !defined(__WINRT__)
#if defined(__WIN32__) && !defined(HAVE_STDIO_H) && !defined(__WINRT__) && !defined(__GDK__)
/* Flag tracking the attachment of the console: 0=unattached, 1=attached to a console, 2=attached to a file, -1=error */
static int consoleAttached = 0;
@@ -374,7 +374,7 @@ static void SDLCALL
SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
const char *message)
{
#if defined(__WIN32__) || defined(__WINRT__)
#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__)
/* Way too many allocations here, urgh */
/* Note: One can't call SDL_SetError here, since that function itself logs. */
{
@@ -383,7 +383,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
LPTSTR tstr;
SDL_bool isstack;
#if !defined(HAVE_STDIO_H) && !defined(__WINRT__)
#if !defined(HAVE_STDIO_H) && !defined(__WINRT__) && !defined(__GDK__)
BOOL attachResult;
DWORD attachError;
DWORD charsWritten;
@@ -422,7 +422,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
}
}
}
#endif /* !defined(HAVE_STDIO_H) && !defined(__WINRT__) */
#endif /* !defined(HAVE_STDIO_H) && !defined(__WINRT__) && !defined(__GDK__) */
length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1 + 1;
output = SDL_small_alloc(char, length, &isstack);
@@ -432,7 +432,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
/* Output to debugger */
OutputDebugString(tstr);
#if !defined(HAVE_STDIO_H) && !defined(__WINRT__)
#if !defined(HAVE_STDIO_H) && !defined(__WINRT__) && !defined(__GDK__)
/* Screen output to stderr, if console was attached. */
if (consoleAttached == 1) {
if (!WriteConsole(stderrHandle, tstr, (DWORD) SDL_tcslen(tstr), &charsWritten, NULL)) {
@@ -447,7 +447,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
OutputDebugString(TEXT("Error calling WriteFile\r\n"));
}
}
#endif /* !defined(HAVE_STDIO_H) && !defined(__WINRT__) */
#endif /* !defined(HAVE_STDIO_H) && !defined(__WINRT__) && !defined(__GDK__) */
SDL_free(tstr);
SDL_small_free(output, isstack);

View File

@@ -20,7 +20,7 @@
*/
#include "../SDL_internal.h"
#if defined(__WIN32__) || defined(__WINRT__)
#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__)
#include "../core/windows/SDL_windows.h"
#endif

View File

@@ -519,7 +519,7 @@ WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
SDL_assert(client != NULL);
#ifdef __WINRT__ /* CreateEventEx() arrived in Vista, so we need an #ifdef for XP. */
#if defined(__WINRT__) || defined(__GDK__) /* CreateEventEx() arrived in Vista, so we need an #ifdef for XP. */
this->hidden->event = CreateEventEx(NULL, NULL, 0, EVENT_ALL_ACCESS);
#else
this->hidden->event = CreateEventW(NULL, 0, 0, NULL);

177
src/core/gdk/SDL_gdk.cpp Normal file
View File

@@ -0,0 +1,177 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#include "SDL_system.h"
#include "../windows/SDL_windows.h"
#include "SDL_messagebox.h"
#include "SDL_main.h"
#include <XGameRuntime.h>
#include <xsapi-c/services_c.h>
#include <shellapi.h> /* CommandLineToArgvW() */
static XTaskQueueHandle GDK_GlobalTaskQueue;
extern "C" DECLSPEC int
SDL_GDKGetTaskQueue(XTaskQueueHandle * outTaskQueue)
{
/* If this is the first call, first create the global task queue. */
if (!GDK_GlobalTaskQueue) {
HRESULT hr;
hr = XTaskQueueCreate(XTaskQueueDispatchMode::ThreadPool,
XTaskQueueDispatchMode::Manual,
&GDK_GlobalTaskQueue
);
if (FAILED(hr)) {
SDL_SetError("[GDK] Could not create global task queue");
return -1;
}
/* The initial call gets the non-duplicated handle so they can clean it up */
*outTaskQueue = GDK_GlobalTaskQueue;
} else {
/* Duplicate the global task queue handle into outTaskQueue */
if (FAILED(XTaskQueueDuplicateHandle(GDK_GlobalTaskQueue, outTaskQueue))) {
SDL_SetError("[GDK] Unable to acquire global task queue");
return -1;
}
}
return 0;
}
extern "C" void
GDK_DispatchTaskQueue(void)
{
/* If there is no global task queue, don't do anything.
* This gives the option to opt-out for those who want to handle everything themselves.
*/
if (GDK_GlobalTaskQueue) {
/* Dispatch any callbacks which are ready. */
while (XTaskQueueDispatch(GDK_GlobalTaskQueue, XTaskQueuePort::Completion, 0))
;
}
}
/* Pop up an out of memory message, returns to Windows */
extern "C" static BOOL
OutOfMemory(void)
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal Error", "Out of memory - aborting", NULL);
return FALSE;
}
/* Gets the arguments with GetCommandLine, converts them to argc and argv
and calls SDL_main */
extern "C" DECLSPEC int
SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved)
{
LPWSTR *argvw;
char **argv;
int i, argc, result;
HRESULT hr;
XTaskQueueHandle taskQueue;
argvw = CommandLineToArgvW(GetCommandLineW(), &argc);
if (argvw == NULL) {
return OutOfMemory();
}
/* Note that we need to be careful about how we allocate/free memory here.
* If the application calls SDL_SetMemoryFunctions(), we can't rely on
* SDL_free() to use the same allocator after SDL_main() returns.
*/
/* Parse it into argv and argc */
argv = (char **) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (argc + 1) * sizeof(*argv));
if (!argv) {
return OutOfMemory();
}
for (i = 0; i < argc; ++i) {
DWORD len;
char *arg = WIN_StringToUTF8W(argvw[i]);
if (!arg) {
return OutOfMemory();
}
len = (DWORD) SDL_strlen(arg);
argv[i] = (char *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len + 1);
if (!argv[i]) {
return OutOfMemory();
}
SDL_memcpy(argv[i], arg, len);
SDL_free(arg);
}
argv[i] = NULL;
LocalFree(argvw);
hr = XGameRuntimeInitialize();
if (SUCCEEDED(hr) && SDL_GDKGetTaskQueue(&taskQueue) == 0) {
Uint32 titleid = 0;
char scidBuffer[64];
XblInitArgs xblArgs;
XTaskQueueSetCurrentProcessTaskQueue(taskQueue);
/* Try to get the title ID and initialize Xbox Live */
hr = XGameGetXboxTitleId(&titleid);
if (SUCCEEDED(hr)) {
SDL_zero(xblArgs);
xblArgs.queue = taskQueue;
SDL_snprintf(scidBuffer, 64, "00000000-0000-0000-0000-0000%08X", titleid);
xblArgs.scid = scidBuffer;
hr = XblInitialize(&xblArgs);
} else {
SDL_SetError("[GDK] Unable to get titleid. Will not call XblInitialize. Check MicrosoftGame.config!");
}
SDL_SetMainReady();
/* Run the application main() code */
result = mainFunction(argc, argv);
/* !!! FIXME: This follows the docs exactly, but for some reason still leaks handles on exit? */
/* Terminate the task queue and dispatch any pending tasks */
XTaskQueueTerminate(taskQueue, false, nullptr, nullptr);
while (XTaskQueueDispatch(taskQueue, XTaskQueuePort::Completion, 0))
;
XTaskQueueCloseHandle(taskQueue);
XGameRuntimeUninitialize();
} else {
#ifdef __WINGDK__
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal Error", "[GDK] Could not initialize - aborting", NULL);
#else
SDL_assert_always(0 && "[GDK] Could not initialize - aborting");
#endif
result = -1;
}
/* Free argv, to avoid memory leak */
for (i = 0; i < argc; ++i) {
HeapFree(GetProcessHeap(), 0, argv[i]);
}
HeapFree(GetProcessHeap(), 0, argv);
return result;
}

24
src/core/gdk/SDL_gdk.h Normal file
View File

@@ -0,0 +1,24 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
/* This is called from WIN_PumpEvents on GDK */
extern void GDK_DispatchTaskQueue(void);

View File

@@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if defined(__WIN32__) || defined(__WINRT__)
#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__)
#include "SDL_windows.h"
#include "SDL_error.h"
@@ -338,6 +338,6 @@ WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect)
winrect->bottom = sdlrect->y + sdlrect->h - 1;
}
#endif /* __WIN32__ || __WINRT__ */
#endif /* defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -40,6 +40,16 @@
#define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */
#endif
#define WINVER _WIN32_WINNT
#elif defined(__WINGDK__)
#define WIN32_LEAN_AND_MEAN
#define STRICT
#ifndef UNICODE
#define UNICODE 1
#endif
#undef WINVER
#undef _WIN32_WINNT
#define _WIN32_WINNT 0xA00
#define WINVER _WIN32_WINNT
#endif
#include <windows.h>

View File

@@ -24,7 +24,7 @@
#include "../SDL_internal.h"
#endif
#if defined(__WIN32__) || defined(__WINRT__)
#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__)
#include "../core/windows/SDL_windows.h"
#endif
#if defined(__OS2__)
@@ -456,7 +456,7 @@ CPU_haveNEON(void)
query the OS kernel in a platform-specific way. :/ */
#if defined(SDL_CPUINFO_DISABLED)
return 0; /* disabled */
#elif (defined(__WINDOWS__) || defined(__WINRT__)) && (defined(_M_ARM) || defined(_M_ARM64))
#elif (defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__)) && (defined(_M_ARM) || defined(_M_ARM64))
/* Visual Studio, for ARM, doesn't define __ARM_ARCH. Handle this first. */
/* Seems to have been removed */
# if !defined(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE)
@@ -671,7 +671,7 @@ SDL_GetCPUCount(void)
sysctlbyname("hw.ncpu", &SDL_CPUCount, &size, NULL, 0);
}
#endif
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__GDK__)
if (SDL_CPUCount <= 0) {
SYSTEM_INFO info;
GetSystemInfo(&info);
@@ -912,11 +912,11 @@ SDL_GetCPUFeatures(void)
SDL_CPUFeatures |= CPU_HAS_NEON;
SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 16);
}
if (CPU_haveLSX()) {
if (CPU_haveLSX()) {
SDL_CPUFeatures |= CPU_HAS_LSX;
SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 16);
}
if (CPU_haveLASX()) {
if (CPU_haveLASX()) {
SDL_CPUFeatures |= CPU_HAS_LASX;
SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 32);
}
@@ -1053,7 +1053,7 @@ SDL_GetSystemRAM(void)
}
}
#endif
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__GDK__)
if (SDL_SystemRAM <= 0) {
MEMORYSTATUSEX stat;
stat.dwLength = sizeof(stat);

View File

@@ -849,3 +849,5 @@
++'_SDL_HasLASX'.'SDL2.dll'.'SDL_HasLASX'
++'_SDL_RenderGetD3D12Device'.'SDL2.dll'.'SDL_RenderGetD3D12Device'
++'_SDL_utf8strnlen'.'SDL2.dll'.'SDL_utf8strnlen'
# ++'_SDL_GDKGetTaskQueue'.'SDL2.dll'.'SDL_GDKGetTaskQueue'
# ++'_SDL_GDKRunApp'.'SDL2.dll'.'SDL_GDKRunApp'

View File

@@ -875,3 +875,5 @@
#define SDL_HasLASX SDL_HasLASX_REAL
#define SDL_RenderGetD3D12Device SDL_RenderGetD3D12Device_REAL
#define SDL_utf8strnlen SDL_utf8strnlen_REAL
#define SDL_GDKGetTaskQueue SDL_GDKGetTaskQueue_REAL
#define SDL_GDKRunApp SDL_GDKRunApp_REAL

View File

@@ -48,7 +48,7 @@ SDL_DYNAPI_PROC(int,SDL_snprintf,(SDL_OUT_Z_CAP(b) char *a, size_t b, SDL_PRINTF
#undef SDL_CreateThread
#endif
#if defined(__WIN32__)
#if defined(__WIN32__) || defined(__GDK__)
SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThread,(SDL_ThreadFunction a, const char *b, void *c, pfnSDL_CurrentBeginThread d, pfnSDL_CurrentEndThread e),(a,b,c,d,e),return)
#elif defined(__OS2__)
SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThread,(SDL_ThreadFunction a, const char *b, void *c, pfnSDL_CurrentBeginThread d, pfnSDL_CurrentEndThread e),(a,b,c,d,e),return)
@@ -62,9 +62,12 @@ SDL_DYNAPI_PROC(SDL_RWops*,SDL_RWFromFP,(FILE *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(SDL_RWops*,SDL_RWFromFP,(void *a, SDL_bool b),(a,b),return)
#endif
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__GDK__)
SDL_DYNAPI_PROC(int,SDL_RegisterApp,(const char *a, Uint32 b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_UnregisterApp,(void),(),)
#endif
#if defined(__WIN32__) || defined(__WINGDK__)
SDL_DYNAPI_PROC(int,SDL_Direct3D9GetAdapterIndex,(int a),(a),return)
SDL_DYNAPI_PROC(IDirect3DDevice9*,SDL_RenderGetD3D9Device,(SDL_Renderer *a),(a),return)
#endif
@@ -599,7 +602,7 @@ SDL_DYNAPI_PROC(void,SDL_GL_ResetAttributes,(void),(),)
SDL_DYNAPI_PROC(SDL_bool,SDL_HasAVX,(void),(),return)
SDL_DYNAPI_PROC(SDL_AssertionHandler,SDL_GetDefaultAssertionHandler,(void),(),return)
SDL_DYNAPI_PROC(SDL_AssertionHandler,SDL_GetAssertionHandler,(void **a),(a),return)
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__WINGDK__)
SDL_DYNAPI_PROC(SDL_bool,SDL_DXGIGetOutputInfo,(int a,int *b, int *c),(a,b,c),return)
#endif
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderIsClipEnabled,(SDL_Renderer *a),(a),return)
@@ -620,7 +623,7 @@ SDL_DYNAPI_PROC(int,SDL_QueueAudio,(SDL_AudioDeviceID a, const void *b, Uint32 c
SDL_DYNAPI_PROC(Uint32,SDL_GetQueuedAudioSize,(SDL_AudioDeviceID a),(a),return)
SDL_DYNAPI_PROC(void,SDL_ClearQueuedAudio,(SDL_AudioDeviceID a),(a),)
SDL_DYNAPI_PROC(SDL_Window*,SDL_GetGrabbedWindow,(void),(),return)
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__GDK__)
SDL_DYNAPI_PROC(void,SDL_SetWindowsMessageHook,(SDL_WindowsMessageHook a, void *b),(a,b),)
#endif
SDL_DYNAPI_PROC(int,SDL_GetDisplayDPI,(int a, float *b, float *c, float *d),(a,b,c,d),return)
@@ -744,7 +747,7 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_HasColorKey,(SDL_Surface *a),(a),return)
#undef SDL_CreateThreadWithStackSize
#endif
#if defined(__WIN32__)
#if defined(__WIN32__) || defined(__GDK__)
SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThreadWithStackSize,(SDL_ThreadFunction a, const char *b, const size_t c, void *d, pfnSDL_CurrentBeginThread e, pfnSDL_CurrentEndThread f),(a,b,c,d,e,f),return)
#elif defined(__OS2__)
SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThreadWithStackSize,(SDL_ThreadFunction a, const char *b, const size_t c, void *d, pfnSDL_CurrentBeginThread e, pfnSDL_CurrentEndThread f),(a,b,c,d,e,f),return)
@@ -854,7 +857,7 @@ SDL_DYNAPI_PROC(float,SDL_roundf,(float a),(a),return)
SDL_DYNAPI_PROC(long,SDL_lround,(double a),(a),return)
SDL_DYNAPI_PROC(long,SDL_lroundf,(float a),(a),return)
SDL_DYNAPI_PROC(int,SDL_SoftStretchLinear,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return)
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__WINGDK__)
SDL_DYNAPI_PROC(ID3D11Device*,SDL_RenderGetD3D11Device,(SDL_Renderer *a),(a),return)
#endif
SDL_DYNAPI_PROC(int,SDL_UpdateNVTexture,(SDL_Texture *a, const SDL_Rect *b, const Uint8 *c, int d, const Uint8 *e, int f),(a,b,c,d,e,f),return)
@@ -948,7 +951,12 @@ SDL_DYNAPI_PROC(void,SDL_GUIDToString,(SDL_GUID a, char *b, int c),(a,b,c),)
SDL_DYNAPI_PROC(SDL_GUID,SDL_GUIDFromString,(const char *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_HasLSX,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_HasLASX,(void),(),return)
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__GDK__)
SDL_DYNAPI_PROC(ID3D12Device*,SDL_RenderGetD3D12Device,(SDL_Renderer *a),(a),return)
#endif
SDL_DYNAPI_PROC(size_t,SDL_utf8strnlen,(const char *a, size_t b),(a,b),return)
#if defined(__GDK__)
SDL_DYNAPI_PROC(int,SDL_GDKGetTaskQueue,(XTaskQueueHandle *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GDKRunApp,(SDL_main_func a, void *b),(a,b),return)
#endif

View File

@@ -35,7 +35,7 @@
#include "SDL_syswm.h"
#undef SDL_PRIs64
#if defined(__WIN32__) && !defined(__CYGWIN__)
#if (defined(__WIN32__) || defined(__GDK__)) && !defined(__CYGWIN__)
#define SDL_PRIs64 "I64d"
#else
#define SDL_PRIs64 "lld"

View File

@@ -28,7 +28,7 @@
#include "SDL_events_c.h"
#include "../SDL_hints_c.h"
#include "../video/SDL_sysvideo.h"
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__GDK__)
#include "../core/windows/SDL_windows.h" // For GetDoubleClickTime()
#endif
#if defined(__OS2__)
@@ -55,7 +55,7 @@ SDL_MouseDoubleClickTimeChanged(void *userdata, const char *name, const char *ol
if (hint && *hint) {
mouse->double_click_time = SDL_atoi(hint);
} else {
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__GDK__)
mouse->double_click_time = GetDoubleClickTime();
#elif defined(__OS2__)
mouse->double_click_time = WinQuerySysValue(HWND_DESKTOP, SV_DBLCLKTIME);
@@ -1069,7 +1069,7 @@ SDL_CaptureMouse(SDL_bool enabled)
return SDL_Unsupported();
}
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__WINGDK__)
/* Windows mouse capture is tied to the current thread, and must be called
* from the thread that created the window being captured. Since we update
* the mouse capture state from the event processing, any application state
@@ -1078,7 +1078,7 @@ SDL_CaptureMouse(SDL_bool enabled)
if (!SDL_OnVideoThread()) {
return SDL_SetError("SDL_CaptureMouse() must be called on the main thread");
}
#endif /* __WIN32__ */
#endif /* defined(__WIN32__) || defined(__WINGDK__) */
if (enabled && SDL_GetKeyboardFocus() == NULL) {
return SDL_SetError("No window has focus");

View File

@@ -29,7 +29,7 @@
#define MUST_THREAD_EVENTS
#endif
#ifdef __WIN32__ /* Windows doesn't allow a separate event thread */
#if defined(__WIN32__) || defined(__GDK__) /* Windows doesn't allow a separate event thread */
#define CANT_THREAD_EVENTS
#endif

View File

@@ -30,7 +30,7 @@
#include "../SDL_internal.h"
#if defined(__WIN32__)
#if defined(__WIN32__) || defined(__GDK__)
#include "../core/windows/SDL_windows.h"
#endif
@@ -62,7 +62,7 @@
#include "nacl_io/nacl_io.h"
#endif
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__GDK__)
/* Functions to read/write Win32 API file pointers */
@@ -303,7 +303,7 @@ windows_file_close(SDL_RWops * context)
}
return 0;
}
#endif /* __WIN32__ */
#endif /* defined(__WIN32__) || defined(__GDK__) */
#ifdef HAVE_STDIO_H
@@ -574,7 +574,7 @@ SDL_RWFromFile(const char *file, const char *mode)
rwops->close = Android_JNI_FileClose;
rwops->type = SDL_RWOPS_JNIFILE;
#elif defined(__WIN32__)
#elif defined(__WIN32__) || defined(__GDK__)
rwops = SDL_AllocRW();
if (!rwops)
return NULL; /* SDL_SetError already setup by SDL_AllocRW() */

View File

@@ -37,7 +37,7 @@
#if !SDL_HIDAPI_DISABLED
#if defined(__WIN32__)
#if defined(__WIN32__) || defined(__WINGDK__)
#include "../core/windows/SDL_windows.h"
#endif
@@ -89,7 +89,7 @@ static struct
SDL_bool m_bCanGetNotifications;
Uint32 m_unLastDetect;
#if defined(__WIN32__)
#if defined(__WIN32__) || defined(__WINGDK__)
SDL_threadID m_nThreadID;
WNDCLASSEXA m_wndClass;
HWND m_hwndMsg;
@@ -110,7 +110,7 @@ static struct
} SDL_HIDAPI_discovery;
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__WINGDK__)
struct _DEV_BROADCAST_HDR
{
DWORD dbch_size;
@@ -156,7 +156,7 @@ static LRESULT CALLBACK ControllerWndProc(HWND hwnd, UINT message, WPARAM wParam
return DefWindowProc(hwnd, message, wParam, lParam);
}
#endif /* __WIN32__ */
#endif /* defined(__WIN32__) || defined(__WINGDK__) */
#if defined(__MACOSX__)
@@ -219,7 +219,7 @@ HIDAPI_InitializeDiscovery()
SDL_HIDAPI_discovery.m_bCanGetNotifications = SDL_FALSE;
SDL_HIDAPI_discovery.m_unLastDetect = 0;
#if defined(__WIN32__)
#if defined(__WIN32__) || defined(__WINGDK__)
SDL_HIDAPI_discovery.m_nThreadID = SDL_ThreadID();
SDL_zero(SDL_HIDAPI_discovery.m_wndClass);
@@ -246,7 +246,7 @@ HIDAPI_InitializeDiscovery()
SDL_HIDAPI_discovery.m_hNotify = RegisterDeviceNotification( SDL_HIDAPI_discovery.m_hwndMsg, &devBroadcast, DEVICE_NOTIFY_WINDOW_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES );
SDL_HIDAPI_discovery.m_bCanGetNotifications = ( SDL_HIDAPI_discovery.m_hNotify != 0 );
}
#endif /* __WIN32__ */
#endif /* defined(__WIN32__) || defined(__WINGDK__) */
#if defined(__MACOSX__)
SDL_HIDAPI_discovery.m_notificationPort = IONotificationPortCreate(kIOMasterPortDefault);
@@ -369,7 +369,7 @@ HIDAPI_UpdateDiscovery()
return;
}
#if defined(__WIN32__)
#if defined(__WIN32__) || defined(__WINGDK__)
#if 0 /* just let the usual SDL_PumpEvents loop dispatch these, fixing bug 4286. --ryan. */
/* We'll only get messages on the same thread that created the window */
if (SDL_ThreadID() == SDL_HIDAPI_discovery.m_nThreadID) {
@@ -382,7 +382,7 @@ HIDAPI_UpdateDiscovery()
}
}
#endif
#endif /* __WIN32__ */
#endif /* defined(__WIN32__) || defined(__WINGDK__) */
#if defined(__MACOSX__)
if (SDL_HIDAPI_discovery.m_notificationPort) {
@@ -474,7 +474,7 @@ HIDAPI_ShutdownDiscovery()
return;
}
#if defined(__WIN32__)
#if defined(__WIN32__) || defined(__WINGDK__)
if (SDL_HIDAPI_discovery.m_hNotify)
UnregisterDeviceNotification(SDL_HIDAPI_discovery.m_hNotify);
@@ -578,7 +578,7 @@ static const SDL_UDEV_Symbols *udev_ctx = NULL;
#include "mac/hid.c"
#define HAVE_PLATFORM_BACKEND 1
#define udev_ctx 1
#elif __WINDOWS__
#elif __WINDOWS__ || __WINGDK__
#include "windows/hid.c"
#define HAVE_PLATFORM_BACKEND 1
#define udev_ctx 1

View File

@@ -1019,7 +1019,7 @@ static char *SDL_PrivateGetControllerGUIDFromMappingString(const char *pMapping)
pchGUID[pFirstComma - pMapping] = '\0';
/* Convert old style GUIDs to the new style in 2.0.5 */
#if __WIN32__
#if defined(__WIN32__) || defined(__WINGDK__)
if (SDL_strlen(pchGUID) == 32 &&
SDL_memcmp(&pchGUID[20], "504944564944", 12) == 0) {
SDL_memcpy(&pchGUID[20], "000000000000", 12);

View File

@@ -37,7 +37,7 @@
/* This is included in only one place because it has a large static list of controllers */
#include "controller_type.h"
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__WINGDK__)
/* Needed for checking for input remapping programs */
#include "../core/windows/SDL_windows.h"
@@ -2362,7 +2362,7 @@ static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid)
static SDL_bool SDL_IsPS4RemapperRunning(void)
{
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__WINGDK__)
const char *mapper_processes[] = {
"DS4Windows.exe",
"InputMapper.exe",

View File

@@ -156,7 +156,7 @@ SetInitState(SDL_DriverXboxOne_Context *ctx, SDL_XboxOneInitState state)
static void
SendAckIfNeeded(SDL_HIDAPI_Device *device, Uint8 *data, int size)
{
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__WINGDK__)
/* The Windows driver is taking care of acks */
#else
if ((data[1] & 0x30) == 0x30) {
@@ -179,7 +179,7 @@ SendAckIfNeeded(SDL_HIDAPI_Device *device, Uint8 *data, int size)
SDL_SetError("Couldn't send ack packet");
}
}
#endif /* __WIN32__ */
#endif /* defined(__WIN32__) || defined(__WINGDK__ */
}
#if 0
@@ -912,7 +912,7 @@ HIDAPI_DriverXboxOne_UpdateInitState(SDL_HIDAPI_Device *device, SDL_DriverXboxOn
switch (ctx->init_state) {
case XBOX_ONE_INIT_STATE_START_NEGOTIATING:
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__WINGDK__)
/* The Windows driver is taking care of negotiation */
SetInitState(ctx, XBOX_ONE_INIT_STATE_COMPLETE);
#else

View File

@@ -32,7 +32,7 @@
#include "SDL_hidapi_rumble.h"
#include "../../SDL_hints_c.h"
#if defined(__WIN32__)
#if defined(__WIN32__) || defined(__WINGDK__)
#include "../windows/SDL_rawinputjoystick_c.h"
#endif

View File

@@ -0,0 +1,41 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
/* Include this so we define UNICODE properly */
#include "../../core/windows/SDL_windows.h"
/* Include the SDL main definition header */
#include "SDL.h"
#include "SDL_main.h"
#ifdef main
# undef main
#endif /* main */
/* This is where execution begins */
int WINAPI
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
{
return SDL_GDKRunApp(SDL_main, NULL);
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1775,7 +1775,7 @@ SDL_RenderDriver D3D_RenderDriver = {
};
#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__WINGDK__)
/* This function needs to always exist on Windows, for the Dynamic API. */
IDirect3DDevice9 *
SDL_RenderGetD3D9Device(SDL_Renderer * renderer)
@@ -1799,6 +1799,6 @@ SDL_RenderGetD3D9Device(SDL_Renderer * renderer)
return device;
}
#endif /* __WIN32__ */
#endif /* defined(__WIN32__) || defined(__WINGDK__) */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -672,7 +672,7 @@ done:
return result;
}
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__WINGDK__)
static DXGI_MODE_ROTATION
D3D11_GetCurrentRotation()
@@ -681,7 +681,7 @@ D3D11_GetCurrentRotation()
return DXGI_MODE_ROTATION_IDENTITY;
}
#endif /* __WIN32__ */
#endif /* defined(__WIN32__) || defined(__WINGDK__) */
static BOOL
D3D11_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation)
@@ -827,7 +827,7 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
goto done;
#endif
} else {
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__WINGDK__)
SDL_SysWMinfo windowinfo;
SDL_VERSION(&windowinfo.version);
SDL_GetWindowWMInfo(renderer->window, &windowinfo);
@@ -849,7 +849,7 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
#else
SDL_SetError(__FUNCTION__", Unable to find something to attach a swap chain to");
goto done;
#endif /* ifdef __WIN32__ / else */
#endif /* defined(__WIN32__) || defined(__WINGDK__) / else */
}
data->swapEffect = swapChainDesc.SwapEffect;
@@ -2473,7 +2473,7 @@ SDL_RenderDriver D3D11_RenderDriver = {
#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__WINGDK__)
/* This function needs to always exist on Windows, for the Dynamic API. */
ID3D11Device *
SDL_RenderGetD3D11Device(SDL_Renderer * renderer)
@@ -2497,6 +2497,6 @@ SDL_RenderGetD3D11Device(SDL_Renderer * renderer)
return device;
}
#endif /* __WIN32__ */
#endif /* defined(__WIN32__) || defined(__WINGDK__) */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -3042,7 +3042,7 @@ SDL_RenderDriver D3D12_RenderDriver = {
#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED */
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__GDK__)
#ifdef __cplusplus
extern "C"
#endif
@@ -3069,6 +3069,6 @@ SDL_RenderGetD3D12Device(SDL_Renderer * renderer)
return device;
}
#endif /* __WIN32__ */
#endif /* defined(__WIN32__) || defined(__GDK__) */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -1715,7 +1715,7 @@ GL_IsProbablyAccelerated(const GL_RenderData *data)
/*const char *vendor = (const char *) data->glGetString(GL_VENDOR);*/
const char *renderer = (const char *) data->glGetString(GL_RENDERER);
#ifdef __WINDOWS__
#if defined(__WINDOWS__) || defined(__WINGDK__)
if (SDL_strcmp(renderer, "GDI Generic") == 0) {
return SDL_FALSE; /* Microsoft's fallback software renderer. Fix your system! */
}

View File

@@ -32,7 +32,7 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net
#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED
#if defined(__WIN32__)
#if defined(__WIN32__) || defined(__GDK__)
#include "../../core/windows/SDL_windows.h"
#endif

View File

@@ -25,7 +25,7 @@
#include "../SDL_internal.h"
#if defined(__WIN32__)
#if defined(__WIN32__) || defined(__WINGDK__)
#include "../core/windows/SDL_windows.h"
#endif
@@ -35,7 +35,7 @@
#include "SDL_stdinc.h"
#if defined(__WIN32__) && (!defined(HAVE_SETENV) || !defined(HAVE_GETENV))
#if (defined(__WIN32__) || defined(__WINGDK__)) && (!defined(HAVE_SETENV) || !defined(HAVE_GETENV))
/* Note this isn't thread-safe! */
static char *SDL_envmem = NULL; /* Ugh, memory leak */
static size_t SDL_envmemlen = 0;
@@ -54,7 +54,7 @@ SDL_setenv(const char *name, const char *value, int overwrite)
return setenv(name, value, overwrite);
}
#elif defined(__WIN32__)
#elif defined(__WIN32__) || defined(__WINGDK__)
int
SDL_setenv(const char *name, const char *value, int overwrite)
{
@@ -187,7 +187,7 @@ SDL_getenv(const char *name)
return getenv(name);
}
#elif defined(__WIN32__)
#elif defined(__WIN32__) || defined(__WINGDK__)
char *
SDL_getenv(const char *name)
{

View File

@@ -131,7 +131,7 @@ static struct
{ "US-ASCII", ENCODING_ASCII },
{ "8859-1", ENCODING_LATIN1 },
{ "ISO-8859-1", ENCODING_LATIN1 },
#if defined(__WIN32__) || defined(__OS2__)
#if defined(__WIN32__) || defined(__OS2__) || defined(__GDK__)
{ "WCHAR_T", ENCODING_UTF16LE },
#else
{ "WCHAR_T", ENCODING_UCS4NATIVE },

View File

@@ -1667,7 +1667,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
/* Clear minimized if not on windows, only windows handles it at create rather than FinishWindowCreation,
* but it's important or window focus will get broken on windows!
*/
#if !defined(__WIN32__)
#if !defined(__WIN32__) && !defined(__GDK__)
if (window->flags & SDL_WINDOW_MINIMIZED) {
window->flags &= ~SDL_WINDOW_MINIMIZED;
}
@@ -2534,7 +2534,7 @@ SDL_CreateWindowFramebuffer(SDL_Window * window)
attempt_texture_framebuffer = SDL_FALSE;
}
#if defined(__WIN32__) /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) */
#if defined(__WIN32__) || defined(__WINGDK__) /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) */
else if ((_this->CreateWindowFramebuffer != NULL) && (SDL_strcmp(_this->name, "windows") == 0)) {
attempt_texture_framebuffer = SDL_FALSE;
}

View File

@@ -53,6 +53,10 @@
#include "wmmsg.h"
#endif
#ifdef __GDK__
#include "../../core/gdk/SDL_gdk.h"
#endif
/* #define HIGHDPI_DEBUG */
/* Masks for processing the windows KEYDOWN and KEYUP messages */
@@ -1803,6 +1807,10 @@ WIN_PumpEvents(_THIS)
/* Update mouse capture */
WIN_UpdateMouseCapture();
#ifdef __GDK__
GDK_DispatchTaskQueue();
#endif
}