Created
January 12, 2017 09:41
-
-
Save muhqu/4eccab916f919384b1add9ccb0196e89 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local PRESSED = {}; | |
local MAPPING = {}; | |
MAPPING[4] = "F13"; | |
MAPPING[5] = "F14"; | |
MAPPING[6] = "F15"; | |
local DPI_TABLE={800, 1900, 2800} | |
local DPI_TABLE_LEN=table.getn(DPI_TABLE) | |
local DPI_INDEX=1 | |
SetMouseDPITable(DPI_TABLE) | |
SetMouseDPITableIndex(DPI_INDEX); | |
function OnEvent(event, arg) | |
-- OutputLogMessage("event = %s, arg = %s\n", event, arg); | |
if (event == "MOUSE_BUTTON_PRESSED" and not PRESSED[arg]) then | |
PRESSED[arg] = true; | |
local key = MAPPING[arg]; | |
OutputLogMessage("event = %s, arg = %s, key = %s\n", event, arg, key or ""); | |
if key then | |
PressKey(key); | |
end | |
if arg == 7 and DPI_INDEX < DPI_TABLE_LEN then | |
DPI_INDEX = DPI_INDEX +1; | |
OutputLogMessage("DPI_INDEX UP, DPI_INDEX = %s, DPI = %s\n", DPI_INDEX, DPI_TABLE[DPI_INDEX]); | |
SetMouseDPITableIndex(DPI_INDEX); | |
end | |
if arg == 8 and DPI_INDEX > 1 then | |
DPI_INDEX = DPI_INDEX -1; | |
OutputLogMessage("DPI_INDEX UP, DPI_INDEX = %s, DPI = %s\n", DPI_INDEX, DPI_TABLE[DPI_INDEX]); | |
SetMouseDPITableIndex(DPI_INDEX); | |
end | |
end | |
if (event == "MOUSE_BUTTON_RELEASED" and PRESSED[arg]) then | |
PRESSED[arg] = false; | |
local key = MAPPING[arg]; | |
OutputLogMessage("event = %s, arg = %s, key = %s\n", event, arg, key or ""); | |
if key then | |
ReleaseKey(key); | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment