Add scancodes as constants in lua
This commit is contained in:
parent
6c6afe569f
commit
1af2795e7d
6
main.lua
6
main.lua
@ -15,10 +15,10 @@ function couch.update(delta)
|
||||
end
|
||||
|
||||
function couch.keypressed(scancode)
|
||||
if scancode == 30 then roll_x = 1.0 end
|
||||
if scancode == 32 then roll_x = -1.0 end
|
||||
if scancode == couch.KEY_A then roll_x = 1.0 end
|
||||
if scancode == couch.KEY_D then roll_x = -1.0 end
|
||||
end
|
||||
|
||||
function couch.keyreleased(scancode)
|
||||
if scancode == 30 or scancode == 32 then roll_x = 0.0 end
|
||||
if scancode == couch.KEY_A or scancode == couch.KEY_D then roll_x = 0.0 end
|
||||
end
|
||||
|
@ -24,6 +24,8 @@ impl Lua {
|
||||
|
||||
// Hook into globals
|
||||
ctx.globals().set("couch", couch).unwrap();
|
||||
let setup = include_str!("setup.lua");
|
||||
ctx.load(&setup).exec().unwrap();
|
||||
let path = std::path::Path::new("main.lua");
|
||||
let buf = std::fs::read(&path).expect("Could not find main.lua");
|
||||
ctx.load(&buf).exec().unwrap();
|
||||
|
230
src/scripting/setup.lua
Normal file
230
src/scripting/setup.lua
Normal file
@ -0,0 +1,230 @@
|
||||
couch.KEY_RESERVED = 0
|
||||
couch.KEY_ESC = 1
|
||||
couch.KEY_1 = 2
|
||||
couch.KEY_2 = 3
|
||||
couch.KEY_3 = 4
|
||||
couch.KEY_4 = 5
|
||||
couch.KEY_5 = 6
|
||||
couch.KEY_6 = 7
|
||||
couch.KEY_7 = 8
|
||||
couch.KEY_8 = 9
|
||||
couch.KEY_9 = 10
|
||||
couch.KEY_0 = 11
|
||||
couch.KEY_MINUS = 12
|
||||
couch.KEY_EQUAL = 13
|
||||
couch.KEY_BACKSPACE = 14
|
||||
couch.KEY_TAB = 15
|
||||
couch.KEY_Q = 16
|
||||
couch.KEY_W = 17
|
||||
couch.KEY_E = 18
|
||||
couch.KEY_R = 19
|
||||
couch.KEY_T = 20
|
||||
couch.KEY_Y = 21
|
||||
couch.KEY_U = 22
|
||||
couch.KEY_I = 23
|
||||
couch.KEY_O = 24
|
||||
couch.KEY_P = 25
|
||||
couch.KEY_LEFTBRACE = 26
|
||||
couch.KEY_RIGHTBRACE = 27
|
||||
couch.KEY_ENTER = 28
|
||||
couch.KEY_LEFTCTRL = 29
|
||||
couch.KEY_A = 30
|
||||
couch.KEY_S = 31
|
||||
couch.KEY_D = 32
|
||||
couch.KEY_F = 33
|
||||
couch.KEY_G = 34
|
||||
couch.KEY_H = 35
|
||||
couch.KEY_J = 36
|
||||
couch.KEY_K = 37
|
||||
couch.KEY_L = 38
|
||||
couch.KEY_SEMICOLON = 39
|
||||
couch.KEY_APOSTROPHE = 40
|
||||
couch.KEY_GRAVE = 41
|
||||
couch.KEY_LEFTSHIFT = 42
|
||||
couch.KEY_BACKSLASH = 43
|
||||
couch.KEY_Z = 44
|
||||
couch.KEY_X = 45
|
||||
couch.KEY_C = 46
|
||||
couch.KEY_V = 47
|
||||
couch.KEY_B = 48
|
||||
couch.KEY_N = 49
|
||||
couch.KEY_M = 50
|
||||
couch.KEY_COMMA = 51
|
||||
couch.KEY_DOT = 52
|
||||
couch.KEY_SLASH = 53
|
||||
couch.KEY_RIGHTSHIFT = 54
|
||||
couch.KEY_KPASTERISK = 55
|
||||
couch.KEY_LEFTALT = 56
|
||||
couch.KEY_SPACE = 57
|
||||
couch.KEY_CAPSLOCK = 58
|
||||
couch.KEY_F1 = 59
|
||||
couch.KEY_F2 = 60
|
||||
couch.KEY_F3 = 61
|
||||
couch.KEY_F4 = 62
|
||||
couch.KEY_F5 = 63
|
||||
couch.KEY_F6 = 64
|
||||
couch.KEY_F7 = 65
|
||||
couch.KEY_F8 = 66
|
||||
couch.KEY_F9 = 67
|
||||
couch.KEY_F10 = 68
|
||||
couch.KEY_NUMLOCK = 69
|
||||
couch.KEY_SCROLLLOCK = 70
|
||||
couch.KEY_KP7 = 71
|
||||
couch.KEY_KP8 = 72
|
||||
couch.KEY_KP9 = 73
|
||||
couch.KEY_KPMINUS = 74
|
||||
couch.KEY_KP4 = 75
|
||||
couch.KEY_KP5 = 76
|
||||
couch.KEY_KP6 = 77
|
||||
couch.KEY_KPPLUS = 78
|
||||
couch.KEY_KP1 = 79
|
||||
couch.KEY_KP2 = 80
|
||||
couch.KEY_KP3 = 81
|
||||
couch.KEY_KP0 = 82
|
||||
couch.KEY_KPDOT = 83
|
||||
|
||||
couch.KEY_ZENKAKUHANKAKU = 85
|
||||
couch.KEY_102ND = 86
|
||||
couch.KEY_F11 = 87
|
||||
couch.KEY_F12 = 88
|
||||
couch.KEY_RO = 89
|
||||
couch.KEY_KATAKANA = 90
|
||||
couch.KEY_HIRAGANA = 91
|
||||
couch.KEY_HENKAN = 92
|
||||
couch.KEY_KATAKANAHIRAGANA = 93
|
||||
couch.KEY_MUHENKAN = 94
|
||||
couch.KEY_KPJPCOMMA = 95
|
||||
couch.KEY_KPENTER = 96
|
||||
couch.KEY_RIGHTCTRL = 97
|
||||
couch.KEY_KPSLASH = 98
|
||||
couch.KEY_SYSRQ = 99
|
||||
couch.KEY_RIGHTALT = 100
|
||||
couch.KEY_LINEFEED = 101
|
||||
couch.KEY_HOME = 102
|
||||
couch.KEY_UP = 103
|
||||
couch.KEY_PAGEUP = 104
|
||||
couch.KEY_LEFT = 105
|
||||
couch.KEY_RIGHT = 106
|
||||
couch.KEY_END = 107
|
||||
couch.KEY_DOWN = 108
|
||||
couch.KEY_PAGEDOWN = 109
|
||||
couch.KEY_INSERT = 110
|
||||
couch.KEY_DELETE = 111
|
||||
couch.KEY_MACRO = 112
|
||||
couch.KEY_MUTE = 113
|
||||
couch.KEY_VOLUMEDOWN = 114
|
||||
couch.KEY_VOLUMEUP = 115
|
||||
couch.KEY_POWER = 116 -- SC System Power Down
|
||||
couch.KEY_KPEQUAL = 117
|
||||
couch.KEY_KPPLUSMINUS = 118
|
||||
couch.KEY_PAUSE = 119
|
||||
couch.KEY_SCALE = 120 -- AL Compiz Scale (Expose)
|
||||
|
||||
couch.KEY_KPCOMMA = 121
|
||||
couch.KEY_HANGEUL = 122
|
||||
couch.KEY_HANGUEL = couch.KEY_HANGEUL
|
||||
couch.KEY_HANJA = 123
|
||||
couch.KEY_YEN = 124
|
||||
couch.KEY_LEFTMETA = 125
|
||||
couch.KEY_RIGHTMETA = 126
|
||||
couch.KEY_COMPOSE = 127
|
||||
|
||||
couch.KEY_STOP = 128 -- AC Stop
|
||||
couch.KEY_AGAIN = 129
|
||||
couch.KEY_PROPS = 130 -- AC Properties
|
||||
couch.KEY_UNDO = 131 -- AC Undo
|
||||
couch.KEY_FRONT = 132
|
||||
couch.KEY_COPY = 133 -- AC Copy
|
||||
couch.KEY_OPEN = 134 -- AC Open
|
||||
couch.KEY_PASTE = 135 -- AC Paste
|
||||
couch.KEY_FIND = 136 -- AC Search
|
||||
couch.KEY_CUT = 137 -- AC Cut
|
||||
couch.KEY_HELP = 138 -- AL Integrated Help Center
|
||||
couch.KEY_MENU = 139 -- Menu (show menu)
|
||||
couch.KEY_CALC = 140 -- AL Calculator
|
||||
couch.KEY_SETUP = 141
|
||||
couch.KEY_SLEEP = 142 -- SC System Sleep
|
||||
couch.KEY_WAKEUP = 143 -- System Wake Up
|
||||
couch.KEY_FILE = 144 -- AL Local Machine Browser
|
||||
couch.KEY_SENDFILE = 145
|
||||
couch.KEY_DELETEFILE = 146
|
||||
couch.KEY_XFER = 147
|
||||
couch.KEY_PROG1 = 148
|
||||
couch.KEY_PROG2 = 149
|
||||
couch.KEY_WWW = 150 -- AL Internet Browser
|
||||
couch.KEY_MSDOS = 151
|
||||
couch.KEY_COFFEE = 152 -- AL Terminal Lock/Screensaver
|
||||
couch.KEY_SCREENLOCK = couch.KEY_COFFEE
|
||||
couch.KEY_ROTATE_DISPLAY = 153 -- Display orientation for e.g. tablets
|
||||
couch.KEY_DIRECTION = couch.KEY_ROTATE_DISPLAY
|
||||
couch.KEY_CYCLEWINDOWS = 154
|
||||
couch.KEY_MAIL = 155
|
||||
couch.KEY_BOOKMARKS = 156 -- AC Bookmarks
|
||||
couch.KEY_COMPUTER = 157
|
||||
couch.KEY_BACK = 158 -- AC Back
|
||||
couch.KEY_FORWARD = 159 -- AC Forward
|
||||
couch.KEY_CLOSECD = 160
|
||||
couch.KEY_EJECTCD = 161
|
||||
couch.KEY_EJECTCLOSECD = 162
|
||||
couch.KEY_NEXTSONG = 163
|
||||
couch.KEY_PLAYPAUSE = 164
|
||||
couch.KEY_PREVIOUSSONG = 165
|
||||
couch.KEY_STOPCD = 166
|
||||
couch.KEY_RECORD = 167
|
||||
couch.KEY_REWIND = 168
|
||||
couch.KEY_PHONE = 169 -- Media Select Telephone
|
||||
couch.KEY_ISO = 170
|
||||
couch.KEY_CONFIG = 171 -- AL Consumer Control Configuration
|
||||
couch.KEY_HOMEPAGE = 172 -- AC Home
|
||||
couch.KEY_REFRESH = 173 -- AC Refresh
|
||||
couch.KEY_EXIT = 174 -- AC Exit
|
||||
couch.KEY_MOVE = 175
|
||||
couch.KEY_EDIT = 176
|
||||
couch.KEY_SCROLLUP = 177
|
||||
couch.KEY_SCROLLDOWN = 178
|
||||
couch.KEY_KPLEFTPAREN = 179
|
||||
couch.KEY_KPRIGHTPAREN = 180
|
||||
couch.KEY_NEW = 181 -- AC New
|
||||
couch.KEY_REDO = 182 -- AC Redo/Repeat
|
||||
|
||||
couch.KEY_F13 = 183
|
||||
couch.KEY_F14 = 184
|
||||
couch.KEY_F15 = 185
|
||||
couch.KEY_F16 = 186
|
||||
couch.KEY_F17 = 187
|
||||
couch.KEY_F18 = 188
|
||||
couch.KEY_F19 = 189
|
||||
couch.KEY_F20 = 190
|
||||
couch.KEY_F21 = 191
|
||||
couch.KEY_F22 = 192
|
||||
couch.KEY_F23 = 193
|
||||
couch.KEY_F24 = 194
|
||||
|
||||
couch.KEY_PLAYCD = 200
|
||||
couch.KEY_PAUSECD = 201
|
||||
couch.KEY_PROG3 = 202
|
||||
couch.KEY_PROG4 = 203
|
||||
couch.KEY_ALL_APPLICATIONS = 204 -- AC Desktop Show All Applications
|
||||
couch.KEY_DASHBOARD = couch.KEY_ALL_APPLICATIONS
|
||||
couch.KEY_SUSPEND = 205
|
||||
couch.KEY_CLOSE = 206 -- AC Close
|
||||
couch.KEY_PLAY = 207
|
||||
couch.KEY_FASTFORWARD = 208
|
||||
couch.KEY_BASSBOOST = 209
|
||||
couch.KEY_PRINT = 210 -- AC Print
|
||||
couch.KEY_HP = 211
|
||||
couch.KEY_CAMERA = 212
|
||||
couch.KEY_SOUND = 213
|
||||
couch.KEY_QUESTION = 214
|
||||
couch.KEY_EMAIL = 215
|
||||
couch.KEY_CHAT = 216
|
||||
couch.KEY_SEARCH = 217
|
||||
couch.KEY_CONNECT = 218
|
||||
couch.KEY_FINANCE = 219 -- AL Checkbook/Finance
|
||||
couch.KEY_SPORT = 220
|
||||
couch.KEY_SHOP = 221
|
||||
couch.KEY_ALTERASE = 222
|
||||
couch.KEY_CANCEL = 223 -- AC Cancel
|
||||
couch.KEY_BRIGHTNESSDOWN = 224
|
||||
couch.KEY_BRIGHTNESSUP = 225
|
||||
couch.KEY_MEDIA = 226
|
Loading…
Reference in New Issue
Block a user