1 /*
2  * Copyright (c) 2023 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 #ifndef FOUNDATION_ACE_ADAPTER_PREVIEW_EXTERNAL_MULTIMODALINPUT_KEY_EVENT_H
17 #define FOUNDATION_ACE_ADAPTER_PREVIEW_EXTERNAL_MULTIMODALINPUT_KEY_EVENT_H
18 
19 #include <vector>
20 
21 #include "adapter/preview/external/multimodalinput/common_type.h"
22 
23 namespace OHOS {
24 namespace MMI {
25 
26 enum class KeyCode : int32_t {
27     KEY_UNKNOWN = -1,
28     KEY_FN = 0, // New
29     KEY_HOME = 1,
30     KEY_BACK = 2,
31     KEY_CALL = 3,
32     KEY_ENDCALL = 4,
33     KEY_CLEAR = 5,
34     KEY_HEADSETHOOK = 6,
35     KEY_FOCUS = 7,
36     KEY_NOTIFICATION = 8,
37     KEY_SEARCH = 9,
38     KEY_MEDIA_PLAY_PAUSE = 10,
39     KEY_MEDIA_STOP = 11,
40     KEY_MEDIA_NEXT = 12,
41     KEY_MEDIA_PREVIOUS = 13,
42     KEY_MEDIA_REWIND = 14,
43     KEY_MEDIA_FAST_FORWARD = 15,
44     KEY_VOLUME_UP = 16,
45     KEY_VOLUME_DOWN = 17,
46     KEY_POWER = 18,
47     KEY_CAMERA = 19,
48     KEY_VOICE_ASSISTANT = 20,
49     KEY_CUSTOM1 = 21,
50     KEY_VOLUME_MUTE = 22, // New
51     KEY_MUTE = 23,        // New
52     KEY_BRIGHTNESS_UP = 40,
53     KEY_BRIGHTNESS_DOWN = 41,
54     KEY_WEAR_1 = 1001,
55     KEY_0 = 2000,
56     KEY_1 = 2001,
57     KEY_2 = 2002,
58     KEY_3 = 2003,
59     KEY_4 = 2004,
60     KEY_5 = 2005,
61     KEY_6 = 2006,
62     KEY_7 = 2007,
63     KEY_8 = 2008,
64     KEY_9 = 2009,
65     KEY_STAR = 2010,
66     KEY_POUND = 2011,
67     KEY_DPAD_UP = 2012,
68     KEY_DPAD_DOWN = 2013,
69     KEY_DPAD_LEFT = 2014,
70     KEY_DPAD_RIGHT = 2015,
71     KEY_DPAD_CENTER = 2016,
72     KEY_A = 2017,
73     KEY_B = 2018,
74     KEY_C = 2019,
75     KEY_D = 2020,
76     KEY_E = 2021,
77     KEY_F = 2022,
78     KEY_G = 2023,
79     KEY_H = 2024,
80     KEY_I = 2025,
81     KEY_J = 2026,
82     KEY_K = 2027,
83     KEY_L = 2028,
84     KEY_M = 2029,
85     KEY_N = 2030,
86     KEY_O = 2031,
87     KEY_P = 2032,
88     KEY_Q = 2033,
89     KEY_R = 2034,
90     KEY_S = 2035,
91     KEY_T = 2036,
92     KEY_U = 2037,
93     KEY_V = 2038,
94     KEY_W = 2039,
95     KEY_X = 2040,
96     KEY_Y = 2041,
97     KEY_Z = 2042,
98     KEY_COMMA = 2043,
99     KEY_PERIOD = 2044,
100     KEY_ALT_LEFT = 2045,
101     KEY_ALT_RIGHT = 2046,
102     KEY_SHIFT_LEFT = 2047,
103     KEY_SHIFT_RIGHT = 2048,
104     KEY_TAB = 2049,
105     KEY_SPACE = 2050,
106     KEY_SYM = 2051,
107     KEY_EXPLORER = 2052,
108     KEY_ENVELOPE = 2053,
109     KEY_ENTER = 2054,
110     KEY_DEL = 2055,
111     KEY_GRAVE = 2056,
112     KEY_MINUS = 2057,
113     KEY_EQUALS = 2058,
114     KEY_LEFT_BRACKET = 2059,
115     KEY_RIGHT_BRACKET = 2060,
116     KEY_BACKSLASH = 2061,
117     KEY_SEMICOLON = 2062,
118     KEY_APOSTROPHE = 2063,
119     KEY_SLASH = 2064,
120     KEY_AT = 2065,
121     KEY_PLUS = 2066,
122     KEY_MENU = 2067,
123     KEY_PAGE_UP = 2068,
124     KEY_PAGE_DOWN = 2069,
125     KEY_ESCAPE = 2070,
126     KEY_FORWARD_DEL = 2071,
127     KEY_CTRL_LEFT = 2072,
128     KEY_CTRL_RIGHT = 2073,
129     KEY_CAPS_LOCK = 2074,
130     KEY_SCROLL_LOCK = 2075,
131     KEY_META_LEFT = 2076,
132     KEY_META_RIGHT = 2077,
133     KEY_FUNCTION = 2078,
134     KEY_SYSRQ = 2079,
135     KEY_BREAK = 2080,
136     KEY_MOVE_HOME = 2081,
137     KEY_MOVE_END = 2082,
138     KEY_INSERT = 2083,
139     KEY_FORWARD = 2084,
140     KEY_MEDIA_PLAY = 2085,
141     KEY_MEDIA_PAUSE = 2086,
142     KEY_MEDIA_CLOSE = 2087,
143     KEY_MEDIA_EJECT = 2088,
144     KEY_MEDIA_RECORD = 2089,
145     KEY_F1 = 2090,
146     KEY_F2 = 2091,
147     KEY_F3 = 2092,
148     KEY_F4 = 2093,
149     KEY_F5 = 2094,
150     KEY_F6 = 2095,
151     KEY_F7 = 2096,
152     KEY_F8 = 2097,
153     KEY_F9 = 2098,
154     KEY_F10 = 2099,
155     KEY_F11 = 2100,
156     KEY_F12 = 2101,
157     KEY_NUM_LOCK = 2102,
158     KEY_NUMPAD_0 = 2103,
159     KEY_NUMPAD_1 = 2104,
160     KEY_NUMPAD_2 = 2105,
161     KEY_NUMPAD_3 = 2106,
162     KEY_NUMPAD_4 = 2107,
163     KEY_NUMPAD_5 = 2108,
164     KEY_NUMPAD_6 = 2109,
165     KEY_NUMPAD_7 = 2110,
166     KEY_NUMPAD_8 = 2111,
167     KEY_NUMPAD_9 = 2112,
168     KEY_NUMPAD_DIVIDE = 2113,
169     KEY_NUMPAD_MULTIPLY = 2114,
170     KEY_NUMPAD_SUBTRACT = 2115,
171     KEY_NUMPAD_ADD = 2116,
172     KEY_NUMPAD_DOT = 2117,
173     KEY_NUMPAD_COMMA = 2118,
174     KEY_NUMPAD_ENTER = 2119,
175     KEY_NUMPAD_EQUALS = 2120,
176     KEY_NUMPAD_LEFT_PAREN = 2121,
177     KEY_NUMPAD_RIGHT_PAREN = 2122,
178     // New Start
179     KEY_VIRTUAL_MULTITASK = 2210,
180     KEY_BUTTON_A = 2301,
181     KEY_BUTTON_B = 2302,
182     KEY_BUTTON_C = 2303,
183     KEY_BUTTON_X = 2304,
184     KEY_BUTTON_Y = 2305,
185     KEY_BUTTON_Z = 2306,
186     KEY_BUTTON_L1 = 2307,
187     KEY_BUTTON_R1 = 2308,
188     KEY_BUTTON_L2 = 2309,
189     KEY_BUTTON_R2 = 2310,
190     KEY_BUTTON_SELECT = 2311,
191     KEY_BUTTON_START = 2312,
192     KEY_BUTTON_MODE = 2313,
193     KEY_BUTTON_THUMBL = 2314,
194     KEY_BUTTON_THUMBR = 2315,
195     KEY_BUTTON_TRIGGER = 2401,
196     KEY_BUTTON_THUMB = 2402,
197     KEY_BUTTON_THUMB2 = 2403,
198     KEY_BUTTON_TOP = 2404,
199     KEY_BUTTON_TOP2 = 2405,
200     KEY_BUTTON_PINKIE = 2406,
201     KEY_BUTTON_BASE1 = 2407,
202     KEY_BUTTON_BASE2 = 2408,
203     KEY_BUTTON_BASE3 = 2409,
204     KEY_BUTTON_BASE4 = 2410,
205     KEY_BUTTON_BASE5 = 2411,
206     KEY_BUTTON_BASE6 = 2412,
207     KEY_BUTTON_BASE7 = 2413,
208     KEY_BUTTON_BASE8 = 2414,
209     KEY_BUTTON_BASE9 = 2415,
210     KEY_BUTTON_DEAD = 2416,
211     KEY_SLEEP = 2600,
212     KEY_ZENKAKU_HANKAKU = 2601,
213     KEY_102ND = 2602,
214     KEY_RO = 2603,
215     KEY_KATAKANA = 2604,
216     KEY_HIRAGANA = 2605,
217     KEY_HENKAN = 2606,
218     KEY_KATAKANA_HIRAGANA = 2607,
219     KEY_MUHENKAN = 2608,
220     KEY_LINEFEED = 2609,
221     KEY_MACRO = 2610,
222     KEY_NUMPAD_PLUSMINUS = 2611,
223     KEY_SCALE = 2612,
224     KEY_HANGUEL = 2613,
225     KEY_HANJA = 2614,
226     KEY_YEN = 2615,
227     KEY_STOP = 2616,
228     KEY_AGAIN = 2617,
229     KEY_PROPS = 2618,
230     KEY_UNDO = 2619,
231     KEY_COPY = 2620,
232     KEY_OPEN = 2621,
233     KEY_PASTE = 2622,
234     KEY_FIND = 2623,
235     KEY_CUT = 2624,
236     KEY_HELP = 2625,
237     KEY_CALC = 2626,
238     KEY_FILE = 2627,
239     KEY_BOOKMARKS = 2628,
240     KEY_NEXT = 2629,
241     KEY_PLAYPAUSE = 2630,
242     KEY_PREVIOUS = 2631,
243     KEY_STOPCD = 2632,
244     KEY_CONFIG = 2634,
245     KEY_REFRESH = 2635,
246     KEY_EXIT = 2636,
247     KEY_EDIT = 2637,
248     KEY_SCROLLUP = 2638,
249     KEY_SCROLLDOWN = 2639,
250     KEY_NEW = 2640,
251     KEY_REDO = 2641,
252     KEY_CLOSE = 2642,
253     KEY_PLAY = 2643,
254     KEY_BASSBOOST = 2644,
255     KEY_PRINT = 2645,
256     KEY_CHAT = 2646,
257     KEY_FINANCE = 2647,
258     KEY_CANCEL = 2648,
259     KEY_KBDILLUM_TOGGLE = 2649,
260     KEY_KBDILLUM_DOWN = 2650,
261     KEY_KBDILLUM_UP = 2651,
262     KEY_SEND = 2652,
263     KEY_REPLY = 2653,
264     KEY_FORWARDMAIL = 2654,
265     KEY_SAVE = 2655,
266     KEY_DOCUMENTS = 2656,
267     KEY_VIDEO_NEXT = 2657,
268     KEY_VIDEO_PREV = 2658,
269     KEY_BRIGHTNESS_CYCLE = 2659,
270     KEY_BRIGHTNESS_ZERO = 2660,
271     KEY_DISPLAY_OFF = 2661,
272     KEY_BTN_MISC = 2662,
273     KEY_GOTO = 2663,
274     KEY_INFO = 2664,
275     KEY_PROGRAM = 2665,
276     KEY_PVR = 2666,
277     KEY_SUBTITLE = 2667,
278     KEY_FULL_SCREEN = 2668,
279     KEY_KEYBOARD = 2669,
280     KEY_ASPECT_RATIO = 2670,
281     KEY_PC = 2671,
282     KEY_TV = 2672,
283     KEY_TV2 = 2673,
284     KEY_VCR = 2674,
285     KEY_VCR2 = 2675,
286     KEY_SAT = 2676,
287     KEY_CD = 2677,
288     KEY_TAPE = 2678,
289     KEY_TUNER = 2679,
290     KEY_PLAYER = 2680,
291     KEY_DVD = 2681,
292     KEY_AUDIO = 2682,
293     KEY_VIDEO = 2683,
294     KEY_MEMO = 2684,
295     KEY_CALENDAR = 2685,
296     KEY_RED = 2686,
297     KEY_GREEN = 2687,
298     KEY_YELLOW = 2688,
299     KEY_BLUE = 2689,
300     KEY_CHANNELUP = 2690,
301     KEY_CHANNELDOWN = 2691,
302     KEY_LAST = 2692,
303     KEY_RESTART = 2693,
304     KEY_SLOW = 2694,
305     KEY_SHUFFLE = 2695,
306     KEY_VIDEOPHONE = 2696,
307     KEY_GAMES = 2697,
308     KEY_ZOOMIN = 2698,
309     KEY_ZOOMOUT = 2699,
310     KEY_ZOOMRESET = 2700,
311     KEY_WORDPROCESSOR = 2701,
312     KEY_EDITOR = 2702,
313     KEY_SPREADSHEET = 2703,
314     KEY_GRAPHICSEDITOR = 2704,
315     KEY_PRESENTATION = 2705,
316     KEY_DATABASE = 2706,
317     KEY_NEWS = 2707,
318     KEY_VOICEMAIL = 2708,
319     KEY_ADDRESSBOOK = 2709,
320     KEY_MESSENGER = 2710,
321     KEY_BRIGHTNESS_TOGGLE = 2711,
322     KEY_SPELLCHECK = 2712,
323     KEY_COFFEE = 2713,
324     KEY_MEDIA_REPEAT = 2714,
325     KEY_IMAGES = 2715,
326     KEY_BUTTONCONFIG = 2716,
327     KEY_TASKMANAGER = 2717,
328     KEY_JOURNAL = 2718,
329     KEY_CONTROLPANEL = 2719,
330     KEY_APPSELECT = 2720,
331     KEY_SCREENSAVER = 2721,
332     KEY_ASSISTANT = 2722,
333     KEY_KBD_LAYOUT_NEXT = 2723,
334     KEY_BRIGHTNESS_MIN = 2724,
335     KEY_BRIGHTNESS_MAX = 2725,
336     KEY_KBDINPUTASSIST_PREV = 2726,
337     KEY_KBDINPUTASSIST_NEXT = 2727,
338     KEY_KBDINPUTASSIST_PREVGROUP = 2728,
339     KEY_KBDINPUTASSIST_NEXTGROUP = 2729,
340     KEY_KBDINPUTASSIST_ACCEPT = 2730,
341     KEY_KBDINPUTASSIST_CANCEL = 2731,
342     KEY_FRONT = 2800,
343     KEY_SETUP = 2801,
344     KEY_WAKEUP = 2802,
345     KEY_SENDFILE = 2803,
346     KEY_DELETEFILE = 2804,
347     KEY_XFER = 2805,
348     KEY_PROG1 = 2806,
349     KEY_PROG2 = 2807,
350     KEY_MSDOS = 2808,
351     KEY_SCREENLOCK = 2809,
352     KEY_DIRECTION_ROTATE_DISPLAY = 2810,
353     KEY_CYCLEWINDOWS = 2811,
354     KEY_COMPUTER = 2812,
355     KEY_EJECTCLOSECD = 2813,
356     KEY_ISO = 2814,
357     KEY_MOVE = 2815,
358     KEY_F13 = 2816,
359     KEY_F14 = 2817,
360     KEY_F15 = 2818,
361     KEY_F16 = 2819,
362     KEY_F17 = 2820,
363     KEY_F18 = 2821,
364     KEY_F19 = 2822,
365     KEY_F20 = 2823,
366     KEY_F21 = 2824,
367     KEY_F22 = 2825,
368     KEY_F23 = 2826,
369     KEY_F24 = 2827,
370     KEY_PROG3 = 2828,
371     KEY_PROG4 = 2829,
372     KEY_DASHBOARD = 2830,
373     KEY_SUSPEND = 2831,
374     KEY_HP = 2832,
375     KEY_SOUND = 2833,
376     KEY_QUESTION = 2834,
377     KEY_CONNECT = 2836,
378     KEY_SPORT = 2837,
379     KEY_SHOP = 2838,
380     KEY_ALTERASE = 2839,
381     KEY_SWITCHVIDEOMODE = 2841,
382     KEY_BATTERY = 2842,
383     KEY_BLUETOOTH = 2843,
384     KEY_WLAN = 2844,
385     KEY_UWB = 2845,
386     KEY_WWAN_WIMAX = 2846,
387     KEY_RFKILL = 2847,
388     KEY_CHANNEL = 3001,
389     KEY_BTN_0 = 3100,
390     KEY_BTN_1 = 3101,
391     KEY_BTN_2 = 3102,
392     KEY_BTN_3 = 3103,
393     KEY_BTN_4 = 3104,
394     KEY_BTN_5 = 3105,
395     KEY_BTN_6 = 3106,
396     KEY_BTN_7 = 3107,
397     KEY_BTN_8 = 3108,
398     KEY_BTN_9 = 3109,
399     KEY_BRL_DOT1 = 3201,
400     KEY_BRL_DOT2 = 3202,
401     KEY_BRL_DOT3 = 3203,
402     KEY_BRL_DOT4 = 3204,
403     KEY_BRL_DOT5 = 3205,
404     KEY_BRL_DOT6 = 3206,
405     KEY_BRL_DOT7 = 3207,
406     KEY_BRL_DOT8 = 3208,
407     KEY_BRL_DOT9 = 3209,
408     KEY_BRL_DOT10 = 3210,
409     // New End
410     KEY_LEFT_KNOB_ROLL_UP = 10001,
411     KEY_LEFT_KNOB_ROLL_DOWN = 10002,
412     KEY_LEFT_KNOB = 10003,
413     KEY_RIGHT_KNOB_ROLL_UP = 10004,
414     KEY_RIGHT_KNOB_ROLL_DOWN = 10005,
415     KEY_RIGHT_KNOB = 10006,
416     KEY_VOICE_SOURCE_SWITCH = 10007,
417     KEY_LAUNCHER_MENU = 10008,
418 
419     TV_CONTROL_BACK = KEY_BACK,
420     TV_CONTROL_UP = KEY_DPAD_UP,
421     TV_CONTROL_DOWN = KEY_DPAD_DOWN,
422     TV_CONTROL_LEFT = KEY_DPAD_LEFT,
423     TV_CONTROL_RIGHT = KEY_DPAD_RIGHT,
424     TV_CONTROL_CENTER = KEY_DPAD_CENTER,
425     TV_CONTROL_ENTER = KEY_ENTER,
426     TV_CONTROL_MEDIA_PLAY = KEY_MEDIA_PLAY,
427 };
428 
429 enum class KeyAction : int32_t {
430     UNKNOWN = -1,
431     DOWN = 0,
432     UP = 1,
433     LONG_PRESS = 2,
434     CLICK = 3,
435 };
436 
437 class KeyEvent {
438 public:
439     KeyEvent() = default;
440     ~KeyEvent() = default;
441 
442 public:
443     KeyCode code { KeyCode::KEY_UNKNOWN };
444     const char* key = "";
445     KeyAction action { KeyAction::UNKNOWN };
446     std::vector<KeyCode> pressedCodes;
447     int32_t repeatTime = 0;
448     TimeStamp timeStamp;
449     int32_t metaKey = 0;
450     int64_t deviceId = 0;
451     SourceType sourceType { SourceType::NONE };
452     bool enableCapsLock_;
453     bool enableNumLock_;
454 };
455 
456 } // namespace MMI
457 } // namespace OHOS
458 #endif // FOUNDATION_ACE_ADAPTER_PREVIEW_EXTERNAL_MULTIMODALINPUT_KEY_EVENT_H
459