summaryrefslogtreecommitdiffstats
path: root/platform/javascript/os_javascript.cpp
diff options
context:
space:
mode:
authorMax Hilbrunner <mhilbrunner@users.noreply.github.com>2018-07-10 13:26:43 +0200
committerGitHub <noreply@github.com>2018-07-10 13:26:43 +0200
commit48471ee0995061ea8c8b5957db905fcf31cd8682 (patch)
treef2ddf3bbed07bd7eee08b1809d1e0b9d3edb3b52 /platform/javascript/os_javascript.cpp
parent3eb25ac3fbea09817ef28354f58ba55d2ecd1a6d (diff)
parent9cc41a59ac579b3676a832ebc4f1c865413897ce (diff)
downloadredot-engine-48471ee0995061ea8c8b5957db905fcf31cd8682.tar.gz
Merge pull request #20049 from moiman100/extra-mouse-buttons
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;
}