Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- pastebin get BGVe1Ntb shelly
- local shellrun = function()
- term.clear()
- term.setCursorPos(1,1)
- shell.run("/rom/programs/shell.lua")
- end
- local modem = peripheral.find("modem")
- modem.open(8)
- local keysDown = {}
- local getKeyInput = function()
- local charConversion = {
- one = 1,
- two = 2,
- three = 3,
- four = 4,
- five = 5,
- six = 6,
- seven = 7,
- eight = 8,
- nine = 9,
- zero = 0,
- minus = "-",
- equals = "=",
- plus = "+",
- grave = "`",
- leftBracket = "[",
- rightBracket = "]",
- space = " ",
- at = "@",
- circumflex = "^",
- underscore = "_",
- numPad1 = 1,
- numPad2 = 2,
- numPad3 = 3,
- numPad4 = 4,
- numPad5 = 5,
- numPad6 = 6,
- numPad7 = 7,
- numPad8 = 8,
- numPad9 = 9,
- numPad0 = 0,
- numPadAdd = "+",
- numPadSubtract = "-",
- numPadDivide = "/",
- multiply = "*",
- comma = ",",
- period = ".",
- slash = "/",
- colon = ":",
- semiColon = ";",
- apostrophe = "'"
- }
- local charConversionShift = {
- period = ">",
- comma = "<",
- slash = "?",
- apostrophe = "\"",
- leftBracket = "{",
- rightBracket = "}",
- grave = "~",
- equals = "+",
- one = "!",
- three = "#",
- four = "$",
- five = "%",
- seven = "&",
- eight = "*",
- nine = "(",
- zero = ")",
- }
- while true do
- local evt, side, freq, repfreq, message = os.pullEventRaw()
- if evt == "modem_message" then
- if type(message) == "table" then
- if type(message.key) == "number" and type(message.status) == "boolean" then
- if message.status then
- keysDown[message.key] = true
- if (charConversionShift[keys.getName(message.key)]) and (keysDown[keys.leftShift] or keysDown[keys.rightShift]) then
- os.queueEvent("char",charConversionShift[keys.getName(message.key)])
- elseif charConversion[keys.getName(message.key)] then
- os.queueEvent("char",charConversion[keys.getName(message.key)])
- elseif #keys.getName(message.key) == 1 then
- if (keysDown[keys.leftShift] or keysDown[keys.rightShift]) then
- os.queueEvent("char",keys.getName(message.key))
- else
- os.queueEvent("char",keys.getName(message.key))
- end
- end
- os.queueEvent("key",message.key,true)
- else
- keysDown[message.key] = false
- os.queueEvent("key_up",message.key)
- end
- elseif message.key == "terminate" then
- os.queueEvent("terminate")
- elseif message.key == "shutdown" then
- os.shutdown()
- elseif message.key == "reboot" then
- os.reboot()
- end
- end
- elseif evt == "monitor_touch" then
- os.queueEvent("mouse_click",1,freq,repfreq)
- os.queueEvent("mouse_up",1,freq,repfreq)
- end
- end
- end
- parallel.waitForAny(getKeyInput,shellrun)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement