123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- #include "types.h"
- #include "ir_map.h"
- #include "app_event.h"
- #include "app_ir.h"
- #include "umf_debug.h"
- #include "customize.h"
- //#define APP_IR_DEBUG
- #ifdef APP_IR_DEBUG
- #undef DEBF
- #define DEBF(fmt, arg...) UMFDBG(0,fmt, ##arg)
- #else
- #define DEBF(fmt, arg...)
- #endif
- #ifdef SUPPORT_USB_UPGRADE_LONG_PRESS_KEYPAD_POWER
- extern UINT8 IsKeypadPowerOnPressRepeat;
- #endif
- typedef struct
- {
- UINT32 dEvent;
- UINT8 bRepeatRate;
- } stUIEventRepeat_t;
- stUIEventRepeat_t stRepeatEvent[] =
- {
- //add customer repeatkey here as follow ruls
- #ifdef SUPPORT_USB_UPGRADE_LONG_PRESS_KEYPAD_POWER
- {UI_EVENT_KEYPAD_POWER, 1},
- #endif
- {UI_EVENT_KEYPAD_LEFT, 1},
- {UI_EVENT_KEYPAD_RIGHT, 1},
- {UI_EVENT_KEYPAD_DOWN, 1},
- {UI_EVENT_KEYPAD_UP, 1},
- {UI_EVENT_LEFT, 1},
- {UI_EVENT_RIGHT, 1},
- {UI_EVENT_DOWN, 1},
- {UI_EVENT_UP, 1},
- {UI_EVENT_VOL_DN, 1},
- {UI_EVENT_VOL_UP, 1},
- {UI_EVENT_CH_UP, 1},
- {UI_EVENT_CH_DN, 1},
- #ifdef SUPPORT_PIPMENU_TO_NEXT_AND_FF
- {UI_EVENT_PIP_MENU, 10},
- #endif
- };
- UINT8 dRepeatEventNum = sizeof(stRepeatEvent)/sizeof(stUIEventRepeat_t);
- UINT8 APP_RepeatEventCheck(UINT32 dEvent)
- {
- UINT8 bIndex;
- UINT8 bResult = FALSE;
- static UINT32 dPreEvent = UI_EVENT_NULL;
- static UINT8 bRepeatNum = 0;
- if (dPreEvent == UI_EVENT_FACTORY || dPreEvent == UI_EVENT_FAC_HOTEL)
- {
- return TRUE;
- }
- if (dPreEvent == dEvent)
- {
- #ifdef SUPPORT_USB_UPGRADE_LONG_PRESS_KEYPAD_POWER
- if(dEvent == UI_EVENT_POWER)
- {
- dEvent = UI_EVENT_KEYPAD_POWER;
- }
- #endif
- for(bIndex = 0;bIndex < dRepeatEventNum;bIndex++)
- {
- if (dEvent == stRepeatEvent[bIndex].dEvent)
- {
- #ifdef SUPPORT_USB_UPGRADE_LONG_PRESS_KEYPAD_POWER
- if(dEvent == UI_EVENT_KEYPAD_POWER)
- {
- IsKeypadPowerOnPressRepeat = TRUE;
- }
- #endif
- bRepeatNum++;
- if (bRepeatNum >= stRepeatEvent[bIndex].bRepeatRate)
- {
- bRepeatNum = 0;
- bResult = TRUE;
- }
- break;
- }
- }
- }
- else
- {
- bRepeatNum = 0;
- dPreEvent = dEvent;
- }
-
- return bResult;
- }
- #if 0
- UINT8 APP_Ir_GetEventByKeyValue(UINT8 bIRIndex, UINT8 bKey, UINT32 *pdEvent)
- {
- if (pdEvent == NULL)
- {
- return FALSE;
- }
- if (stIR_map[bIRIndex].pfIRGetEvent == NULL)
- {
- return FALSE;
- }
- return stIR_map[bIRIndex].pfIRGetEvent(bKey,pdEvent);
- }
- UINT8 APP_Ir_GetEvent(UINT16 wCID, UINT8 bKey, UINT32 *pdEvent)
- {
- UINT32 i;
- if (pdEvent == NULL)
- {
- return FALSE;
- }
- for(i=0;i<dIR_map_size;i++)
- {
- if (stIR_map[i].wCID == wCID)
- {
- break;
- }
- }
- if (i < dIR_map_size)
- {
- if (TRUE == APP_Ir_GetEventByKeyValue(i, bKey, pdEvent))
- {
- return TRUE;
- }
- }
- return FALSE;
- }
- UINT8 APP_Ir_GetKeyValueByEvent(UINT8 bIRIndex, UINT32 dEvent, UINT8 *pbKey)
- {
- UINT32 i;
- if (pbKey == NULL)
- {
- return FALSE;
- }
- for(i=0;i<stIR_map[bIRIndex].dMapsize;i++)
- {
- if (stIR_map[bIRIndex].pdIR_Map[i] == dEvent)
- {
- break;
- }
- }
- if (i < stIR_map[bIRIndex].dMapsize)
- {
- *pbKey = i;
- return TRUE;
- }
- return FALSE;
- }
- void APP_Init_Ir_Standby_Param(void)
- {
- UINT8 i,j;
- UINT8 bIrParamBase = IOP_STANDBY_IR_PARAM_TABLE_BASE_IDX;
- UINT8 bWakeupKeyBase;
- UINT8 bKeyValue = 0;
- UINT8 bWakeupKeyNum = 0;
- UINT32 dEvent;
- UINT8 index;
- for(i = 0;i<dIR_map_size;i++)
- {
- if (i < SUPPORT_MULTI_IR_MAX_NUM)
- {
- bWakeupKeyNum = 0;
- index = IOP_STANDBY_IR_VENDER_IDX + i*2;
- IopStandby_Param[index] = stIR_map[i].wCID>>8; // high byte of vender key num for each IR
- DEBF("set IopStandby_Param[0x%x] 0x%x\n", index, IopStandby_Param[index]);
- index = IOP_STANDBY_IR_VENDER_IDX+i*2+1;
- IopStandby_Param[index] = stIR_map[i].wCID&0xff; // low byte of vender key num for each IR
- DEBF("set IopStandby_Param[0x%x] 0x%x\n", index, IopStandby_Param[index]);
- for(j=0;((j<stIR_map[i].dWakeupTablesize)&&(j<IOP_IR_PARAM_TABLE_SIZE));j++)
- {
- bWakeupKeyBase = bIrParamBase+i*IOP_IR_PARAM_TABLE_SIZE;
- dEvent = stIR_map[i].pdIR_WakeupTable[j];
- if ((dEvent != 0) &&
- (dEvent != UI_EVENT_NULL) &&
- (TRUE == APP_Ir_GetKeyValueByEvent(i, dEvent, &bKeyValue)))
- {
- index = bWakeupKeyBase + bWakeupKeyNum;
- IopStandby_Param[index] = bKeyValue; // each IR wakeup key
- DEBF("set IopStandby_Param[0x%x] 0x%x\n", index, IopStandby_Param[index]);
- bWakeupKeyNum++;
- }
- }
- index = IOP_STANDBY_IR_WAKEUP_KEY_NUM_IDX + i;
- IopStandby_Param[index] = bWakeupKeyNum; // wakeup key num of each IR
- DEBF("set IopStandby_Param[0x%x] 0x%x\n", index, IopStandby_Param[index]);
- }
- else
- {
- break;
- }
- }
- index = IOP_STANDBY_IR_PARAM_NUM_IDX;
- IopStandby_Param[index] = i; // support IR num
- DEBF("set IopStandby_Param[0x%x] 0x%x\n", index, IopStandby_Param[index]);
- index = IOP_STANDBY_IR_WAKEUP_TABLE_SIZE_IDX;
- IopStandby_Param[index] = IOP_IR_PARAM_TABLE_SIZE; // support wake up table max num
- DEBF("set IopStandby_Param[0x%x] 0x%x\n", index, IopStandby_Param[index]);
- }
- #endif
|