summaryrefslogtreecommitdiffstats
path: root/platform/javascript/os_javascript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/javascript/os_javascript.cpp')
-rw-r--r--platform/javascript/os_javascript.cpp51
1 files changed, 50 insertions, 1 deletions
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index 7c7aeac980..1a40f6a979 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -295,6 +295,30 @@ EM_BOOL OS_JavaScript::mouse_button_callback(int p_event_type, const EmscriptenM
default: return false;
}
+ if (ev->is_pressed()) {
+
+ uint64_t diff = p_event->timestamp - os->last_click_ms;
+
+ if (ev->get_button_index() == os->last_click_button_index) {
+
+ if (diff < 400 && Point2(os->last_click_pos).distance_to(ev->get_position()) < 5) {
+
+ os->last_click_ms = 0;
+ os->last_click_pos = Point2(-100, -100);
+ os->last_click_button_index = -1;
+ ev->set_doubleclick(true);
+ }
+
+ } else {
+ os->last_click_button_index = ev->get_button_index();
+ }
+
+ if (!ev->is_doubleclick()) {
+ os->last_click_ms += diff;
+ os->last_click_pos = ev->get_position();
+ }
+ }
+
int mask = os->input->get_mouse_button_mask();
int button_flag = 1 << (ev->get_button_index() - 1);
if (ev->is_pressed()) {
@@ -452,7 +476,6 @@ EM_BOOL OS_JavaScript::wheel_callback(int p_event_type, const EmscriptenWheelEve
InputDefault *input = get_singleton()->input;
Ref<InputEventMouseButton> ev;
ev.instance();
- ev->set_button_mask(input->get_mouse_button_mask());
ev->set_position(input->get_mouse_position());
ev->set_global_position(ev->get_position());
@@ -475,10 +498,14 @@ EM_BOOL OS_JavaScript::wheel_callback(int p_event_type, const EmscriptenWheelEve
// Different browsers give wildly different delta values, and we can't
// interpret deltaMode, so use default value for wheel events' factor.
+ int button_flag = 1 << (ev->get_button_index() - 1);
+
ev->set_pressed(true);
+ ev->set_button_mask(input->get_mouse_button_mask() | button_flag);
input->parse_input_event(ev);
ev->set_pressed(false);
+ ev->set_button_mask(input->get_mouse_button_mask() & ~button_flag);
input->parse_input_event(ev);
return true;
@@ -862,6 +889,24 @@ void OS_JavaScript::finalize() {
// Miscellaneous
+Error OS_JavaScript::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool read_stderr) {
+
+ ERR_EXPLAIN("OS::execute() is not available on the HTML5 platform");
+ ERR_FAIL_V(ERR_UNAVAILABLE);
+}
+
+Error OS_JavaScript::kill(const ProcessID &p_pid) {
+
+ ERR_EXPLAIN("OS::kill() is not available on the HTML5 platform");
+ ERR_FAIL_V(ERR_UNAVAILABLE);
+}
+
+int OS_JavaScript::get_process_id() const {
+
+ ERR_EXPLAIN("OS::get_process_id() is not available on the HTML5 platform");
+ ERR_FAIL_V(0);
+}
+
extern "C" EMSCRIPTEN_KEEPALIVE void send_notification(int p_notification) {
if (p_notification == MainLoop::NOTIFICATION_WM_MOUSE_ENTER || p_notification == MainLoop::NOTIFICATION_WM_MOUSE_EXIT) {
@@ -1049,6 +1094,10 @@ OS_JavaScript::OS_JavaScript(int p_argc, char *p_argv[]) {
}
set_cmdline(p_argv[0], arguments);
+ last_click_button_index = -1;
+ last_click_ms = 0;
+ last_click_pos = Point2(-100, -100);
+
window_maximized = false;
entering_fullscreen = false;
just_exited_fullscreen = false;