summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-01-17 14:10:50 +0100
committerRémi Verschelde <rverschelde@gmail.com>2020-01-17 14:10:52 +0100
commit435f86cf879965305e15da4f3e9b971b15464b68 (patch)
tree64e629c9aeae78da6187245ced3de797196cf3bd
parent0aefec24548edbb96e4991ede4465473e0c225e1 (diff)
HTML5: Address removal of 'timestamp' in Emscripten 1.39.5
It was removed as noted in the changelog: https://github.com/emscripten-core/emscripten/blob/1.39.5/ChangeLog.md#v1395-12202019 > Removed `timestamp` field from mouse, wheel, devicemotion and > deviceorientation events. The presence of a `timestamp` on these > events was slightly arbitrary, and populating this field caused > a small profileable overhead that all users might not care about. > It is easy to get a timestamp of an event by calling > `emscripten_get_now()` or `emscripten_performance_now()` inside > the event handler function of any event. Fixes #34648.
-rw-r--r--platform/javascript/os_javascript.cpp3
-rw-r--r--platform/javascript/os_javascript.h2
2 files changed, 3 insertions, 2 deletions
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index 5562b059f4..592def8011 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -301,6 +301,7 @@ EM_BOOL OS_JavaScript::mouse_button_callback(int p_event_type, const EmscriptenM
ev->set_position(correct_canvas_position(p_event->canvasX, p_event->canvasY));
ev->set_global_position(ev->get_position());
dom2godot_mod(p_event, ev);
+
switch (p_event->button) {
case DOM_BUTTON_LEFT: ev->set_button_index(BUTTON_LEFT); break;
case DOM_BUTTON_MIDDLE: ev->set_button_index(BUTTON_MIDDLE); break;
@@ -312,7 +313,7 @@ EM_BOOL OS_JavaScript::mouse_button_callback(int p_event_type, const EmscriptenM
if (ev->is_pressed()) {
- uint64_t diff = p_event->timestamp - os->last_click_ms;
+ double diff = emscripten_get_now() - os->last_click_ms;
if (ev->get_button_index() == os->last_click_button_index) {
diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h
index a5696f8aae..2d1c765e76 100644
--- a/platform/javascript/os_javascript.h
+++ b/platform/javascript/os_javascript.h
@@ -55,7 +55,7 @@ class OS_JavaScript : public OS_Unix {
Point2 touches[32];
Point2i last_click_pos;
- uint64_t last_click_ms;
+ double last_click_ms;
int last_click_button_index;
MainLoop *main_loop;