From 2c2153de9d3f33877b855a4a3a5a9d90b9e3f3fa Mon Sep 17 00:00:00 2001 From: fgenesis Date: Sun, 22 Sep 2024 02:36:18 +0200 Subject: [PATCH] Add MOUSE_BUTTON_REAL_* mapping IDs because sometimes we need to handle unmapped mouse buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One such case is the editor; if Ctrl was mapped to RMB then rotating tiles in 45° increment mode is impossible (since the editor checks for Ctrl to enable increment mode, and it did the wrong thing when releasing "both" at the same time) --- Aquaria/SceneEditor.cpp | 8 ++++---- BBGE/ActionStatus.cpp | 9 +++++++++ BBGE/ActionStatus.h | 7 ++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Aquaria/SceneEditor.cpp b/Aquaria/SceneEditor.cpp index ed7c8fc..c7c9176 100644 --- a/Aquaria/SceneEditor.cpp +++ b/Aquaria/SceneEditor.cpp @@ -691,10 +691,10 @@ void SceneEditor::init() addAction(MakeFunctionEvent(SceneEditor, editModeEntities), KEY_F6, 0); addAction(MakeFunctionEvent(SceneEditor, editModePaths), KEY_F7, 0); - addAction(MakeFunctionEvent(SceneEditor, mouseButtonLeft), MOUSE_BUTTON_LEFT, 1); - addAction(MakeFunctionEvent(SceneEditor, mouseButtonRight), MOUSE_BUTTON_RIGHT, 1); - addAction(MakeFunctionEvent(SceneEditor, mouseButtonLeftUp), MOUSE_BUTTON_LEFT, 0); - addAction(MakeFunctionEvent(SceneEditor, mouseButtonRightUp), MOUSE_BUTTON_RIGHT, 0); + addAction(MakeFunctionEvent(SceneEditor, mouseButtonLeft), MOUSE_BUTTON_REAL_LEFT, 1); + addAction(MakeFunctionEvent(SceneEditor, mouseButtonRight), MOUSE_BUTTON_REAL_RIGHT, 1); + addAction(MakeFunctionEvent(SceneEditor, mouseButtonLeftUp), MOUSE_BUTTON_REAL_LEFT, 0); + addAction(MakeFunctionEvent(SceneEditor, mouseButtonRightUp), MOUSE_BUTTON_REAL_RIGHT, 0); addAction(MakeFunctionEvent(SceneEditor, placeElement), KEY_SPACE, 1); diff --git a/BBGE/ActionStatus.cpp b/BBGE/ActionStatus.cpp index 1016c6c..b1f75c8 100644 --- a/BBGE/ActionStatus.cpp +++ b/BBGE/ActionStatus.cpp @@ -94,6 +94,15 @@ bool ActionButtonStatus::_queryStatus(int k) const if (k >= MOUSE_BUTTON_EXTRA_START && k < MOUSE_BUTTON_EXTRA_END) return core->mouse.buttons.extra[k - MOUSE_BUTTON_EXTRA_START]; + if (k == MOUSE_BUTTON_REAL_LEFT) + return core->mouse.pure_buttons.left == DOWN; + + if (k == MOUSE_BUTTON_REAL_RIGHT) + return core->mouse.pure_buttons.right == DOWN; + + if (k == MOUSE_BUTTON_REAL_MIDDLE) + return core->mouse.pure_buttons.middle == DOWN; + // --- joystick from here --- Joystick *j = core->getJoystick(joystickID); diff --git a/BBGE/ActionStatus.h b/BBGE/ActionStatus.h index 76dbb3d..49fb26f 100644 --- a/BBGE/ActionStatus.h +++ b/BBGE/ActionStatus.h @@ -11,7 +11,12 @@ const unsigned mouseExtraButtons = 8; // *_END is non-inclusive! enum ActionButtonType { - MOUSE_BUTTON_LEFT = KEY_MAXARRAY + 1, + // Only concerns real mouse buttons, not whatever is mapped to "left mouse" + MOUSE_BUTTON_REAL_LEFT = KEY_MAXARRAY + 1, + MOUSE_BUTTON_REAL_RIGHT, + MOUSE_BUTTON_REAL_MIDDLE, + + MOUSE_BUTTON_LEFT, MOUSE_BUTTON_RIGHT, MOUSE_BUTTON_MIDDLE, MOUSE_BUTTON_EXTRA_START,