update SDL3 from 3.2.20 to 3.4.2
This commit is contained in:
+74
-15
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2026 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
|
||||
@@ -30,6 +30,10 @@
|
||||
// this checks for HAVE_DBUS_DBUS_H internally.
|
||||
#include "core/linux/SDL_dbus.h"
|
||||
|
||||
#if defined(SDL_PLATFORM_UNIX) && !defined(SDL_PLATFORM_ANDROID)
|
||||
#include "core/unix/SDL_gtk.h"
|
||||
#endif
|
||||
|
||||
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
@@ -144,7 +148,7 @@ static bool SDL_ValidMetadataProperty(const char *name)
|
||||
|
||||
bool SDL_SetAppMetadataProperty(const char *name, const char *value)
|
||||
{
|
||||
if (!SDL_ValidMetadataProperty(name)) {
|
||||
CHECK_PARAM(!SDL_ValidMetadataProperty(name)) {
|
||||
return SDL_InvalidParamError("name");
|
||||
}
|
||||
|
||||
@@ -153,7 +157,7 @@ bool SDL_SetAppMetadataProperty(const char *name, const char *value)
|
||||
|
||||
const char *SDL_GetAppMetadataProperty(const char *name)
|
||||
{
|
||||
if (!SDL_ValidMetadataProperty(name)) {
|
||||
CHECK_PARAM(!SDL_ValidMetadataProperty(name)) {
|
||||
SDL_InvalidParamError("name");
|
||||
return NULL;
|
||||
}
|
||||
@@ -185,6 +189,8 @@ static bool SDL_MainIsReady = false;
|
||||
static bool SDL_MainIsReady = true;
|
||||
#endif
|
||||
static SDL_ThreadID SDL_MainThreadID = 0;
|
||||
static SDL_ThreadID SDL_EventsThreadID = 0;
|
||||
static SDL_ThreadID SDL_VideoThreadID = 0;
|
||||
static bool SDL_bInMainQuit = false;
|
||||
static Uint8 SDL_SubsystemRefCount[32];
|
||||
|
||||
@@ -233,6 +239,7 @@ static bool SDL_ShouldQuitSubsystem(Uint32 subsystem)
|
||||
return (((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 1)) || SDL_bInMainQuit);
|
||||
}
|
||||
|
||||
#if !defined(SDL_VIDEO_DISABLED) || !defined(SDL_AUDIO_DISABLED) || !defined(SDL_JOYSTICK_DISABLED)
|
||||
/* Private helper to either increment's existing ref counter,
|
||||
* or fully init a new subsystem. */
|
||||
static bool SDL_InitOrIncrementSubsystem(Uint32 subsystem)
|
||||
@@ -248,6 +255,7 @@ static bool SDL_InitOrIncrementSubsystem(Uint32 subsystem)
|
||||
}
|
||||
return SDL_InitSubSystem(subsystem);
|
||||
}
|
||||
#endif // !SDL_VIDEO_DISABLED || !SDL_AUDIO_DISABLED || !SDL_JOYSTICK_DISABLED
|
||||
|
||||
void SDL_SetMainReady(void)
|
||||
{
|
||||
@@ -260,14 +268,21 @@ void SDL_SetMainReady(void)
|
||||
|
||||
bool SDL_IsMainThread(void)
|
||||
{
|
||||
if (SDL_MainThreadID == 0) {
|
||||
// Not initialized yet?
|
||||
return true;
|
||||
if (SDL_VideoThreadID) {
|
||||
return (SDL_GetCurrentThreadID() == SDL_VideoThreadID);
|
||||
}
|
||||
if (SDL_MainThreadID == SDL_GetCurrentThreadID()) {
|
||||
return true;
|
||||
if (SDL_EventsThreadID) {
|
||||
return (SDL_GetCurrentThreadID() == SDL_EventsThreadID);
|
||||
}
|
||||
return false;
|
||||
if (SDL_MainThreadID) {
|
||||
return (SDL_GetCurrentThreadID() == SDL_MainThreadID);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SDL_IsVideoThread(void)
|
||||
{
|
||||
return (SDL_GetCurrentThreadID() == SDL_VideoThreadID);
|
||||
}
|
||||
|
||||
// Initialize all the subsystems that require initialization before threads start
|
||||
@@ -275,6 +290,11 @@ void SDL_InitMainThread(void)
|
||||
{
|
||||
static bool done_info = false;
|
||||
|
||||
// If we haven't done it by now, mark this as the main thread
|
||||
if (SDL_MainThreadID == 0) {
|
||||
SDL_MainThreadID = SDL_GetCurrentThreadID();
|
||||
}
|
||||
|
||||
SDL_InitTLSData();
|
||||
SDL_InitEnvironment();
|
||||
SDL_InitTicks();
|
||||
@@ -311,6 +331,26 @@ bool SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
return SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?");
|
||||
}
|
||||
|
||||
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
||||
MAIN_THREAD_EM_ASM({
|
||||
// make sure this generic table to hang SDL-specific Javascript stuff is available at init time.
|
||||
if (typeof(Module['SDL3']) === 'undefined') {
|
||||
Module['SDL3'] = {};
|
||||
}
|
||||
|
||||
var SDL3 = Module['SDL3'];
|
||||
#if defined(__wasm32__)
|
||||
if (typeof(SDL3.JSVarToCPtr) === 'undefined') { SDL3.JSVarToCPtr = function(v) { return v; }; }
|
||||
if (typeof(SDL3.CPtrToHeap32Index) === 'undefined') { SDL3.CPtrToHeap32Index = function(ptr) { return ptr >>> 2; }; }
|
||||
#elif defined(__wasm64__)
|
||||
if (typeof(SDL3.JSVarToCPtr) === 'undefined') { SDL3.JSVarToCPtr = function(v) { return BigInt(v); }; }
|
||||
if (typeof(SDL3.CPtrToHeap32Index) === 'undefined') { SDL3.CPtrToHeap32Index = function(ptr) { return Number(ptr / 4n); }; }
|
||||
#else
|
||||
#error Please define your platform.
|
||||
#endif
|
||||
});
|
||||
#endif
|
||||
|
||||
SDL_InitMainThread();
|
||||
|
||||
#ifdef SDL_USE_LIBDBUS
|
||||
@@ -329,6 +369,11 @@ bool SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
if (flags & SDL_INIT_EVENTS) {
|
||||
if (SDL_ShouldInitSubsystem(SDL_INIT_EVENTS)) {
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_EVENTS);
|
||||
|
||||
// Note which thread initialized events
|
||||
// This is the thread which should be pumping events
|
||||
SDL_EventsThreadID = SDL_GetCurrentThreadID();
|
||||
|
||||
if (!SDL_InitEvents()) {
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_EVENTS);
|
||||
goto quit_and_error;
|
||||
@@ -348,12 +393,16 @@ bool SDL_InitSubSystem(SDL_InitFlags flags)
|
||||
goto quit_and_error;
|
||||
}
|
||||
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_VIDEO);
|
||||
|
||||
// We initialize video on the main thread
|
||||
// On Apple platforms this is a requirement.
|
||||
// On other platforms, this is the definition.
|
||||
SDL_MainThreadID = SDL_GetCurrentThreadID();
|
||||
SDL_VideoThreadID = SDL_GetCurrentThreadID();
|
||||
#ifdef SDL_PLATFORM_APPLE
|
||||
SDL_assert(SDL_VideoThreadID == SDL_MainThreadID);
|
||||
#endif
|
||||
|
||||
SDL_IncrementSubsystemRefCount(SDL_INIT_VIDEO);
|
||||
if (!SDL_VideoInit(NULL)) {
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_VIDEO);
|
||||
SDL_PushError();
|
||||
@@ -603,6 +652,7 @@ void SDL_QuitSubSystem(SDL_InitFlags flags)
|
||||
if (SDL_ShouldQuitSubsystem(SDL_INIT_VIDEO)) {
|
||||
SDL_QuitRender();
|
||||
SDL_VideoQuit();
|
||||
SDL_VideoThreadID = 0;
|
||||
// video implies events
|
||||
SDL_QuitSubSystem(SDL_INIT_EVENTS);
|
||||
}
|
||||
@@ -613,6 +663,7 @@ void SDL_QuitSubSystem(SDL_InitFlags flags)
|
||||
if (flags & SDL_INIT_EVENTS) {
|
||||
if (SDL_ShouldQuitSubsystem(SDL_INIT_EVENTS)) {
|
||||
SDL_QuitEvents();
|
||||
SDL_EventsThreadID = 0;
|
||||
}
|
||||
SDL_DecrementSubsystemRefCount(SDL_INIT_EVENTS);
|
||||
}
|
||||
@@ -663,6 +714,10 @@ void SDL_Quit(void)
|
||||
SDL_DBus_Quit();
|
||||
#endif
|
||||
|
||||
#if defined(SDL_PLATFORM_UNIX) && !defined(SDL_PLATFORM_ANDROID) && !defined(SDL_PLATFORM_EMSCRIPTEN) && !defined(SDL_PLATFORM_PRIVATE)
|
||||
SDL_Gtk_Quit();
|
||||
#endif
|
||||
|
||||
SDL_QuitTimers();
|
||||
SDL_QuitAsyncIO();
|
||||
|
||||
@@ -676,7 +731,7 @@ void SDL_Quit(void)
|
||||
/* Now that every subsystem has been quit, we reset the subsystem refcount
|
||||
* and the list of initialized subsystems.
|
||||
*/
|
||||
SDL_memset(SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount));
|
||||
SDL_zeroa(SDL_SubsystemRefCount);
|
||||
|
||||
SDL_QuitLog();
|
||||
SDL_QuitHints();
|
||||
@@ -728,6 +783,8 @@ const char *SDL_GetPlatform(void)
|
||||
return "macOS";
|
||||
#elif defined(SDL_PLATFORM_NETBSD)
|
||||
return "NetBSD";
|
||||
#elif defined(SDL_PLATFORM_NGAGE)
|
||||
return "Nokia N-Gage";
|
||||
#elif defined(SDL_PLATFORM_OPENBSD)
|
||||
return "OpenBSD";
|
||||
#elif defined(SDL_PLATFORM_OS2)
|
||||
@@ -748,6 +805,8 @@ const char *SDL_GetPlatform(void)
|
||||
return "Xbox One";
|
||||
#elif defined(SDL_PLATFORM_XBOXSERIES)
|
||||
return "Xbox Series X|S";
|
||||
#elif defined(SDL_PLATFORM_VISIONOS)
|
||||
return "visionOS";
|
||||
#elif defined(SDL_PLATFORM_IOS)
|
||||
return "iOS";
|
||||
#elif defined(SDL_PLATFORM_TVOS)
|
||||
@@ -760,6 +819,8 @@ const char *SDL_GetPlatform(void)
|
||||
return "PlayStation Vita";
|
||||
#elif defined(SDL_PLATFORM_3DS)
|
||||
return "Nintendo 3DS";
|
||||
#elif defined(SDL_PLATFORM_HURD)
|
||||
return "GNU/Hurd";
|
||||
#elif defined(__managarm__)
|
||||
return "Managarm";
|
||||
#else
|
||||
@@ -831,9 +892,7 @@ SDL_Sandbox SDL_GetSandbox(void)
|
||||
|
||||
#ifdef SDL_PLATFORM_WIN32
|
||||
|
||||
#if (!defined(HAVE_LIBC) || defined(__WATCOMC__)) && !defined(SDL_STATIC_LIB)
|
||||
// FIXME: Still need to include DllMain() on Watcom C ?
|
||||
|
||||
#if !defined(HAVE_LIBC) && !defined(SDL_STATIC_LIB)
|
||||
BOOL APIENTRY MINGW32_FORCEALIGN _DllMainCRTStartup(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
switch (ul_reason_for_call) {
|
||||
|
||||
Reference in New Issue
Block a user