1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 #ifndef __APP_KEY_H__ 5 #define __APP_KEY_H__ 6 7 #include "hal_key.h" 8 9 #define APP_KEY_SET_MESSAGE(appevt, code, evt) (appevt = (((uint32_t)code&0xffffff)<<8)|(evt&0xff)) 10 #define APP_KEY_GET_CODE(appevt, code) (code = (appevt>>8)&0xffffff) 11 #define APP_KEY_GET_EVENT(appevt, evt) (evt = appevt&0xff) 12 13 #define APP_KEY_CODE_GOOGLE APP_KEY_CODE_FN15 14 #define APP_KEY_CODE_VOICEPATH APP_KEY_CODE_FN15 15 16 enum APP_KEY_CODE_T { 17 APP_KEY_CODE_NONE = HAL_KEY_CODE_NONE, 18 APP_KEY_CODE_PWR = HAL_KEY_CODE_PWR, 19 APP_KEY_CODE_FN1 = HAL_KEY_CODE_FN1, 20 APP_KEY_CODE_FN2 = HAL_KEY_CODE_FN2, 21 APP_KEY_CODE_FN3 = HAL_KEY_CODE_FN3, 22 APP_KEY_CODE_FN4 = HAL_KEY_CODE_FN4, 23 APP_KEY_CODE_FN5 = HAL_KEY_CODE_FN5, 24 APP_KEY_CODE_FN6 = HAL_KEY_CODE_FN6, 25 APP_KEY_CODE_FN7 = HAL_KEY_CODE_FN7, 26 APP_KEY_CODE_FN8 = HAL_KEY_CODE_FN8, 27 APP_KEY_CODE_FN9 = HAL_KEY_CODE_FN9, 28 APP_KEY_CODE_FN10 = HAL_KEY_CODE_FN10, 29 APP_KEY_CODE_FN11 = HAL_KEY_CODE_FN11, 30 APP_KEY_CODE_FN12 = HAL_KEY_CODE_FN12, 31 APP_KEY_CODE_FN13 = HAL_KEY_CODE_FN13, 32 APP_KEY_CODE_FN14 = HAL_KEY_CODE_FN14, 33 APP_KEY_CODE_FN15 = HAL_KEY_CODE_FN15, 34 }; 35 36 enum APP_KEY_EVENT_T { 37 APP_KEY_EVENT_NONE = HAL_KEY_EVENT_NONE, 38 APP_KEY_EVENT_DOWN = HAL_KEY_EVENT_DOWN, 39 APP_KEY_EVENT_FIRST_DOWN = HAL_KEY_EVENT_FIRST_DOWN, 40 APP_KEY_EVENT_CONTINUED_DOWN = HAL_KEY_EVENT_CONTINUED_DOWN, 41 APP_KEY_EVENT_UP = HAL_KEY_EVENT_UP, 42 APP_KEY_EVENT_UP_AFTER_LONGPRESS = HAL_KEY_EVENT_UP_AFTER_LONGPRESS, 43 APP_KEY_EVENT_LONGPRESS = HAL_KEY_EVENT_LONGPRESS, 44 APP_KEY_EVENT_LONGLONGPRESS = HAL_KEY_EVENT_LONGLONGPRESS, 45 APP_KEY_EVENT_CLICK = HAL_KEY_EVENT_CLICK, 46 APP_KEY_EVENT_DOUBLECLICK = HAL_KEY_EVENT_DOUBLECLICK, 47 APP_KEY_EVENT_TRIPLECLICK = HAL_KEY_EVENT_TRIPLECLICK, 48 APP_KEY_EVENT_ULTRACLICK = HAL_KEY_EVENT_ULTRACLICK, 49 APP_KEY_EVENT_RAMPAGECLICK = HAL_KEY_EVENT_RAMPAGECLICK, 50 APP_KEY_EVENT_REPEAT = HAL_KEY_EVENT_REPEAT, 51 APP_KEY_EVENT_GROUPKEY_DOWN = HAL_KEY_EVENT_GROUPKEY_DOWN, 52 APP_KEY_EVENT_GROUPKEY_REPEAT = HAL_KEY_EVENT_GROUPKEY_REPEAT, 53 APP_KEY_EVENT_INITDOWN = HAL_KEY_EVENT_INITDOWN, 54 APP_KEY_EVENT_INITUP = HAL_KEY_EVENT_INITUP, 55 APP_KEY_EVENT_INITLONGPRESS = HAL_KEY_EVENT_INITLONGPRESS, 56 APP_KEY_EVENT_INITLONGLONGPRESS = HAL_KEY_EVENT_INITLONGLONGPRESS, 57 APP_KEY_EVENT_INITFINISHED = HAL_KEY_EVENT_INITFINISHED, 58 59 APP_KEY_EVENT_NUM = HAL_KEY_EVENT_NUM, 60 }; 61 62 typedef struct { 63 uint32_t code; 64 uint8_t event; 65 }APP_KEY_STATUS; 66 67 typedef void (*APP_KEY_HANDLE_CB_T)(APP_KEY_STATUS*, void *param); 68 69 typedef struct { 70 APP_KEY_STATUS key_status; 71 const char* string; 72 APP_KEY_HANDLE_CB_T function; 73 void *param; 74 } APP_KEY_HANDLE; 75 76 #ifdef __cplusplus 77 extern "C" { 78 #endif 79 80 int app_key_open(int checkPwrKey); 81 82 int app_key_close(void); 83 84 uint32_t app_key_read_status(uint32_t code); 85 86 int app_key_handle_registration(const APP_KEY_HANDLE *key_handle); 87 88 void app_key_handle_clear(void); 89 90 void app_key_simulate_key_event(uint32_t key_code, uint8_t key_event); 91 92 int simul_key_event_process(uint32_t key_code, uint8_t key_event); 93 94 #ifdef __cplusplus 95 } 96 #endif 97 #endif//__FMDEC_H__ 98