static EM_BOOL joy_callback_func(int p_type, const EmscriptenGamepadEvent *p_event, void *p_user) { OS_JavaScript *os = (OS_JavaScript*) OS::get_singleton(); if (os) { return os->joy_connection_changed(p_type, p_event); } return false; }
static EM_BOOL _browser_resize_callback(int event_type, const EmscriptenUiEvent *ui_event, void *user_data) { ERR_FAIL_COND_V(event_type != EMSCRIPTEN_EVENT_RESIZE, false); OS_JavaScript *os = static_cast<OS_JavaScript *>(user_data); // The order of the fullscreen change event and the window size change // event varies, even within just one browser, so defer handling os->request_canvas_size_adjustment(); return false; }
static EM_BOOL _fullscreen_change_callback(int event_type, const EmscriptenFullscreenChangeEvent *event, void *user_data) { ERR_FAIL_COND_V(event_type != EMSCRIPTEN_EVENT_FULLSCREENCHANGE, false); OS_JavaScript *os = static_cast<OS_JavaScript *>(user_data); String id = String::utf8(event->id); // empty id is canvas if (id.empty() || id == "canvas") { OS::VideoMode vm = os->get_video_mode(); // this event property is the only reliable information on // browser fullscreen state vm.fullscreen = event->isFullscreen; os->set_video_mode(vm); os->request_canvas_size_adjustment(); } return false; }
static EM_BOOL _browser_resize_callback(int event_type, const EmscriptenUiEvent *ui_event, void *user_data) { ERR_FAIL_COND_V(event_type!=EMSCRIPTEN_EVENT_RESIZE, false); OS_JavaScript* os = static_cast<OS_JavaScript*>(user_data); // the order in which _browser_resize_callback and // _fullscreen_change_callback are called is browser-dependent, // so try adjusting for fullscreen in both if (os->is_window_fullscreen() || os->is_window_maximized()) { OS::VideoMode vm = os->get_video_mode(); vm.width = ui_event->windowInnerWidth; vm.height = ui_event->windowInnerHeight; os->set_video_mode(vm); emscripten_set_canvas_size(ui_event->windowInnerWidth, ui_event->windowInnerHeight); } return false; }
static EM_BOOL _fullscreen_change_callback(int event_type, const EmscriptenFullscreenChangeEvent *event, void *user_data) { ERR_FAIL_COND_V(event_type!=EMSCRIPTEN_EVENT_FULLSCREENCHANGE, false); OS_JavaScript* os = static_cast<OS_JavaScript*>(user_data); String id = String::utf8(event->id); // empty id is canvas if (id.empty() || id=="canvas") { OS::VideoMode vm = os->get_video_mode(); // this event property is the only reliable information on // browser fullscreen state vm.fullscreen = event->isFullscreen; if (event->isFullscreen) { vm.width = event->screenWidth; vm.height = event->screenHeight; os->set_video_mode(vm); emscripten_set_canvas_size(vm.width, vm.height); } else { os->set_video_mode(vm); if (!os->is_window_maximized()) { os->set_window_size(_windowed_size); } } } return false; }