-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkey.go
325 lines (317 loc) · 10.3 KB
/
key.go
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
package glimmer
import "github.com/hajimehoshi/ebiten/v2"
type KeyCode int
const (
KeyCodeUnknown KeyCode = -1
KeyCodeA KeyCode = KeyCode(ebiten.KeyA)
KeyCodeB KeyCode = KeyCode(ebiten.KeyB)
KeyCodeC KeyCode = KeyCode(ebiten.KeyC)
KeyCodeD KeyCode = KeyCode(ebiten.KeyD)
KeyCodeE KeyCode = KeyCode(ebiten.KeyE)
KeyCodeF KeyCode = KeyCode(ebiten.KeyF)
KeyCodeG KeyCode = KeyCode(ebiten.KeyG)
KeyCodeH KeyCode = KeyCode(ebiten.KeyH)
KeyCodeI KeyCode = KeyCode(ebiten.KeyI)
KeyCodeJ KeyCode = KeyCode(ebiten.KeyJ)
KeyCodeK KeyCode = KeyCode(ebiten.KeyK)
KeyCodeL KeyCode = KeyCode(ebiten.KeyL)
KeyCodeM KeyCode = KeyCode(ebiten.KeyM)
KeyCodeN KeyCode = KeyCode(ebiten.KeyN)
KeyCodeO KeyCode = KeyCode(ebiten.KeyO)
KeyCodeP KeyCode = KeyCode(ebiten.KeyP)
KeyCodeQ KeyCode = KeyCode(ebiten.KeyQ)
KeyCodeR KeyCode = KeyCode(ebiten.KeyR)
KeyCodeS KeyCode = KeyCode(ebiten.KeyS)
KeyCodeT KeyCode = KeyCode(ebiten.KeyT)
KeyCodeU KeyCode = KeyCode(ebiten.KeyU)
KeyCodeV KeyCode = KeyCode(ebiten.KeyV)
KeyCodeW KeyCode = KeyCode(ebiten.KeyW)
KeyCodeX KeyCode = KeyCode(ebiten.KeyX)
KeyCodeY KeyCode = KeyCode(ebiten.KeyY)
KeyCodeZ KeyCode = KeyCode(ebiten.KeyZ)
KeyCodeAltLeft KeyCode = KeyCode(ebiten.KeyAltLeft)
KeyCodeAltRight KeyCode = KeyCode(ebiten.KeyAltRight)
KeyCodeArrowDown KeyCode = KeyCode(ebiten.KeyArrowDown)
KeyCodeArrowLeft KeyCode = KeyCode(ebiten.KeyArrowLeft)
KeyCodeArrowRight KeyCode = KeyCode(ebiten.KeyArrowRight)
KeyCodeArrowUp KeyCode = KeyCode(ebiten.KeyArrowUp)
KeyCodeBackquote KeyCode = KeyCode(ebiten.KeyBackquote)
KeyCodeBackslash KeyCode = KeyCode(ebiten.KeyBackslash)
KeyCodeBackspace KeyCode = KeyCode(ebiten.KeyBackspace)
KeyCodeBracketLeft KeyCode = KeyCode(ebiten.KeyBracketLeft)
KeyCodeBracketRight KeyCode = KeyCode(ebiten.KeyBracketRight)
KeyCodeCapsLock KeyCode = KeyCode(ebiten.KeyCapsLock)
KeyCodeComma KeyCode = KeyCode(ebiten.KeyComma)
KeyCodeContextMenu KeyCode = KeyCode(ebiten.KeyContextMenu)
KeyCodeControlLeft KeyCode = KeyCode(ebiten.KeyControlLeft)
KeyCodeControlRight KeyCode = KeyCode(ebiten.KeyControlRight)
KeyCodeDelete KeyCode = KeyCode(ebiten.KeyDelete)
KeyCodeDigit0 KeyCode = KeyCode(ebiten.KeyDigit0)
KeyCodeDigit1 KeyCode = KeyCode(ebiten.KeyDigit1)
KeyCodeDigit2 KeyCode = KeyCode(ebiten.KeyDigit2)
KeyCodeDigit3 KeyCode = KeyCode(ebiten.KeyDigit3)
KeyCodeDigit4 KeyCode = KeyCode(ebiten.KeyDigit4)
KeyCodeDigit5 KeyCode = KeyCode(ebiten.KeyDigit5)
KeyCodeDigit6 KeyCode = KeyCode(ebiten.KeyDigit6)
KeyCodeDigit7 KeyCode = KeyCode(ebiten.KeyDigit7)
KeyCodeDigit8 KeyCode = KeyCode(ebiten.KeyDigit8)
KeyCodeDigit9 KeyCode = KeyCode(ebiten.KeyDigit9)
KeyCodeEnd KeyCode = KeyCode(ebiten.KeyEnd)
KeyCodeEnter KeyCode = KeyCode(ebiten.KeyEnter)
KeyCodeEqual KeyCode = KeyCode(ebiten.KeyEqual)
KeyCodeEscape KeyCode = KeyCode(ebiten.KeyEscape)
KeyCodeF1 KeyCode = KeyCode(ebiten.KeyF1)
KeyCodeF2 KeyCode = KeyCode(ebiten.KeyF2)
KeyCodeF3 KeyCode = KeyCode(ebiten.KeyF3)
KeyCodeF4 KeyCode = KeyCode(ebiten.KeyF4)
KeyCodeF5 KeyCode = KeyCode(ebiten.KeyF5)
KeyCodeF6 KeyCode = KeyCode(ebiten.KeyF6)
KeyCodeF7 KeyCode = KeyCode(ebiten.KeyF7)
KeyCodeF8 KeyCode = KeyCode(ebiten.KeyF8)
KeyCodeF9 KeyCode = KeyCode(ebiten.KeyF9)
KeyCodeF10 KeyCode = KeyCode(ebiten.KeyF10)
KeyCodeF11 KeyCode = KeyCode(ebiten.KeyF11)
KeyCodeF12 KeyCode = KeyCode(ebiten.KeyF12)
KeyCodeHome KeyCode = KeyCode(ebiten.KeyHome)
KeyCodeInsert KeyCode = KeyCode(ebiten.KeyInsert)
KeyCodeMetaLeft KeyCode = KeyCode(ebiten.KeyMetaLeft)
KeyCodeMetaRight KeyCode = KeyCode(ebiten.KeyMetaRight)
KeyCodeMinus KeyCode = KeyCode(ebiten.KeyMinus)
KeyCodePageDown KeyCode = KeyCode(ebiten.KeyPageDown)
KeyCodePageUp KeyCode = KeyCode(ebiten.KeyPageUp)
KeyCodePause KeyCode = KeyCode(ebiten.KeyPause)
KeyCodePeriod KeyCode = KeyCode(ebiten.KeyPeriod)
KeyCodePrintScreen KeyCode = KeyCode(ebiten.KeyPrintScreen)
KeyCodeQuote KeyCode = KeyCode(ebiten.KeyQuote)
KeyCodeScrollLock KeyCode = KeyCode(ebiten.KeyScrollLock)
KeyCodeSemicolon KeyCode = KeyCode(ebiten.KeySemicolon)
KeyCodeShiftLeft KeyCode = KeyCode(ebiten.KeyShiftLeft)
KeyCodeShiftRight KeyCode = KeyCode(ebiten.KeyShiftRight)
KeyCodeSlash KeyCode = KeyCode(ebiten.KeySlash)
KeyCodeSpace KeyCode = KeyCode(ebiten.KeySpace)
KeyCodeTab KeyCode = KeyCode(ebiten.KeyTab)
KeyCodeAlt KeyCode = KeyCode(ebiten.KeyAlt)
KeyCodeControl KeyCode = KeyCode(ebiten.KeyControl)
KeyCodeShift KeyCode = KeyCode(ebiten.KeyShift)
KeyCodeMeta KeyCode = KeyCode(ebiten.KeyMeta)
)
var KeyCodeToUnshiftedAsciiMap = map[KeyCode]rune{
KeyCodeA: 'a',
KeyCodeB: 'b',
KeyCodeC: 'c',
KeyCodeD: 'd',
KeyCodeE: 'e',
KeyCodeF: 'f',
KeyCodeG: 'g',
KeyCodeH: 'h',
KeyCodeI: 'i',
KeyCodeJ: 'j',
KeyCodeK: 'k',
KeyCodeL: 'l',
KeyCodeM: 'm',
KeyCodeN: 'n',
KeyCodeO: 'o',
KeyCodeP: 'p',
KeyCodeQ: 'q',
KeyCodeR: 'r',
KeyCodeS: 's',
KeyCodeT: 't',
KeyCodeU: 'u',
KeyCodeV: 'v',
KeyCodeW: 'w',
KeyCodeX: 'x',
KeyCodeY: 'y',
KeyCodeZ: 'z',
KeyCodeBackquote: '`',
KeyCodeBackslash: '\\',
KeyCodeBackspace: '\b',
KeyCodeBracketLeft: '[',
KeyCodeBracketRight: ']',
KeyCodeComma: ',',
KeyCodeDelete: '\x7f',
KeyCodeDigit0: '0',
KeyCodeDigit1: '1',
KeyCodeDigit2: '2',
KeyCodeDigit3: '3',
KeyCodeDigit4: '4',
KeyCodeDigit5: '5',
KeyCodeDigit6: '6',
KeyCodeDigit7: '7',
KeyCodeDigit8: '8',
KeyCodeDigit9: '9',
KeyCodeEnter: '\n',
KeyCodeEqual: '=',
KeyCodeEscape: '\x1b',
KeyCodeMinus: '-',
KeyCodePeriod: '.',
KeyCodeQuote: '\'',
KeyCodeSemicolon: ';',
KeyCodeSlash: '/',
KeyCodeSpace: ' ',
KeyCodeTab: '\t',
}
var KeyCodeToShiftedAsciiMap = map[KeyCode]rune{
KeyCodeA: 'A',
KeyCodeB: 'B',
KeyCodeC: 'C',
KeyCodeD: 'D',
KeyCodeE: 'E',
KeyCodeF: 'F',
KeyCodeG: 'G',
KeyCodeH: 'H',
KeyCodeI: 'I',
KeyCodeJ: 'J',
KeyCodeK: 'K',
KeyCodeL: 'L',
KeyCodeM: 'M',
KeyCodeN: 'N',
KeyCodeO: 'O',
KeyCodeP: 'P',
KeyCodeQ: 'Q',
KeyCodeR: 'R',
KeyCodeS: 'S',
KeyCodeT: 'T',
KeyCodeU: 'U',
KeyCodeV: 'V',
KeyCodeW: 'W',
KeyCodeX: 'X',
KeyCodeY: 'Y',
KeyCodeZ: 'Z',
KeyCodeBackquote: '~',
KeyCodeBackslash: '|',
KeyCodeBackspace: '\b',
KeyCodeBracketLeft: '{',
KeyCodeBracketRight: '}',
KeyCodeComma: '<',
KeyCodeDelete: '\x7f',
KeyCodeDigit0: ')',
KeyCodeDigit1: '!',
KeyCodeDigit2: '@',
KeyCodeDigit3: '#',
KeyCodeDigit4: '$',
KeyCodeDigit5: '%',
KeyCodeDigit6: '^',
KeyCodeDigit7: '&',
KeyCodeDigit8: '*',
KeyCodeDigit9: '(',
KeyCodeEnter: '\n',
KeyCodeEqual: '+',
KeyCodeEscape: '\x1b',
KeyCodeMinus: '_',
KeyCodePeriod: '>',
KeyCodeQuote: '"',
KeyCodeSemicolon: ':',
KeyCodeSlash: '?',
KeyCodeSpace: ' ',
KeyCodeTab: '\t',
}
var UnshiftedAsciiToKeyCodeMap = map[rune]KeyCode{
'a': KeyCodeA,
'b': KeyCodeB,
'c': KeyCodeC,
'd': KeyCodeD,
'e': KeyCodeE,
'f': KeyCodeF,
'g': KeyCodeG,
'h': KeyCodeH,
'i': KeyCodeI,
'j': KeyCodeJ,
'k': KeyCodeK,
'l': KeyCodeL,
'm': KeyCodeM,
'n': KeyCodeN,
'o': KeyCodeO,
'p': KeyCodeP,
'q': KeyCodeQ,
'r': KeyCodeR,
's': KeyCodeS,
't': KeyCodeT,
'u': KeyCodeU,
'v': KeyCodeV,
'w': KeyCodeW,
'x': KeyCodeX,
'y': KeyCodeY,
'z': KeyCodeZ,
'`': KeyCodeBackquote,
'\\': KeyCodeBackslash,
'\b': KeyCodeBackspace,
'[': KeyCodeBracketLeft,
']': KeyCodeBracketRight,
',': KeyCodeComma,
'\x7f': KeyCodeDelete,
'0': KeyCodeDigit0,
'1': KeyCodeDigit1,
'2': KeyCodeDigit2,
'3': KeyCodeDigit3,
'4': KeyCodeDigit4,
'5': KeyCodeDigit5,
'6': KeyCodeDigit6,
'7': KeyCodeDigit7,
'8': KeyCodeDigit8,
'9': KeyCodeDigit9,
'\n': KeyCodeEnter,
'=': KeyCodeEqual,
'\x1b': KeyCodeEscape,
'-': KeyCodeMinus,
'.': KeyCodePeriod,
'\'': KeyCodeQuote,
';': KeyCodeSemicolon,
'/': KeyCodeSlash,
' ': KeyCodeSpace,
'\t': KeyCodeTab,
}
var ShiftedAsciiToKeyCodeMap = map[rune]KeyCode{
'A': KeyCodeA,
'B': KeyCodeB,
'C': KeyCodeC,
'D': KeyCodeD,
'E': KeyCodeE,
'F': KeyCodeF,
'G': KeyCodeG,
'H': KeyCodeH,
'I': KeyCodeI,
'J': KeyCodeJ,
'K': KeyCodeK,
'L': KeyCodeL,
'M': KeyCodeM,
'N': KeyCodeN,
'O': KeyCodeO,
'P': KeyCodeP,
'Q': KeyCodeQ,
'R': KeyCodeR,
'S': KeyCodeS,
'T': KeyCodeT,
'U': KeyCodeU,
'V': KeyCodeV,
'W': KeyCodeW,
'X': KeyCodeX,
'Y': KeyCodeY,
'Z': KeyCodeZ,
'~': KeyCodeBackquote,
'|': KeyCodeBackslash,
'\b': KeyCodeBackspace,
'{': KeyCodeBracketLeft,
'}': KeyCodeBracketRight,
'<': KeyCodeComma,
'\x7f': KeyCodeDelete,
')': KeyCodeDigit0,
'!': KeyCodeDigit1,
'@': KeyCodeDigit2,
'#': KeyCodeDigit3,
'$': KeyCodeDigit4,
'%': KeyCodeDigit5,
'^': KeyCodeDigit6,
'&': KeyCodeDigit7,
'*': KeyCodeDigit8,
'(': KeyCodeDigit9,
'\n': KeyCodeEnter,
'+': KeyCodeEqual,
'\x1b': KeyCodeEscape,
'_': KeyCodeMinus,
'>': KeyCodePeriod,
'"': KeyCodeQuote,
':': KeyCodeSemicolon,
'?': KeyCodeSlash,
' ': KeyCodeSpace,
'\t': KeyCodeTab,
}