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:
parent
451648c34d
commit
31c21b9750
|
@ -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) {
|
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;
|
EmscriptenWebGLContextAttributes attributes;
|
||||||
emscripten_webgl_init_context_attributes(&attributes);
|
emscripten_webgl_init_context_attributes(&attributes);
|
||||||
attributes.alpha = GLOBAL_GET("display/window/per_pixel_transparency/allowed");
|
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;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OS_JavaScript::get_swap_ok_cancel() {
|
||||||
|
return swap_ok_cancel;
|
||||||
|
}
|
||||||
|
|
||||||
void OS_JavaScript::swap_buffers() {
|
void OS_JavaScript::swap_buffers() {
|
||||||
emscripten_webgl_commit_frame();
|
emscripten_webgl_commit_frame();
|
||||||
}
|
}
|
||||||
|
@ -1428,6 +1443,7 @@ OS_JavaScript::OS_JavaScript(int p_argc, char *p_argv[]) {
|
||||||
visual_server = NULL;
|
visual_server = NULL;
|
||||||
audio_driver_javascript = NULL;
|
audio_driver_javascript = NULL;
|
||||||
|
|
||||||
|
swap_ok_cancel = false;
|
||||||
idb_available = false;
|
idb_available = false;
|
||||||
sync_wait_time = -1;
|
sync_wait_time = -1;
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ class OS_JavaScript : public OS_Unix {
|
||||||
AudioDriverJavaScript *audio_driver_javascript;
|
AudioDriverJavaScript *audio_driver_javascript;
|
||||||
VisualServer *visual_server;
|
VisualServer *visual_server;
|
||||||
|
|
||||||
|
bool swap_ok_cancel;
|
||||||
bool idb_available;
|
bool idb_available;
|
||||||
int64_t sync_wait_time;
|
int64_t sync_wait_time;
|
||||||
int64_t last_sync_check_time;
|
int64_t last_sync_check_time;
|
||||||
|
@ -115,6 +116,7 @@ public:
|
||||||
// Override return type to make writing static callbacks less tedious.
|
// Override return type to make writing static callbacks less tedious.
|
||||||
static OS_JavaScript *get_singleton();
|
static OS_JavaScript *get_singleton();
|
||||||
|
|
||||||
|
virtual bool get_swap_ok_cancel();
|
||||||
virtual void swap_buffers();
|
virtual void swap_buffers();
|
||||||
virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0);
|
virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0);
|
||||||
virtual VideoMode get_video_mode(int p_screen = 0) const;
|
virtual VideoMode get_video_mode(int p_screen = 0) const;
|
||||||
|
|
Loading…
Reference in New Issue