Implement HTML5 cancel/ok button swap on Windows.

Platform is detected on init via the `navigator.platform` string.

(cherry picked from commit 0b286a287c)
This commit is contained in:
Fabio Alessandrelli 2020-07-27 13:53:03 +02:00 committed by Rémi Verschelde
parent 451648c34d
commit 31c21b9750
2 changed files with 18 additions and 0 deletions

View file

@ -916,6 +916,17 @@ void OS_JavaScript::initialize_core() {
Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
/* clang-format off */
swap_ok_cancel = EM_ASM_INT({
const win = (['Windows', 'Win64', 'Win32', 'WinCE']);
const plat = navigator.platform || "";
if (win.indexOf(plat) !== -1) {
return 1;
}
return 0;
}) == 1;
/* clang-format on */
EmscriptenWebGLContextAttributes attributes;
emscripten_webgl_init_context_attributes(&attributes);
attributes.alpha = GLOBAL_GET("display/window/per_pixel_transparency/allowed");
@ -1084,6 +1095,10 @@ Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver,
return OK;
}
bool OS_JavaScript::get_swap_ok_cancel() {
return swap_ok_cancel;
}
void OS_JavaScript::swap_buffers() {
emscripten_webgl_commit_frame();
}
@ -1428,6 +1443,7 @@ OS_JavaScript::OS_JavaScript(int p_argc, char *p_argv[]) {
visual_server = NULL;
audio_driver_javascript = NULL;
swap_ok_cancel = false;
idb_available = false;
sync_wait_time = -1;