Skip to content

Commit e7e2571

Browse files
author
Avaer Kazmer
authored
Merge pull request #1013 from exokitxr/mouse-button
Bugfix GLFW middle/right mouse buttons tracking
2 parents cf1da2c + 29bc666 commit e7e2571

File tree

1 file changed

+8
-2
lines changed
  • deps/exokit-bindings/glfw/src

1 file changed

+8
-2
lines changed

deps/exokit-bindings/glfw/src/glfw.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,11 +620,17 @@ void APIENTRY cursorEnterCB(NATIVEwindow* window, int entered) {
620620
void APIENTRY mouseButtonCB(NATIVEwindow *window, int button, int action, int mods) {
621621
Nan::HandleScope scope;
622622

623+
if (button == 2) {
624+
button = 1;
625+
} else if (button == 1) {
626+
button = 2;
627+
}
628+
623629
{
624630
Local<Object> evt = Nan::New<Object>();
625631
evt->Set(JS_STR("type"),JS_STR(action ? "mousedown" : "mouseup"));
626632
evt->Set(JS_STR("button"),JS_INT(button));
627-
evt->Set(JS_STR("which"),JS_INT(button));
633+
evt->Set(JS_STR("which"),JS_INT(button + 1));
628634
evt->Set(JS_STR("clientX"),JS_INT(lastX));
629635
evt->Set(JS_STR("clientY"),JS_INT(lastY));
630636
evt->Set(JS_STR("pageX"),JS_INT(lastX));
@@ -648,7 +654,7 @@ void APIENTRY mouseButtonCB(NATIVEwindow *window, int button, int action, int mo
648654
Local<Object> evt = Nan::New<Object>();
649655
evt->Set(JS_STR("type"),JS_STR("click"));
650656
evt->Set(JS_STR("button"),JS_INT(button));
651-
evt->Set(JS_STR("which"),JS_INT(button));
657+
evt->Set(JS_STR("which"),JS_INT(button + 1));
652658
evt->Set(JS_STR("clientX"),JS_INT(lastX));
653659
evt->Set(JS_STR("clientY"),JS_INT(lastY));
654660
evt->Set(JS_STR("pageX"),JS_INT(lastX));

0 commit comments

Comments
 (0)