From 9a2d996b53d9220100a7207bee7fef669c7ccd9b Mon Sep 17 00:00:00 2001 From: z64555 Date: Thu, 29 Oct 2020 10:58:34 -0500 Subject: [PATCH] Fixes #2844 where mouse buttons X1 and X2 were not detected. --- code/io/mouse.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/code/io/mouse.cpp b/code/io/mouse.cpp index ec226d230d..dfae4541a1 100644 --- a/code/io/mouse.cpp +++ b/code/io/mouse.cpp @@ -81,12 +81,26 @@ namespace return false; } - if (e.button.button == SDL_BUTTON_LEFT) - mouse_mark_button(MOUSE_LEFT_BUTTON, e.button.state); - else if (e.button.button == SDL_BUTTON_MIDDLE) - mouse_mark_button(MOUSE_MIDDLE_BUTTON, e.button.state); - else if (e.button.button == SDL_BUTTON_RIGHT) - mouse_mark_button(MOUSE_RIGHT_BUTTON, e.button.state); + switch (e.button.button) { + case SDL_BUTTON_LEFT: + mouse_mark_button(MOUSE_LEFT_BUTTON, e.button.state); + break; + case SDL_BUTTON_RIGHT: + mouse_mark_button(MOUSE_RIGHT_BUTTON, e.button.state); + break; + case SDL_BUTTON_MIDDLE: + mouse_mark_button(MOUSE_MIDDLE_BUTTON, e.button.state); + break; + case SDL_BUTTON_X1: + mouse_mark_button(MOUSE_X1_BUTTON, e.button.state); + break; + case SDL_BUTTON_X2: + mouse_mark_button(MOUSE_X2_BUTTON, e.button.state); + break; + default: + // SDL gave us an unknown button. Just log it + mprintf(("Unknown SDL button %i", e.button.button)); + } return true; }