chore(build): use SDL3

This commit is contained in:
phaneron 2025-04-12 04:38:19 -04:00
parent 9d04a35d87
commit b3c0734a9e
3286 changed files with 866354 additions and 554996 deletions

31
vendor/sdl-3.2.10/src/misc/SDL_sysurl.h vendored Normal file
View file

@ -0,0 +1,31 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 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"
#ifdef __cplusplus
extern "C" {
#endif
extern bool SDL_SYS_OpenURL(const char *url);
#ifdef __cplusplus
}
#endif

31
vendor/sdl-3.2.10/src/misc/SDL_url.c vendored Normal file
View file

@ -0,0 +1,31 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 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_sysurl.h"
bool SDL_OpenURL(const char *url)
{
if (!url) {
return SDL_InvalidParamError("url");
}
return SDL_SYS_OpenURL(url);
}

View file

@ -0,0 +1,29 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 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_sysurl.h"
#include "../../core/android/SDL_android.h"
bool SDL_SYS_OpenURL(const char *url)
{
return Android_JNI_OpenURL(url);
}

View file

@ -0,0 +1,28 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 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_sysurl.h"
bool SDL_SYS_OpenURL(const char *url)
{
return SDL_Unsupported();
}

View file

@ -0,0 +1,33 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 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_sysurl.h"
#include <emscripten/emscripten.h>
EM_JS_DEPS(sdlsysurl, "$UTF8ToString");
bool SDL_SYS_OpenURL(const char *url)
{
EM_ASM(window.open(UTF8ToString($0), "_blank"), url);
return true;
}

View file

@ -0,0 +1,34 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 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_sysurl.h"
#include <Url.h>
bool SDL_SYS_OpenURL(const char *url)
{
BUrl burl(url);
const status_t rc = burl.OpenWithPreferredApplication(false);
if (rc != B_NO_ERROR) {
return SDL_SetError("URL open failed (err=%d)", (int)rc);
}
return true;
}

View file

@ -0,0 +1,42 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 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"
#if defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS)
#include "../SDL_sysurl.h"
#import <UIKit/UIKit.h>
bool SDL_SYS_OpenURL(const char *url)
{
@autoreleasepool {
NSString *nsstr = [NSString stringWithUTF8String:url];
NSURL *nsurl = [NSURL URLWithString:nsstr];
if (![[UIApplication sharedApplication] canOpenURL:nsurl]) {
return SDL_SetError("No handler registered for this type of URL");
}
[[UIApplication sharedApplication] openURL:nsurl options:@{} completionHandler:^(BOOL success) {}];
return true;
}
}
#endif // SDL_PLATFORM_IOS || SDL_PLATFORM_TVOS

View file

@ -0,0 +1,42 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 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"
#if defined(SDL_PLATFORM_MACOS)
#include "../SDL_sysurl.h"
#import <Cocoa/Cocoa.h>
bool SDL_SYS_OpenURL(const char *url)
{
@autoreleasepool {
CFURLRef cfurl = CFURLCreateWithBytes(NULL, (const UInt8 *)url, SDL_strlen(url), kCFStringEncodingUTF8, NULL);
OSStatus status = LSOpenCFURLRef(cfurl, NULL);
CFRelease(cfurl);
if (status != noErr) {
return SDL_SetError("LSOpenCFURLRef() failed: %d", status);
}
return true;
}
}
#endif // SDL_PLATFORM_MACOS

View file

@ -0,0 +1,49 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 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_sysurl.h"
#include <kernel.h>
#include <swis.h>
#ifndef URI_Dispatch
#define URI_Dispatch 0x4e381
#endif
bool SDL_SYS_OpenURL(const char *url)
{
_kernel_swi_regs regs;
_kernel_oserror *error;
regs.r[0] = 0;
regs.r[1] = (int)url;
regs.r[2] = 0;
error = _kernel_swi(URI_Dispatch, &regs, &regs);
if (error) {
return SDL_SetError("Couldn't open given URL: %s", error->errmess);
}
if (regs.r[0] & 1) {
return SDL_SetError("Couldn't open given URL.");
}
return true;
}

View file

@ -0,0 +1,71 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 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_sysurl.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include <errno.h>
#ifdef USE_POSIX_SPAWN
#include <spawn.h>
extern char **environ;
#endif
bool SDL_SYS_OpenURL(const char *url)
{
const char *args[] = { "xdg-open", url, NULL };
SDL_Environment *env = NULL;
SDL_Process *process = NULL;
bool result = false;
env = SDL_CreateEnvironment(true);
if (!env) {
goto done;
}
// Clear LD_PRELOAD so Chrome opens correctly when this application is launched by Steam
SDL_UnsetEnvironmentVariable(env, "LD_PRELOAD");
SDL_PropertiesID props = SDL_CreateProperties();
if (!props) {
goto done;
}
SDL_SetPointerProperty(props, SDL_PROP_PROCESS_CREATE_ARGS_POINTER, args);
SDL_SetPointerProperty(props, SDL_PROP_PROCESS_CREATE_ENVIRONMENT_POINTER, env);
SDL_SetBooleanProperty(props, SDL_PROP_PROCESS_CREATE_BACKGROUND_BOOLEAN, true);
process = SDL_CreateProcessWithProperties(props);
SDL_DestroyProperties(props);
if (!process) {
goto done;
}
result = true;
done:
SDL_DestroyEnvironment(env);
SDL_DestroyProcess(process);
return result;
}

View file

@ -0,0 +1,41 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 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_sysurl.h"
#include <string.h>
#include <psp2/apputil.h>
bool SDL_SYS_OpenURL(const char *url)
{
SceAppUtilInitParam init_param;
SceAppUtilBootParam boot_param;
SceAppUtilWebBrowserParam browser_param;
SDL_zero(init_param);
SDL_zero(boot_param);
sceAppUtilInit(&init_param, &boot_param);
SDL_zero(browser_param);
browser_param.str = url;
browser_param.strlen = SDL_strlen(url);
sceAppUtilLaunchWebBrowser(&browser_param);
return true;
}

View file

@ -0,0 +1,62 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 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_sysurl.h"
#include "../../core/windows/SDL_windows.h"
#include <shellapi.h>
#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
bool SDL_SYS_OpenURL(const char *url)
{
// Not supported
return SDL_Unsupported();
}
#else
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx
bool SDL_SYS_OpenURL(const char *url)
{
WCHAR *wurl;
HINSTANCE rc;
// MSDN says for safety's sake, make sure COM is initialized.
const HRESULT hr = WIN_CoInitialize();
if (FAILED(hr)) {
return WIN_SetErrorFromHRESULT("CoInitialize failed", hr);
}
wurl = WIN_UTF8ToStringW(url);
if (!wurl) {
WIN_CoUninitialize();
return false;
}
// Success returns value greater than 32. Less is an error.
rc = ShellExecuteW(NULL, L"open", wurl, NULL, NULL, SW_SHOWNORMAL);
SDL_free(wurl);
WIN_CoUninitialize();
if (rc <= ((HINSTANCE)32)) {
return WIN_SetError("Couldn't open given URL.");
}
return true;
}
#endif