-
Notifications
You must be signed in to change notification settings - Fork 3
/
indeck-keyboard.lua
120 lines (113 loc) · 2.85 KB
/
indeck-keyboard.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
local mod = (...):match("(.-)[^%.]+$")
local IndeckKeyboard = {
}
setmetatable(IndeckKeyboard, {__index=letters.TapKeyboard})
local IndeckKeyboard_mt = {
__index = IndeckKeyboard
}
function IndeckKeyboard:new(o)
o = o or {}
if not o.keyboardConfig then
o.keyboardConfig = letters.KeyboardConfig:new()
o.keyboardConfig:addStandardKeys()
o.keyboardConfig:addIndeckMacroRows()
o.keyboardConfig:addLeftCommands()
o.keyboardConfig:addRightCommands()
end
o = letters.TapKeyboard:new(o)
setmetatable(o, IndeckKeyboard_mt)
o.transform:translate(-1.0, 0, 0)
return o
end
-- An Indeck-specific macro pad
function letters.KeyboardConfig:addIndeckMacroRows()
local macroRows = {
{
{'lovr.', width = 2.5},
{'graphics.', width = 3},
{'headset.', width = 3},
{'get', width = 1.5},
{'set', width = 1.5},
{'new', width = 1.5},
{'vec3(', width = 2},
},
{
{'local', width = 2},
{'self', width = 2},
{'function', width = 3},
{'end', width = 1.5},
':', '()', '{}',
{'print(\'', width = 2},
{'--', width = 1.5},
},
{
{'for ', width = 1.5},
' in ', 'i',
{'pairs', width = 1.5},
{' do ', width = 1},
{'if ', width = 1.5},
{'then', width = 1.5},
{'else', width = 1.5},
{' not ', width = 1.5},
{' and ', width = 1.5},
{' or ', width = 1.5},
},
{
{'~'},
{'!'},
{'@'},
{'#'},
{'$'},
{'%'},
{'^'},
{'&'},
{'*'},
{'('},
{')'},
{'_'},
{'+'},
{'{'},
{'}'},
},
{},
}
for i, row in ipairs(macroRows) do
self:insertRow(i, row)
end
end
-- Add Indeck-specific commands as a sidebar
function letters.KeyboardConfig:addLeftCommands()
local commands = {
{'load session', width = 4},
{'save session', width = 4},
{'new window', width = 4},
{'close window', width = 4},
{'fullscreen', width = 4},
{'profiler', width = 4},
{'', type = 'spacer', width = 4},
}
-- if we have macro rows, pad them
for i=1, #self.rows-#commands-1 do
table.insert(commands, 1, {'', type='spacer', width=4})
end
self:insertColumn(1, 1, commands)
self:insertBlankColumn(2)
end
-- Add Indeck-specific commands as a sidebar
function letters.KeyboardConfig:addRightCommands()
local commands = {
{'open file', width = 4},
{'save file', width = 4},
{'center view', width = 4},
{'restart game', width = 4},
{'docs', width = 4},
{'execute line', width = 4},
}
-- if we have macro rows, pad them
for i=1, #self.rows-#commands-2 do
table.insert(commands, 1, {'', type='spacer', width=4})
end
self:insertBlankColumn(255)
self:insertColumn(255, 1, commands)
end
return IndeckKeyboard