Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- This script is made by GeekGarage aka. xibit1987
- Created for G19, but will work on other G-Series hardware
- Guide on how to use:
- {["key"]=12, ["state"]=false, ["type"]="t", ["keys"]={"rctrl", "lshift", "s"}, ["mouse"]=1, ["lcdText"]={"Text Here", "and you", "can use up to 8 lines on G19", "and 3 lines on others"}}
- "key" is the G-Key number, for now it's not in use and is only there to keep an overview of the array so it's easy to see what key you are editing
- "state" DO NOT TOUCH! Used to check state in toggle type mode
- "type" is Toggle type key [t] or Hold/keep pressed down type of key [h]
- "keys" are what keys to emulate pressed, always add modifiers first like "lshift", "rshift", "lctrl", since it will be pressed in the order they are added (Look at example above). Default if not in use is ["keys"]={nil}
- "mouse" is what mouse button to press (can only handle a single button. Default if not in use ["mouse"]=nil
- "lcdText" is the text you want to display. each section ["Text Here"] is a new line. The display can show up to 9 lines, but the last line is used to show if key is toggled or pressed down
- Remember if you add a line ONLY the last one is without "," at the end. Same if you delete some of the keys, remember to remove "," at the last one
- this is a default line for a key not in use:
- {["key"]=1, ["state"]=false, ["type"]="t", ["keys"]={nil}, ["mouse"]=nil, ["lcdText"]={nil}}
- ]]--
- --if used on a gaming series without display set to false
- enableLCD = true
- lcdMessageTimeout = 5000 --in ms
- --Set up G-Keys Here--
- gKey = {
- {["key"]=1, ["state"]=false, ["type"]="h", ["keys"]={nil}, ["mouse"]=nil, ["lcdText"]={nil}},
- {["key"]=2, ["state"]=false, ["type"]="h", ["keys"]={nil}, ["mouse"]=nil, ["lcdText"]={nil}},
- {["key"]=3, ["state"]=false, ["type"]="h", ["keys"]={nil}, ["mouse"]=nil, ["lcdText"]={nil}},
- {["key"]=4, ["state"]=false, ["type"]="h", ["keys"]={nil}, ["mouse"]=nil, ["lcdText"]={nil}},
- {["key"]=5, ["state"]=false, ["type"]="h", ["keys"]={nil}, ["mouse"]=nil, ["lcdText"]={nil}},
- {["key"]=6, ["state"]=false, ["type"]="h", ["keys"]={nil}, ["mouse"]=nil, ["lcdText"]={nil}},
- {["key"]=7, ["state"]=false, ["type"]="t", ["keys"]={nil}, ["mouse"]=nil, ["lcdText"]={nil}},
- {["key"]=8, ["state"]=false, ["type"]="t", ["keys"]={nil}, ["mouse"]=nil, ["lcdText"]={nil}},
- {["key"]=9, ["state"]=false, ["type"]="t", ["keys"]={nil}, ["mouse"]=nil, ["lcdText"]={nil}},
- {["key"]=10, ["state"]=false, ["type"]="t", ["keys"]={nil}, ["mouse"]=nil, ["lcdText"]={nil}},
- {["key"]=11, ["state"]=false, ["type"]="t", ["keys"]={nil}, ["mouse"]=nil, ["lcdText"]={nil}},
- {["key"]=12, ["state"]=false, ["type"]="t", ["keys"]={nil}, ["mouse"]=nil, ["lcdText"]={nil}}
- }
- --DO NOT EDIT BELOW THIS LINE
- function toggleState(arg)
- if gKey[arg]["keys"][1] == nil and gKey[arg]["mouse"] == nil then
- drawLCD("empty", arg)
- else
- OutputLCDMessage(gKey[arg]["keys"], lcdMessageTimeout)
- if not gKey[arg]["state"] then
- drawLCD("tOn", arg)
- for k,v in pairs(gKey[arg]["keys"]) do
- PressKey(v);
- end
- Sleep(50);
- if gKey[arg]["mouse"] ~= nil then
- PressMouseButton(gKey[arg]["mouse"]);
- end
- gKey[arg]["state"] = true
- else
- drawLCD("tOff", arg)
- for k,v in pairs(gKey[arg]["keys"]) do
- ReleaseKey(v);
- end
- if gKey[arg]["mouse"] ~= nil then
- ReleaseMouseButton(gKey[arg]["mouse"]);
- end
- gKey[arg]["state"] = false
- end
- end
- end
- function holdState(event, arg)
- if event == "G_PRESSED" then
- drawLCD("hOn", arg)
- for k,v in pairs(gKey[arg]["keys"]) do
- PressKey(v);
- end
- Sleep(50);
- if gKey[arg]["mouse"] ~= nil then
- PressMouseButton(gKey[arg]["mouse"]);
- end
- end
- if event == "G_RELEASED" then
- drawLCD("hOff", arg)
- for k,v in pairs(gKey[arg]["keys"]) do
- ReleaseKey(v);
- end
- Sleep(50);
- if gKey[arg]["mouse"] ~= nil then
- ReleaseMouseButton(gKey[arg]["mouse"]);
- end
- end
- end
- function drawLCD(_lineToWrite, arg)
- if enableLCD then
- ClearLCD()
- if _lineToWrite == "nArray" then
- _messageToWrite = "Key Not In Array"
- elseif gKey[arg]["keys"][1] == nil and gKey[arg]["mouse"] == nil then
- _messageToWrite = "Key Not Configured"
- else
- for k,v in pairs(gKey[arg]["lcdText"]) do
- OutputLCDMessage(v, lcdMessageTimeout)
- end
- if _lineToWrite == "tOn" then
- _messageToWrite = "Key Toggled ON"
- elseif _lineToWrite == "tOff" then
- _messageToWrite = "Key Toggled OFF"
- elseif _lineToWrite == "hOn" then
- _messageToWrite = "Key Hold ON"
- elseif _lineToWrite == "hOff" then
- _messageToWrite = "Key Hold OFF"
- end
- end
- OutputLCDMessage(_messageToWrite, lcdMessageTimeout)
- end
- end
- function OnEvent(event, arg)
- if event == "G_PRESSED" then
- if arg >= 1 and arg <= tonumber(#gKey) then
- if gKey[arg]["type"] == "t" then
- toggleState(arg)
- elseif gKey[arg]["type"] == "h" then
- holdState(event, arg)
- end
- else
- drawLCD("nArray", arg)
- end
- elseif event == "G_RELEASED" then
- if arg >= 1 and arg <= tonumber(#gKey) then
- if gKey[arg]["type"] == "h" then
- holdState(event, arg)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement