From b0bcb4a47d0e5c3eb4a71dbef2a3ad7420ce8539 Mon Sep 17 00:00:00 2001 From: Bruno Garcia Date: Tue, 16 Nov 2021 09:24:23 -0300 Subject: [PATCH] Swap mouse right and middle buttons on X11 (Fix #65) --- src/x11/X11MiniFB.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/x11/X11MiniFB.c b/src/x11/X11MiniFB.c index 3f910e5..bdff6d7 100644 --- a/src/x11/X11MiniFB.c +++ b/src/x11/X11MiniFB.c @@ -240,6 +240,18 @@ processEvent(SWindowData *window_data, XEvent *event) { mfb_mouse_button button = (mfb_mouse_button) event->xbutton.button; int is_pressed = (event->type == ButtonPress); window_data->mod_keys = translate_mod(event->xkey.state); + + // Swap mouse right and middle for parity with other platforms: + // https://github.com/emoon/minifb/issues/65 + switch (button) { + case Button2: + button = Button3; + break; + case Button3: + button = Button2; + break; + } + switch (button) { case Button1: case Button2: