objc

NXInputManager+Types.h
Go to the documentation of this file.
1 
5 #pragma once
6 #include <stdint.h>
7 
9 // TYPES
10 
19 typedef enum {
21  NXInputStateOn = (1 << 0),
23  (1 << 1),
27  NXInputStateClick = (1 << 2),
32  (1 << 5),
33  NXInputStateRepeat = (1 << 6),
34  NXInputStateFunction = (1 << 7),
35  NXInputStateCapsLock = (1 << 8),
36  NXInputStateNumLock = (1 << 9),
37  NXInputStateScrollLock = (1 << 10),
38  NXInputStateLeftShift = (1 << 11),
39  NXInputStateRightShift = (1 << 12),
40  NXInputStateLeftMeta = (1 << 13),
42  (1 << 14),
43  NXInputStateLeftAlt = (1 << 15),
44  NXInputStateRightAlt = (1 << 16),
48  (1 << 19),
50  (1 << 20),
67 } NXInputState;
69 
71 // KEYCODES
72 
73 #define KEYCODE_NONE 0x0000
74 #define KEYCODE_ESC 0x0001
75 #define KEYCODE_1 0x0002
76 #define KEYCODE_2 0x0003
77 #define KEYCODE_3 0x0004
78 #define KEYCODE_4 0x0005
79 #define KEYCODE_5 0x0006
80 #define KEYCODE_6 0x0007
81 #define KEYCODE_7 0x0008
82 #define KEYCODE_8 0x0009
83 #define KEYCODE_9 0x000A
84 #define KEYCODE_0 0x000B
85 #define KEYCODE_MINUS 0x000C
86 #define KEYCODE_EQUAL 0x000D
87 #define KEYCODE_BACKSPACE 0x000E
88 #define KEYCODE_TAB 0x000F
89 #define KEYCODE_Q 0x0010
90 #define KEYCODE_W 0x0011
91 #define KEYCODE_E 0x0012
92 #define KEYCODE_R 0x0013
93 #define KEYCODE_T 0x0014
94 #define KEYCODE_Y 0x0015
95 #define KEYCODE_U 0x0016
96 #define KEYCODE_I 0x0017
97 #define KEYCODE_O 0x0018
98 #define KEYCODE_P 0x0019
99 #define KEYCODE_LEFTBRACE 0x001A
100 #define KEYCODE_RIGHTBRACE 0x001B
101 #define KEYCODE_ENTER 0x001C
102 #define KEYCODE_LEFTCTRL 0x001D
103 #define KEYCODE_A 0x001E
104 #define KEYCODE_S 0x001F
105 #define KEYCODE_D 0x0020
106 #define KEYCODE_F 0x0021
107 #define KEYCODE_G 0x0022
108 #define KEYCODE_H 0x0023
109 #define KEYCODE_J 0x0024
110 #define KEYCODE_K 0x0025
111 #define KEYCODE_L 0x0026
112 #define KEYCODE_SEMICOLON 0x0027
113 #define KEYCODE_APOSTROPHE 0x0028
114 #define KEYCODE_GRAVE 0x0029
115 #define KEYCODE_LEFTSHIFT 0x002A
116 #define KEYCODE_BACKSLASH 0x002B
117 #define KEYCODE_Z 0x002C
118 #define KEYCODE_X 0x002D
119 #define KEYCODE_C 0x002E
120 #define KEYCODE_V 0x002F
121 #define KEYCODE_B 0x0030
122 #define KEYCODE_N 0x0031
123 #define KEYCODE_M 0x0032
124 #define KEYCODE_COMMA 0x0033
125 #define KEYCODE_DOT 0x0034
126 #define KEYCODE_SLASH 0x0035
127 #define KEYCODE_RIGHTSHIFT 0x0036
128 #define KEYCODE_KPASTERISK 0x0037
129 #define KEYCODE_LEFTALT 0x0038
130 #define KEYCODE_SPACE 0x0039
131 #define KEYCODE_CAPSLOCK 0x003A
132 #define KEYCODE_F1 0x003B
133 #define KEYCODE_F2 0x003C
134 #define KEYCODE_F3 0x003D
135 #define KEYCODE_F4 0x003E
136 #define KEYCODE_F5 0x003F
137 #define KEYCODE_F6 0x0040
138 #define KEYCODE_F7 0x0041
139 #define KEYCODE_F8 0x0042
140 #define KEYCODE_F9 0x0043
141 #define KEYCODE_F10 0x0044
142 #define KEYCODE_NUMLOCK 0x0045
143 #define KEYCODE_SCROLLLOCK 0x0046
144 #define KEYCODE_KP7 0x0047
145 #define KEYCODE_KP8 0x0048
146 #define KEYCODE_KP9 0x0049
147 #define KEYCODE_KPMINUS 0x004A
148 #define KEYCODE_KP4 0x004B
149 #define KEYCODE_KP5 0x004C
150 #define KEYCODE_KP6 0x004D
151 #define KEYCODE_KPPLUS 0x004E
152 #define KEYCODE_KP1 0x004F
153 #define KEYCODE_KP2 0x0050
154 #define KEYCODE_KP3 0x0051
155 #define KEYCODE_KP0 0x0052
156 #define KEYCODE_KPDOT 0x0053
157 #define KEYCODE_F11 0x0057
158 #define KEYCODE_F12 0x0058
159 #define KEYCODE_KPENTER 0x0060
160 #define KEYCODE_RIGHTCTRL 0x0061
161 #define KEYCODE_KPSLASH 0x0062
162 #define KEYCODE_SYSRQ 0x0063
163 #define KEYCODE_RIGHTALT 0x0064
164 #define KEYCODE_LINEFEED 0x0065
165 #define KEYCODE_HOME 0x0066
166 #define KEYCODE_UP 0x0067
167 #define KEYCODE_PAGEUP 0x0068
168 #define KEYCODE_LEFT 0x0069
169 #define KEYCODE_RIGHT 0x006A
170 #define KEYCODE_END 0x006B
171 #define KEYCODE_DOWN 0x006C
172 #define KEYCODE_PAGEDOWN 0x006D
173 #define KEYCODE_INSERT 0x006E
174 #define KEYCODE_DELETE 0x006F
175 #define KEYCODE_MACRO 0x0070
176 #define KEYCODE_MUTE 0x0071
177 #define KEYCODE_VOLUMEDOWN 0x0072
178 #define KEYCODE_VOLUMEUP 0x0073
179 #define KEYCODE_POWER 0x0074
180 #define KEYCODE_KPEQUAL 0x0075
181 #define KEYCODE_KPPLUSMINUS 0x0076
182 #define KEYCODE_KPCOMMA 0x0079
183 #define KEYCODE_LEFTMETA 0x007D
184 #define KEYCODE_RIGHTMETA 0x007E
185 #define KEYCODE_SLEEP 0x008E
186 #define KEYCODE_WAKEUP 0x008F
187 #define KEYCODE_KPLEFTPAREN 0x00B3
188 #define KEYCODE_KPRIGHTPAREN 0x00B4
189 #define KEYCODE_F13 0x00B7
190 #define KEYCODE_F14 0x00B8
191 #define KEYCODE_F15 0x00B9
192 #define KEYCODE_F16 0x00BA
193 #define KEYCODE_F17 0x00BB
194 #define KEYCODE_F18 0x00BC
195 #define KEYCODE_F19 0x00BD
196 #define KEYCODE_F20 0x00BE
197 #define KEYCODE_F21 0x00BF
198 #define KEYCODE_F22 0x00C0
199 #define KEYCODE_F23 0x00C1
200 #define KEYCODE_F24 0x00C2
201 #define KEYCODE_CLOSE 0x00CE
202 #define KEYCODE_PLAY 0x00CF
203 #define KEYCODE_PRINT 0x00D2
204 #define KEYCODE_SEARCH 0x00D9
205 #define KEYCODE_CANCEL 0x00DF
206 #define KEYCODE_BRIGHTNESS_DOWN 0x00E0
207 #define KEYCODE_BRIGHTNESS_UP 0x00E1
208 #define KEYCODE_BRIGHTNESS_CYCLE 0x00F3
209 #define KEYCODE_BRIGHTNESS_AUTO 0x00F4
210 #define KEYCODE_BTN0 0x0100
211 #define KEYCODE_BTN1 0x0101
212 #define KEYCODE_BTN2 0x0102
213 #define KEYCODE_BTN3 0x0103
214 #define KEYCODE_BTN4 0x0104
215 #define KEYCODE_BTN5 0x0105
216 #define KEYCODE_BTN6 0x0106
217 #define KEYCODE_BTN7 0x0107
218 #define KEYCODE_BTN8 0x0108
219 #define KEYCODE_BTN9 0x0109
220 #define KEYCODE_BTNLEFT 0x0110
221 #define KEYCODE_BTNRIGHT 0x0111
222 #define KEYCODE_BTNMIDDLE 0x0112
223 #define KEYCODE_BTNSIDE 0x0113
224 #define KEYCODE_BTNEXTRA 0x0114
225 #define KEYCODE_BTNTOUCH 0x014A
226 #define KEYCODE_EJECT 0x0200
227 #define KEYCODE_POWER_OFF 0x0201
228 #define KEYCODE_POWER_ON 0x0202
229 #define KEYCODE_INPUT_SELECT 0x0203
230 #define KEYCODE_INPUT_PC 0x0204
231 #define KEYCODE_INPUT_VIDEO1 0x0205
232 #define KEYCODE_INPUT_VIDEO2 0x0206
233 #define KEYCODE_INPUT_VIDEO3 0x0207
234 #define KEYCODE_INPUT_VIDEO4 0x0208
235 #define KEYCODE_INPUT_VIDEO5 0x0209
236 #define KEYCODE_INPUT_HDMI1 0x020A
237 #define KEYCODE_INPUT_HDMI2 0x020B
238 #define KEYCODE_INPUT_HDMI3 0x020C
239 #define KEYCODE_INPUT_HDMI4 0x020D
240 #define KEYCODE_INPUT_HDMI5 0x020E
241 #define KEYCODE_INPUT_AUX1 0x020F
242 #define KEYCODE_INPUT_AUX2 0x0210
243 #define KEYCODE_INPUT_AUX3 0x0211
244 #define KEYCODE_INPUT_AUX4 0x0212
245 #define KEYCODE_INPUT_AUX5 0x0213
246 #define KEYCODE_INPUT_CD 0x0214
247 #define KEYCODE_INPUT_DVD 0x0215
248 #define KEYCODE_INPUT_PHONO 0x0216
249 #define KEYCODE_INPUT_TAPE1 0x0217
250 #define KEYCODE_INPUT_TAPE2 0x0218
251 #define KEYCODE_INPUT_TUNER 0x0219
252 #define KEYCODE_INPUT_ANALOG 0x021A
253 #define KEYCODE_INPUT_DIGITAL 0x021B
254 #define KEYCODE_INPUT_INTERNET 0x021C
255 #define KEYCODE_INPUT_TEXT 0x021D
256 #define KEYCODE_INPUT_NEXT 0x021E
257 #define KEYCODE_INPUT_PREV 0x021F
258 #define KEYCODE_VIDEO_ASPECT 0x0220
259 #define KEYCODE_VIDEO_PIP 0x0221
260 #define KEYCODE_AUDIO_MONITOR 0x0222
261 #define KEYCODE_CLEAR 0x0223
262 #define KEYCODE_TIMER 0x0224
263 #define KEYCODE_CHANNEL_PREV 0x0225
264 #define KEYCODE_CHANNEL_GUIDE 0x0226
265 #define KEYCODE_RECORD 0x0227
266 #define KEYCODE_RECORD_SPEED 0x0228
267 #define KEYCODE_PLAY_SPEED 0x0229
268 #define KEYCODE_PLAY_MODE 0x022A
269 #define KEYCODE_REPLAY 0x022B
270 #define KEYCODE_DISPLAY 0x022C
271 #define KEYCODE_MENU 0x022D
272 #define KEYCODE_INFO 0x022E
273 #define KEYCODE_THUMBS_UP 0x022F
274 #define KEYCODE_THUMBS_DOWN 0x0230
275 #define KEYCODE_FAVOURITE 0x0231
276 #define KEYCODE_BUTTON_RED 0x0232
277 #define KEYCODE_BUTTON_GREEN 0x0233
278 #define KEYCODE_BUTTON_YELLOW 0x0234
279 #define KEYCODE_BUTTON_BLUE 0x0235
280 #define KEYCODE_SEARCH_LEFT 0x0236
281 #define KEYCODE_SEARCH_RIGHT 0x0237
282 #define KEYCODE_CHAPTER_NEXT 0x0238
283 #define KEYCODE_CHAPTER_PREV 0x0239
284 #define KEYCODE_NAV_SELECT 0x023A
285 #define KEYCODE_SUBTITLE_TOGGLE 0x023B
286 #define KEYCODE_SUBTITLE_ON 0x023C
287 #define KEYCODE_SUBTITLE_OFF 0x023D
288 #define KEYCODE_STOP 0x023E
289 #define KEYCODE_PAUSE 0x023F
290 #define KEYCODE_BROWSE 0x0240
291 #define KEYCODE_SHUFFLE 0x0241
292 #define KEYCODE_REPEAT 0x0242
293 #define KEYCODE_KEYPAD_10PLUS 0x0243
294 
296 // FUNCTION DECLARATIONS
297 
301 static inline NXInputState keycode_to_state(uint16_t keycode) {
302  switch (keycode) {
303  case KEYCODE_LEFTCTRL:
305  case KEYCODE_RIGHTCTRL:
307  case KEYCODE_LEFTSHIFT:
308  return NXInputStateLeftShift;
309  case KEYCODE_RIGHTSHIFT:
310  return NXInputStateRightShift;
311  case KEYCODE_LEFTALT:
312  return NXInputStateLeftAlt;
313  case KEYCODE_RIGHTALT:
314  return NXInputStateRightAlt;
315  case KEYCODE_LEFTMETA:
316  return NXInputStateLeftMeta;
317  case KEYCODE_RIGHTMETA:
318  return NXInputStateRightMeta;
319  case KEYCODE_CAPSLOCK:
320  return NXInputStateCapsLock;
321  case KEYCODE_NUMLOCK:
322  return NXInputStateNumLock;
323  case KEYCODE_SCROLLLOCK:
324  return NXInputStateScrollLock;
325  default:
326  return NXInputStateNone;
327  }
328 }
329 
333 static inline char keycode_to_char(uint16_t keycode) {
334  switch (keycode) {
335  case KEYCODE_1:
336  return '1';
337  case KEYCODE_2:
338  return '2';
339  case KEYCODE_3:
340  return '3';
341  case KEYCODE_4:
342  return '4';
343  case KEYCODE_5:
344  return '5';
345  case KEYCODE_6:
346  return '6';
347  case KEYCODE_7:
348  return '7';
349  case KEYCODE_8:
350  return '8';
351  case KEYCODE_9:
352  return '9';
353  case KEYCODE_0:
354  return '0';
355  case KEYCODE_MINUS:
356  return '-';
357  case KEYCODE_EQUAL:
358  return '=';
359  case KEYCODE_TAB:
360  return '\t';
361  case KEYCODE_Q:
362  return 'Q';
363  case KEYCODE_W:
364  return 'W';
365  case KEYCODE_E:
366  return 'E';
367  case KEYCODE_R:
368  return 'R';
369  case KEYCODE_T:
370  return 'T';
371  case KEYCODE_Y:
372  return 'Y';
373  case KEYCODE_U:
374  return 'U';
375  case KEYCODE_I:
376  return 'I';
377  case KEYCODE_O:
378  return 'O';
379  case KEYCODE_P:
380  return 'P';
381  case KEYCODE_LEFTBRACE:
382  return '[';
383  case KEYCODE_RIGHTBRACE:
384  return ']';
385  case KEYCODE_ENTER:
386  return '\n';
387  case KEYCODE_A:
388  return 'A';
389  case KEYCODE_S:
390  return 'S';
391  case KEYCODE_D:
392  return 'D';
393  case KEYCODE_F:
394  return 'F';
395  case KEYCODE_G:
396  return 'G';
397  case KEYCODE_H:
398  return 'H';
399  case KEYCODE_J:
400  return 'J';
401  case KEYCODE_K:
402  return 'K';
403  case KEYCODE_L:
404  return 'L';
405  case KEYCODE_SEMICOLON:
406  return ';';
407  case KEYCODE_APOSTROPHE:
408  return '\'';
409  case KEYCODE_GRAVE:
410  return '`';
411  case KEYCODE_BACKSLASH:
412  return '\\';
413  case KEYCODE_Z:
414  return 'Z';
415  case KEYCODE_X:
416  return 'X';
417  case KEYCODE_C:
418  return 'C';
419  case KEYCODE_V:
420  return 'V';
421  case KEYCODE_B:
422  return 'B';
423  case KEYCODE_N:
424  return 'N';
425  case KEYCODE_M:
426  return 'M';
427  case KEYCODE_COMMA:
428  return ',';
429  case KEYCODE_DOT:
430  return '.';
431  case KEYCODE_SLASH:
432  return '/';
433  case KEYCODE_KPASTERISK:
434  return '*';
435  case KEYCODE_SPACE:
436  return ' ';
437  case KEYCODE_KP7:
438  return '7';
439  case KEYCODE_KP8:
440  return '8';
441  case KEYCODE_KP9:
442  return '9';
443  case KEYCODE_KPMINUS:
444  return '-';
445  case KEYCODE_KP4:
446  return '4';
447  case KEYCODE_KP5:
448  return '5';
449  case KEYCODE_KP6:
450  return '6';
451  case KEYCODE_KPPLUS:
452  return '+';
453  case KEYCODE_KP1:
454  return '1';
455  case KEYCODE_KP2:
456  return '2';
457  case KEYCODE_KP3:
458  return '3';
459  case KEYCODE_KP0:
460  return '0';
461  case KEYCODE_KPDOT:
462  return '.';
463  case KEYCODE_KPENTER:
464  return '\n';
465  case KEYCODE_KPSLASH:
466  return '/';
467  case KEYCODE_LINEFEED:
468  return '\r';
469  case KEYCODE_KPCOMMA:
470  return ',';
471  case KEYCODE_KPLEFTPAREN:
472  return '(';
473  case KEYCODE_KPRIGHTPAREN:
474  return ')';
475  default:
476  return 0;
477  }
478 }
Left Meta (Command) modifier is active.
Scroll Lock state is active.
Left Shift modifier is active.
Convenience mask: either left or right Alt (Option).
Convenience mask: either left or right Shift.
A triple-click event was generated.
No input state set.
Alias for NXInputStateOn; used to indicate a rising edge.
A repeated key/button event (auto-repeat).
Convenience mask: either left or right Control.
Key/button is currently pressed (logical on).
A single click event was generated.
static NXInputState keycode_to_state(uint16_t keycode)
Convert a keycode to a control character.
Convenience mask: either left or right Meta (Command).
Right Shift modifier is active.
Num Lock state is active.
Right Meta (Command) modifier is active.
Key/button is currently released (logical off).
static char keycode_to_char(uint16_t keycode)
Convert a keycode to its one-byte character representation.
Convenience mask: either left or right Windows/Meta.
NXInputState
Input state flags used by the input manager and key handling.
Function key or mode modifier is active.
Left Control modifier is active.
Left Windows/Meta modifier is active.
Left Option/Alt modifier is active.
Caps Lock state is active.
Right Control modifier is active.
Alias for NXInputStateOff; used to indicate a falling edge.
Right Option/Alt modifier is active.
A double-click event was generated.
Right Windows/Meta modifier is active.
A long-press (long click) event was generated.