From feb3520ee907d398eebebc7989bda08aec0ed3c4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 26 Feb 2021 10:37:55 +0100 Subject: [PATCH] - added m_swapbuttons CVAR for the Windows RawInput and DirectInput backends. The problem I discovered is that these backends do not respect the GUI-side system setting for swapping the buttons, so this needs to be done in-application so that swapped buttons can behave the same in the menu and the game. --- src/common/platform/win32/i_mouse.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/common/platform/win32/i_mouse.cpp b/src/common/platform/win32/i_mouse.cpp index a3042236a..7da7e1c4b 100644 --- a/src/common/platform/win32/i_mouse.cpp +++ b/src/common/platform/win32/i_mouse.cpp @@ -380,9 +380,18 @@ void FMouse::WheelMoved(int axis, int wheelmove) // //========================================================================== +CVAR(Bool, m_swapbuttons, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) + void FMouse::PostButtonEvent(int button, bool down) { event_t ev = { 0 }; + + // Neither RawInput nor DirectInput check the GUI setting for swapped mouse buttons so we have to do our own implementation... + if (m_swapbuttons && button < 2) + { + button = 1 - button; + } + int mask = 1 << button; ev.data1 = KEY_MOUSE1 + button;