Advertisement
theoriginalbit

CCKeyboard

Mar 24th, 2013
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 22.65 KB | None | 0 0
  1. --[[
  2. Author: TheOriginalBIT
  3. Version: 1.0
  4. Created: 25 Mar 2013
  5. Last Update: 25 Mar 2013
  6.  
  7. License:
  8.  
  9. COPYRIGHT NOTICE
  10. Copyright © 2013 Joshua Asbury a.k.a TheOriginalBIT [theoriginalbit@gmail.com]
  11.  
  12. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
  13. associated documentation files (the "Software"), to deal in the Software without restriction,
  14. including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
  15. copies of the Software, and to permit persons to whom the Software is furnished to do so,
  16. subject to the following conditions:
  17.  
  18. -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  19. -Visible credit is given to the original author.
  20. -The software is distributed in a non-profit way.
  21.  
  22. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  23. WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  24. COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  25. ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26. ]]--
  27.  
  28. local views = {}
  29. local cycleInfo = {}
  30. local activeView = nil
  31. local monitorSide = nil
  32. local monitorObj = nil
  33. local offset_x, offset_y = 0, 0
  34.  
  35. local shiftPressed = false
  36. local routineKeyboard = nil
  37.  
  38. _G.assert = function(condition, errMsg, level) if not condition then error(errMsg, (tonumber(level) or 1) + 1) end return condition end
  39.  
  40. function setActiveScreen(key)
  41.   assert(views[key], 'A screen with the key \''..key..'\' does not exist', 2)
  42.   activeView = key
  43. end
  44.  
  45. function cycleActiveScreen()
  46.   activeView = cycleInfo[activeView]._next
  47. end
  48.  
  49. function registerScreen(key, prev_screen, next_screen)
  50.   assert(not views[key], 'A screen with the key \''..key..'\' already exists', 2)
  51.   assert(type(prev_screen) == 'string', 'Invalid parameter: expected prev_screen to be a string, got '..type(prev_screen), 2)
  52.   assert(type(next_screen) == 'string', 'Invalid parameter: expected next_screen to be a string, got '..type(next_screen), 2)
  53.   views[key] = {}
  54.   cycleInfo[key] = { _prev = prev_screen, _next = next_screen}
  55. end
  56.  
  57. function registerKey(screen, key, text, xPos, yPos, width, height, func, backColor, textColor)
  58.   assert(views[screen], 'A screen with the key \''..screen..'\' does not exist', 2)
  59.   assert(not views[screen][key], 'A key with the key \''..screen..'\' already exists', 2)
  60.   assert(type(text) == 'string', 'Invalid parameter: expected text to be a string, got '..type(text), 2)
  61.   assert(type(xPos) == 'number', 'Invalid parameter: expected xPos to be a number, got '..type(xPos), 2)
  62.   assert(type(yPos) == 'number', 'Invalid parameter: expected yPos to be a number, got '..type(yPos), 2)
  63.   assert(type(width) == 'number' or type(width) == 'nil', 'Invalid parameter: expected width to be a number or nil, got '..type(width), 2)
  64.   assert(type(height) == 'number' or type(height) == 'nil', 'Invalid parameter: expected height to be a number or nil, got '..type(height), 2)
  65.   assert(type(func) == 'function', 'Invalid parameter: expected func to be a function, got '..type(func), 2)
  66.   assert(type(backColor) == 'number' and backColor >= 2^0 and backColor <= 2^15, 'Invalid parameter: expected backColor to be a number color, got '..type(backColor), 2)
  67.   assert(type(textColor) == 'number' and textColor >= 2^0 and textColor <= 2^15, 'Invalid parameter: expected textColor to be a number color, got '..type(textColor), 2)
  68.  
  69.   views[screen][key] = {}
  70.   views[screen][key]._t = text
  71.   views[screen][key]._x = xPos
  72.   views[screen][key]._y = yPos
  73.   views[screen][key]._w = width or #text
  74.   views[screen][key]._h = height or 1
  75.   views[screen][key]._bc = backColor
  76.   views[screen][key]._tc = textColor
  77.   views[screen][key].onClick = key == 'SF' and func or function( ... )
  78.     func(...)
  79.     shiftPressed = false -- turn off shift, we have done our capital letter
  80.   end
  81.   views[screen][key].wasClicked = function(self, mouse_x, mouse_y)
  82.     return mouse_x >= self._x + offset_x and mouse_x <= self._x + offset_x + self._w - 1 and mouse_y >= self._y + offset_y and mouse_y <= self._y + offset_y + self._h - 1
  83.   end
  84.   views[screen][key].onDraw = function(self)
  85.     if self._t == '^ ' and shiftPressed then
  86.       term.setBackgroundColor(colors.lightBlue)
  87.     else
  88.       term.setBackgroundColor(self._bc)
  89.     end
  90.     term.setTextColor(self._tc)
  91.     for y = 0, self._h - 1 do
  92.       term.setCursorPos(offset_x + self._x, offset_y + self._y + y)
  93.       write( string.rep(' ', self._w) )
  94.     end
  95.  
  96.     term.setCursorPos(offset_x + self._x + math.floor(self._w / 2 - #self._t / 2), offset_y + self._y + math.floor(self._h / 2))
  97.     if shiftPressed and not (self._t == '  space  ' or self._t == 'enter') then
  98.       write(string.upper(self._t) or '?')
  99.     else
  100.       write(self._t or '?')
  101.     end
  102.   end
  103. end
  104.  
  105. function render()
  106.   term.redirect(monitorObj)
  107.  
  108.   term.setBackgroundColor(colors.lightGray)
  109.  
  110.   for i = 1, 4 do
  111.     term.setCursorPos(offset_x + 1, offset_y + i)
  112.     write( string.rep(' ', 19) )
  113.   end
  114.  
  115.   for _,v in pairs(views[activeView]) do
  116.     v:onDraw()
  117.   end
  118.  
  119.   term.restore()
  120. end
  121.  
  122. local function run()
  123.   while true do
  124.     local event = { coroutine.yield() }
  125.     if event[1] == 'terminate' then
  126.       return
  127.     elseif (event[1] == 'monitor_touch' and event[2] == monitorSide) then
  128.       for _, v in pairs(views[activeView]) do
  129.         if v:wasClicked( event[3], event[4]) then
  130.           v:onClick()
  131.           break -- a button was clicked, we don't have stacked buttons
  132.         end
  133.       end
  134.     end
  135.   end
  136. end
  137.  
  138. function pullEvent(useRaw)
  139.   local pullEvent = useRaw and os.pullEventRaw or os.pullEvent
  140.   local event = { pullEvent() }
  141.   coroutine.resume(routineKeyboard, unpack(event) )
  142.   return unpack(event)
  143. end
  144.  
  145. function isAlive()
  146.   return routineKeyboard and coroutine.status(routineKeyboard) ~= 'dead'
  147. end
  148.  
  149. function startCoroutine()
  150.   if not routineKeyboard or not isAlive() then
  151.     routineKeyboard = coroutine.create(run)
  152.   end
  153.   coroutine.resume(routineKeyboard)
  154. end
  155.  
  156. function setup( side, topLeftX, topLeftY )
  157.   if topLeftX then
  158.     offset_x = topLeftX
  159.   end
  160.   if topLeftY then
  161.     offset_y = topLeftY
  162.   end
  163.  
  164.   assert(type(side) == 'string', 'Invalid parameter: expected side to be a string, got '..type(side), 2)
  165.   if peripheral.getType(side) ~= 'monitor' then printError('No monitor on the computers '..side..' side') error() end
  166.   monitorSide = side
  167.   monitorObj = peripheral.wrap(side)
  168.   if not monitorObj.isColor() then printError('Monitor must be an advanced monitor') error() end
  169.   monitorObj.setTextScale(1)
  170.  
  171.   local mw, mh = monitorObj.getSize()
  172.   local scale = mw / 19
  173.   if scale > 5 then scale = 5 end
  174.   if scale < 0.5 then scale = 0.5 end
  175.   monitorObj.setTextScale(scale)
  176.  
  177.   term.redirect(monitorObj)
  178.   local w, h = term.getSize()
  179.   term.restore()
  180.   if w < 19 then
  181.     printError('Monitor is not wide enough to display keyboard')
  182.     error()
  183.   end
  184.   if h < 4 then
  185.     printError('Monitor is not tall enough to display keyboard')
  186.     error()
  187.   end
  188.  
  189.   registerScreen('ABC', '#+=', '123')
  190.   registerScreen('123', 'ABC', '#+=')
  191.   registerScreen('#+=', '123', 'ABC')
  192.  
  193.   setActiveScreen('ABC')
  194.  
  195.   -- FIRST VIEW: ABC
  196.   do
  197.     -- First row, ASCII keyboard
  198.     registerKey('ABC', 'q', 'q', 1, 1, nil, nil, function() os.queueEvent('key', keys.q) os.queueEvent('char', shiftPressed and 'Q' or 'q') end, colors.lightGray, colors.black)
  199.     registerKey('ABC', 'w', 'w', 3, 1, nil, nil, function() os.queueEvent('key', keys.w) os.queueEvent('char', shiftPressed and 'W' or 'w') end, colors.lightGray, colors.black)
  200.     registerKey('ABC', 'e', 'e', 5, 1, nil, nil, function() os.queueEvent('key', keys.e) os.queueEvent('char', shiftPressed and 'E' or 'e') end, colors.lightGray, colors.black)
  201.     registerKey('ABC', 'r', 'r', 7, 1, nil, nil, function() os.queueEvent('key', keys.r) os.queueEvent('char', shiftPressed and 'R' or 'r') end, colors.lightGray, colors.black)
  202.     registerKey('ABC', 't', 't', 9, 1, nil, nil, function() os.queueEvent('key', keys.t) os.queueEvent('char', shiftPressed and 'T' or 't') end, colors.lightGray, colors.black)
  203.     registerKey('ABC', 'y', 'y', 11, 1, nil, nil, function() os.queueEvent('key', keys.y) os.queueEvent('char', shiftPressed and 'Y' or 'y') end, colors.lightGray, colors.black)
  204.     registerKey('ABC', 'u', 'u', 13, 1, nil, nil, function() os.queueEvent('key', keys.u) os.queueEvent('char', shiftPressed and 'U' or 'u') end, colors.lightGray, colors.black)
  205.     registerKey('ABC', 'i', 'i', 15, 1, nil, nil, function() os.queueEvent('key', keys.i) os.queueEvent('char', shiftPressed and 'I' or 'i') end, colors.lightGray, colors.black)
  206.     registerKey('ABC', 'o', 'o', 17, 1, nil, nil, function() os.queueEvent('key', keys.o) os.queueEvent('char', shiftPressed and 'O' or 'o') end, colors.lightGray, colors.black)
  207.     registerKey('ABC', 'p', 'p', 19, 1, nil, nil, function() os.queueEvent('key', keys.p) os.queueEvent('char', shiftPressed and 'P' or 'p') end, colors.lightGray, colors.black)
  208.  
  209.     -- Second row, ASCII keyboard
  210.     registerKey('ABC', 'a', 'a', 2, 2, nil, nil, function() os.queueEvent('key', keys.a) os.queueEvent('char', shiftPressed and 'A' or 'a') end, colors.lightGray, colors.black)
  211.     registerKey('ABC', 's', 's', 4, 2, nil, nil, function() os.queueEvent('key', keys.s) os.queueEvent('char', shiftPressed and 'S' or 's') end, colors.lightGray, colors.black)
  212.     registerKey('ABC', 'd', 'd', 6, 2, nil, nil, function() os.queueEvent('key', keys.d) os.queueEvent('char', shiftPressed and 'D' or 'd') end, colors.lightGray, colors.black)
  213.     registerKey('ABC', 'f', 'f', 8, 2, nil, nil, function() os.queueEvent('key', keys.f) os.queueEvent('char', shiftPressed and 'F' or 'f') end, colors.lightGray, colors.black)
  214.     registerKey('ABC', 'g', 'g', 10, 2, nil, nil, function() os.queueEvent('key', keys.g) os.queueEvent('char', shiftPressed and 'G' or 'g') end, colors.lightGray, colors.black)
  215.     registerKey('ABC', 'h', 'h', 12, 2, nil, nil, function() os.queueEvent('key', keys.h) os.queueEvent('char', shiftPressed and 'H' or 'h') end, colors.lightGray, colors.black)
  216.     registerKey('ABC', 'j', 'j', 14, 2, nil, nil, function() os.queueEvent('key', keys.j) os.queueEvent('char', shiftPressed and 'J' or 'j') end, colors.lightGray, colors.black)
  217.     registerKey('ABC', 'k', 'k', 16, 2, nil, nil, function() os.queueEvent('key', keys.k) os.queueEvent('char', shiftPressed and 'K' or 'k') end, colors.lightGray, colors.black)
  218.     registerKey('ABC', 'l', 'l', 18, 2, nil, nil, function() os.queueEvent('key', keys.l) os.queueEvent('char', shiftPressed and 'L' or 'l') end, colors.lightGray, colors.black)
  219.  
  220.     -- Third row, ASCII keyboard
  221.     registerKey('ABC', 'SF', '^ ', 1, 3, nil, nil, function() os.queueEvent('key', keys.leftShift) shiftPressed = not shiftPressed end, colors.lightGray, colors.black)
  222.     registerKey('ABC', 'z', 'z', 4, 3, nil, nil, function() os.queueEvent('key', keys.z) os.queueEvent('char', shiftPressed and 'Z' or 'z') end, colors.lightGray, colors.black)
  223.     registerKey('ABC', 'x', 'x', 6, 3, nil, nil, function() os.queueEvent('key', keys.x) os.queueEvent('char', shiftPressed and 'X' or 'x') end, colors.lightGray, colors.black)
  224.     registerKey('ABC', 'c', 'c', 8, 3, nil, nil, function() os.queueEvent('key', keys.c) os.queueEvent('char', shiftPressed and 'C' or 'c') end, colors.lightGray, colors.black)
  225.     registerKey('ABC', 'v', 'v', 10, 3, nil, nil, function() os.queueEvent('key', keys.v) os.queueEvent('char', shiftPressed and 'V' or 'v') end, colors.lightGray, colors.black)
  226.     registerKey('ABC', 'b', 'b', 12, 3, nil, nil, function() os.queueEvent('key', keys.b) os.queueEvent('char', shiftPressed and 'B' or 'b') end, colors.lightGray, colors.black)
  227.     registerKey('ABC', 'n', 'n', 14, 3, nil, nil, function() os.queueEvent('key', keys.n) os.queueEvent('char', shiftPressed and 'N' or 'n') end, colors.lightGray, colors.black)
  228.     registerKey('ABC', 'm', 'm', 16, 3, nil, nil, function() os.queueEvent('key', keys.m) os.queueEvent('char', shiftPressed and 'M' or 'm') end, colors.lightGray, colors.black)
  229.     registerKey('ABC', 'BK', '<-', 18, 3, nil, nil, function() os.queueEvent('key', keys.backspace) end, colors.lightGray, colors.black)
  230.  
  231.     -- Fourth row, ASCII keyboard
  232.     registerKey('ABC', 'SP_123', '123', 1, 4, nil, nil, function() setActiveScreen('123') end, colors.lightGray, colors.black)
  233.     registerKey('ABC', 'SB', '  space  ', 5, 4, nil, nil, function() os.queueEvent('key', keys.space) os.queueEvent('char', ' ') end, colors.lightGray, colors.black)
  234.     registerKey('ABC', 'EN', 'enter', 15, 4, nil, nil, function() os.queueEvent('key', keys.enter) end, colors.lightGray, colors.black)
  235.   end
  236.  
  237.   -- SECOND VIEW: 123
  238.   do
  239.     -- First row, Numbers
  240.     registerKey('123', '1', '1', 1, 1, nil, nil, function() os.queueEvent('key', keys.one) os.queueEvent('char', '1') end, colors.lightGray, colors.black)
  241.     registerKey('123', '2', '2', 3, 1, nil, nil, function() os.queueEvent('key', keys.two) os.queueEvent('char', '2') end, colors.lightGray, colors.black)
  242.     registerKey('123', '3', '3', 5, 1, nil, nil, function() os.queueEvent('key', keys.three) os.queueEvent('char', '3') end, colors.lightGray, colors.black)
  243.     registerKey('123', '4', '4', 7, 1, nil, nil, function() os.queueEvent('key', keys.four) os.queueEvent('char', '4') end, colors.lightGray, colors.black)
  244.     registerKey('123', '5', '5', 9, 1, nil, nil, function() os.queueEvent('key', keys.five) os.queueEvent('char', '5') end, colors.lightGray, colors.black)
  245.     registerKey('123', '6', '6', 11, 1, nil, nil, function() os.queueEvent('key', keys.six) os.queueEvent('char', '6') end, colors.lightGray, colors.black)
  246.     registerKey('123', '7', '7', 13, 1, nil, nil, function() os.queueEvent('key', keys.seven) os.queueEvent('char', '7') end, colors.lightGray, colors.black)
  247.     registerKey('123', '8', '8', 15, 1, nil, nil, function() os.queueEvent('key', keys.eight) os.queueEvent('char', '8') end, colors.lightGray, colors.black)
  248.     registerKey('123', '9', '9', 17, 1, nil, nil, function() os.queueEvent('key', keys.nine) os.queueEvent('char', '9') end, colors.lightGray, colors.black)
  249.     registerKey('123', '0', '0', 19, 1, nil, nil, function() os.queueEvent('key', keys.zero) os.queueEvent('char', '0') end, colors.lightGray, colors.black)
  250.  
  251.     -- Second row, Symbols
  252.     registerKey('123', 'minus', '-', 2, 2, nil, nil, function() os.queueEvent('key', keys.minus) os.queueEvent('char', '-') end, colors.lightGray, colors.black)
  253.     registerKey('123', 'slash', '/', 4, 2, nil, nil, function() os.queueEvent('key', keys.slash) os.queueEvent('char', '/') end, colors.lightGray, colors.black)
  254.     registerKey('123', 'colon', ':', 6, 2, nil, nil, function() os.queueEvent('key', keys.colon) os.queueEvent('char', ':') end, colors.lightGray, colors.black)
  255.     registerKey('123', 'semicolon', ';', 8, 2, nil, nil, function() os.queueEvent('key', keys.colon) os.queueEvent('char', ';') end, colors.lightGray, colors.black)
  256.     registerKey('123', 'lbracket', '(', 10, 2, nil, nil, function() os.queueEvent('key', keys.nine) os.queueEvent('char', '(') end, colors.lightGray, colors.black)
  257.     registerKey('123', 'rbrakcet', ')', 12, 2, nil, nil, function() os.queueEvent('key', keys.zero) os.queueEvent('char', ')') end, colors.lightGray, colors.black)
  258.     registerKey('123', 'dollars', '$', 14, 2, nil, nil, function() os.queueEvent('key', keys.four) os.queueEvent('char', '$') end, colors.lightGray, colors.black)
  259.     registerKey('123', 'amp', '&', 16, 2, nil, nil, function() os.queueEvent('key', keys.seven) os.queueEvent('char', '&') end, colors.lightGray, colors.black)
  260.     registerKey('123', 'at', '@', 18, 2, nil, nil, function() os.queueEvent('key', keys.two) os.queueEvent('char', '@') end, colors.lightGray, colors.black)
  261.  
  262.     -- third row, Symbols
  263.     registerKey('123', 'CYC_#+=', '#=', 1, 3, nil, nil, function() setActiveScreen('#+=') end, colors.lightGray, colors.black)
  264.     registerKey('123', 'period', '.', 5, 3, nil, nil, function() os.queueEvent('key', keys.period) os.queueEvent('char', '.') end, colors.lightGray, colors.black)
  265.     registerKey('123', 'comma', ',', 7, 3, nil, nil, function() os.queueEvent('key', keys.comma) os.queueEvent('char', ',') end, colors.lightGray, colors.black)
  266.     registerKey('123', 'question', '?', 9, 3, nil, nil, function() os.queueEvent('key', keys.slash) os.queueEvent('char', '?') end, colors.lightGray, colors.black)
  267.     registerKey('123', 'exclamation', '!', 11, 3, nil, nil, function() os.queueEvent('key', keys.one) os.queueEvent('char', '!') end, colors.lightGray, colors.black)
  268.     registerKey('123', 'singleQuote', '\'', 13, 3, nil, nil, function() os.queueEvent('key', 0) os.queueEvent('char', '\'') end, colors.lightGray, colors.black)
  269.     registerKey('123', 'quote', '\"', 15, 3, nil, nil, function() os.queueEvent('key', 0) os.queueEvent('char', '\"') end, colors.lightGray, colors.black)
  270.     registerKey('123', 'BK', '<-', 18, 3, nil, nil, function() os.queueEvent('key', keys.backspace) end, colors.lightGray, colors.black)
  271.  
  272.     -- Fourth row, Standard
  273.     registerKey('123', 'SP_ABC', 'ABC', 1, 4, nil, nil, function() setActiveScreen('ABC') end, colors.lightGray, colors.black)
  274.     registerKey('123', 'SB', '  space  ', 5, 4, nil, nil, function() os.queueEvent('key', keys.space) os.queueEvent('char', ' ') end, colors.lightGray, colors.black)
  275.     registerKey('123', 'EN', 'enter', 15, 4, nil, nil, function() os.queueEvent('key', keys.enter) end, colors.lightGray, colors.black)
  276.   end
  277.  
  278.   -- THIRD VIEW: #+=
  279.   do
  280.     -- First row, Symbols
  281.     registerKey('#+=', 'lsbrace', '[', 1, 1, nil, nil, function() os.queueEvent('key', keys.leftBracket) os.queueEvent('char', '[') end, colors.lightGray, colors.black)
  282.     registerKey('#+=', 'rsbrace', ']', 3, 1, nil, nil, function() os.queueEvent('key', keys.rightBracket) os.queueEvent('char', ']') end, colors.lightGray, colors.black)
  283.     registerKey('#+=', 'lcbrace', '{', 5, 1, nil, nil, function() os.queueEvent('key', keys.leftBracket) os.queueEvent('char', '{') end, colors.lightGray, colors.black)
  284.     registerKey('#+=', 'rcbrace', '}', 7, 1, nil, nil, function() os.queueEvent('key', keys.rightBracket) os.queueEvent('char', '}') end, colors.lightGray, colors.black)
  285.     registerKey('#+=', 'hash', '#', 9, 1, nil, nil, function() os.queueEvent('key', keys.three) os.queueEvent('char', '#') end, colors.lightGray, colors.black)
  286.     registerKey('#+=', 'percent', '%', 11, 1, nil, nil, function() os.queueEvent('key', keys.five) os.queueEvent('char', '%') end, colors.lightGray, colors.black)
  287.     registerKey('#+=', 'carrot', '^', 13, 1, nil, nil, function() os.queueEvent('key', keys.six) os.queueEvent('char', '^') end, colors.lightGray, colors.black)
  288.     registerKey('#+=', 'asterisk', '*', 15, 1, nil, nil, function() os.queueEvent('key', keys.eight) os.queueEvent('char', '*') end, colors.lightGray, colors.black)
  289.     registerKey('#+=', 'plus', '+', 17, 1, nil, nil, function() os.queueEvent('key', keys.equals) os.queueEvent('char', '+') end, colors.lightGray, colors.black)
  290.     registerKey('#+=', 'equals', '=', 19, 1, nil, nil, function() os.queueEvent('key', keys.equals) os.queueEvent('char', '=') end, colors.lightGray, colors.black)
  291.  
  292.     -- Second row, Symbols
  293.     registerKey('#+=', 'score', '_', 2, 2, nil, nil, function() os.queueEvent('key', keys.minus) os.queueEvent('char', '_') end, colors.lightGray, colors.black)
  294.     registerKey('#+=', 'backslash', '\\', 4, 2, nil, nil, function() os.queueEvent('key', keys.backslash) os.queueEvent('char', '\\') end, colors.lightGray, colors.black)
  295.     registerKey('#+=', 'bar', '|', 6, 2, nil, nil, function() os.queueEvent('key', keys.backslash) os.queueEvent('char', '|') end, colors.lightGray, colors.black)
  296.     registerKey('#+=', 'tild', '~', 8, 2, nil, nil, function() os.queueEvent('key', 0) os.queueEvent('char', '~') end, colors.lightGray, colors.black)
  297.     registerKey('#+=', 'lt', '<', 10, 2, nil, nil, function() os.queueEvent('key', keys.comma) os.queueEvent('char', '<') end, colors.lightGray, colors.black)
  298.     registerKey('#+=', 'gt', '>', 12, 2, nil, nil, function() os.queueEvent('key', keys.period) os.queueEvent('char', '>') end, colors.lightGray, colors.black)
  299.     registerKey('#+=', 'dollars', '$', 14, 2, nil, nil, function() os.queueEvent('key', keys.four) os.queueEvent('char', '$') end, colors.lightGray, colors.black)
  300.     registerKey('#+=', 'amp', '&', 16, 2, nil, nil, function() os.queueEvent('key', keys.seven) os.queueEvent('char', '&') end, colors.lightGray, colors.black)
  301.     registerKey('#+=', 'at', '@', 18, 2, nil, nil, function() os.queueEvent('key', keys.two) os.queueEvent('char', '@') end, colors.lightGray, colors.black)
  302.  
  303.     -- third row, Symbols
  304.     registerKey('#+=', 'CYC_123', '12', 1, 3, nil, nil, function() setActiveScreen('123') end, colors.lightGray, colors.black)
  305.     registerKey('#+=', 'period', '.', 5, 3, nil, nil, function() os.queueEvent('key', keys.period) os.queueEvent('char', '.') end, colors.lightGray, colors.black)
  306.     registerKey('#+=', 'comma', ',', 7, 3, nil, nil, function() os.queueEvent('key', keys.comma) os.queueEvent('char', ',') end, colors.lightGray, colors.black)
  307.     registerKey('#+=', 'question', '?', 9, 3, nil, nil, function() os.queueEvent('key', keys.slash) os.queueEvent('char', '?') end, colors.lightGray, colors.black)
  308.     registerKey('#+=', 'exclamation', '!', 11, 3, nil, nil, function() os.queueEvent('key', keys.one) os.queueEvent('char', '!') end, colors.lightGray, colors.black)
  309.     registerKey('#+=', 'singleQuote', '\'', 13, 3, nil, nil, function() os.queueEvent('key', 0) os.queueEvent('char', '\'') end, colors.lightGray, colors.black)
  310.     registerKey('#+=', 'quote', '\"', 15, 3, nil, nil, function() os.queueEvent('key', 0) os.queueEvent('char', '\"') end, colors.lightGray, colors.black)
  311.     registerKey('#+=', 'BK', '<-', 18, 3, nil, nil, function() os.queueEvent('key', keys.backspace) end, colors.lightGray, colors.black)
  312.  
  313.     -- Fourth row, Standard
  314.     registerKey('#+=', 'SP_ABC', 'ABC', 1, 4, nil, nil, function() setActiveScreen('ABC') end, colors.lightGray, colors.black)
  315.     registerKey('#+=', 'SB', '  space  ', 5, 4, nil, nil, function() os.queueEvent('key', keys.space) os.queueEvent('char', ' ') end, colors.lightGray, colors.black)
  316.     registerKey('#+=', 'EN', 'enter', 15, 4, nil, nil, function() os.queueEvent('key', keys.enter) end, colors.lightGray, colors.black)
  317.   end
  318.  
  319.   startCoroutine()
  320. end
  321.  
  322. --[[
  323. q w e r t y u i o p
  324.  a s d f g h j k l
  325. ^  z x c v b n m <-
  326. 123   space   enter
  327.  
  328.  
  329.  
  330. 1 2 3 4 5 6 7 8 9 0
  331. - / : ; ( ) $ & @ "
  332. #+=  . , ? ! '   <-
  333. ABC   space   enter
  334.  
  335.  
  336.  
  337. [ ] { } # % ^ * + =
  338. _ \ | ~ < > $ & @ "
  339. 123  . , ? ! '   <-
  340. ABC   space   enter
  341. ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement