emscripten: Unify creation of Module['SDL3'] in at SDL_Init time.
This commit is contained in:
@@ -326,6 +326,14 @@ 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?");
|
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({
|
||||||
|
if (typeof(Module['SDL3']) === 'undefined') {
|
||||||
|
Module['SDL3'] = {};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
SDL_InitMainThread();
|
SDL_InitMainThread();
|
||||||
|
|
||||||
#ifdef SDL_USE_LIBDBUS
|
#ifdef SDL_USE_LIBDBUS
|
||||||
|
|||||||
@@ -116,9 +116,6 @@ static bool DUMMYAUDIO_Init(SDL_AudioDriverImpl *impl)
|
|||||||
// on Emscripten without threads, we just fire a repeating timer to consume audio.
|
// on Emscripten without threads, we just fire a repeating timer to consume audio.
|
||||||
#if defined(SDL_PLATFORM_EMSCRIPTEN) && !defined(__EMSCRIPTEN_PTHREADS__)
|
#if defined(SDL_PLATFORM_EMSCRIPTEN) && !defined(__EMSCRIPTEN_PTHREADS__)
|
||||||
MAIN_THREAD_EM_ASM({
|
MAIN_THREAD_EM_ASM({
|
||||||
if (typeof(Module['SDL3']) === 'undefined') {
|
|
||||||
Module['SDL3'] = {};
|
|
||||||
}
|
|
||||||
Module['SDL3'].dummy_audio = {};
|
Module['SDL3'].dummy_audio = {};
|
||||||
Module['SDL3'].dummy_audio.timers = [];
|
Module['SDL3'].dummy_audio.timers = [];
|
||||||
Module['SDL3'].dummy_audio.timers[0] = undefined;
|
Module['SDL3'].dummy_audio.timers[0] = undefined;
|
||||||
|
|||||||
@@ -151,9 +151,6 @@ static bool EMSCRIPTENAUDIO_OpenDevice(SDL_AudioDevice *device)
|
|||||||
|
|
||||||
// create context
|
// create context
|
||||||
const bool result = MAIN_THREAD_EM_ASM_INT({
|
const bool result = MAIN_THREAD_EM_ASM_INT({
|
||||||
if (typeof(Module['SDL3']) === 'undefined') {
|
|
||||||
Module['SDL3'] = {};
|
|
||||||
}
|
|
||||||
var SDL3 = Module['SDL3'];
|
var SDL3 = Module['SDL3'];
|
||||||
if (typeof(SDL3.audio_playback) === 'undefined') {
|
if (typeof(SDL3.audio_playback) === 'undefined') {
|
||||||
SDL3.audio_playback = {};
|
SDL3.audio_playback = {};
|
||||||
|
|||||||
@@ -247,9 +247,6 @@ static void EMSCRIPTENCAMERA_DetectDevices(void)
|
|||||||
static bool EMSCRIPTENCAMERA_Init(SDL_CameraDriverImpl *impl)
|
static bool EMSCRIPTENCAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||||
{
|
{
|
||||||
MAIN_THREAD_EM_ASM({
|
MAIN_THREAD_EM_ASM({
|
||||||
if (typeof(Module['SDL3']) === 'undefined') {
|
|
||||||
Module['SDL3'] = {};
|
|
||||||
}
|
|
||||||
Module['SDL3'].camera = {};
|
Module['SDL3'].camera = {};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -957,9 +957,6 @@ EMSCRIPTEN_KEEPALIVE void Emscripten_HandlePointerGeneric(SDL_WindowData *window
|
|||||||
static void Emscripten_prep_pointer_event_callbacks(void)
|
static void Emscripten_prep_pointer_event_callbacks(void)
|
||||||
{
|
{
|
||||||
MAIN_THREAD_EM_ASM({
|
MAIN_THREAD_EM_ASM({
|
||||||
if (typeof(Module['SDL3']) === 'undefined') {
|
|
||||||
Module['SDL3'] = {};
|
|
||||||
}
|
|
||||||
var SDL3 = Module['SDL3'];
|
var SDL3 = Module['SDL3'];
|
||||||
|
|
||||||
if (SDL3.makePointerEventCStruct === undefined) {
|
if (SDL3.makePointerEventCStruct === undefined) {
|
||||||
@@ -1166,10 +1163,6 @@ static void Emscripten_set_drag_event_callbacks(SDL_WindowData *data)
|
|||||||
var target = document.querySelector(UTF8ToString($1));
|
var target = document.querySelector(UTF8ToString($1));
|
||||||
if (target) {
|
if (target) {
|
||||||
var data = $0;
|
var data = $0;
|
||||||
|
|
||||||
if (typeof(Module['SDL3']) === 'undefined') {
|
|
||||||
Module['SDL3'] = {};
|
|
||||||
}
|
|
||||||
var SDL3 = Module['SDL3'];
|
var SDL3 = Module['SDL3'];
|
||||||
|
|
||||||
var makeDropEventCStruct = function(event) {
|
var makeDropEventCStruct = function(event) {
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ bool Emscripten_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *wind
|
|||||||
var canvas = document.querySelector(canvasId);
|
var canvas = document.querySelector(canvasId);
|
||||||
|
|
||||||
//TODO: this should store a context per canvas
|
//TODO: this should store a context per canvas
|
||||||
if (!Module['SDL3']) Module['SDL3'] = {};
|
|
||||||
var SDL3 = Module['SDL3'];
|
var SDL3 = Module['SDL3'];
|
||||||
if (SDL3.ctxCanvas !== canvas) {
|
if (SDL3.ctxCanvas !== canvas) {
|
||||||
SDL3.ctx = Browser.createContext(canvas, false, true);
|
SDL3.ctx = Browser.createContext(canvas, false, true);
|
||||||
|
|||||||
@@ -228,9 +228,6 @@ void Emscripten_InitMouse(void)
|
|||||||
|
|
||||||
// Add event listeners to track mouse events on the document
|
// Add event listeners to track mouse events on the document
|
||||||
MAIN_THREAD_EM_ASM({
|
MAIN_THREAD_EM_ASM({
|
||||||
if (!Module['SDL3']) {
|
|
||||||
Module['SDL3'] = {};
|
|
||||||
}
|
|
||||||
var SDL3 = Module['SDL3'];
|
var SDL3 = Module['SDL3'];
|
||||||
SDL3['mouse_x'] = 0;
|
SDL3['mouse_x'] = 0;
|
||||||
SDL3['mouse_y'] = 0;
|
SDL3['mouse_y'] = 0;
|
||||||
|
|||||||
@@ -101,10 +101,6 @@ static void Emscripten_ListenSystemTheme(void)
|
|||||||
{
|
{
|
||||||
MAIN_THREAD_EM_ASM({
|
MAIN_THREAD_EM_ASM({
|
||||||
if (window.matchMedia) {
|
if (window.matchMedia) {
|
||||||
if (typeof(Module['SDL3']) === 'undefined') {
|
|
||||||
Module['SDL3'] = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
var SDL3 = Module['SDL3'];
|
var SDL3 = Module['SDL3'];
|
||||||
|
|
||||||
SDL3.eventHandlerThemeChanged = function(event) {
|
SDL3.eventHandlerThemeChanged = function(event) {
|
||||||
|
|||||||
Reference in New Issue
Block a user