From 215343bf0be7aa04dab501601d84844dc91be52b Mon Sep 17 00:00:00 2001 From: YamikoHikariX Date: Thu, 14 Dec 2023 09:28:11 +0700 Subject: [PATCH 1/2] Added an ability to disable side mouse buttons behavior --- gui_ping_wheel.lua | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/gui_ping_wheel.lua b/gui_ping_wheel.lua index 08af195..db13970 100644 --- a/gui_ping_wheel.lua +++ b/gui_ping_wheel.lua @@ -28,6 +28,8 @@ end -- NEW: LOTS OF PRETTY COLORS! ----------------------------------------------------------------------------------------------- local custom_keybind_mode = false -- set to true for custom keybind +local side_mouse_buttons_on = true -- Set to false to disable side mouse button functionality + local pingCommands = { -- the options in the ping wheel, displayed clockwise from 12 o'clock { name = "Attack", color = { 1, 0.5, 0.3, 1 } }, -- color is optional, if no color is chosen it will be white @@ -194,13 +196,19 @@ function widget:Initialize() textAlignRadiusRatio = style.textAlignRadiusRatio dividerColor = style.dividerColor - -- we disable the mouse build spacing widget here, sigh - widgetHandler:DisableWidget("Mouse Buildspacing") + if side_mouse_buttons_on then + -- we disable the mouse build spacing widget here, sigh + widgetHandler:DisableWidget("Mouse Buildspacing") + end end -- when widget exits, re-enable the mouse build spacing widget function widget:Shutdown() --:EnableWidget("Mouse Buildspacing") + if side_mouse_buttons_on then + -- Re-enable the mouse build spacing widget + widgetHandler:EnableWidget("Mouse Buildspacing") + end end -- Store the ping location in pingWorldLocation @@ -285,9 +293,8 @@ function widget:KeyRelease(key, mods) end function widget:MousePress(mx, my, button) - if keyDown or button == 4 or button == 5 then - -- functionality of mouse build spacing is put in here, sigh - -- check if alt is pressed + if side_mouse_buttons_on and (keyDown or button == 4 or button == 5) then + -- Functionality for side mouse buttons is enabled local alt, ctrl, meta, shift = spGetModKeyState() if (button == 4 or button == 5) and alt then if button == 4 then @@ -305,13 +312,22 @@ function widget:MousePress(mx, my, button) end TurnOn("mouse press") return true -- block all other mouse presses + elseif not side_mouse_buttons_on and keyDown then + -- Side mouse buttons are disabled, but keyDown functionality remains + if button == 1 then + pingWheel = pingCommands + elseif button == 3 then + pingWheel = pingMessages + end + TurnOn("mouse press") + return true -- block all other mouse presses else - -- set pingwheel to not display - --TurnOff("mouse press") + -- Handle cases where neither keyDown nor side mouse buttons are involved FadeOut() end end + -- when mouse is pressed, issue the ping command function widget:MouseRelease(mx, my, button) if displayPingWheel From a97284ba50bbbff697f8530993245a407e005ab8 Mon Sep 17 00:00:00 2001 From: YamikoHikariX Date: Sat, 16 Dec 2023 09:50:00 +0700 Subject: [PATCH 2/2] Added skipping of toggle commands --- gui_smart_commands.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gui_smart_commands.lua b/gui_smart_commands.lua index e5e9f09..1ebd9d6 100644 --- a/gui_smart_commands.lua +++ b/gui_smart_commands.lua @@ -23,6 +23,12 @@ local selectedUnits = {} local active = false local mouseClicked = false local curMods = {} -- {alt, ctrl, meta, shift} +local toggleBindings = { + "repeat", + "firestate", + "movestate", + "onoff", +} -- shortcuts local echo = Spring.Echo @@ -204,6 +210,10 @@ local function setActiveCmdFromKey(key) local cmdName = keyToBinding[keyString] --echo("keyString: "..keyString..", cmdName: "..tableToString(cmdName)) if cmdName then + -- if cmdName is a toggle, skip it + for _, binding in pairs(toggleBindings) do + if cmdName == binding then return false end + end --echo("command set through keybind search: "..tableToString(cmdName)) if type(cmdName) == "table" then -- we have multiple commands possible local cmd