Skip to content

Commit 15ebad6

Browse files
committed
emscripten: Implement SDL_OpenURL
1 parent 99af328 commit 15ebad6

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,11 @@ elseif(EMSCRIPTEN)
11701170
# Hide noisy warnings that intend to aid mostly during initial stages of porting a new
11711171
# project. Uncomment at will for verbose cross-compiling -I/../ path info.
11721172
target_compile_options(sdl-build-options INTERFACE "-Wno-warn-absolute-paths")
1173+
1174+
file(GLOB EMSRIPTEN_MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/emscripten/*.c)
1175+
set(SOURCE_FILES ${SOURCE_FILES} ${EMSRIPTEN_MISC_SOURCES})
1176+
set(HAVE_SDL_MISC TRUE)
1177+
11731178
if(SDL_AUDIO)
11741179
set(SDL_AUDIO_DRIVER_EMSCRIPTEN 1)
11751180
file(GLOB EM_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/emscripten/*.c)

configure

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26618,6 +26618,9 @@ $as_echo "#define SDL_AUDIO_DRIVER_EMSCRIPTEN 1" >>confdefs.h
2661826618
CheckClockGettime
2661926619
CheckEmscriptenGLES
2662026620

26621+
SOURCES="$SOURCES $srcdir/src/misc/emscripten/*.c"
26622+
have_misc=yes
26623+
2662126624
# Set up files for the power library
2662226625
if test x$enable_power = xyes; then
2662326626

configure.ac

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4339,6 +4339,9 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works. --ryan.
43394339
CheckClockGettime
43404340
CheckEmscriptenGLES
43414341

4342+
SOURCES="$SOURCES $srcdir/src/misc/emscripten/*.c"
4343+
have_misc=yes
4344+
43424345
# Set up files for the power library
43434346
if test x$enable_power = xyes; then
43444347
AC_DEFINE(SDL_POWER_EMSCRIPTEN, 1, [ ])

src/misc/emscripten/SDL_sysurl.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Simple DirectMedia Layer
3+
Copyright (C) 1997-2022 Sam Lantinga <[email protected]>
4+
5+
This software is provided 'as-is', without any express or implied
6+
warranty. In no event will the authors be held liable for any damages
7+
arising from the use of this software.
8+
9+
Permission is granted to anyone to use this software for any purpose,
10+
including commercial applications, and to alter it and redistribute it
11+
freely, subject to the following restrictions:
12+
13+
1. The origin of this software must not be misrepresented; you must not
14+
claim that you wrote the original software. If you use this software
15+
in a product, an acknowledgment in the product documentation would be
16+
appreciated but is not required.
17+
2. Altered source versions must be plainly marked as such, and must not be
18+
misrepresented as being the original software.
19+
3. This notice may not be removed or altered from any source distribution.
20+
*/
21+
22+
#include "../SDL_sysurl.h"
23+
24+
#include <emscripten/emscripten.h>
25+
26+
int
27+
SDL_SYS_OpenURL(const char *url)
28+
{
29+
EM_ASM({
30+
window.open(UTF8ToString($0), "_blank");
31+
}, url);
32+
33+
return 0;
34+
}
35+
36+
/* vi: set ts=4 sw=4 expandtab: */
37+

0 commit comments

Comments
 (0)