• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "key_event.h"
17 #include "hilog/log.h"
18 
19 using namespace OHOS::HiviewDFX;
20 namespace OHOS {
21 namespace MMI {
22 namespace {
23     constexpr HiLogLabel LABEL = { LOG_CORE, 0xD002800, "KeyEvent" };
24 }
25 const int32_t KeyEvent::KEYCODE_FN = 0;
26 const int32_t KeyEvent::KEYCODE_UNKNOWN = -1;
27 const int32_t KeyEvent::KEYCODE_HOME = 1;
28 const int32_t KeyEvent::KEYCODE_BACK = 2;
29 const int32_t KeyEvent::KEYCODE_CALL = 3;
30 const int32_t KeyEvent::KEYCODE_ENDCALL = 4;
31 const int32_t KeyEvent::KEYCODE_CLEAR = 5;
32 const int32_t KeyEvent::KEYCODE_HEADSETHOOK = 6;
33 const int32_t KeyEvent::KEYCODE_FOCUS = 7;
34 const int32_t KeyEvent::KEYCODE_NOTIFICATION = 8;
35 const int32_t KeyEvent::KEYCODE_SEARCH = 9;
36 const int32_t KeyEvent::KEYCODE_MEDIA_PLAY_PAUSE = 10;
37 const int32_t KeyEvent::KEYCODE_MEDIA_STOP = 11;
38 const int32_t KeyEvent::KEYCODE_MEDIA_NEXT = 12;
39 const int32_t KeyEvent::KEYCODE_MEDIA_PREVIOUS = 13;
40 const int32_t KeyEvent::KEYCODE_MEDIA_REWIND = 14;
41 const int32_t KeyEvent::KEYCODE_MEDIA_FAST_FORWARD = 15;
42 const int32_t KeyEvent::KEYCODE_VOLUME_UP = 16;
43 const int32_t KeyEvent::KEYCODE_VOLUME_DOWN = 17;
44 const int32_t KeyEvent::KEYCODE_POWER = 18;
45 const int32_t KeyEvent::KEYCODE_CAMERA = 19;
46 const int32_t KeyEvent::KEYCODE_VOICE_ASSISTANT = 20;
47 const int32_t KeyEvent::KEYCODE_CUSTOM1 = 21;
48 const int32_t KeyEvent::KEYCODE_VOLUME_MUTE = 22;
49 const int32_t KeyEvent::KEYCODE_MUTE = 23;
50 const int32_t KeyEvent::KEYCODE_BRIGHTNESS_UP = 40;
51 const int32_t KeyEvent::KEYCODE_BRIGHTNESS_DOWN = 41;
52 const int32_t KeyEvent::KEYCODE_WEAR_1 = 1001;
53 const int32_t KeyEvent::KEYCODE_0 = 2000;
54 const int32_t KeyEvent::KEYCODE_1 = 2001;
55 const int32_t KeyEvent::KEYCODE_2 = 2002;
56 const int32_t KeyEvent::KEYCODE_3 = 2003;
57 const int32_t KeyEvent::KEYCODE_4 = 2004;
58 const int32_t KeyEvent::KEYCODE_5 = 2005;
59 const int32_t KeyEvent::KEYCODE_6 = 2006;
60 const int32_t KeyEvent::KEYCODE_7 = 2007;
61 const int32_t KeyEvent::KEYCODE_8 = 2008;
62 const int32_t KeyEvent::KEYCODE_9 = 2009;
63 const int32_t KeyEvent::KEYCODE_STAR = 2010;
64 const int32_t KeyEvent::KEYCODE_POUND = 2011;
65 const int32_t KeyEvent::KEYCODE_DPAD_UP = 2012;
66 const int32_t KeyEvent::KEYCODE_DPAD_DOWN = 2013;
67 const int32_t KeyEvent::KEYCODE_DPAD_LEFT = 2014;
68 const int32_t KeyEvent::KEYCODE_DPAD_RIGHT = 2015;
69 const int32_t KeyEvent::KEYCODE_DPAD_CENTER = 2016;
70 const int32_t KeyEvent::KEYCODE_A = 2017;
71 const int32_t KeyEvent::KEYCODE_B = 2018;
72 const int32_t KeyEvent::KEYCODE_C = 2019;
73 const int32_t KeyEvent::KEYCODE_D = 2020;
74 const int32_t KeyEvent::KEYCODE_E = 2021;
75 const int32_t KeyEvent::KEYCODE_F = 2022;
76 const int32_t KeyEvent::KEYCODE_G = 2023;
77 const int32_t KeyEvent::KEYCODE_H = 2024;
78 const int32_t KeyEvent::KEYCODE_I = 2025;
79 const int32_t KeyEvent::KEYCODE_J = 2026;
80 const int32_t KeyEvent::KEYCODE_K = 2027;
81 const int32_t KeyEvent::KEYCODE_L = 2028;
82 const int32_t KeyEvent::KEYCODE_M = 2029;
83 const int32_t KeyEvent::KEYCODE_N = 2030;
84 const int32_t KeyEvent::KEYCODE_O = 2031;
85 const int32_t KeyEvent::KEYCODE_P = 2032;
86 const int32_t KeyEvent::KEYCODE_Q = 2033;
87 const int32_t KeyEvent::KEYCODE_R = 2034;
88 const int32_t KeyEvent::KEYCODE_S = 2035;
89 const int32_t KeyEvent::KEYCODE_T = 2036;
90 const int32_t KeyEvent::KEYCODE_U = 2037;
91 const int32_t KeyEvent::KEYCODE_V = 2038;
92 const int32_t KeyEvent::KEYCODE_W = 2039;
93 const int32_t KeyEvent::KEYCODE_X = 2040;
94 const int32_t KeyEvent::KEYCODE_Y = 2041;
95 const int32_t KeyEvent::KEYCODE_Z = 2042;
96 const int32_t KeyEvent::KEYCODE_COMMA = 2043;
97 const int32_t KeyEvent::KEYCODE_PERIOD = 2044;
98 const int32_t KeyEvent::KEYCODE_ALT_LEFT = 2045;
99 const int32_t KeyEvent::KEYCODE_ALT_RIGHT = 2046;
100 const int32_t KeyEvent::KEYCODE_SHIFT_LEFT = 2047;
101 const int32_t KeyEvent::KEYCODE_SHIFT_RIGHT = 2048;
102 const int32_t KeyEvent::KEYCODE_TAB = 2049;
103 const int32_t KeyEvent::KEYCODE_SPACE = 2050;
104 const int32_t KeyEvent::KEYCODE_SYM = 2051;
105 const int32_t KeyEvent::KEYCODE_EXPLORER = 2052;
106 const int32_t KeyEvent::KEYCODE_ENVELOPE = 2053;
107 const int32_t KeyEvent::KEYCODE_ENTER = 2054;
108 const int32_t KeyEvent::KEYCODE_DEL = 2055;
109 const int32_t KeyEvent::KEYCODE_GRAVE = 2056;
110 const int32_t KeyEvent::KEYCODE_MINUS = 2057;
111 const int32_t KeyEvent::KEYCODE_EQUALS = 2058;
112 const int32_t KeyEvent::KEYCODE_LEFT_BRACKET = 2059;
113 const int32_t KeyEvent::KEYCODE_RIGHT_BRACKET = 2060;
114 const int32_t KeyEvent::KEYCODE_BACKSLASH = 2061;
115 const int32_t KeyEvent::KEYCODE_SEMICOLON = 2062;
116 const int32_t KeyEvent::KEYCODE_APOSTROPHE = 2063;
117 const int32_t KeyEvent::KEYCODE_SLASH = 2064;
118 const int32_t KeyEvent::KEYCODE_AT = 2065;
119 const int32_t KeyEvent::KEYCODE_PLUS = 2066;
120 const int32_t KeyEvent::KEYCODE_MENU = 2067;
121 const int32_t KeyEvent::KEYCODE_PAGE_UP = 2068;
122 const int32_t KeyEvent::KEYCODE_PAGE_DOWN = 2069;
123 const int32_t KeyEvent::KEYCODE_ESCAPE = 2070;
124 const int32_t KeyEvent::KEYCODE_FORWARD_DEL = 2071;
125 const int32_t KeyEvent::KEYCODE_CTRL_LEFT = 2072;
126 const int32_t KeyEvent::KEYCODE_CTRL_RIGHT = 2073;
127 const int32_t KeyEvent::KEYCODE_CAPS_LOCK = 2074;
128 const int32_t KeyEvent::KEYCODE_SCROLL_LOCK = 2075;
129 const int32_t KeyEvent::KEYCODE_META_LEFT = 2076;
130 const int32_t KeyEvent::KEYCODE_META_RIGHT = 2077;
131 const int32_t KeyEvent::KEYCODE_FUNCTION = 2078;
132 const int32_t KeyEvent::KEYCODE_SYSRQ = 2079;
133 const int32_t KeyEvent::KEYCODE_BREAK = 2080;
134 const int32_t KeyEvent::KEYCODE_MOVE_HOME = 2081;
135 const int32_t KeyEvent::KEYCODE_MOVE_END = 2082;
136 const int32_t KeyEvent::KEYCODE_INSERT = 2083;
137 const int32_t KeyEvent::KEYCODE_FORWARD = 2084;
138 const int32_t KeyEvent::KEYCODE_MEDIA_PLAY = 2085;
139 const int32_t KeyEvent::KEYCODE_MEDIA_PAUSE = 2086;
140 const int32_t KeyEvent::KEYCODE_MEDIA_CLOSE = 2087;
141 const int32_t KeyEvent::KEYCODE_MEDIA_EJECT = 2088;
142 const int32_t KeyEvent::KEYCODE_MEDIA_RECORD = 2089;
143 const int32_t KeyEvent::KEYCODE_F1 = 2090;
144 const int32_t KeyEvent::KEYCODE_F2 = 2091;
145 const int32_t KeyEvent::KEYCODE_F3 = 2092;
146 const int32_t KeyEvent::KEYCODE_F4 = 2093;
147 const int32_t KeyEvent::KEYCODE_F5 = 2094;
148 const int32_t KeyEvent::KEYCODE_F6 = 2095;
149 const int32_t KeyEvent::KEYCODE_F7 = 2096;
150 const int32_t KeyEvent::KEYCODE_F8 = 2097;
151 const int32_t KeyEvent::KEYCODE_F9 = 2098;
152 const int32_t KeyEvent::KEYCODE_F10 = 2099;
153 const int32_t KeyEvent::KEYCODE_F11 = 2100;
154 const int32_t KeyEvent::KEYCODE_F12 = 2101;
155 const int32_t KeyEvent::KEYCODE_NUM_LOCK = 2102;
156 const int32_t KeyEvent::KEYCODE_NUMPAD_0 = 2103;
157 const int32_t KeyEvent::KEYCODE_NUMPAD_1 = 2104;
158 const int32_t KeyEvent::KEYCODE_NUMPAD_2 = 2105;
159 const int32_t KeyEvent::KEYCODE_NUMPAD_3 = 2106;
160 const int32_t KeyEvent::KEYCODE_NUMPAD_4 = 2107;
161 const int32_t KeyEvent::KEYCODE_NUMPAD_5 = 2108;
162 const int32_t KeyEvent::KEYCODE_NUMPAD_6 = 2109;
163 const int32_t KeyEvent::KEYCODE_NUMPAD_7 = 2110;
164 const int32_t KeyEvent::KEYCODE_NUMPAD_8 = 2111;
165 const int32_t KeyEvent::KEYCODE_NUMPAD_9 = 2112;
166 const int32_t KeyEvent::KEYCODE_NUMPAD_DIVIDE = 2113;
167 const int32_t KeyEvent::KEYCODE_NUMPAD_MULTIPLY = 2114;
168 const int32_t KeyEvent::KEYCODE_NUMPAD_SUBTRACT = 2115;
169 const int32_t KeyEvent::KEYCODE_NUMPAD_ADD = 2116;
170 const int32_t KeyEvent::KEYCODE_NUMPAD_DOT = 2117;
171 const int32_t KeyEvent::KEYCODE_NUMPAD_COMMA = 2118;
172 const int32_t KeyEvent::KEYCODE_NUMPAD_ENTER = 2119;
173 const int32_t KeyEvent::KEYCODE_NUMPAD_EQUALS = 2120;
174 const int32_t KeyEvent::KEYCODE_NUMPAD_LEFT_PAREN = 2121;
175 const int32_t KeyEvent::KEYCODE_NUMPAD_RIGHT_PAREN = 2122;
176 const int32_t KeyEvent::KEYCODE_VIRTUAL_MULTITASK = 2210;
177 const int32_t KeyEvent::KEYCODE_BUTTON_A = 2301;
178 const int32_t KeyEvent::KEYCODE_BUTTON_B = 2302;
179 const int32_t KeyEvent::KEYCODE_BUTTON_C = 2303;
180 const int32_t KeyEvent::KEYCODE_BUTTON_X = 2304;
181 const int32_t KeyEvent::KEYCODE_BUTTON_Y = 2305;
182 const int32_t KeyEvent::KEYCODE_BUTTON_Z = 2306;
183 const int32_t KeyEvent::KEYCODE_BUTTON_L1 = 2307;
184 const int32_t KeyEvent::KEYCODE_BUTTON_R1 = 2308;
185 const int32_t KeyEvent::KEYCODE_BUTTON_L2 = 2309;
186 const int32_t KeyEvent::KEYCODE_BUTTON_R2 = 2310;
187 const int32_t KeyEvent::KEYCODE_BUTTON_SELECT = 2311;
188 const int32_t KeyEvent::KEYCODE_BUTTON_START = 2312;
189 const int32_t KeyEvent::KEYCODE_BUTTON_MODE = 2313;
190 const int32_t KeyEvent::KEYCODE_BUTTON_THUMBL = 2314;
191 const int32_t KeyEvent::KEYCODE_BUTTON_THUMBR = 2315;
192 const int32_t KeyEvent::KEYCODE_BUTTON_TRIGGER = 2401;
193 const int32_t KeyEvent::KEYCODE_BUTTON_THUMB = 2402;
194 const int32_t KeyEvent::KEYCODE_BUTTON_THUMB2 = 2403;
195 const int32_t KeyEvent::KEYCODE_BUTTON_TOP = 2404;
196 const int32_t KeyEvent::KEYCODE_BUTTON_TOP2 = 2405;
197 const int32_t KeyEvent::KEYCODE_BUTTON_PINKIE = 2406;
198 const int32_t KeyEvent::KEYCODE_BUTTON_BASE1 = 2407;
199 const int32_t KeyEvent::KEYCODE_BUTTON_BASE2 = 2408;
200 const int32_t KeyEvent::KEYCODE_BUTTON_BASE3 = 2409;
201 const int32_t KeyEvent::KEYCODE_BUTTON_BASE4 = 2410;
202 const int32_t KeyEvent::KEYCODE_BUTTON_BASE5 = 2411;
203 const int32_t KeyEvent::KEYCODE_BUTTON_BASE6 = 2412;
204 const int32_t KeyEvent::KEYCODE_BUTTON_BASE7 = 2413;
205 const int32_t KeyEvent::KEYCODE_BUTTON_BASE8 = 2414;
206 const int32_t KeyEvent::KEYCODE_BUTTON_BASE9 = 2415;
207 const int32_t KeyEvent::KEYCODE_BUTTON_DEAD = 2416;
208 const int32_t KeyEvent::KEYCODE_SLEEP = 2600;
209 const int32_t KeyEvent::KEYCODE_ZENKAKU_HANKAKU = 2601;
210 const int32_t KeyEvent::KEYCODE_102ND = 2602;
211 const int32_t KeyEvent::KEYCODE_RO = 2603;
212 const int32_t KeyEvent::KEYCODE_KATAKANA = 2604;
213 const int32_t KeyEvent::KEYCODE_HIRAGANA = 2605;
214 const int32_t KeyEvent::KEYCODE_HENKAN = 2606;
215 const int32_t KeyEvent::KEYCODE_KATAKANA_HIRAGANA = 2607;
216 const int32_t KeyEvent::KEYCODE_MUHENKAN = 2608;
217 const int32_t KeyEvent::KEYCODE_LINEFEED = 2609;
218 const int32_t KeyEvent::KEYCODE_MACRO = 2610;
219 const int32_t KeyEvent::KEYCODE_NUMPAD_PLUSMINUS = 2611;
220 const int32_t KeyEvent::KEYCODE_SCALE = 2612;
221 const int32_t KeyEvent::KEYCODE_HANGUEL = 2613;
222 const int32_t KeyEvent::KEYCODE_HANJA = 2614;
223 const int32_t KeyEvent::KEYCODE_YEN = 2615;
224 const int32_t KeyEvent::KEYCODE_STOP = 2616;
225 const int32_t KeyEvent::KEYCODE_AGAIN = 2617;
226 const int32_t KeyEvent::KEYCODE_PROPS = 2618;
227 const int32_t KeyEvent::KEYCODE_UNDO = 2619;
228 const int32_t KeyEvent::KEYCODE_COPY = 2620;
229 const int32_t KeyEvent::KEYCODE_OPEN = 2621;
230 const int32_t KeyEvent::KEYCODE_PASTE = 2622;
231 const int32_t KeyEvent::KEYCODE_FIND = 2623;
232 const int32_t KeyEvent::KEYCODE_CUT = 2624;
233 const int32_t KeyEvent::KEYCODE_HELP = 2625;
234 const int32_t KeyEvent::KEYCODE_CALC = 2626;
235 const int32_t KeyEvent::KEYCODE_FILE = 2627;
236 const int32_t KeyEvent::KEYCODE_BOOKMARKS = 2628;
237 const int32_t KeyEvent::KEYCODE_NEXT = 2629;
238 const int32_t KeyEvent::KEYCODE_PLAYPAUSE = 2630;
239 const int32_t KeyEvent::KEYCODE_PREVIOUS = 2631;
240 const int32_t KeyEvent::KEYCODE_STOPCD = 2632;
241 const int32_t KeyEvent::KEYCODE_CONFIG = 2634;
242 const int32_t KeyEvent::KEYCODE_REFRESH = 2635;
243 const int32_t KeyEvent::KEYCODE_EXIT = 2636;
244 const int32_t KeyEvent::KEYCODE_EDIT = 2637;
245 const int32_t KeyEvent::KEYCODE_SCROLLUP = 2638;
246 const int32_t KeyEvent::KEYCODE_SCROLLDOWN = 2639;
247 const int32_t KeyEvent::KEYCODE_NEW = 2640;
248 const int32_t KeyEvent::KEYCODE_REDO = 2641;
249 const int32_t KeyEvent::KEYCODE_CLOSE = 2642;
250 const int32_t KeyEvent::KEYCODE_PLAY = 2643;
251 const int32_t KeyEvent::KEYCODE_BASSBOOST = 2644;
252 const int32_t KeyEvent::KEYCODE_PRINT = 2645;
253 const int32_t KeyEvent::KEYCODE_CHAT = 2646;
254 const int32_t KeyEvent::KEYCODE_FINANCE = 2647;
255 const int32_t KeyEvent::KEYCODE_CANCEL = 2648;
256 const int32_t KeyEvent::KEYCODE_KBDILLUM_TOGGLE = 2649;
257 const int32_t KeyEvent::KEYCODE_KBDILLUM_DOWN = 2650;
258 const int32_t KeyEvent::KEYCODE_KBDILLUM_UP = 2651;
259 const int32_t KeyEvent::KEYCODE_SEND = 2652;
260 const int32_t KeyEvent::KEYCODE_REPLY = 2653;
261 const int32_t KeyEvent::KEYCODE_FORWARDMAIL = 2654;
262 const int32_t KeyEvent::KEYCODE_SAVE = 2655;
263 const int32_t KeyEvent::KEYCODE_DOCUMENTS = 2656;
264 const int32_t KeyEvent::KEYCODE_VIDEO_NEXT = 2657;
265 const int32_t KeyEvent::KEYCODE_VIDEO_PREV = 2658;
266 const int32_t KeyEvent::KEYCODE_BRIGHTNESS_CYCLE = 2659;
267 const int32_t KeyEvent::KEYCODE_BRIGHTNESS_ZERO = 2660;
268 const int32_t KeyEvent::KEYCODE_DISPLAY_OFF = 2661;
269 const int32_t KeyEvent::KEYCODE_BTN_MISC = 2662;
270 const int32_t KeyEvent::KEYCODE_GOTO = 2663;
271 const int32_t KeyEvent::KEYCODE_INFO = 2664;
272 const int32_t KeyEvent::KEYCODE_PROGRAM = 2665;
273 const int32_t KeyEvent::KEYCODE_PVR = 2666;
274 const int32_t KeyEvent::KEYCODE_SUBTITLE = 2667;
275 const int32_t KeyEvent::KEYCODE_FULL_SCREEN = 2668;
276 const int32_t KeyEvent::KEYCODE_KEYBOARD = 2669;
277 const int32_t KeyEvent::KEYCODE_ASPECT_RATIO = 2670;
278 const int32_t KeyEvent::KEYCODE_PC = 2671;
279 const int32_t KeyEvent::KEYCODE_TV = 2672;
280 const int32_t KeyEvent::KEYCODE_TV2 = 2673;
281 const int32_t KeyEvent::KEYCODE_VCR = 2674;
282 const int32_t KeyEvent::KEYCODE_VCR2 = 2675;
283 const int32_t KeyEvent::KEYCODE_SAT = 2676;
284 const int32_t KeyEvent::KEYCODE_CD = 2677;
285 const int32_t KeyEvent::KEYCODE_TAPE = 2678;
286 const int32_t KeyEvent::KEYCODE_TUNER = 2679;
287 const int32_t KeyEvent::KEYCODE_PLAYER = 2680;
288 const int32_t KeyEvent::KEYCODE_DVD = 2681;
289 const int32_t KeyEvent::KEYCODE_AUDIO = 2682;
290 const int32_t KeyEvent::KEYCODE_VIDEO = 2683;
291 const int32_t KeyEvent::KEYCODE_MEMO = 2684;
292 const int32_t KeyEvent::KEYCODE_CALENDAR = 2685;
293 const int32_t KeyEvent::KEYCODE_RED = 2686;
294 const int32_t KeyEvent::KEYCODE_GREEN = 2687;
295 const int32_t KeyEvent::KEYCODE_YELLOW = 2688;
296 const int32_t KeyEvent::KEYCODE_BLUE = 2689;
297 const int32_t KeyEvent::KEYCODE_CHANNELUP = 2690;
298 const int32_t KeyEvent::KEYCODE_CHANNELDOWN = 2691;
299 const int32_t KeyEvent::KEYCODE_LAST = 2692;
300 const int32_t KeyEvent::KEYCODE_RESTART = 2693;
301 const int32_t KeyEvent::KEYCODE_SLOW = 2694;
302 const int32_t KeyEvent::KEYCODE_SHUFFLE = 2695;
303 const int32_t KeyEvent::KEYCODE_VIDEOPHONE = 2696;
304 const int32_t KeyEvent::KEYCODE_GAMES = 2697;
305 const int32_t KeyEvent::KEYCODE_ZOOMIN = 2698;
306 const int32_t KeyEvent::KEYCODE_ZOOMOUT = 2699;
307 const int32_t KeyEvent::KEYCODE_ZOOMRESET = 2700;
308 const int32_t KeyEvent::KEYCODE_WORDPROCESSOR = 2701;
309 const int32_t KeyEvent::KEYCODE_EDITOR = 2702;
310 const int32_t KeyEvent::KEYCODE_SPREADSHEET = 2703;
311 const int32_t KeyEvent::KEYCODE_GRAPHICSEDITOR = 2704;
312 const int32_t KeyEvent::KEYCODE_PRESENTATION = 2705;
313 const int32_t KeyEvent::KEYCODE_DATABASE = 2706;
314 const int32_t KeyEvent::KEYCODE_NEWS = 2707;
315 const int32_t KeyEvent::KEYCODE_VOICEMAIL = 2708;
316 const int32_t KeyEvent::KEYCODE_ADDRESSBOOK = 2709;
317 const int32_t KeyEvent::KEYCODE_MESSENGER = 2710;
318 const int32_t KeyEvent::KEYCODE_BRIGHTNESS_TOGGLE = 2711;
319 const int32_t KeyEvent::KEYCODE_SPELLCHECK = 2712;
320 const int32_t KeyEvent::KEYCODE_COFFEE = 2713;
321 const int32_t KeyEvent::KEYCODE_MEDIA_REPEAT = 2714;
322 const int32_t KeyEvent::KEYCODE_IMAGES = 2715;
323 const int32_t KeyEvent::KEYCODE_BUTTONCONFIG = 2716;
324 const int32_t KeyEvent::KEYCODE_TASKMANAGER = 2717;
325 const int32_t KeyEvent::KEYCODE_JOURNAL = 2718;
326 const int32_t KeyEvent::KEYCODE_CONTROLPANEL = 2719;
327 const int32_t KeyEvent::KEYCODE_APPSELECT = 2720;
328 const int32_t KeyEvent::KEYCODE_SCREENSAVER = 2721;
329 const int32_t KeyEvent::KEYCODE_ASSISTANT = 2722;
330 const int32_t KeyEvent::KEYCODE_KBD_LAYOUT_NEXT = 2723;
331 const int32_t KeyEvent::KEYCODE_BRIGHTNESS_MIN = 2724;
332 const int32_t KeyEvent::KEYCODE_BRIGHTNESS_MAX = 2725;
333 const int32_t KeyEvent::KEYCODE_KBDINPUTASSIST_PREV = 2726;
334 const int32_t KeyEvent::KEYCODE_KBDINPUTASSIST_NEXT = 2727;
335 const int32_t KeyEvent::KEYCODE_KBDINPUTASSIST_PREVGROUP = 2728;
336 const int32_t KeyEvent::KEYCODE_KBDINPUTASSIST_NEXTGROUP = 2729;
337 const int32_t KeyEvent::KEYCODE_KBDINPUTASSIST_ACCEPT = 2730;
338 const int32_t KeyEvent::KEYCODE_KBDINPUTASSIST_CANCEL = 2731;
339 const int32_t KeyEvent::KEYCODE_FRONT = 2800;
340 const int32_t KeyEvent::KEYCODE_SETUP = 2801;
341 const int32_t KeyEvent::KEYCODE_WAKEUP = 2802;
342 const int32_t KeyEvent::KEYCODE_SENDFILE = 2803;
343 const int32_t KeyEvent::KEYCODE_DELETEFILE = 2804;
344 const int32_t KeyEvent::KEYCODE_XFER = 2805;
345 const int32_t KeyEvent::KEYCODE_PROG1 = 2806;
346 const int32_t KeyEvent::KEYCODE_PROG2 = 2807;
347 const int32_t KeyEvent::KEYCODE_MSDOS = 2808;
348 const int32_t KeyEvent::KEYCODE_SCREENLOCK = 2809;
349 const int32_t KeyEvent::KEYCODE_DIRECTION_ROTATE_DISPLAY = 2810;
350 const int32_t KeyEvent::KEYCODE_CYCLEWINDOWS = 2811;
351 const int32_t KeyEvent::KEYCODE_COMPUTER = 2812;
352 const int32_t KeyEvent::KEYCODE_EJECTCLOSECD = 2813;
353 const int32_t KeyEvent::KEYCODE_ISO = 2814;
354 const int32_t KeyEvent::KEYCODE_MOVE = 2815;
355 const int32_t KeyEvent::KEYCODE_F13 = 2816;
356 const int32_t KeyEvent::KEYCODE_F14 = 2817;
357 const int32_t KeyEvent::KEYCODE_F15 = 2818;
358 const int32_t KeyEvent::KEYCODE_F16 = 2819;
359 const int32_t KeyEvent::KEYCODE_F17 = 2820;
360 const int32_t KeyEvent::KEYCODE_F18 = 2821;
361 const int32_t KeyEvent::KEYCODE_F19 = 2822;
362 const int32_t KeyEvent::KEYCODE_F20 = 2823;
363 const int32_t KeyEvent::KEYCODE_F21 = 2824;
364 const int32_t KeyEvent::KEYCODE_F22 = 2825;
365 const int32_t KeyEvent::KEYCODE_F23 = 2826;
366 const int32_t KeyEvent::KEYCODE_F24 = 2827;
367 const int32_t KeyEvent::KEYCODE_PROG3 = 2828;
368 const int32_t KeyEvent::KEYCODE_PROG4 = 2829;
369 const int32_t KeyEvent::KEYCODE_DASHBOARD = 2830;
370 const int32_t KeyEvent::KEYCODE_SUSPEND = 2831;
371 const int32_t KeyEvent::KEYCODE_HP = 2832;
372 const int32_t KeyEvent::KEYCODE_SOUND = 2833;
373 const int32_t KeyEvent::KEYCODE_QUESTION = 2834;
374 const int32_t KeyEvent::KEYCODE_CONNECT = 2836;
375 const int32_t KeyEvent::KEYCODE_SPORT = 2837;
376 const int32_t KeyEvent::KEYCODE_SHOP = 2838;
377 const int32_t KeyEvent::KEYCODE_ALTERASE = 2839;
378 const int32_t KeyEvent::KEYCODE_SWITCHVIDEOMODE = 2841;
379 const int32_t KeyEvent::KEYCODE_BATTERY = 2842;
380 const int32_t KeyEvent::KEYCODE_BLUETOOTH = 2843;
381 const int32_t KeyEvent::KEYCODE_WLAN = 2844;
382 const int32_t KeyEvent::KEYCODE_UWB = 2845;
383 const int32_t KeyEvent::KEYCODE_WWAN_WIMAX = 2846;
384 const int32_t KeyEvent::KEYCODE_RFKILL = 2847;
385 const int32_t KeyEvent::KEYCODE_CHANNEL = 3001;
386 const int32_t KeyEvent::KEYCODE_BTN_0 = 3100;
387 const int32_t KeyEvent::KEYCODE_BTN_1 = 3101;
388 const int32_t KeyEvent::KEYCODE_BTN_2 = 3102;
389 const int32_t KeyEvent::KEYCODE_BTN_3 = 3103;
390 const int32_t KeyEvent::KEYCODE_BTN_4 = 3104;
391 const int32_t KeyEvent::KEYCODE_BTN_5 = 3105;
392 const int32_t KeyEvent::KEYCODE_BTN_6 = 3106;
393 const int32_t KeyEvent::KEYCODE_BTN_7 = 3107;
394 const int32_t KeyEvent::KEYCODE_BTN_8 = 3108;
395 const int32_t KeyEvent::KEYCODE_BTN_9 = 3109;
396 const int32_t KeyEvent::KEYCODE_BRL_DOT1 = 3201;
397 const int32_t KeyEvent::KEYCODE_BRL_DOT2 = 3202;
398 const int32_t KeyEvent::KEYCODE_BRL_DOT3 = 3203;
399 const int32_t KeyEvent::KEYCODE_BRL_DOT4 = 3204;
400 const int32_t KeyEvent::KEYCODE_BRL_DOT5 = 3205;
401 const int32_t KeyEvent::KEYCODE_BRL_DOT6 = 3206;
402 const int32_t KeyEvent::KEYCODE_BRL_DOT7 = 3207;
403 const int32_t KeyEvent::KEYCODE_BRL_DOT8 = 3208;
404 const int32_t KeyEvent::KEYCODE_BRL_DOT9 = 3209;
405 const int32_t KeyEvent::KEYCODE_BRL_DOT10 = 3210;
406 const int32_t KeyEvent::KEYCODE_LEFT_KNOB_ROLL_UP = 10001;
407 const int32_t KeyEvent::KEYCODE_LEFT_KNOB_ROLL_DOWN = 10002;
408 const int32_t KeyEvent::KEYCODE_LEFT_KNOB = 10003;
409 const int32_t KeyEvent::KEYCODE_RIGHT_KNOB_ROLL_UP = 10004;
410 const int32_t KeyEvent::KEYCODE_RIGHT_KNOB_ROLL_DOWN = 10005;
411 const int32_t KeyEvent::KEYCODE_RIGHT_KNOB = 10006;
412 const int32_t KeyEvent::KEYCODE_VOICE_SOURCE_SWITCH = 10007;
413 const int32_t KeyEvent::KEYCODE_LAUNCHER_MENU = 10008;
414 
415 const int32_t KeyEvent::KEY_ACTION_UNKNOWN = 0X00000000;
416 const int32_t KeyEvent::KEY_ACTION_CANCEL = 0X00000001;
417 
418 const int32_t KeyEvent::KEY_ACTION_DOWN = 0x00000002;
419 const int32_t KeyEvent::KEY_ACTION_UP = 0X00000003;
420 
KeyItem()421 KeyEvent::KeyItem::KeyItem() {}
422 
~KeyItem()423 KeyEvent::KeyItem::~KeyItem() {}
424 
GetKeyCode() const425 int32_t KeyEvent::KeyItem::GetKeyCode() const
426 {
427     return keyCode_;
428 }
429 
SetKeyCode(int32_t keyCode)430 void KeyEvent::KeyItem::SetKeyCode(int32_t keyCode)
431 {
432     keyCode_ = keyCode;
433 }
434 
GetDownTime() const435 int64_t KeyEvent::KeyItem::GetDownTime() const
436 {
437     return downTime_;
438 }
439 
SetDownTime(int64_t downTime)440 void KeyEvent::KeyItem::SetDownTime(int64_t downTime)
441 {
442     downTime_ = downTime;
443 }
444 
GetDeviceId() const445 int32_t KeyEvent::KeyItem::GetDeviceId() const
446 {
447     return deviceId_;
448 }
449 
SetDeviceId(int32_t deviceId)450 void KeyEvent::KeyItem::SetDeviceId(int32_t deviceId)
451 {
452     deviceId_ = deviceId;
453 }
454 
IsPressed() const455 bool KeyEvent::KeyItem::IsPressed() const
456 {
457     return pressed_;
458 }
459 
SetPressed(bool pressed)460 void KeyEvent::KeyItem::SetPressed(bool pressed)
461 {
462     pressed_ = pressed;
463 }
464 
465 
WriteToParcel(Parcel & out) const466 bool KeyEvent::KeyItem::WriteToParcel(Parcel &out) const
467 {
468     if (!out.WriteBool(pressed_)) {
469         return false;
470     }
471     if (!out.WriteInt64(downTime_)) {
472         return false;
473     }
474     if (!out.WriteInt32(deviceId_)) {
475         return false;
476     }
477     if (!out.WriteInt32(keyCode_)) {
478         return false;
479     }
480 
481     return true;
482 }
483 
ReadFromParcel(Parcel & in)484 bool KeyEvent::KeyItem::ReadFromParcel(Parcel &in)
485 {
486     if (!in.ReadBool(pressed_)) {
487         return false;
488     }
489     if (!in.ReadInt64(downTime_)) {
490         return false;
491     }
492     if (!in.ReadInt32(deviceId_)) {
493         return false;
494     }
495     if (!in.ReadInt32(keyCode_)) {
496         return false;
497     }
498 
499     return true;
500 }
501 
from(std::shared_ptr<InputEvent> inputEvent)502 std::shared_ptr<KeyEvent> KeyEvent::from(std::shared_ptr<InputEvent> inputEvent)
503 {
504     return nullptr;
505 }
506 
KeyEvent(int32_t eventType)507 KeyEvent::KeyEvent(int32_t eventType) : InputEvent(eventType) {}
508 
KeyEvent(const KeyEvent & other)509 KeyEvent::KeyEvent(const KeyEvent& other)
510     : InputEvent(other),
511     keyCode_(other.keyCode_),
512     keys_(other.keys_),
513     keyAction_(other.keyAction_) {}
514 
~KeyEvent()515 KeyEvent::~KeyEvent() {}
516 
Create()517 std::shared_ptr<KeyEvent> KeyEvent::Create()
518 {
519     return std::shared_ptr<KeyEvent>(new KeyEvent(InputEvent::EVENT_TYPE_KEY));
520 }
521 
GetKeyCode() const522 int32_t KeyEvent::GetKeyCode() const
523 {
524     return keyCode_;
525 }
526 
SetKeyCode(int32_t keyCode)527 void KeyEvent::SetKeyCode(int32_t keyCode)
528 {
529     keyCode_ = keyCode;
530 }
531 
GetKeyAction() const532 int32_t KeyEvent::GetKeyAction() const
533 {
534     return keyAction_;
535 }
536 
SetKeyAction(int32_t keyAction)537 void KeyEvent::SetKeyAction(int32_t keyAction)
538 {
539     keyAction_ = keyAction;
540 }
541 
AddKeyItem(const KeyItem & keyItem)542 void KeyEvent::AddKeyItem(const KeyItem& keyItem)
543 {
544     keys_.push_back(keyItem);
545 }
546 
GetKeyItems()547 std::vector<KeyEvent::KeyItem> KeyEvent::GetKeyItems()
548 {
549     return keys_;
550 }
551 
GetPressedKeys() const552 std::vector<int32_t> KeyEvent::GetPressedKeys() const
553 {
554     std::vector<int32_t> result;
555     for (const auto &item : keys_) {
556         if (item.IsPressed()) {
557             result.push_back(item.GetKeyCode());
558         }
559     }
560     return result;
561 }
562 
AddPressedKeyItems(const KeyItem & keyItem)563 void KeyEvent::AddPressedKeyItems(const KeyItem& keyItem)
564 {
565     std::vector<int32_t> pressedkeys = GetPressedKeys();
566     std::vector<int32_t>::iterator result = std::find(pressedkeys.begin(),
567         pressedkeys.end(), keyItem.GetKeyCode());
568     if (result == pressedkeys.end()) {
569         keys_.push_back(keyItem);
570     }
571 }
572 
RemoveReleasedKeyItems(const KeyItem & keyItem)573 void KeyEvent::RemoveReleasedKeyItems(const KeyItem& keyItem)
574 {
575     std::vector<KeyItem> tempKeyItems = keys_;
576     keys_.clear();
577     for (const auto &item : tempKeyItems) {
578         if (item.GetKeyCode() != keyItem.GetKeyCode()) {
579             keys_.push_back(item);
580         }
581     }
582 }
583 
GetKeyItem() const584 const KeyEvent::KeyItem* KeyEvent::GetKeyItem() const
585 {
586     return GetKeyItem(keyCode_);
587 }
588 
GetKeyItem(int32_t keyCode) const589 const KeyEvent::KeyItem* KeyEvent::GetKeyItem(int32_t keyCode) const
590 {
591     for (const auto &item : keys_) {
592         if (item.GetKeyCode() == keyCode) {
593             return &item;
594         }
595     }
596     return nullptr;
597 }
598 
ActionToString(int32_t action)599 const char* KeyEvent::ActionToString(int32_t action)
600 {
601     switch (action) {
602         case KEY_ACTION_UNKNOWN:
603             return "KEY_ACTION_UNKNOWN";
604         case KEY_ACTION_CANCEL:
605             return "KEY_ACTION_CANCEL";
606         case KEY_ACTION_DOWN:
607             return "KEY_ACTION_DOWN";
608         case KEY_ACTION_UP:
609             return "KEY_ACTION_UP";
610         default:
611             return "KEY_ACTION_INVALID";
612     }
613 }
614 
KeyCodeToString(int32_t keyCode)615 const char* KeyEvent::KeyCodeToString(int32_t keyCode)
616 {
617     switch (keyCode) {
618         case KEYCODE_FN:
619             return "KEYCODE_FN";
620         case KEYCODE_UNKNOWN:
621             return "KEYCODE_UNKNOWN";
622         case KEYCODE_HOME:
623             return "KEYCODE_HOME";
624         case KEYCODE_BACK:
625             return "KEYCODE_BACK";
626         case KEYCODE_CALL:
627             return "KEYCODE_CALL";
628         case KEYCODE_ENDCALL:
629             return "KEYCODE_ENDCALL";
630         case KEYCODE_CLEAR:
631             return "KEYCODE_CLEAR";
632         case KEYCODE_HEADSETHOOK:
633             return "KEYCODE_HEADSETHOOK";
634         case KEYCODE_FOCUS:
635             return "KEYCODE_FOCUS";
636         case KEYCODE_NOTIFICATION:
637             return "KEYCODE_NOTIFICATION";
638         case KEYCODE_SEARCH:
639             return "KEYCODE_SEARCH";
640         case KEYCODE_MEDIA_PLAY_PAUSE:
641             return "KEYCODE_MEDIA_PLAY_PAUSE";
642         case KEYCODE_MEDIA_STOP:
643             return "KEYCODE_MEDIA_STOP";
644         case KEYCODE_MEDIA_NEXT:
645             return "KEYCODE_MEDIA_NEXT";
646         case KEYCODE_MEDIA_PREVIOUS:
647             return "KEYCODE_MEDIA_PREVIOUS";
648         case KEYCODE_MEDIA_REWIND:
649             return "KEYCODE_MEDIA_REWIND";
650         case KEYCODE_MEDIA_FAST_FORWARD:
651             return "KEYCODE_MEDIA_FAST_FORWARD";
652         case KEYCODE_VOLUME_UP:
653             return "KEYCODE_VOLUME_UP";
654         case KEYCODE_VOLUME_DOWN:
655             return "KEYCODE_VOLUME_DOWN";
656         case KEYCODE_POWER:
657             return "KEYCODE_POWER";
658         case KEYCODE_CAMERA:
659             return "KEYCODE_CAMERA";
660         case KEYCODE_VOICE_ASSISTANT:
661             return "KEYCODE_VOICE_ASSISTANT";
662         case KEYCODE_CUSTOM1:
663             return "KEYCODE_CUSTOM1";
664         case KEYCODE_VOLUME_MUTE:
665             return "KEYCODE_VOLUME_MUTE";
666         case KEYCODE_MUTE:
667             return "KEYCODE_MUTE";
668         case KEYCODE_BRIGHTNESS_UP:
669             return "KEYCODE_BRIGHTNESS_UP";
670         case KEYCODE_BRIGHTNESS_DOWN:
671             return "KEYCODE_BRIGHTNESS_DOWN";
672         case KEYCODE_WEAR_1:
673             return "KEYCODE_WEAR_1";
674         case KEYCODE_0:
675             return "KEYCODE_0";
676         case KEYCODE_1:
677             return "KEYCODE_1";
678         case KEYCODE_2:
679             return "KEYCODE_2";
680         case KEYCODE_3:
681             return "KEYCODE_3";
682         case KEYCODE_4:
683             return "KEYCODE_4";
684         case KEYCODE_5:
685             return "KEYCODE_5";
686         case KEYCODE_6:
687             return "KEYCODE_6";
688         case KEYCODE_7:
689             return "KEYCODE_7";
690         case KEYCODE_8:
691             return "KEYCODE_8";
692         case KEYCODE_9:
693             return "KEYCODE_9";
694         case KEYCODE_STAR:
695             return "KEYCODE_STAR";
696         case KEYCODE_POUND:
697             return "KEYCODE_POUND";
698         case KEYCODE_DPAD_UP:
699             return "KEYCODE_DPAD_UP";
700         case KEYCODE_DPAD_DOWN:
701             return "KEYCODE_DPAD_DOWN";
702         case KEYCODE_DPAD_LEFT:
703             return "KEYCODE_DPAD_LEFT";
704         case KEYCODE_DPAD_RIGHT:
705             return "KEYCODE_DPAD_RIGHT";
706         case KEYCODE_DPAD_CENTER:
707             return "KEYCODE_DPAD_CENTER";
708         case KEYCODE_A:
709             return "KEYCODE_A";
710         case KEYCODE_B:
711             return "KEYCODE_B";
712         case KEYCODE_C:
713             return "KEYCODE_C";
714         case KEYCODE_D:
715             return "KEYCODE_D";
716         case KEYCODE_E:
717             return "KEYCODE_E";
718         case KEYCODE_F:
719             return "KEYCODE_F";
720         case KEYCODE_G:
721             return "KEYCODE_G";
722         case KEYCODE_H:
723             return "KEYCODE_H";
724         case KEYCODE_I:
725             return "KEYCODE_I";
726         case KEYCODE_J:
727             return "KEYCODE_J";
728         case KEYCODE_K:
729             return "KEYCODE_K";
730         case KEYCODE_L:
731             return "KEYCODE_L";
732         case KEYCODE_M:
733             return "KEYCODE_M";
734         case KEYCODE_N:
735             return "KEYCODE_N";
736         case KEYCODE_O:
737             return "KEYCODE_O";
738         case KEYCODE_P:
739             return "KEYCODE_P";
740         case KEYCODE_Q:
741             return "KEYCODE_Q";
742         case KEYCODE_R:
743             return "KEYCODE_R";
744         case KEYCODE_S:
745             return "KEYCODE_S";
746         case KEYCODE_T:
747             return "KEYCODE_T";
748         case KEYCODE_U:
749             return "KEYCODE_U";
750         case KEYCODE_V:
751             return "KEYCODE_V";
752         case KEYCODE_W:
753             return "KEYCODE_W";
754         case KEYCODE_X:
755             return "KEYCODE_X";
756         case KEYCODE_Y:
757             return "KEYCODE_Y";
758         case KEYCODE_Z:
759             return "KEYCODE_Z";
760         case KEYCODE_COMMA:
761             return "KEYCODE_COMMA";
762         case KEYCODE_PERIOD:
763             return "KEYCODE_PERIOD";
764         case KEYCODE_ALT_LEFT:
765             return "KEYCODE_ALT_LEFT";
766         case KEYCODE_ALT_RIGHT:
767             return "KEYCODE_ALT_RIGHT";
768         case KEYCODE_SHIFT_LEFT:
769             return "KEYCODE_SHIFT_LEFT";
770         case KEYCODE_SHIFT_RIGHT:
771             return "KEYCODE_SHIFT_RIGHT";
772         case KEYCODE_TAB:
773             return "KEYCODE_TAB";
774         case KEYCODE_SPACE:
775             return "KEYCODE_SPACE";
776         case KEYCODE_SYM:
777             return "KEYCODE_SYM";
778         case KEYCODE_EXPLORER:
779             return "KEYCODE_EXPLORER";
780         case KEYCODE_ENVELOPE:
781             return "KEYCODE_ENVELOPE";
782         case KEYCODE_ENTER:
783             return "KEYCODE_ENTER";
784         case KEYCODE_DEL:
785             return "KEYCODE_DEL";
786         case KEYCODE_GRAVE:
787             return "KEYCODE_GRAVE";
788         case KEYCODE_MINUS:
789             return "KEYCODE_MINUS";
790         case KEYCODE_EQUALS:
791             return "KEYCODE_EQUALS";
792         case KEYCODE_LEFT_BRACKET:
793             return "KEYCODE_LEFT_BRACKET";
794         case KEYCODE_RIGHT_BRACKET:
795             return "KEYCODE_RIGHT_BRACKET";
796         case KEYCODE_BACKSLASH:
797             return "KEYCODE_BACKSLASH";
798         case KEYCODE_SEMICOLON:
799             return "KEYCODE_SEMICOLON";
800         case KEYCODE_APOSTROPHE:
801             return "KEYCODE_APOSTROPHE";
802         case KEYCODE_SLASH:
803             return "KEYCODE_SLASH";
804         case KEYCODE_AT:
805             return "KEYCODE_AT";
806         case KEYCODE_PLUS:
807             return "KEYCODE_PLUS";
808         case KEYCODE_MENU:
809             return "KEYCODE_MENU";
810         case KEYCODE_PAGE_UP:
811             return "KEYCODE_PAGE_UP";
812         case KEYCODE_PAGE_DOWN:
813             return "KEYCODE_PAGE_DOWN";
814         case KEYCODE_ESCAPE:
815             return "KEYCODE_ESCAPE";
816         case KEYCODE_FORWARD_DEL:
817             return "KEYCODE_FORWARD_DEL";
818         case KEYCODE_CTRL_LEFT:
819             return "KEYCODE_CTRL_LEFT";
820         case KEYCODE_CTRL_RIGHT:
821             return "KEYCODE_CTRL_RIGHT";
822         case KEYCODE_CAPS_LOCK:
823             return "KEYCODE_CAPS_LOCK";
824         case KEYCODE_SCROLL_LOCK:
825             return "KEYCODE_SCROLL_LOCK";
826         case KEYCODE_META_LEFT:
827             return "KEYCODE_META_LEFT";
828         case KEYCODE_META_RIGHT:
829             return "KEYCODE_META_RIGHT";
830         case KEYCODE_FUNCTION:
831             return "KEYCODE_FUNCTION";
832         case KEYCODE_SYSRQ:
833             return "KEYCODE_SYSRQ";
834         case KEYCODE_BREAK:
835             return "KEYCODE_BREAK";
836         case KEYCODE_MOVE_HOME:
837             return "KEYCODE_MOVE_HOME";
838         case KEYCODE_MOVE_END:
839             return "KEYCODE_MOVE_END";
840         case KEYCODE_INSERT:
841             return "KEYCODE_INSERT";
842         case KEYCODE_FORWARD:
843             return "KEYCODE_FORWARD";
844         case KEYCODE_MEDIA_PLAY:
845             return "KEYCODE_MEDIA_PLAY";
846         case KEYCODE_MEDIA_PAUSE:
847             return "KEYCODE_MEDIA_PAUSE";
848         case KEYCODE_MEDIA_CLOSE:
849             return "KEYCODE_MEDIA_CLOSE";
850         case KEYCODE_MEDIA_EJECT:
851             return "KEYCODE_MEDIA_EJECT";
852         case KEYCODE_MEDIA_RECORD:
853             return "KEYCODE_MEDIA_RECORD";
854         case KEYCODE_F1:
855             return "KEYCODE_F1";
856         case KEYCODE_F2:
857             return "KEYCODE_F2";
858         case KEYCODE_F3:
859             return "KEYCODE_F3";
860         case KEYCODE_F4:
861             return "KEYCODE_F4";
862         case KEYCODE_F5:
863             return "KEYCODE_F5";
864         case KEYCODE_F6:
865             return "KEYCODE_F6";
866         case KEYCODE_F7:
867             return "KEYCODE_F7";
868         case KEYCODE_F8:
869             return "KEYCODE_F8";
870         case KEYCODE_F9:
871             return "KEYCODE_F9";
872         case KEYCODE_F10:
873             return "KEYCODE_F10";
874         case KEYCODE_F11:
875             return "KEYCODE_F11";
876         case KEYCODE_F12:
877             return "KEYCODE_F12";
878         case KEYCODE_NUM_LOCK:
879             return "KEYCODE_NUM_LOCK";
880         case KEYCODE_NUMPAD_0:
881             return "KEYCODE_NUMPAD_0";
882         case KEYCODE_NUMPAD_1:
883             return "KEYCODE_NUMPAD_1";
884         case KEYCODE_NUMPAD_2:
885             return "KEYCODE_NUMPAD_2";
886         case KEYCODE_NUMPAD_3:
887             return "KEYCODE_NUMPAD_3";
888         case KEYCODE_NUMPAD_4:
889             return "KEYCODE_NUMPAD_4";
890         case KEYCODE_NUMPAD_5:
891             return "KEYCODE_NUMPAD_5";
892         case KEYCODE_NUMPAD_6:
893             return "KEYCODE_NUMPAD_6";
894         case KEYCODE_NUMPAD_7:
895             return "KEYCODE_NUMPAD_7";
896         case KEYCODE_NUMPAD_8:
897             return "KEYCODE_NUMPAD_8";
898         case KEYCODE_NUMPAD_9:
899             return "KEYCODE_NUMPAD_9";
900         case KEYCODE_NUMPAD_DIVIDE:
901             return "KEYCODE_NUMPAD_DIVIDE";
902         case KEYCODE_NUMPAD_MULTIPLY:
903             return "KEYCODE_NUMPAD_MULTIPLY";
904         case KEYCODE_NUMPAD_SUBTRACT:
905             return "KEYCODE_NUMPAD_SUBTRACT";
906         case KEYCODE_NUMPAD_ADD:
907             return "KEYCODE_NUMPAD_ADD";
908         case KEYCODE_NUMPAD_DOT:
909             return "KEYCODE_NUMPAD_DOT";
910         case KEYCODE_NUMPAD_COMMA:
911             return "KEYCODE_NUMPAD_COMMA";
912         case KEYCODE_NUMPAD_ENTER:
913             return "KEYCODE_NUMPAD_ENTER";
914         case KEYCODE_NUMPAD_EQUALS:
915             return "KEYCODE_NUMPAD_EQUALS";
916         case KEYCODE_NUMPAD_LEFT_PAREN:
917             return "KEYCODE_NUMPAD_LEFT_PAREN";
918         case KEYCODE_NUMPAD_RIGHT_PAREN:
919             return "KEYCODE_NUMPAD_RIGHT_PAREN";
920         case KEYCODE_VIRTUAL_MULTITASK:
921             return "KEYCODE_VIRTUAL_MULTITASK";
922         case KEYCODE_BUTTON_A:
923             return "KEYCODE_BUTTON_A";
924         case KEYCODE_BUTTON_B:
925             return "KEYCODE_BUTTON_B";
926         case KEYCODE_BUTTON_C:
927             return "KEYCODE_BUTTON_C";
928         case KEYCODE_BUTTON_X:
929             return "KEYCODE_BUTTON_X";
930         case KEYCODE_BUTTON_Y:
931             return "KEYCODE_BUTTON_Y";
932         case KEYCODE_BUTTON_Z:
933             return "KEYCODE_BUTTON_Z";
934         case KEYCODE_BUTTON_L1:
935             return "KEYCODE_BUTTON_L1";
936         case KEYCODE_BUTTON_R1:
937             return "KEYCODE_BUTTON_R1";
938         case KEYCODE_BUTTON_L2:
939             return "KEYCODE_BUTTON_L2";
940         case KEYCODE_BUTTON_R2:
941             return "KEYCODE_BUTTON_R2";
942         case KEYCODE_BUTTON_SELECT:
943             return "KEYCODE_BUTTON_SELECT";
944         case KEYCODE_BUTTON_START:
945             return "KEYCODE_BUTTON_START";
946         case KEYCODE_BUTTON_MODE:
947             return "KEYCODE_BUTTON_MODE";
948         case KEYCODE_BUTTON_THUMBL:
949             return "KEYCODE_BUTTON_THUMBL";
950         case KEYCODE_BUTTON_THUMBR:
951             return "KEYCODE_BUTTON_THUMBR";
952         case KEYCODE_BUTTON_TRIGGER:
953             return "KEYCODE_BUTTON_TRIGGER";
954         case KEYCODE_BUTTON_THUMB:
955             return "KEYCODE_BUTTON_THUMB";
956         case KEYCODE_BUTTON_THUMB2:
957             return "KEYCODE_BUTTON_THUMB2";
958         case KEYCODE_BUTTON_TOP:
959             return "KEYCODE_BUTTON_TOP";
960         case KEYCODE_BUTTON_TOP2:
961             return "KEYCODE_BUTTON_TOP2";
962         case KEYCODE_BUTTON_PINKIE:
963             return "KEYCODE_BUTTON_PINKIE";
964         case KEYCODE_BUTTON_BASE1:
965             return "KEYCODE_BUTTON_BASE1";
966         case KEYCODE_BUTTON_BASE2:
967             return "KEYCODE_BUTTON_BASE2";
968         case KEYCODE_BUTTON_BASE3:
969             return "KEYCODE_BUTTON_BASE3";
970         case KEYCODE_BUTTON_BASE4:
971             return "KEYCODE_BUTTON_BASE4";
972         case KEYCODE_BUTTON_BASE5:
973             return "KEYCODE_BUTTON_BASE5";
974         case KEYCODE_BUTTON_BASE6:
975             return "KEYCODE_BUTTON_BASE6";
976         case KEYCODE_BUTTON_BASE7:
977             return "KEYCODE_BUTTON_BASE7";
978         case KEYCODE_BUTTON_BASE8:
979             return "KEYCODE_BUTTON_BASE8";
980         case KEYCODE_BUTTON_BASE9:
981             return "KEYCODE_BUTTON_BASE9";
982         case KEYCODE_BUTTON_DEAD:
983             return "KEYCODE_BUTTON_DEAD";
984         case KEYCODE_SLEEP:
985             return "KEYCODE_SLEEP";
986         case KEYCODE_ZENKAKU_HANKAKU:
987             return "KEYCODE_ZENKAKU_HANKAKU";
988         case KEYCODE_102ND:
989             return "KEYCODE_102ND";
990         case KEYCODE_RO:
991             return "KEYCODE_RO";
992         case KEYCODE_KATAKANA:
993             return "KEYCODE_KATAKANA";
994         case KEYCODE_HIRAGANA:
995             return "KEYCODE_HIRAGANA";
996         case KEYCODE_HENKAN:
997             return "KEYCODE_HENKAN";
998         case KEYCODE_KATAKANA_HIRAGANA:
999             return "KEYCODE_KATAKANA_HIRAGANA";
1000         case KEYCODE_MUHENKAN:
1001             return "KEYCODE_MUHENKAN";
1002         case KEYCODE_LINEFEED:
1003             return "KEYCODE_LINEFEED";
1004         case KEYCODE_MACRO:
1005             return "KEYCODE_MACRO";
1006         case KEYCODE_NUMPAD_PLUSMINUS:
1007             return "KEYCODE_NUMPAD_PLUSMINUS";
1008         case KEYCODE_SCALE:
1009             return "KEYCODE_SCALE";
1010         case KEYCODE_HANGUEL:
1011             return "KEYCODE_HANGUEL";
1012         case KEYCODE_HANJA:
1013             return "KEYCODE_HANJA";
1014         case KEYCODE_YEN:
1015             return "KEYCODE_YEN";
1016         case KEYCODE_STOP:
1017             return "KEYCODE_STOP";
1018         case KEYCODE_AGAIN:
1019             return "KEYCODE_AGAIN";
1020         case KEYCODE_PROPS:
1021             return "KEYCODE_PROPS";
1022         case KEYCODE_UNDO:
1023             return "KEYCODE_UNDO";
1024         case KEYCODE_COPY:
1025             return "KEYCODE_COPY";
1026         case KEYCODE_OPEN:
1027             return "KEYCODE_OPEN";
1028         case KEYCODE_PASTE:
1029             return "KEYCODE_PASTE";
1030         case KEYCODE_FIND:
1031             return "KEYCODE_FIND";
1032         case KEYCODE_CUT:
1033             return "KEYCODE_CUT";
1034         case KEYCODE_HELP:
1035             return "KEYCODE_HELP";
1036         case KEYCODE_CALC:
1037             return "KEYCODE_CALC";
1038         case KEYCODE_FILE:
1039             return "KEYCODE_FILE";
1040         case KEYCODE_BOOKMARKS:
1041             return "KEYCODE_BOOKMARKS";
1042         case KEYCODE_NEXT:
1043             return "KEYCODE_NEXT";
1044         case KEYCODE_PLAYPAUSE:
1045             return "KEYCODE_PLAYPAUSE";
1046         case KEYCODE_PREVIOUS:
1047             return "KEYCODE_PREVIOUS";
1048         case KEYCODE_STOPCD:
1049             return "KEYCODE_STOPCD";
1050         case KEYCODE_CONFIG:
1051             return "KEYCODE_CONFIG";
1052         case KEYCODE_REFRESH:
1053             return "KEYCODE_REFRESH";
1054         case KEYCODE_EXIT:
1055             return "KEYCODE_EXIT";
1056         case KEYCODE_EDIT:
1057             return "KEYCODE_EDIT";
1058         case KEYCODE_SCROLLUP:
1059             return "KEYCODE_SCROLLUP";
1060         case KEYCODE_SCROLLDOWN:
1061             return "KEYCODE_SCROLLDOWN";
1062         case KEYCODE_NEW:
1063             return "KEYCODE_NEW";
1064         case KEYCODE_REDO:
1065             return "KEYCODE_REDO";
1066         case KEYCODE_CLOSE:
1067             return "KEYCODE_CLOSE";
1068         case KEYCODE_PLAY:
1069             return "KEYCODE_PLAY";
1070         case KEYCODE_BASSBOOST:
1071             return "KEYCODE_BASSBOOST";
1072         case KEYCODE_PRINT:
1073             return "KEYCODE_PRINT";
1074         case KEYCODE_CHAT:
1075             return "KEYCODE_CHAT";
1076         case KEYCODE_FINANCE:
1077             return "KEYCODE_FINANCE";
1078         case KEYCODE_CANCEL:
1079             return "KEYCODE_CANCEL";
1080         case KEYCODE_KBDILLUM_TOGGLE:
1081             return "KEYCODE_KBDILLUM_TOGGLE";
1082         case KEYCODE_KBDILLUM_DOWN:
1083             return "KEYCODE_KBDILLUM_DOWN";
1084         case KEYCODE_KBDILLUM_UP:
1085             return "KEYCODE_KBDILLUM_UP";
1086         case KEYCODE_SEND:
1087             return "KEYCODE_SEND";
1088         case KEYCODE_REPLY:
1089             return "KEYCODE_REPLY";
1090         case KEYCODE_FORWARDMAIL:
1091             return "KEYCODE_FORWARDMAIL";
1092         case KEYCODE_SAVE:
1093             return "KEYCODE_SAVE";
1094         case KEYCODE_DOCUMENTS:
1095             return "KEYCODE_DOCUMENTS";
1096         case KEYCODE_VIDEO_NEXT:
1097             return "KEYCODE_VIDEO_NEXT";
1098         case KEYCODE_VIDEO_PREV:
1099             return "KEYCODE_VIDEO_PREV";
1100         case KEYCODE_BRIGHTNESS_CYCLE:
1101             return "KEYCODE_BRIGHTNESS_CYCLE";
1102         case KEYCODE_BRIGHTNESS_ZERO:
1103             return "KEYCODE_BRIGHTNESS_ZERO";
1104         case KEYCODE_DISPLAY_OFF:
1105             return "KEYCODE_DISPLAY_OFF";
1106         case KEYCODE_BTN_MISC:
1107             return "KEYCODE_BTN_MISC";
1108         case KEYCODE_GOTO:
1109             return "KEYCODE_GOTO";
1110         case KEYCODE_INFO:
1111             return "KEYCODE_INFO";
1112         case KEYCODE_PROGRAM:
1113             return "KEYCODE_PROGRAM";
1114         case KEYCODE_PVR:
1115             return "KEYCODE_PVR";
1116         case KEYCODE_SUBTITLE:
1117             return "KEYCODE_SUBTITLE";
1118         case KEYCODE_FULL_SCREEN:
1119             return "KEYCODE_FULL_SCREEN";
1120         case KEYCODE_KEYBOARD:
1121             return "KEYCODE_KEYBOARD";
1122         case KEYCODE_ASPECT_RATIO:
1123             return "KEYCODE_ASPECT_RATIO";
1124         case KEYCODE_PC:
1125             return "KEYCODE_PC";
1126         case KEYCODE_TV:
1127             return "KEYCODE_TV";
1128         case KEYCODE_TV2:
1129             return "KEYCODE_TV2";
1130         case KEYCODE_VCR:
1131             return "KEYCODE_VCR";
1132         case KEYCODE_VCR2:
1133             return "KEYCODE_VCR2";
1134         case KEYCODE_SAT:
1135             return "KEYCODE_SAT";
1136         case KEYCODE_CD:
1137             return "KEYCODE_CD";
1138         case KEYCODE_TAPE:
1139             return "KEYCODE_TAPE";
1140         case KEYCODE_TUNER:
1141             return "KEYCODE_TUNER";
1142         case KEYCODE_PLAYER:
1143             return "KEYCODE_PLAYER";
1144         case KEYCODE_DVD:
1145             return "KEYCODE_DVD";
1146         case KEYCODE_AUDIO:
1147             return "KEYCODE_AUDIO";
1148         case KEYCODE_VIDEO:
1149             return "KEYCODE_VIDEO";
1150         case KEYCODE_MEMO:
1151             return "KEYCODE_MEMO";
1152         case KEYCODE_CALENDAR:
1153             return "KEYCODE_CALENDAR";
1154         case KEYCODE_RED:
1155             return "KEYCODE_RED";
1156         case KEYCODE_GREEN:
1157             return "KEYCODE_GREEN";
1158         case KEYCODE_YELLOW:
1159             return "KEYCODE_YELLOW";
1160         case KEYCODE_BLUE:
1161             return "KEYCODE_BLUE";
1162         case KEYCODE_CHANNELUP:
1163             return "KEYCODE_CHANNELUP";
1164         case KEYCODE_CHANNELDOWN:
1165             return "KEYCODE_CHANNELDOWN";
1166         case KEYCODE_LAST:
1167             return "KEYCODE_LAST";
1168         case KEYCODE_RESTART:
1169             return "KEYCODE_RESTART";
1170         case KEYCODE_SLOW:
1171             return "KEYCODE_SLOW";
1172         case KEYCODE_SHUFFLE:
1173             return "KEYCODE_SHUFFLE";
1174         case KEYCODE_VIDEOPHONE:
1175             return "KEYCODE_VIDEOPHONE";
1176         case KEYCODE_GAMES:
1177             return "KEYCODE_GAMES";
1178         case KEYCODE_ZOOMIN:
1179             return "KEYCODE_ZOOMIN";
1180         case KEYCODE_ZOOMOUT:
1181             return "KEYCODE_ZOOMOUT";
1182         case KEYCODE_ZOOMRESET:
1183             return "KEYCODE_ZOOMRESET";
1184         case KEYCODE_WORDPROCESSOR:
1185             return "KEYCODE_WORDPROCESSOR";
1186         case KEYCODE_EDITOR:
1187             return "KEYCODE_EDITOR";
1188         case KEYCODE_SPREADSHEET:
1189             return "KEYCODE_SPREADSHEET";
1190         case KEYCODE_GRAPHICSEDITOR:
1191             return "KEYCODE_GRAPHICSEDITOR";
1192         case KEYCODE_PRESENTATION:
1193             return "KEYCODE_PRESENTATION";
1194         case KEYCODE_DATABASE:
1195             return "KEYCODE_DATABASE";
1196         case KEYCODE_NEWS:
1197             return "KEYCODE_NEWS";
1198         case KEYCODE_VOICEMAIL:
1199             return "KEYCODE_VOICEMAIL";
1200         case KEYCODE_ADDRESSBOOK:
1201             return "KEYCODE_ADDRESSBOOK";
1202         case KEYCODE_MESSENGER:
1203             return "KEYCODE_MESSENGER";
1204         case KEYCODE_BRIGHTNESS_TOGGLE:
1205             return "KEYCODE_BRIGHTNESS_TOGGLE";
1206         case KEYCODE_SPELLCHECK:
1207             return "KEYCODE_SPELLCHECK";
1208         case KEYCODE_COFFEE:
1209             return "KEYCODE_COFFEE";
1210         case KEYCODE_MEDIA_REPEAT:
1211             return "KEYCODE_MEDIA_REPEAT";
1212         case KEYCODE_IMAGES:
1213             return "KEYCODE_IMAGES";
1214         case KEYCODE_BUTTONCONFIG:
1215             return "KEYCODE_BUTTONCONFIG";
1216         case KEYCODE_TASKMANAGER:
1217             return "KEYCODE_TASKMANAGER";
1218         case KEYCODE_JOURNAL:
1219             return "KEYCODE_JOURNAL";
1220         case KEYCODE_CONTROLPANEL:
1221             return "KEYCODE_CONTROLPANEL";
1222         case KEYCODE_APPSELECT:
1223             return "KEYCODE_APPSELECT";
1224         case KEYCODE_SCREENSAVER:
1225             return "KEYCODE_SCREENSAVER";
1226         case KEYCODE_ASSISTANT:
1227             return "KEYCODE_ASSISTANT";
1228         case KEYCODE_KBD_LAYOUT_NEXT:
1229             return "KEYCODE_KBD_LAYOUT_NEXT";
1230         case KEYCODE_BRIGHTNESS_MIN:
1231             return "KEYCODE_BRIGHTNESS_MIN";
1232         case KEYCODE_BRIGHTNESS_MAX:
1233             return "KEYCODE_BRIGHTNESS_MAX";
1234         case KEYCODE_KBDINPUTASSIST_PREV:
1235             return "KEYCODE_KBDINPUTASSIST_PREV";
1236         case KEYCODE_KBDINPUTASSIST_NEXT:
1237             return "KEYCODE_KBDINPUTASSIST_NEXT";
1238         case KEYCODE_KBDINPUTASSIST_PREVGROUP:
1239             return "KEYCODE_KBDINPUTASSIST_PREVGROUP";
1240         case KEYCODE_KBDINPUTASSIST_NEXTGROUP:
1241             return "KEYCODE_KBDINPUTASSIST_NEXTGROUP";
1242         case KEYCODE_KBDINPUTASSIST_ACCEPT:
1243             return "KEYCODE_KBDINPUTASSIST_ACCEPT";
1244         case KEYCODE_KBDINPUTASSIST_CANCEL:
1245             return "KEYCODE_KBDINPUTASSIST_CANCEL";
1246         case KEYCODE_FRONT:
1247             return "KEYCODE_FRONT";
1248         case KEYCODE_SETUP:
1249             return "KEYCODE_SETUP";
1250         case KEYCODE_WAKEUP:
1251             return "KEYCODE_WAKEUP";
1252         case KEYCODE_SENDFILE:
1253             return "KEYCODE_SENDFILE";
1254         case KEYCODE_DELETEFILE:
1255             return "KEYCODE_DELETEFILE";
1256         case KEYCODE_XFER:
1257             return "KEYCODE_XFER";
1258         case KEYCODE_PROG1:
1259             return "KEYCODE_PROG1";
1260         case KEYCODE_PROG2:
1261             return "KEYCODE_PROG2";
1262         case KEYCODE_MSDOS:
1263             return "KEYCODE_MSDOS";
1264         case KEYCODE_SCREENLOCK:
1265             return "KEYCODE_SCREENLOCK";
1266         case KEYCODE_DIRECTION_ROTATE_DISPLAY:
1267             return "KEYCODE_DIRECTION_ROTATE_DISPLAY";
1268         case KEYCODE_CYCLEWINDOWS:
1269             return "KEYCODE_CYCLEWINDOWS";
1270         case KEYCODE_COMPUTER:
1271             return "KEYCODE_COMPUTER";
1272         case KEYCODE_EJECTCLOSECD:
1273             return "KEYCODE_EJECTCLOSECD";
1274         case KEYCODE_ISO:
1275             return "KEYCODE_ISO";
1276         case KEYCODE_MOVE:
1277             return "KEYCODE_MOVE";
1278         case KEYCODE_F13:
1279             return "KEYCODE_F13";
1280         case KEYCODE_F14:
1281             return "KEYCODE_F14";
1282         case KEYCODE_F15:
1283             return "KEYCODE_F15";
1284         case KEYCODE_F16:
1285             return "KEYCODE_F16";
1286         case KEYCODE_F17:
1287             return "KEYCODE_F17";
1288         case KEYCODE_F18:
1289             return "KEYCODE_F18";
1290         case KEYCODE_F19:
1291             return "KEYCODE_F19";
1292         case KEYCODE_F20:
1293             return "KEYCODE_F20";
1294         case KEYCODE_F21:
1295             return "KEYCODE_F21";
1296         case KEYCODE_F22:
1297             return "KEYCODE_F22";
1298         case KEYCODE_F23:
1299             return "KEYCODE_F23";
1300         case KEYCODE_F24:
1301             return "KEYCODE_F24";
1302         case KEYCODE_PROG3:
1303             return "KEYCODE_PROG3";
1304         case KEYCODE_PROG4:
1305             return "KEYCODE_PROG4";
1306         case KEYCODE_DASHBOARD:
1307             return "KEYCODE_DASHBOARD";
1308         case KEYCODE_SUSPEND:
1309             return "KEYCODE_SUSPEND";
1310         case KEYCODE_HP:
1311             return "KEYCODE_HP";
1312         case KEYCODE_SOUND:
1313             return "KEYCODE_SOUND";
1314         case KEYCODE_QUESTION:
1315             return "KEYCODE_QUESTION";
1316         case KEYCODE_CONNECT:
1317             return "KEYCODE_CONNECT";
1318         case KEYCODE_SPORT:
1319             return "KEYCODE_SPORT";
1320         case KEYCODE_SHOP:
1321             return "KEYCODE_SHOP";
1322         case KEYCODE_ALTERASE:
1323             return "KEYCODE_ALTERASE";
1324         case KEYCODE_SWITCHVIDEOMODE:
1325             return "KEYCODE_SWITCHVIDEOMODE";
1326         case KEYCODE_BATTERY:
1327             return "KEYCODE_BATTERY";
1328         case KEYCODE_BLUETOOTH:
1329             return "KEYCODE_BLUETOOTH";
1330         case KEYCODE_WLAN:
1331             return "KEYCODE_WLAN";
1332         case KEYCODE_UWB:
1333             return "KEYCODE_UWB";
1334         case KEYCODE_WWAN_WIMAX:
1335             return "KEYCODE_WWAN_WIMAX";
1336         case KEYCODE_RFKILL:
1337             return "KEYCODE_RFKILL";
1338         case KEYCODE_CHANNEL:
1339             return "KEYCODE_CHANNEL";
1340         case KEYCODE_BTN_0:
1341             return "KEYCODE_BTN_0";
1342         case KEYCODE_BTN_1:
1343             return "KEYCODE_BTN_1";
1344         case KEYCODE_BTN_2:
1345             return "KEYCODE_BTN_2";
1346         case KEYCODE_BTN_3:
1347             return "KEYCODE_BTN_3";
1348         case KEYCODE_BTN_4:
1349             return "KEYCODE_BTN_4";
1350         case KEYCODE_BTN_5:
1351             return "KEYCODE_BTN_5";
1352         case KEYCODE_BTN_6:
1353             return "KEYCODE_BTN_6";
1354         case KEYCODE_BTN_7:
1355             return "KEYCODE_BTN_7";
1356         case KEYCODE_BTN_8:
1357             return "KEYCODE_BTN_8";
1358         case KEYCODE_BTN_9:
1359             return "KEYCODE_BTN_9";
1360         case KEYCODE_BRL_DOT1:
1361             return "KEYCODE_BRL_DOT1";
1362         case KEYCODE_BRL_DOT2:
1363             return "KEYCODE_BRL_DOT2";
1364         case KEYCODE_BRL_DOT3:
1365             return "KEYCODE_BRL_DOT3";
1366         case KEYCODE_BRL_DOT4:
1367             return "KEYCODE_BRL_DOT4";
1368         case KEYCODE_BRL_DOT5:
1369             return "KEYCODE_BRL_DOT5";
1370         case KEYCODE_BRL_DOT6:
1371             return "KEYCODE_BRL_DOT6";
1372         case KEYCODE_BRL_DOT7:
1373             return "KEYCODE_BRL_DOT7";
1374         case KEYCODE_BRL_DOT8:
1375             return "KEYCODE_BRL_DOT8";
1376         case KEYCODE_BRL_DOT9:
1377             return "KEYCODE_BRL_DOT9";
1378         case KEYCODE_BRL_DOT10:
1379             return "KEYCODE_BRL_DOT10";
1380         case KEYCODE_LEFT_KNOB_ROLL_UP:
1381             return "KEYCODE_LEFT_KNOB_ROLL_UP";
1382         case KEYCODE_LEFT_KNOB_ROLL_DOWN:
1383             return "KEYCODE_LEFT_KNOB_ROLL_DOWN";
1384         case KEYCODE_LEFT_KNOB:
1385             return "KEYCODE_LEFT_KNOB";
1386         case KEYCODE_RIGHT_KNOB_ROLL_UP:
1387             return "KEYCODE_RIGHT_KNOB_ROLL_UP";
1388         case KEYCODE_RIGHT_KNOB_ROLL_DOWN:
1389             return "KEYCODE_RIGHT_KNOB_ROLL_DOWN";
1390         case KEYCODE_RIGHT_KNOB:
1391             return "KEYCODE_RIGHT_KNOB";
1392         case KEYCODE_VOICE_SOURCE_SWITCH:
1393             return "KEYCODE_VOICE_SOURCE_SWITCH";
1394         case KEYCODE_LAUNCHER_MENU:
1395             return "KEYCODE_LAUNCHER_MENU";
1396         default:
1397             return "KEYCODE_INVALID";
1398 
1399     }
1400 }
1401 
Clone(std::shared_ptr<KeyEvent> keyEvent)1402 std::shared_ptr<KeyEvent> KeyEvent::Clone(std::shared_ptr<KeyEvent> keyEvent) {
1403     if (!keyEvent) {
1404         return nullptr;
1405     }
1406 
1407     return std::shared_ptr<KeyEvent>(new KeyEvent(*keyEvent.get()));
1408 }
1409 
IsValidKeyItem() const1410 bool KeyEvent::IsValidKeyItem() const
1411 {
1412     HiLog::Debug(LABEL, "KeyEvent::IsValidKeyItem begin");
1413     int32_t noPressNum = 0;
1414     int32_t keyCode = GetKeyCode();
1415     int32_t action = GetKeyAction();
1416 
1417     for (auto it = keys_.begin(); it != keys_.end(); ++it) {
1418         if (it->GetKeyCode() <= KEYCODE_UNKNOWN) {
1419             HiLog::Error(LABEL, "keyCode is invalid");
1420             return false;
1421         }
1422         if (it->GetDownTime() <= 0) {
1423             HiLog::Error(LABEL, "downtime is invalid");
1424             return false;
1425         }
1426         if (action != KEY_ACTION_UP && it->IsPressed() == false) {
1427             HiLog::Error(LABEL, "isPressed is invalid");
1428             return false;
1429         }
1430         if (action == KEY_ACTION_UP && it->IsPressed() == false) {
1431             noPressNum++;
1432             if (it->GetKeyCode() != keyCode) {
1433                 HiLog::Error(LABEL, "keyCode is invalid when isPressed is false");
1434                 return false;
1435             }
1436         }
1437 
1438         auto item = it;
1439         for (++item; item != keys_.end(); item++) {
1440             if (it->GetKeyCode() == item->GetKeyCode()) {
1441                 HiLog::Error(LABEL, "Keyitems keyCode exist same items");
1442                 return false;
1443             }
1444         }
1445     }
1446 
1447     if (noPressNum != 1) {
1448         HiLog::Error(LABEL, "keyCode is not unique when isPressed is false");
1449         return false;
1450     }
1451     HiLog::Debug(LABEL, "KeyEvent::IsValidKeyItem end");
1452     return true;
1453 }
1454 
IsValid() const1455 bool KeyEvent::IsValid() const
1456 {
1457     HiLog::Debug(LABEL, "KeyEvent::IsValid begin");
1458     int32_t keyCode = GetKeyCode();
1459     if (keyCode <= KEYCODE_UNKNOWN) {
1460         HiLog::Error(LABEL, "KeyCode_ is invalid");
1461         return false;
1462     }
1463 
1464     if (GetActionTime() <= 0) {
1465         HiLog::Error(LABEL, "Actiontime is invalid");
1466         return false;
1467     }
1468 
1469     int32_t action = GetKeyAction();
1470     if (action != KEY_ACTION_CANCEL && action != KEY_ACTION_UP &&
1471         action != KEY_ACTION_DOWN) {
1472         HiLog::Error(LABEL, "Action is invalid");
1473         return false;
1474     }
1475 
1476     if (!IsValidKeyItem()) {
1477         HiLog::Error(LABEL, "IsValidKeyItem is invalid");
1478         return false;
1479     }
1480     HiLog::Debug(LABEL, "KeyEvent::IsValid end");
1481     return true;
1482 }
1483 
1484 
WriteToParcel(Parcel & out) const1485 bool KeyEvent::WriteToParcel(Parcel &out) const
1486 {
1487     if (!InputEvent::WriteToParcel(out)) {
1488         return false;
1489     }
1490     if (!out.WriteInt32(keyCode_)) {
1491         return false;
1492     }
1493     if (keys_.size() > INT_MAX) {
1494         return false;
1495     }
1496     if (!out.WriteInt32(static_cast<int32_t>(keys_.size()))) {
1497         return false;
1498     }
1499     for (const auto &item : keys_) {
1500         if (!item.WriteToParcel(out)) {
1501             return false;
1502         }
1503     }
1504     if (!out.WriteInt32(keyAction_)) {
1505         return false;
1506     }
1507 
1508     return true;
1509 }
1510 
ReadFromParcel(Parcel & in)1511 bool KeyEvent::ReadFromParcel(Parcel &in)
1512 {
1513     if (!InputEvent::ReadFromParcel(in)) {
1514         return false;
1515     }
1516     if (!in.ReadInt32(keyCode_)) {
1517         return false;
1518     }
1519     const int32_t keysSize = in.ReadInt32();
1520     if (keysSize < 0) {
1521         return false;
1522     }
1523     for (int32_t i = 0; i < keysSize; i++) {
1524         KeyItem val = {};
1525         if (!val.ReadFromParcel(in)) {
1526             return false;
1527         }
1528         keys_.push_back(val);
1529     }
1530     if (!in.ReadInt32(keyAction_)) {
1531         return false;
1532     }
1533 
1534     return true;
1535 }
1536 } // namespace MMI
1537 } // namespace OHOS
1538