Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- page = 1
- function OnEvent(event, arg, family)
- OutputLogMessage("event = %s, arg = %s, family = %s\n", event, arg, family);
- modeNumber = GetMKeyState()
- if (event == "M_RELEASED" and arg == 2 and family == "lhc") then
- ClearLCD()
- OutputLCDMessage("Pagination mode M2 activated.")
- OutputLCDMessage("Currently at page " .. page)
- end
- if (event == "G_RELEASED" and GetMKeyState("lhc") == 2 and family == "lhc") then
- if (arg == 24) then
- page = page + 1
- ClearLCD()
- OutputLCDMessage("Switched to page " .. page)
- elseif (arg == 23) then
- if (page > 1) then
- page = page - 1
- ClearLCD()
- OutputLCDMessage("Switched to page " .. page)
- else
- ClearLCD()
- OutputLCDMessage("At page 1")
- OutputLCDMessage("Cannot backtrack further")
- end
- else
- SetBacklightColor(127, 255, 0, "lhc")
- Sleep(250)
- OutputLogMessage("Sending: %s/%s\n", page, arg)
- -- Typed sequence 3/15/+-- (page/key/sca)
- on, off = "numplus", "numminus"
- if IsModifierPressed("shift") then isShiftDown = on else isShiftDown = off end
- if IsModifierPressed("ctrl") then isControlDown = on else isControlDown = off end
- if IsModifierPressed("alt") then isAltDown = on else isAltDown = off end
- local send = {pageString = page .. "n", argString = arg .. "n"} -- coerce to string
- local modlist = {isShiftDown, isControlDown, isAltDown}
- -- send the keys
- for k, v in pairs(send) do
- for i = 1, #v - 1 do
- local c = v:sub(i,i)
- PressAndReleaseKey("num" .. c)
- end
- PressAndReleaseKey("numslash")
- end
- --[[
- for k, v in pairs(modlist) do
- PressAndReleaseKey(v)
- end]]
- PressAndReleaseKey("numminus", "numminus", "numminus", "Enter")
- SetBacklightColor(255, 255, 255, "lhc")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment