From 5a079a2d114f96d4847d1ee305d5b7c16eeec50e Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 27 Dec 2025 12:03:39 -0800 Subject: Initial commit --- contrib/SDL-3.2.8/src/misc/SDL_sysurl.h | 31 ++++++++++ contrib/SDL-3.2.8/src/misc/SDL_url.c | 31 ++++++++++ contrib/SDL-3.2.8/src/misc/android/SDL_sysurl.c | 29 +++++++++ contrib/SDL-3.2.8/src/misc/dummy/SDL_sysurl.c | 28 +++++++++ contrib/SDL-3.2.8/src/misc/emscripten/SDL_sysurl.c | 33 ++++++++++ contrib/SDL-3.2.8/src/misc/haiku/SDL_sysurl.cc | 34 +++++++++++ contrib/SDL-3.2.8/src/misc/ios/SDL_sysurl.m | 42 +++++++++++++ contrib/SDL-3.2.8/src/misc/macos/SDL_sysurl.m | 42 +++++++++++++ contrib/SDL-3.2.8/src/misc/riscos/SDL_sysurl.c | 49 +++++++++++++++ contrib/SDL-3.2.8/src/misc/unix/SDL_sysurl.c | 71 ++++++++++++++++++++++ contrib/SDL-3.2.8/src/misc/vita/SDL_sysurl.c | 41 +++++++++++++ contrib/SDL-3.2.8/src/misc/windows/SDL_sysurl.c | 62 +++++++++++++++++++ 12 files changed, 493 insertions(+) create mode 100644 contrib/SDL-3.2.8/src/misc/SDL_sysurl.h create mode 100644 contrib/SDL-3.2.8/src/misc/SDL_url.c create mode 100644 contrib/SDL-3.2.8/src/misc/android/SDL_sysurl.c create mode 100644 contrib/SDL-3.2.8/src/misc/dummy/SDL_sysurl.c create mode 100644 contrib/SDL-3.2.8/src/misc/emscripten/SDL_sysurl.c create mode 100644 contrib/SDL-3.2.8/src/misc/haiku/SDL_sysurl.cc create mode 100644 contrib/SDL-3.2.8/src/misc/ios/SDL_sysurl.m create mode 100644 contrib/SDL-3.2.8/src/misc/macos/SDL_sysurl.m create mode 100644 contrib/SDL-3.2.8/src/misc/riscos/SDL_sysurl.c create mode 100644 contrib/SDL-3.2.8/src/misc/unix/SDL_sysurl.c create mode 100644 contrib/SDL-3.2.8/src/misc/vita/SDL_sysurl.c create mode 100644 contrib/SDL-3.2.8/src/misc/windows/SDL_sysurl.c (limited to 'contrib/SDL-3.2.8/src/misc') diff --git a/contrib/SDL-3.2.8/src/misc/SDL_sysurl.h b/contrib/SDL-3.2.8/src/misc/SDL_sysurl.h new file mode 100644 index 0000000..b5ee700 --- /dev/null +++ b/contrib/SDL-3.2.8/src/misc/SDL_sysurl.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + 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 diff --git a/contrib/SDL-3.2.8/src/misc/SDL_url.c b/contrib/SDL-3.2.8/src/misc/SDL_url.c new file mode 100644 index 0000000..b3163ab --- /dev/null +++ b/contrib/SDL-3.2.8/src/misc/SDL_url.c @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + 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); +} diff --git a/contrib/SDL-3.2.8/src/misc/android/SDL_sysurl.c b/contrib/SDL-3.2.8/src/misc/android/SDL_sysurl.c new file mode 100644 index 0000000..d79f1e0 --- /dev/null +++ b/contrib/SDL-3.2.8/src/misc/android/SDL_sysurl.c @@ -0,0 +1,29 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + 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); +} diff --git a/contrib/SDL-3.2.8/src/misc/dummy/SDL_sysurl.c b/contrib/SDL-3.2.8/src/misc/dummy/SDL_sysurl.c new file mode 100644 index 0000000..64dcfa9 --- /dev/null +++ b/contrib/SDL-3.2.8/src/misc/dummy/SDL_sysurl.c @@ -0,0 +1,28 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + 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(); +} diff --git a/contrib/SDL-3.2.8/src/misc/emscripten/SDL_sysurl.c b/contrib/SDL-3.2.8/src/misc/emscripten/SDL_sysurl.c new file mode 100644 index 0000000..881de01 --- /dev/null +++ b/contrib/SDL-3.2.8/src/misc/emscripten/SDL_sysurl.c @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + 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 + +EM_JS_DEPS(sdlsysurl, "$UTF8ToString"); + +bool SDL_SYS_OpenURL(const char *url) +{ + EM_ASM(window.open(UTF8ToString($0), "_blank"), url); + return true; +} diff --git a/contrib/SDL-3.2.8/src/misc/haiku/SDL_sysurl.cc b/contrib/SDL-3.2.8/src/misc/haiku/SDL_sysurl.cc new file mode 100644 index 0000000..1ce5955 --- /dev/null +++ b/contrib/SDL-3.2.8/src/misc/haiku/SDL_sysurl.cc @@ -0,0 +1,34 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + 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 + +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; +} diff --git a/contrib/SDL-3.2.8/src/misc/ios/SDL_sysurl.m b/contrib/SDL-3.2.8/src/misc/ios/SDL_sysurl.m new file mode 100644 index 0000000..1221eda --- /dev/null +++ b/contrib/SDL-3.2.8/src/misc/ios/SDL_sysurl.m @@ -0,0 +1,42 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + 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 + +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 diff --git a/contrib/SDL-3.2.8/src/misc/macos/SDL_sysurl.m b/contrib/SDL-3.2.8/src/misc/macos/SDL_sysurl.m new file mode 100644 index 0000000..64d9c92 --- /dev/null +++ b/contrib/SDL-3.2.8/src/misc/macos/SDL_sysurl.m @@ -0,0 +1,42 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + 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 + +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 diff --git a/contrib/SDL-3.2.8/src/misc/riscos/SDL_sysurl.c b/contrib/SDL-3.2.8/src/misc/riscos/SDL_sysurl.c new file mode 100644 index 0000000..f5a92b2 --- /dev/null +++ b/contrib/SDL-3.2.8/src/misc/riscos/SDL_sysurl.c @@ -0,0 +1,49 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + 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 +#include + +#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, ®s, ®s); + 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; +} diff --git a/contrib/SDL-3.2.8/src/misc/unix/SDL_sysurl.c b/contrib/SDL-3.2.8/src/misc/unix/SDL_sysurl.c new file mode 100644 index 0000000..e72894b --- /dev/null +++ b/contrib/SDL-3.2.8/src/misc/unix/SDL_sysurl.c @@ -0,0 +1,71 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + 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 +#include +#include +#include +#include +#include +#ifdef USE_POSIX_SPAWN +#include +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; +} diff --git a/contrib/SDL-3.2.8/src/misc/vita/SDL_sysurl.c b/contrib/SDL-3.2.8/src/misc/vita/SDL_sysurl.c new file mode 100644 index 0000000..fb901c3 --- /dev/null +++ b/contrib/SDL-3.2.8/src/misc/vita/SDL_sysurl.c @@ -0,0 +1,41 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + 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 +#include + +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; +} diff --git a/contrib/SDL-3.2.8/src/misc/windows/SDL_sysurl.c b/contrib/SDL-3.2.8/src/misc/windows/SDL_sysurl.c new file mode 100644 index 0000000..8e7bf0b --- /dev/null +++ b/contrib/SDL-3.2.8/src/misc/windows/SDL_sysurl.c @@ -0,0 +1,62 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + 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 + +#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 -- cgit v1.2.3