Skip to content

Instantly share code, notes, and snippets.

@ekilah
Last active July 18, 2023 16:11
Show Gist options
  • Save ekilah/ce7ce9f5115536a8abe1ff7c0844138b to your computer and use it in GitHub Desktop.
Save ekilah/ce7ce9f5115536a8abe1ff7c0844138b to your computer and use it in GitHub Desktop.
Logitech Gaming Software Lua script to use a mouse (ie: G502) to toggle leaning in games that don't let you set leaning to a toggle, instead of a hold, in-game
-- this script will toggle Q and E with the g502's left (11) and right (10) scroll wheel buttons.
-- that includes disabling one when the other is pressed, and vice versa.
isLeftPressed = false
isRightPressed = false
function OnEvent(event, arg)
--OutputLogMessage("event = %s, arg = %s\n", event, arg);
-- left pressed
if event == "MOUSE_BUTTON_PRESSED" and arg == 11 then
isLeftPressed = not isLeftPressed
if isLeftPressed then
--OutputLogMessage("pressing Q\n");
PressKey("q");
if isRightPressed then
isRightPressed = false
--OutputLogMessage("also releasing E\n");
ReleaseKey("e");
end
else
--OutputLogMessage("releasing Q\n");
ReleaseKey("q");
end
end
-- right pressed
if event == "MOUSE_BUTTON_PRESSED" and arg == 10 then
isRightPressed = not isRightPressed
if isRightPressed then
--OutputLogMessage("pressing E\n");
PressKey("e");
if isLeftPressed then
isLeftPressed = false
--OutputLogMessage("also releasing Q\n");
ReleaseKey("q");
end
else
--OutputLogMessage("releasing E\n");
ReleaseKey("e");
end
end
end
@ekilah
Copy link
Author

ekilah commented Mar 30, 2017

sorry about the tabbing, github isn't letting me fix it easily

@sirace666
Copy link

Something needs to be edited or just plug in Logitech software? thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment