KeyboardConfig.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /**
  2. * @file KeyboardConfig.h
  3. * @brief Header file of keyboard configuration.
  4. *
  5. * @verbatim
  6. * ==============================================================================
  7. * ##### How to use #####
  8. * ==============================================================================
  9. *
  10. *
  11. @ endverbatim
  12. *
  13. * @author HiView SoC Software Team
  14. * @version 1.0.0
  15. * @date 2023-05-30
  16. */
  17. #ifdef HV_CONFIG_ARCH_RISC
  18. #include "hv_comm_DataType.h"
  19. #include "hv_comm_Define.h"
  20. #include "hv_comm_Event.h"
  21. #if (HV_PROJECT_CONFIG_OSD_ROTATION == HV_CONFIG_ON)
  22. #if (HV_PROJECT_CONFIG_OSD_KEY_ROTATION == HV_CONFIG_ON)
  23. #include "hv_drv_OsdRotate.h"
  24. #endif
  25. #endif
  26. #endif
  27. #ifdef HV_CONFIG_ARCH_C51
  28. #include "hv_pm51_Base.h"
  29. #endif
  30. #include "Keyboard.h"
  31. #include "KeyboardConfig.h"
  32. /* 配置ADC按键对应键值
  33. 第一列表示按键键值的Index,根据Keyboard.h选择枚举AdcKeyVal 中定义的ADC0或ADC1保留的键值Index;
  34. 第二列表示具体的ADC采样的按键键值,一般为多次测量均值;不同按键键值在物理上决定了对应的是哪一个实体按键,
  35. 第三列表示按键键值的Offset,用于软件按键防抖处理,Offset的数值需要保证不同按键的键值不能产生重叠;
  36. */
  37. #ifdef HV_CONFIG_ARCH_C51
  38. xUSHORT16
  39. #else
  40. USHORT16
  41. #endif
  42. g_asAdcDataMap[ADC_KEY_NUMS][ADCDATAMAPMAX] =
  43. {
  44. {E_ADC0_KEY_VAL_0, 0x3e7, 0x50}, /* KEY2 */
  45. {E_ADC0_KEY_VAL_1, 0x620, 0x50}, /* AUTO */
  46. {E_ADC0_KEY_VAL_2, 0x24, 0x24}, /* DOWN */
  47. {E_ADC1_KEY_VAL_0, 0x3e7, 0x50}, /* UP */
  48. {E_ADC1_KEY_VAL_1, 0x620, 0x50}, /* KEY1 */
  49. {E_ADC1_KEY_VAL_2, 0x24, 0x50}, /* MENU */
  50. };
  51. #if ADC_COMBO_KEY_ENABLE
  52. /* 配置组合按键
  53. 组合按键只支持两路ADC按键同时开启的情况,在每一路ADC中选择一个按键,然后组合在一起定义一个组合按键。
  54. 第一列表示在ADC0中选择的按键键值的Index;
  55. 第二列表示在ADC1中选择的按键键值的Index;
  56. 第三列表示组合后对应的组合按键的Index,在Keyboard.h的 AdcKeyVal枚举中选择即可;
  57. */
  58. AdcComboKeyMap g_stAdcComboKeyMap[ADC_COMBO_KEY_NUMS] =
  59. {
  60. {E_ADC0_KEY_VAL_0, E_ADC1_KEY_VAL_0, E_COMBO_KEY_VAL_0},
  61. };
  62. #endif
  63. #ifdef HV_CONFIG_ARCH_RISC
  64. /* 配置按键键值映射
  65. 将PM51的ADC按键键值映射成主CPU OSD Event按键消息
  66. 第一列表示PM51的ADC按键键值
  67. 第二列表示需要映射的主CPU OSD Event按键消息
  68. */
  69. OsdEvtKeyValue g_enKeyValueMapping[] =
  70. {
  71. [E_ADC0_KEY_VAL_0] = OSDEVT_KEY_HOTKEY2,
  72. [E_ADC0_KEY_VAL_1] = OSDEVT_KEY_EXIT,
  73. [E_ADC0_KEY_VAL_2] = OSDEVT_KEY_DOWN,
  74. [E_ADC1_KEY_VAL_0] = OSDEVT_KEY_UP,
  75. [E_ADC1_KEY_VAL_1] = OSDEVT_KEY_HOTKEY1,
  76. [E_ADC1_KEY_VAL_2] = OSDEVT_KEY_ENTER,
  77. [E_COMBO_KEY_VAL_0]= OSDEVT_KEY_LEFT,
  78. };
  79. #if (HV_PROJECT_CONFIG_OSD_ROTATION == HV_CONFIG_ON)
  80. #if (HV_PROJECT_CONFIG_OSD_KEY_ROTATION == HV_CONFIG_ON)
  81. /* 90, 180, 270 mapping */
  82. OsdEvtKeyValue g_enKeyRotateMapping[OSDEVT_KEY_MAX][3] =
  83. {
  84. /* OSDEVT_KEY_UP */
  85. {OSDEVT_KEY_LEFT, OSDEVT_KEY_DOWN, OSDEVT_KEY_RIGHT},
  86. /* OSDEVT_KEY_DOWN */
  87. {OSDEVT_KEY_RIGHT, OSDEVT_KEY_UP, OSDEVT_KEY_LEFT},
  88. /* OSDEVT_KEY_LEFT */
  89. {OSDEVT_KEY_DOWN, OSDEVT_KEY_RIGHT, OSDEVT_KEY_UP},
  90. /* OSDEVT_KEY_RIGHT */
  91. {OSDEVT_KEY_UP, OSDEVT_KEY_LEFT, OSDEVT_KEY_DOWN},
  92. /* OSDEVT_KEY_ENTER */
  93. {OSDEVT_KEY_ENTER, OSDEVT_KEY_ENTER, OSDEVT_KEY_ENTER},
  94. /* OSDEVT_KEY_EXIT */
  95. {OSDEVT_KEY_EXIT, OSDEVT_KEY_EXIT, OSDEVT_KEY_EXIT},
  96. /* OSDEVT_KEY_HOTKEY1 */
  97. {OSDEVT_KEY_HOTKEY1, OSDEVT_KEY_HOTKEY1, OSDEVT_KEY_HOTKEY1},
  98. /* OSDEVT_KEY_HOTKEY2 */
  99. {OSDEVT_KEY_HOTKEY2, OSDEVT_KEY_HOTKEY2, OSDEVT_KEY_HOTKEY2},
  100. /* OSDEVT_KEY_HOTKEY3 */
  101. {OSDEVT_KEY_HOTKEY3, OSDEVT_KEY_HOTKEY3, OSDEVT_KEY_HOTKEY3},
  102. };
  103. #endif
  104. #endif
  105. UINT32 GetAdcMappedValue(UINT32 uiAdcValue)
  106. {
  107. UINT32 uiArrayNum = 0;
  108. uiArrayNum = sizeof(g_enKeyValueMapping) / sizeof(g_enKeyValueMapping[0]);
  109. if (uiAdcValue >= uiArrayNum)
  110. {
  111. return 0;
  112. }
  113. #if (HV_PROJECT_CONFIG_OSD_ROTATION == HV_CONFIG_ON)
  114. #if (HV_PROJECT_CONFIG_OSD_KEY_ROTATION == HV_CONFIG_ON)
  115. OsdRotationType enRotate = Hv_Drv_OsdGetRotateType();
  116. OsdEvtKeyValue enKey = g_enKeyValueMapping[uiAdcValue];
  117. if (OSD_ROTATION_NONE != enRotate)
  118. {
  119. if (enKey < OSDEVT_KEY_MAX)
  120. {
  121. return g_enKeyRotateMapping[enKey][enRotate - 1];
  122. }
  123. }
  124. #endif
  125. #endif
  126. return g_enKeyValueMapping[uiAdcValue];
  127. }
  128. #endif