summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorLeon Krause <lk@leonkrause.com>2017-09-19 19:15:51 +0200
committerLeon Krause <lk@leonkrause.com>2017-09-19 19:27:52 +0200
commitd1ecc25db4673019d8eff8b90bd94bd60ab2906e (patch)
tree0f0bf9c264c98ba33467aafda7cc4e5ce72eadbb /platform
parentd58b0a5c9a3ca7964ea560b72fc321b4159df89d (diff)
Fix mouse button state in HTML5 platform
Regression from 844c5e12e664e3212feacc9ee3200e116556fbc7
Diffstat (limited to 'platform')
-rw-r--r--platform/javascript/os_javascript.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index 67d2a6e369..f103035b27 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -172,14 +172,14 @@ static EM_BOOL _mousebutton_callback(int event_type, const EmscriptenMouseEvent
if (!is_canvas_focused()) {
focus_canvas();
}
- mask |= 1 << ev->get_button_index();
- } else if (mask & (1 << ev->get_button_index())) {
- mask &= ~(1 << ev->get_button_index());
+ mask |= ev->get_button_index();
+ } else if (mask & ev->get_button_index()) {
+ mask &= ~ev->get_button_index();
} else {
// release event, but press was outside the canvas, so ignore
return false;
}
- ev->set_button_mask(mask >> 1);
+ ev->set_button_mask(mask);
_input->parse_input_event(ev);
// prevent selection dragging
@@ -200,7 +200,7 @@ static EM_BOOL _mousemove_callback(int event_type, const EmscriptenMouseEvent *m
Ref<InputEventMouseMotion> ev;
ev.instance();
dom2godot_mod(mouse_event, ev);
- ev->set_button_mask(input_mask >> 1);
+ ev->set_button_mask(input_mask);
ev->set_position(pos);
ev->set_global_position(ev->get_position());
@@ -227,7 +227,7 @@ static EM_BOOL _wheel_callback(int event_type, const EmscriptenWheelEvent *wheel
Ref<InputEventMouseButton> ev;
ev.instance();
- ev->set_button_mask(_input->get_mouse_button_mask() >> 1);
+ ev->set_button_mask(_input->get_mouse_button_mask());
ev->set_position(_input->get_mouse_position());
ev->set_global_position(ev->get_position());
@@ -291,7 +291,7 @@ static EM_BOOL _touchpress_callback(int event_type, const EmscriptenTouchEvent *
Ref<InputEventMouseButton> ev_mouse;
ev_mouse.instance();
- ev_mouse->set_button_mask(_input->get_mouse_button_mask() >> 1);
+ ev_mouse->set_button_mask(_input->get_mouse_button_mask());
dom2godot_mod(touch_event, ev_mouse);
const EmscriptenTouchPoint &first_touch = touch_event->touches[lowest_id_index];
@@ -334,7 +334,7 @@ static EM_BOOL _touchmove_callback(int event_type, const EmscriptenTouchEvent *t
Ref<InputEventMouseMotion> ev_mouse;
ev_mouse.instance();
dom2godot_mod(touch_event, ev_mouse);
- ev_mouse->set_button_mask(_input->get_mouse_button_mask() >> 1);
+ ev_mouse->set_button_mask(_input->get_mouse_button_mask());
const EmscriptenTouchPoint &first_touch = touch_event->touches[lowest_id_index];
ev_mouse->set_position(Point2(first_touch.canvasX, first_touch.canvasY));