app_ir.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. #include "types.h"
  2. #include "ir_map.h"
  3. #include "app_event.h"
  4. #include "app_ir.h"
  5. #include "umf_debug.h"
  6. #include "customize.h"
  7. //#define APP_IR_DEBUG
  8. #ifdef APP_IR_DEBUG
  9. #undef DEBF
  10. #define DEBF(fmt, arg...) UMFDBG(0,fmt, ##arg)
  11. #else
  12. #define DEBF(fmt, arg...)
  13. #endif
  14. #ifdef SUPPORT_USB_UPGRADE_LONG_PRESS_KEYPAD_POWER
  15. extern UINT8 IsKeypadPowerOnPressRepeat;
  16. #endif
  17. typedef struct
  18. {
  19. UINT32 dEvent;
  20. UINT8 bRepeatRate;
  21. } stUIEventRepeat_t;
  22. stUIEventRepeat_t stRepeatEvent[] =
  23. {
  24. //add customer repeatkey here as follow ruls
  25. #ifdef SUPPORT_USB_UPGRADE_LONG_PRESS_KEYPAD_POWER
  26. {UI_EVENT_KEYPAD_POWER, 1},
  27. #endif
  28. {UI_EVENT_KEYPAD_LEFT, 1},
  29. {UI_EVENT_KEYPAD_RIGHT, 1},
  30. {UI_EVENT_KEYPAD_DOWN, 1},
  31. {UI_EVENT_KEYPAD_UP, 1},
  32. {UI_EVENT_LEFT, 1},
  33. {UI_EVENT_RIGHT, 1},
  34. {UI_EVENT_DOWN, 1},
  35. {UI_EVENT_UP, 1},
  36. {UI_EVENT_VOL_DN, 1},
  37. {UI_EVENT_VOL_UP, 1},
  38. {UI_EVENT_CH_UP, 1},
  39. {UI_EVENT_CH_DN, 1},
  40. #ifdef SUPPORT_PIPMENU_TO_NEXT_AND_FF
  41. {UI_EVENT_PIP_MENU, 10},
  42. #endif
  43. };
  44. UINT8 dRepeatEventNum = sizeof(stRepeatEvent)/sizeof(stUIEventRepeat_t);
  45. UINT8 APP_RepeatEventCheck(UINT32 dEvent)
  46. {
  47. UINT8 bIndex;
  48. UINT8 bResult = FALSE;
  49. static UINT32 dPreEvent = UI_EVENT_NULL;
  50. static UINT8 bRepeatNum = 0;
  51. if (dPreEvent == UI_EVENT_FACTORY || dPreEvent == UI_EVENT_FAC_HOTEL)
  52. {
  53. return TRUE;
  54. }
  55. if (dPreEvent == dEvent)
  56. {
  57. #ifdef SUPPORT_USB_UPGRADE_LONG_PRESS_KEYPAD_POWER
  58. if(dEvent == UI_EVENT_POWER)
  59. {
  60. dEvent = UI_EVENT_KEYPAD_POWER;
  61. }
  62. #endif
  63. for(bIndex = 0;bIndex < dRepeatEventNum;bIndex++)
  64. {
  65. if (dEvent == stRepeatEvent[bIndex].dEvent)
  66. {
  67. #ifdef SUPPORT_USB_UPGRADE_LONG_PRESS_KEYPAD_POWER
  68. if(dEvent == UI_EVENT_KEYPAD_POWER)
  69. {
  70. IsKeypadPowerOnPressRepeat = TRUE;
  71. }
  72. #endif
  73. bRepeatNum++;
  74. if (bRepeatNum >= stRepeatEvent[bIndex].bRepeatRate)
  75. {
  76. bRepeatNum = 0;
  77. bResult = TRUE;
  78. }
  79. break;
  80. }
  81. }
  82. }
  83. else
  84. {
  85. bRepeatNum = 0;
  86. dPreEvent = dEvent;
  87. }
  88. return bResult;
  89. }
  90. #if 0
  91. UINT8 APP_Ir_GetEventByKeyValue(UINT8 bIRIndex, UINT8 bKey, UINT32 *pdEvent)
  92. {
  93. if (pdEvent == NULL)
  94. {
  95. return FALSE;
  96. }
  97. if (stIR_map[bIRIndex].pfIRGetEvent == NULL)
  98. {
  99. return FALSE;
  100. }
  101. return stIR_map[bIRIndex].pfIRGetEvent(bKey,pdEvent);
  102. }
  103. UINT8 APP_Ir_GetEvent(UINT16 wCID, UINT8 bKey, UINT32 *pdEvent)
  104. {
  105. UINT32 i;
  106. if (pdEvent == NULL)
  107. {
  108. return FALSE;
  109. }
  110. for(i=0;i<dIR_map_size;i++)
  111. {
  112. if (stIR_map[i].wCID == wCID)
  113. {
  114. break;
  115. }
  116. }
  117. if (i < dIR_map_size)
  118. {
  119. if (TRUE == APP_Ir_GetEventByKeyValue(i, bKey, pdEvent))
  120. {
  121. return TRUE;
  122. }
  123. }
  124. return FALSE;
  125. }
  126. UINT8 APP_Ir_GetKeyValueByEvent(UINT8 bIRIndex, UINT32 dEvent, UINT8 *pbKey)
  127. {
  128. UINT32 i;
  129. if (pbKey == NULL)
  130. {
  131. return FALSE;
  132. }
  133. for(i=0;i<stIR_map[bIRIndex].dMapsize;i++)
  134. {
  135. if (stIR_map[bIRIndex].pdIR_Map[i] == dEvent)
  136. {
  137. break;
  138. }
  139. }
  140. if (i < stIR_map[bIRIndex].dMapsize)
  141. {
  142. *pbKey = i;
  143. return TRUE;
  144. }
  145. return FALSE;
  146. }
  147. void APP_Init_Ir_Standby_Param(void)
  148. {
  149. UINT8 i,j;
  150. UINT8 bIrParamBase = IOP_STANDBY_IR_PARAM_TABLE_BASE_IDX;
  151. UINT8 bWakeupKeyBase;
  152. UINT8 bKeyValue = 0;
  153. UINT8 bWakeupKeyNum = 0;
  154. UINT32 dEvent;
  155. UINT8 index;
  156. for(i = 0;i<dIR_map_size;i++)
  157. {
  158. if (i < SUPPORT_MULTI_IR_MAX_NUM)
  159. {
  160. bWakeupKeyNum = 0;
  161. index = IOP_STANDBY_IR_VENDER_IDX + i*2;
  162. IopStandby_Param[index] = stIR_map[i].wCID>>8; // high byte of vender key num for each IR
  163. DEBF("set IopStandby_Param[0x%x] 0x%x\n", index, IopStandby_Param[index]);
  164. index = IOP_STANDBY_IR_VENDER_IDX+i*2+1;
  165. IopStandby_Param[index] = stIR_map[i].wCID&0xff; // low byte of vender key num for each IR
  166. DEBF("set IopStandby_Param[0x%x] 0x%x\n", index, IopStandby_Param[index]);
  167. for(j=0;((j<stIR_map[i].dWakeupTablesize)&&(j<IOP_IR_PARAM_TABLE_SIZE));j++)
  168. {
  169. bWakeupKeyBase = bIrParamBase+i*IOP_IR_PARAM_TABLE_SIZE;
  170. dEvent = stIR_map[i].pdIR_WakeupTable[j];
  171. if ((dEvent != 0) &&
  172. (dEvent != UI_EVENT_NULL) &&
  173. (TRUE == APP_Ir_GetKeyValueByEvent(i, dEvent, &bKeyValue)))
  174. {
  175. index = bWakeupKeyBase + bWakeupKeyNum;
  176. IopStandby_Param[index] = bKeyValue; // each IR wakeup key
  177. DEBF("set IopStandby_Param[0x%x] 0x%x\n", index, IopStandby_Param[index]);
  178. bWakeupKeyNum++;
  179. }
  180. }
  181. index = IOP_STANDBY_IR_WAKEUP_KEY_NUM_IDX + i;
  182. IopStandby_Param[index] = bWakeupKeyNum; // wakeup key num of each IR
  183. DEBF("set IopStandby_Param[0x%x] 0x%x\n", index, IopStandby_Param[index]);
  184. }
  185. else
  186. {
  187. break;
  188. }
  189. }
  190. index = IOP_STANDBY_IR_PARAM_NUM_IDX;
  191. IopStandby_Param[index] = i; // support IR num
  192. DEBF("set IopStandby_Param[0x%x] 0x%x\n", index, IopStandby_Param[index]);
  193. index = IOP_STANDBY_IR_WAKEUP_TABLE_SIZE_IDX;
  194. IopStandby_Param[index] = IOP_IR_PARAM_TABLE_SIZE; // support wake up table max num
  195. DEBF("set IopStandby_Param[0x%x] 0x%x\n", index, IopStandby_Param[index]);
  196. }
  197. #endif