blob: 6d072a3ea54254a493d99bcf0520cfbd7aab49a4 [file] [log] [blame]
Michael Wright872db4f2014-04-22 15:03:51 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _LIBINPUT_INPUT_EVENT_LABELS_H
18#define _LIBINPUT_INPUT_EVENT_LABELS_H
19
20#include <input/Input.h>
21#include <android/keycodes.h>
22
23#define DEFINE_KEYCODE(key) { #key, AKEYCODE_##key }
24#define DEFINE_AXIS(axis) { #axis, AMOTION_EVENT_AXIS_##axis }
25#define DEFINE_LED(led) { #led, ALED_##led }
26#define DEFINE_FLAG(flag) { #flag, POLICY_FLAG_##flag }
27
28namespace android {
29
30template<typename T, size_t N>
31size_t size(T (&)[N]) { return N; }
32
33struct InputEventLabel {
34 const char *literal;
35 int value;
36};
37
38
39static const InputEventLabel KEYCODES[] = {
40 // NOTE: If you add a new keycode here you must also add it to several other files.
41 // Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.
42 DEFINE_KEYCODE(UNKNOWN),
43 DEFINE_KEYCODE(SOFT_LEFT),
44 DEFINE_KEYCODE(SOFT_RIGHT),
45 DEFINE_KEYCODE(HOME),
46 DEFINE_KEYCODE(BACK),
47 DEFINE_KEYCODE(CALL),
48 DEFINE_KEYCODE(ENDCALL),
49 DEFINE_KEYCODE(0),
50 DEFINE_KEYCODE(1),
51 DEFINE_KEYCODE(2),
52 DEFINE_KEYCODE(3),
53 DEFINE_KEYCODE(4),
54 DEFINE_KEYCODE(5),
55 DEFINE_KEYCODE(6),
56 DEFINE_KEYCODE(7),
57 DEFINE_KEYCODE(8),
58 DEFINE_KEYCODE(9),
59 DEFINE_KEYCODE(STAR),
60 DEFINE_KEYCODE(POUND),
61 DEFINE_KEYCODE(DPAD_UP),
62 DEFINE_KEYCODE(DPAD_DOWN),
63 DEFINE_KEYCODE(DPAD_LEFT),
64 DEFINE_KEYCODE(DPAD_RIGHT),
65 DEFINE_KEYCODE(DPAD_CENTER),
66 DEFINE_KEYCODE(VOLUME_UP),
67 DEFINE_KEYCODE(VOLUME_DOWN),
68 DEFINE_KEYCODE(POWER),
69 DEFINE_KEYCODE(CAMERA),
70 DEFINE_KEYCODE(CLEAR),
71 DEFINE_KEYCODE(A),
72 DEFINE_KEYCODE(B),
73 DEFINE_KEYCODE(C),
74 DEFINE_KEYCODE(D),
75 DEFINE_KEYCODE(E),
76 DEFINE_KEYCODE(F),
77 DEFINE_KEYCODE(G),
78 DEFINE_KEYCODE(H),
79 DEFINE_KEYCODE(I),
80 DEFINE_KEYCODE(J),
81 DEFINE_KEYCODE(K),
82 DEFINE_KEYCODE(L),
83 DEFINE_KEYCODE(M),
84 DEFINE_KEYCODE(N),
85 DEFINE_KEYCODE(O),
86 DEFINE_KEYCODE(P),
87 DEFINE_KEYCODE(Q),
88 DEFINE_KEYCODE(R),
89 DEFINE_KEYCODE(S),
90 DEFINE_KEYCODE(T),
91 DEFINE_KEYCODE(U),
92 DEFINE_KEYCODE(V),
93 DEFINE_KEYCODE(W),
94 DEFINE_KEYCODE(X),
95 DEFINE_KEYCODE(Y),
96 DEFINE_KEYCODE(Z),
97 DEFINE_KEYCODE(COMMA),
98 DEFINE_KEYCODE(PERIOD),
99 DEFINE_KEYCODE(ALT_LEFT),
100 DEFINE_KEYCODE(ALT_RIGHT),
101 DEFINE_KEYCODE(SHIFT_LEFT),
102 DEFINE_KEYCODE(SHIFT_RIGHT),
103 DEFINE_KEYCODE(TAB),
104 DEFINE_KEYCODE(SPACE),
105 DEFINE_KEYCODE(SYM),
106 DEFINE_KEYCODE(EXPLORER),
107 DEFINE_KEYCODE(ENVELOPE),
108 DEFINE_KEYCODE(ENTER),
109 DEFINE_KEYCODE(DEL),
110 DEFINE_KEYCODE(GRAVE),
111 DEFINE_KEYCODE(MINUS),
112 DEFINE_KEYCODE(EQUALS),
113 DEFINE_KEYCODE(LEFT_BRACKET),
114 DEFINE_KEYCODE(RIGHT_BRACKET),
115 DEFINE_KEYCODE(BACKSLASH),
116 DEFINE_KEYCODE(SEMICOLON),
117 DEFINE_KEYCODE(APOSTROPHE),
118 DEFINE_KEYCODE(SLASH),
119 DEFINE_KEYCODE(AT),
120 DEFINE_KEYCODE(NUM),
121 DEFINE_KEYCODE(HEADSETHOOK),
122 DEFINE_KEYCODE(FOCUS), // *Camera* focus
123 DEFINE_KEYCODE(PLUS),
124 DEFINE_KEYCODE(MENU),
125 DEFINE_KEYCODE(NOTIFICATION),
126 DEFINE_KEYCODE(SEARCH),
127 DEFINE_KEYCODE(MEDIA_PLAY_PAUSE),
128 DEFINE_KEYCODE(MEDIA_STOP),
129 DEFINE_KEYCODE(MEDIA_NEXT),
130 DEFINE_KEYCODE(MEDIA_PREVIOUS),
131 DEFINE_KEYCODE(MEDIA_REWIND),
132 DEFINE_KEYCODE(MEDIA_FAST_FORWARD),
133 DEFINE_KEYCODE(MUTE),
134 DEFINE_KEYCODE(PAGE_UP),
135 DEFINE_KEYCODE(PAGE_DOWN),
136 DEFINE_KEYCODE(PICTSYMBOLS),
137 DEFINE_KEYCODE(SWITCH_CHARSET),
138 DEFINE_KEYCODE(BUTTON_A),
139 DEFINE_KEYCODE(BUTTON_B),
140 DEFINE_KEYCODE(BUTTON_C),
141 DEFINE_KEYCODE(BUTTON_X),
142 DEFINE_KEYCODE(BUTTON_Y),
143 DEFINE_KEYCODE(BUTTON_Z),
144 DEFINE_KEYCODE(BUTTON_L1),
145 DEFINE_KEYCODE(BUTTON_R1),
146 DEFINE_KEYCODE(BUTTON_L2),
147 DEFINE_KEYCODE(BUTTON_R2),
148 DEFINE_KEYCODE(BUTTON_THUMBL),
149 DEFINE_KEYCODE(BUTTON_THUMBR),
150 DEFINE_KEYCODE(BUTTON_START),
151 DEFINE_KEYCODE(BUTTON_SELECT),
152 DEFINE_KEYCODE(BUTTON_MODE),
153 DEFINE_KEYCODE(ESCAPE),
154 DEFINE_KEYCODE(FORWARD_DEL),
155 DEFINE_KEYCODE(CTRL_LEFT),
156 DEFINE_KEYCODE(CTRL_RIGHT),
157 DEFINE_KEYCODE(CAPS_LOCK),
158 DEFINE_KEYCODE(SCROLL_LOCK),
159 DEFINE_KEYCODE(META_LEFT),
160 DEFINE_KEYCODE(META_RIGHT),
161 DEFINE_KEYCODE(FUNCTION),
162 DEFINE_KEYCODE(SYSRQ),
163 DEFINE_KEYCODE(BREAK),
164 DEFINE_KEYCODE(MOVE_HOME),
165 DEFINE_KEYCODE(MOVE_END),
166 DEFINE_KEYCODE(INSERT),
167 DEFINE_KEYCODE(FORWARD),
168 DEFINE_KEYCODE(MEDIA_PLAY),
169 DEFINE_KEYCODE(MEDIA_PAUSE),
170 DEFINE_KEYCODE(MEDIA_CLOSE),
171 DEFINE_KEYCODE(MEDIA_EJECT),
172 DEFINE_KEYCODE(MEDIA_RECORD),
173 DEFINE_KEYCODE(F1),
174 DEFINE_KEYCODE(F2),
175 DEFINE_KEYCODE(F3),
176 DEFINE_KEYCODE(F4),
177 DEFINE_KEYCODE(F5),
178 DEFINE_KEYCODE(F6),
179 DEFINE_KEYCODE(F7),
180 DEFINE_KEYCODE(F8),
181 DEFINE_KEYCODE(F9),
182 DEFINE_KEYCODE(F10),
183 DEFINE_KEYCODE(F11),
184 DEFINE_KEYCODE(F12),
185 DEFINE_KEYCODE(NUM_LOCK),
186 DEFINE_KEYCODE(NUMPAD_0),
187 DEFINE_KEYCODE(NUMPAD_1),
188 DEFINE_KEYCODE(NUMPAD_2),
189 DEFINE_KEYCODE(NUMPAD_3),
190 DEFINE_KEYCODE(NUMPAD_4),
191 DEFINE_KEYCODE(NUMPAD_5),
192 DEFINE_KEYCODE(NUMPAD_6),
193 DEFINE_KEYCODE(NUMPAD_7),
194 DEFINE_KEYCODE(NUMPAD_8),
195 DEFINE_KEYCODE(NUMPAD_9),
196 DEFINE_KEYCODE(NUMPAD_DIVIDE),
197 DEFINE_KEYCODE(NUMPAD_MULTIPLY),
198 DEFINE_KEYCODE(NUMPAD_SUBTRACT),
199 DEFINE_KEYCODE(NUMPAD_ADD),
200 DEFINE_KEYCODE(NUMPAD_DOT),
201 DEFINE_KEYCODE(NUMPAD_COMMA),
202 DEFINE_KEYCODE(NUMPAD_ENTER),
203 DEFINE_KEYCODE(NUMPAD_EQUALS),
204 DEFINE_KEYCODE(NUMPAD_LEFT_PAREN),
205 DEFINE_KEYCODE(NUMPAD_RIGHT_PAREN),
206 DEFINE_KEYCODE(VOLUME_MUTE),
207 DEFINE_KEYCODE(INFO),
208 DEFINE_KEYCODE(CHANNEL_UP),
209 DEFINE_KEYCODE(CHANNEL_DOWN),
210 DEFINE_KEYCODE(ZOOM_IN),
211 DEFINE_KEYCODE(ZOOM_OUT),
212 DEFINE_KEYCODE(TV),
213 DEFINE_KEYCODE(WINDOW),
214 DEFINE_KEYCODE(GUIDE),
215 DEFINE_KEYCODE(DVR),
216 DEFINE_KEYCODE(BOOKMARK),
217 DEFINE_KEYCODE(CAPTIONS),
218 DEFINE_KEYCODE(SETTINGS),
219 DEFINE_KEYCODE(TV_POWER),
220 DEFINE_KEYCODE(TV_INPUT),
221 DEFINE_KEYCODE(STB_POWER),
222 DEFINE_KEYCODE(STB_INPUT),
223 DEFINE_KEYCODE(AVR_POWER),
224 DEFINE_KEYCODE(AVR_INPUT),
225 DEFINE_KEYCODE(PROG_RED),
226 DEFINE_KEYCODE(PROG_GREEN),
227 DEFINE_KEYCODE(PROG_YELLOW),
228 DEFINE_KEYCODE(PROG_BLUE),
229 DEFINE_KEYCODE(APP_SWITCH),
230 DEFINE_KEYCODE(BUTTON_1),
231 DEFINE_KEYCODE(BUTTON_2),
232 DEFINE_KEYCODE(BUTTON_3),
233 DEFINE_KEYCODE(BUTTON_4),
234 DEFINE_KEYCODE(BUTTON_5),
235 DEFINE_KEYCODE(BUTTON_6),
236 DEFINE_KEYCODE(BUTTON_7),
237 DEFINE_KEYCODE(BUTTON_8),
238 DEFINE_KEYCODE(BUTTON_9),
239 DEFINE_KEYCODE(BUTTON_10),
240 DEFINE_KEYCODE(BUTTON_11),
241 DEFINE_KEYCODE(BUTTON_12),
242 DEFINE_KEYCODE(BUTTON_13),
243 DEFINE_KEYCODE(BUTTON_14),
244 DEFINE_KEYCODE(BUTTON_15),
245 DEFINE_KEYCODE(BUTTON_16),
246 DEFINE_KEYCODE(LANGUAGE_SWITCH),
247 DEFINE_KEYCODE(MANNER_MODE),
248 DEFINE_KEYCODE(3D_MODE),
249 DEFINE_KEYCODE(CONTACTS),
250 DEFINE_KEYCODE(CALENDAR),
251 DEFINE_KEYCODE(MUSIC),
252 DEFINE_KEYCODE(CALCULATOR),
253 DEFINE_KEYCODE(ZENKAKU_HANKAKU),
254 DEFINE_KEYCODE(EISU),
255 DEFINE_KEYCODE(MUHENKAN),
256 DEFINE_KEYCODE(HENKAN),
257 DEFINE_KEYCODE(KATAKANA_HIRAGANA),
258 DEFINE_KEYCODE(YEN),
259 DEFINE_KEYCODE(RO),
260 DEFINE_KEYCODE(KANA),
261 DEFINE_KEYCODE(ASSIST),
262 DEFINE_KEYCODE(BRIGHTNESS_DOWN),
263 DEFINE_KEYCODE(BRIGHTNESS_UP),
264 DEFINE_KEYCODE(MEDIA_AUDIO_TRACK),
265 DEFINE_KEYCODE(SLEEP),
266 DEFINE_KEYCODE(WAKEUP),
Tim Kilbourn6b4e02f2014-04-14 15:37:20 -0700267 DEFINE_KEYCODE(PAIRING),
Jinsuk Kimbc4e3962014-05-14 15:36:48 +0900268 DEFINE_KEYCODE(MEDIA_TOP_MENU),
269 DEFINE_KEYCODE(11),
270 DEFINE_KEYCODE(12),
271 DEFINE_KEYCODE(LAST_CHANNEL),
272 DEFINE_KEYCODE(TV_DATA_SERVICE),
Michael Wright51409572014-08-21 19:09:49 -0700273 DEFINE_KEYCODE(VOICE_ASSIST),
ASAZU, Hideki5b3dc862014-08-27 18:06:31 +0900274 DEFINE_KEYCODE(TV_RADIO_SERVICE),
275 DEFINE_KEYCODE(TV_TELETEXT),
276 DEFINE_KEYCODE(TV_NUMBER_ENTRY),
277 DEFINE_KEYCODE(TV_TERRESTRIAL_ANALOG),
278 DEFINE_KEYCODE(TV_TERRESTRIAL_DIGITAL),
279 DEFINE_KEYCODE(TV_SATELLITE),
280 DEFINE_KEYCODE(TV_SATELLITE_BS),
281 DEFINE_KEYCODE(TV_SATELLITE_CS),
282 DEFINE_KEYCODE(TV_SATELLITE_SERVICE),
283 DEFINE_KEYCODE(TV_NETWORK),
284 DEFINE_KEYCODE(TV_ANTENNA_CABLE),
285 DEFINE_KEYCODE(TV_INPUT_HDMI_1),
286 DEFINE_KEYCODE(TV_INPUT_HDMI_2),
287 DEFINE_KEYCODE(TV_INPUT_HDMI_3),
288 DEFINE_KEYCODE(TV_INPUT_HDMI_4),
289 DEFINE_KEYCODE(TV_INPUT_COMPOSITE_1),
290 DEFINE_KEYCODE(TV_INPUT_COMPOSITE_2),
291 DEFINE_KEYCODE(TV_INPUT_COMPONENT_1),
292 DEFINE_KEYCODE(TV_INPUT_COMPONENT_2),
293 DEFINE_KEYCODE(TV_INPUT_VGA_1),
294 DEFINE_KEYCODE(TV_AUDIO_DESCRIPTION),
295 DEFINE_KEYCODE(TV_AUDIO_DESCRIPTION_MIX_UP),
296 DEFINE_KEYCODE(TV_AUDIO_DESCRIPTION_MIX_DOWN),
297 DEFINE_KEYCODE(TV_ZOOM_MODE),
298 DEFINE_KEYCODE(TV_CONTENTS_MENU),
299 DEFINE_KEYCODE(TV_MEDIA_CONTEXT_MENU),
300 DEFINE_KEYCODE(TV_TIMER_PROGRAMMING),
301 DEFINE_KEYCODE(HELP),
Joseph Coopere50376e2015-04-15 16:45:18 -0700302 DEFINE_KEYCODE(NAVIGATE_PREVIOUS),
303 DEFINE_KEYCODE(NAVIGATE_NEXT),
304 DEFINE_KEYCODE(NAVIGATE_IN),
305 DEFINE_KEYCODE(NAVIGATE_OUT),
Anthony Hugh887b00d2015-06-23 10:49:05 -0700306 DEFINE_KEYCODE(STEM_PRIMARY),
307 DEFINE_KEYCODE(STEM_1),
308 DEFINE_KEYCODE(STEM_2),
309 DEFINE_KEYCODE(STEM_3),
David Stevens01ed1862015-07-31 11:08:36 -0700310 DEFINE_KEYCODE(DPAD_UP_LEFT),
311 DEFINE_KEYCODE(DPAD_DOWN_LEFT),
312 DEFINE_KEYCODE(DPAD_UP_RIGHT),
313 DEFINE_KEYCODE(DPAD_DOWN_RIGHT),
Michael Wrightd0aa3302015-08-06 15:17:31 +0100314 DEFINE_KEYCODE(MEDIA_SKIP_FORWARD),
315 DEFINE_KEYCODE(MEDIA_SKIP_BACKWARD),
316 DEFINE_KEYCODE(MEDIA_STEP_FORWARD),
317 DEFINE_KEYCODE(MEDIA_STEP_BACKWARD),
Nick Armstrong-Crewsa180e852015-09-02 13:00:52 -0700318 DEFINE_KEYCODE(SOFT_SLEEP),
Michael Wrighte30f7e12015-10-21 18:09:02 +0100319 DEFINE_KEYCODE(CUT),
320 DEFINE_KEYCODE(COPY),
321 DEFINE_KEYCODE(PASTE),
Jim Millere7a57d12016-06-22 15:58:31 -0700322 DEFINE_KEYCODE(SYSTEM_NAVIGATION_UP),
323 DEFINE_KEYCODE(SYSTEM_NAVIGATION_DOWN),
324 DEFINE_KEYCODE(SYSTEM_NAVIGATION_LEFT),
325 DEFINE_KEYCODE(SYSTEM_NAVIGATION_RIGHT),
Sujith Ramakrishnan73423912017-07-18 18:54:15 -0700326 DEFINE_KEYCODE(ALL_APPS),
Yuichiro Hanada346dbe12018-01-15 22:33:41 +0900327 DEFINE_KEYCODE(REFRESH),
Michael Wright872db4f2014-04-22 15:03:51 -0700328
Yi Kong5bed83b2018-07-17 12:53:47 -0700329 { nullptr, 0 }
Michael Wright872db4f2014-04-22 15:03:51 -0700330};
331
332static const InputEventLabel AXES[] = {
333 DEFINE_AXIS(X),
334 DEFINE_AXIS(Y),
335 DEFINE_AXIS(PRESSURE),
336 DEFINE_AXIS(SIZE),
337 DEFINE_AXIS(TOUCH_MAJOR),
338 DEFINE_AXIS(TOUCH_MINOR),
339 DEFINE_AXIS(TOOL_MAJOR),
340 DEFINE_AXIS(TOOL_MINOR),
341 DEFINE_AXIS(ORIENTATION),
342 DEFINE_AXIS(VSCROLL),
343 DEFINE_AXIS(HSCROLL),
344 DEFINE_AXIS(Z),
345 DEFINE_AXIS(RX),
346 DEFINE_AXIS(RY),
347 DEFINE_AXIS(RZ),
348 DEFINE_AXIS(HAT_X),
349 DEFINE_AXIS(HAT_Y),
350 DEFINE_AXIS(LTRIGGER),
351 DEFINE_AXIS(RTRIGGER),
352 DEFINE_AXIS(THROTTLE),
353 DEFINE_AXIS(RUDDER),
354 DEFINE_AXIS(WHEEL),
355 DEFINE_AXIS(GAS),
356 DEFINE_AXIS(BRAKE),
357 DEFINE_AXIS(DISTANCE),
358 DEFINE_AXIS(TILT),
359 DEFINE_AXIS(GENERIC_1),
360 DEFINE_AXIS(GENERIC_2),
361 DEFINE_AXIS(GENERIC_3),
362 DEFINE_AXIS(GENERIC_4),
363 DEFINE_AXIS(GENERIC_5),
364 DEFINE_AXIS(GENERIC_6),
365 DEFINE_AXIS(GENERIC_7),
366 DEFINE_AXIS(GENERIC_8),
367 DEFINE_AXIS(GENERIC_9),
368 DEFINE_AXIS(GENERIC_10),
369 DEFINE_AXIS(GENERIC_11),
370 DEFINE_AXIS(GENERIC_12),
371 DEFINE_AXIS(GENERIC_13),
372 DEFINE_AXIS(GENERIC_14),
373 DEFINE_AXIS(GENERIC_15),
374 DEFINE_AXIS(GENERIC_16),
375
376 // NOTE: If you add a new axis here you must also add it to several other files.
377 // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
Yi Kong5bed83b2018-07-17 12:53:47 -0700378 { nullptr, 0 }
Michael Wright872db4f2014-04-22 15:03:51 -0700379};
380
381static const InputEventLabel LEDS[] = {
382 DEFINE_LED(NUM_LOCK),
383 DEFINE_LED(CAPS_LOCK),
384 DEFINE_LED(SCROLL_LOCK),
385 DEFINE_LED(COMPOSE),
386 DEFINE_LED(KANA),
387 DEFINE_LED(SLEEP),
388 DEFINE_LED(SUSPEND),
389 DEFINE_LED(MUTE),
390 DEFINE_LED(MISC),
391 DEFINE_LED(MAIL),
392 DEFINE_LED(CHARGING),
393 DEFINE_LED(CONTROLLER_1),
394 DEFINE_LED(CONTROLLER_2),
395 DEFINE_LED(CONTROLLER_3),
396 DEFINE_LED(CONTROLLER_4),
397
398 // NOTE: If you add new LEDs here, you must also add them to Input.h
Yi Kong5bed83b2018-07-17 12:53:47 -0700399 { nullptr, 0 }
Michael Wright872db4f2014-04-22 15:03:51 -0700400};
401
402static const InputEventLabel FLAGS[] = {
Jeff Brown5a7d2f92014-05-20 17:27:38 -0700403 DEFINE_FLAG(VIRTUAL),
Michael Wright872db4f2014-04-22 15:03:51 -0700404 DEFINE_FLAG(FUNCTION),
Jeff Brownc9aa6282015-02-11 19:03:28 -0800405 DEFINE_FLAG(GESTURE),
Michael Wright872db4f2014-04-22 15:03:51 -0700406
Yi Kong5bed83b2018-07-17 12:53:47 -0700407 { nullptr, 0 }
Michael Wright872db4f2014-04-22 15:03:51 -0700408};
409
410static int lookupValueByLabel(const char* literal, const InputEventLabel *list) {
411 while (list->literal) {
412 if (strcmp(literal, list->literal) == 0) {
413 return list->value;
414 }
415 list++;
416 }
417 return list->value;
418}
419
420static const char* lookupLabelByValue(int value, const InputEventLabel* list) {
421 while (list->literal) {
422 if (list->value == value) {
423 return list->literal;
424 }
425 list++;
426 }
Yi Kong5bed83b2018-07-17 12:53:47 -0700427 return nullptr;
Michael Wright872db4f2014-04-22 15:03:51 -0700428}
429
Colin Cross1eadf8d2016-09-27 14:12:09 -0700430static inline int32_t getKeyCodeByLabel(const char* label) {
Michael Wright872db4f2014-04-22 15:03:51 -0700431 return int32_t(lookupValueByLabel(label, KEYCODES));
432}
433
Colin Cross1eadf8d2016-09-27 14:12:09 -0700434static inline const char* getLabelByKeyCode(int32_t keyCode) {
435 if (keyCode >= 0 && keyCode < static_cast<int32_t>(size(KEYCODES))) {
Michael Wright872db4f2014-04-22 15:03:51 -0700436 return KEYCODES[keyCode].literal;
437 }
Yi Kong5bed83b2018-07-17 12:53:47 -0700438 return nullptr;
Michael Wright872db4f2014-04-22 15:03:51 -0700439}
440
Colin Cross1eadf8d2016-09-27 14:12:09 -0700441static inline uint32_t getKeyFlagByLabel(const char* label) {
Michael Wright872db4f2014-04-22 15:03:51 -0700442 return uint32_t(lookupValueByLabel(label, FLAGS));
443}
444
Colin Cross1eadf8d2016-09-27 14:12:09 -0700445static inline int32_t getAxisByLabel(const char* label) {
Michael Wright872db4f2014-04-22 15:03:51 -0700446 return int32_t(lookupValueByLabel(label, AXES));
447}
448
Colin Cross1eadf8d2016-09-27 14:12:09 -0700449static inline const char* getAxisLabel(int32_t axisId) {
Michael Wright872db4f2014-04-22 15:03:51 -0700450 return lookupLabelByValue(axisId, AXES);
451}
452
Colin Cross1eadf8d2016-09-27 14:12:09 -0700453static inline int32_t getLedByLabel(const char* label) {
Michael Wright872db4f2014-04-22 15:03:51 -0700454 return int32_t(lookupValueByLabel(label, LEDS));
455}
456
457
458} // namespace android
459#endif // _LIBINPUT_INPUT_EVENT_LABELS_H