summaryrefslogtreecommitdiff
path: root/platform/javascript/os_javascript.cpp
diff options
context:
space:
mode:
authorunknown <40793342+moiman100@users.noreply.github.com>2018-07-05 17:50:30 +0300
committerunknown <40793342+moiman100@users.noreply.github.com>2018-07-09 14:34:19 +0300
commit9cc41a59ac579b3676a832ebc4f1c865413897ce (patch)
treea25e16f72482be89fe7709a8ab066055253e5dba /platform/javascript/os_javascript.cpp
parent4d9fde944e331e5502083db5ca6f86a304e6630b (diff)
Added support for extra mouse buttons.
Diffstat (limited to 'platform/javascript/os_javascript.cpp')
-rw-r--r--platform/javascript/os_javascript.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index 6c6e4d2d1c..d99bc69f00 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -46,6 +46,8 @@
#define DOM_BUTTON_LEFT 0
#define DOM_BUTTON_MIDDLE 1
#define DOM_BUTTON_RIGHT 2
+#define DOM_BUTTON_XBUTTON1 3
+#define DOM_BUTTON_XBUTTON2 4
template <typename T>
static void dom2godot_mod(T emscripten_event_ptr, Ref<InputEventWithModifiers> godot_event) {
@@ -156,11 +158,12 @@ static EM_BOOL _mousebutton_callback(int event_type, const EmscriptenMouseEvent
ev->set_position(Point2(mouse_event->canvasX, mouse_event->canvasY));
ev->set_global_position(ev->get_position());
dom2godot_mod(mouse_event, ev);
-
switch (mouse_event->button) {
case DOM_BUTTON_LEFT: ev->set_button_index(BUTTON_LEFT); break;
case DOM_BUTTON_MIDDLE: ev->set_button_index(BUTTON_MIDDLE); break;
case DOM_BUTTON_RIGHT: ev->set_button_index(BUTTON_RIGHT); break;
+ case DOM_BUTTON_XBUTTON1: ev->set_button_index(BUTTON_XBUTTON1); break;
+ case DOM_BUTTON_XBUTTON2: ev->set_button_index(BUTTON_XBUTTON2); break;
default: return false;
}