Update SDL3 from 3.2.4 to 3.2.20
This commit is contained in:
@@ -1005,6 +1005,27 @@ static void Emscripten_unset_drag_event_callbacks(SDL_WindowData *data)
|
||||
}, data->canvas_id);
|
||||
}
|
||||
|
||||
static const char *Emscripten_GetKeyboardTargetElement()
|
||||
{
|
||||
const char *target = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT);
|
||||
|
||||
if (!target || !*target) {
|
||||
return EMSCRIPTEN_EVENT_TARGET_WINDOW;
|
||||
}
|
||||
|
||||
if (SDL_strcmp(target, "#none") == 0) {
|
||||
return NULL;
|
||||
} else if (SDL_strcmp(target, "#window") == 0) {
|
||||
return EMSCRIPTEN_EVENT_TARGET_WINDOW;
|
||||
} else if (SDL_strcmp(target, "#document") == 0) {
|
||||
return EMSCRIPTEN_EVENT_TARGET_DOCUMENT;
|
||||
} else if (SDL_strcmp(target, "#screen") == 0) {
|
||||
return EMSCRIPTEN_EVENT_TARGET_SCREEN;
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
void Emscripten_RegisterEventHandlers(SDL_WindowData *data)
|
||||
{
|
||||
const char *keyElement;
|
||||
@@ -1033,12 +1054,8 @@ void Emscripten_RegisterEventHandlers(SDL_WindowData *data)
|
||||
emscripten_set_pointerlockchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, data, 0, Emscripten_HandlePointerLockChange);
|
||||
|
||||
// Keyboard events are awkward
|
||||
keyElement = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT);
|
||||
if (!keyElement || !*keyElement) {
|
||||
keyElement = EMSCRIPTEN_EVENT_TARGET_WINDOW;
|
||||
}
|
||||
|
||||
if (SDL_strcmp(keyElement, "#none") != 0) {
|
||||
keyElement = Emscripten_GetKeyboardTargetElement();
|
||||
if (keyElement) {
|
||||
emscripten_set_keydown_callback(keyElement, data, 0, Emscripten_HandleKey);
|
||||
emscripten_set_keyup_callback(keyElement, data, 0, Emscripten_HandleKey);
|
||||
emscripten_set_keypress_callback(keyElement, data, 0, Emscripten_HandleKeyPress);
|
||||
@@ -1094,12 +1111,8 @@ void Emscripten_UnregisterEventHandlers(SDL_WindowData *data)
|
||||
|
||||
emscripten_set_pointerlockchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, NULL, 0, NULL);
|
||||
|
||||
target = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT);
|
||||
if (!target) {
|
||||
target = EMSCRIPTEN_EVENT_TARGET_WINDOW;
|
||||
}
|
||||
|
||||
if (*target) {
|
||||
target = Emscripten_GetKeyboardTargetElement();
|
||||
if (target) {
|
||||
emscripten_set_keydown_callback(target, NULL, 0, NULL);
|
||||
emscripten_set_keyup_callback(target, NULL, 0, NULL);
|
||||
emscripten_set_keypress_callback(target, NULL, 0, NULL);
|
||||
|
||||
@@ -78,7 +78,7 @@ bool Emscripten_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *wind
|
||||
if (!Module['SDL3']) Module['SDL3'] = {};
|
||||
var SDL3 = Module['SDL3'];
|
||||
if (SDL3.ctxCanvas !== canvas) {
|
||||
SDL3.ctx = Module['createContext'](canvas, false, true);
|
||||
SDL3.ctx = Browser.createContext(canvas, false, true);
|
||||
SDL3.ctxCanvas = canvas;
|
||||
}
|
||||
if (SDL3.w !== w || SDL3.h !== h || SDL3.imageCtx !== SDL3.ctx) {
|
||||
|
||||
@@ -101,7 +101,7 @@ SDL_GLContext Emscripten_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *
|
||||
|
||||
context = emscripten_webgl_create_context(window_data->canvas_id, &attribs);
|
||||
|
||||
if (context < 0) {
|
||||
if (!context) {
|
||||
SDL_SetError("Could not create webgl context");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ static SDL_SystemTheme Emscripten_GetSystemTheme(void)
|
||||
/* Technically, light theme can mean explicit light theme or no preference.
|
||||
https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme#syntax */
|
||||
|
||||
int theme_code = EM_ASM_INT({
|
||||
int theme_code = MAIN_THREAD_EM_ASM_INT({
|
||||
if (!window.matchMedia) {
|
||||
return -1;
|
||||
}
|
||||
@@ -195,7 +195,8 @@ static SDL_VideoDevice *Emscripten_CreateDevice(void)
|
||||
VideoBootStrap Emscripten_bootstrap = {
|
||||
EMSCRIPTENVID_DRIVER_NAME, "SDL emscripten video driver",
|
||||
Emscripten_CreateDevice,
|
||||
NULL // no ShowMessageBox implementation
|
||||
NULL, // no ShowMessageBox implementation
|
||||
false
|
||||
};
|
||||
|
||||
bool Emscripten_VideoInit(SDL_VideoDevice *_this)
|
||||
|
||||
Reference in New Issue
Block a user