123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- /**
- * @file KeyboardConfig.h
- * @brief Header file of keyboard configuration.
- *
- * @verbatim
- * ==============================================================================
- * ##### How to use #####
- * ==============================================================================
- *
- *
- @ endverbatim
- *
- * @author HiView SoC Software Team
- * @version 1.0.0
- * @date 2023-05-30
- */
- #ifdef HV_CONFIG_ARCH_RISC
- #include "hv_comm_DataType.h"
- #include "hv_comm_Define.h"
- #include "hv_comm_Event.h"
- #if (HV_PROJECT_CONFIG_OSD_ROTATION == HV_CONFIG_ON)
- #if (HV_PROJECT_CONFIG_OSD_KEY_ROTATION == HV_CONFIG_ON)
- #include "hv_drv_OsdRotate.h"
- #endif
- #endif
- #endif
- #ifdef HV_CONFIG_ARCH_C51
- #include "hv_pm51_Base.h"
- #endif
- #include "Keyboard.h"
- #include "KeyboardConfig.h"
- /* 配置ADC按键对应键值
- 第一列表示按键键值的Index,根据Keyboard.h选择枚举AdcKeyVal 中定义的ADC0或ADC1保留的键值Index;
- 第二列表示具体的ADC采样的按键键值,一般为多次测量均值;不同按键键值在物理上决定了对应的是哪一个实体按键,
- 第三列表示按键键值的Offset,用于软件按键防抖处理,Offset的数值需要保证不同按键的键值不能产生重叠;
- */
- #ifdef HV_CONFIG_ARCH_C51
- xUSHORT16
- #else
- USHORT16
- #endif
- g_asAdcDataMap[ADC_KEY_NUMS][ADCDATAMAPMAX] =
- {
- {E_ADC0_KEY_VAL_0, 0x3e7, 0x50}, /* KEY2 */
- {E_ADC0_KEY_VAL_1, 0x620, 0x50}, /* AUTO */
- {E_ADC0_KEY_VAL_2, 0x24, 0x24}, /* DOWN */
- {E_ADC1_KEY_VAL_0, 0x3e7, 0x50}, /* UP */
- {E_ADC1_KEY_VAL_1, 0x620, 0x50}, /* KEY1 */
- {E_ADC1_KEY_VAL_2, 0x24, 0x50}, /* MENU */
- };
- #if ADC_COMBO_KEY_ENABLE
- /* 配置组合按键
- 组合按键只支持两路ADC按键同时开启的情况,在每一路ADC中选择一个按键,然后组合在一起定义一个组合按键。
- 第一列表示在ADC0中选择的按键键值的Index;
- 第二列表示在ADC1中选择的按键键值的Index;
- 第三列表示组合后对应的组合按键的Index,在Keyboard.h的 AdcKeyVal枚举中选择即可;
- */
- AdcComboKeyMap g_stAdcComboKeyMap[ADC_COMBO_KEY_NUMS] =
- {
- {E_ADC0_KEY_VAL_0, E_ADC1_KEY_VAL_0, E_COMBO_KEY_VAL_0},
- };
- #endif
- #ifdef HV_CONFIG_ARCH_RISC
- /* 配置按键键值映射
- 将PM51的ADC按键键值映射成主CPU OSD Event按键消息
- 第一列表示PM51的ADC按键键值
- 第二列表示需要映射的主CPU OSD Event按键消息
- */
- OsdEvtKeyValue g_enKeyValueMapping[] =
- {
- [E_ADC0_KEY_VAL_0] = OSDEVT_KEY_HOTKEY2,
- [E_ADC0_KEY_VAL_1] = OSDEVT_KEY_EXIT,
- [E_ADC0_KEY_VAL_2] = OSDEVT_KEY_DOWN,
- [E_ADC1_KEY_VAL_0] = OSDEVT_KEY_UP,
- [E_ADC1_KEY_VAL_1] = OSDEVT_KEY_HOTKEY1,
- [E_ADC1_KEY_VAL_2] = OSDEVT_KEY_ENTER,
- [E_COMBO_KEY_VAL_0]= OSDEVT_KEY_LEFT,
- };
- #if (HV_PROJECT_CONFIG_OSD_ROTATION == HV_CONFIG_ON)
- #if (HV_PROJECT_CONFIG_OSD_KEY_ROTATION == HV_CONFIG_ON)
- /* 90, 180, 270 mapping */
- OsdEvtKeyValue g_enKeyRotateMapping[OSDEVT_KEY_MAX][3] =
- {
- /* OSDEVT_KEY_UP */
- {OSDEVT_KEY_LEFT, OSDEVT_KEY_DOWN, OSDEVT_KEY_RIGHT},
- /* OSDEVT_KEY_DOWN */
- {OSDEVT_KEY_RIGHT, OSDEVT_KEY_UP, OSDEVT_KEY_LEFT},
- /* OSDEVT_KEY_LEFT */
- {OSDEVT_KEY_DOWN, OSDEVT_KEY_RIGHT, OSDEVT_KEY_UP},
- /* OSDEVT_KEY_RIGHT */
- {OSDEVT_KEY_UP, OSDEVT_KEY_LEFT, OSDEVT_KEY_DOWN},
- /* OSDEVT_KEY_ENTER */
- {OSDEVT_KEY_ENTER, OSDEVT_KEY_ENTER, OSDEVT_KEY_ENTER},
- /* OSDEVT_KEY_EXIT */
- {OSDEVT_KEY_EXIT, OSDEVT_KEY_EXIT, OSDEVT_KEY_EXIT},
- /* OSDEVT_KEY_HOTKEY1 */
- {OSDEVT_KEY_HOTKEY1, OSDEVT_KEY_HOTKEY1, OSDEVT_KEY_HOTKEY1},
- /* OSDEVT_KEY_HOTKEY2 */
- {OSDEVT_KEY_HOTKEY2, OSDEVT_KEY_HOTKEY2, OSDEVT_KEY_HOTKEY2},
- /* OSDEVT_KEY_HOTKEY3 */
- {OSDEVT_KEY_HOTKEY3, OSDEVT_KEY_HOTKEY3, OSDEVT_KEY_HOTKEY3},
- };
- #endif
- #endif
- UINT32 GetAdcMappedValue(UINT32 uiAdcValue)
- {
- UINT32 uiArrayNum = 0;
- uiArrayNum = sizeof(g_enKeyValueMapping) / sizeof(g_enKeyValueMapping[0]);
- if (uiAdcValue >= uiArrayNum)
- {
- return 0;
- }
- #if (HV_PROJECT_CONFIG_OSD_ROTATION == HV_CONFIG_ON)
- #if (HV_PROJECT_CONFIG_OSD_KEY_ROTATION == HV_CONFIG_ON)
- OsdRotationType enRotate = Hv_Drv_OsdGetRotateType();
- OsdEvtKeyValue enKey = g_enKeyValueMapping[uiAdcValue];
- if (OSD_ROTATION_NONE != enRotate)
- {
- if (enKey < OSDEVT_KEY_MAX)
- {
- return g_enKeyRotateMapping[enKey][enRotate - 1];
- }
- }
- #endif
- #endif
- return g_enKeyValueMapping[uiAdcValue];
- }
- #endif
|