📄 rc6_ir.c
字号:
bitCount++;
}
else
border = 1;
}
else if (deltaTime - RC6_JITTER < RC6_LONGPULSE && RC6_LONGPULSE < deltaTime + RC6_JITTER)
{
if(start)
{
start = 0;
border = 1;
}
else if(border)
state = ERROR;
else
{
bit = !bit;
bitCount++;
}
}
else if (deltaTime - RC6_JITTER < (RC6_LONGPULSE + RC6_SHORTPULSE)
&& (RC6_LONGPULSE + RC6_SHORTPULSE) < deltaTime + RC6_JITTER)
{
if(start)
{
start = 0;
border = 0;
bit = !bit;
bitCount++;
}
else
state = ERROR;
}
else
state = ERROR;
if(state == DECODE)
{
if(bitCount <= RC6_GROUPSIZE)
{
group |= (bit & 1)<<(RC6_GROUPSIZE - bitCount);
}
else
{
code |= (bit & 1)<<(RC6_CODESIZE + RC6_GROUPSIZE - bitCount);
}
if(bitCount == RC6_GROUPSIZE + RC6_CODESIZE)
{
if (group == g_ir_system_code)
{
static BOOL far sbIsDVDInterStill = FALSE;
/* add code for judging if the key is pressed repeatly more truly */
if((oldcode != code) && (repeating == 1))
repeating = 0;
oldcode = code;
/* add code end */
key = (BYTE)(0x00FF&code);
switch(key)
{
case IRKC_DOWN:
case IRKC_UP:
case IRKC_RIGHT:
case IRKC_LEFT:
case IRKC_PAUSE:
validRepeat=1;
break;
#ifdef USE_SKIPF_KEY_FOR_STEPF_KEY_IN_PAUSE_MODE
#ifdef D_VESTEL_REMOTE
case IRKC_SKIPF: //BT021003: Add STEPF key repeating
if ( (gcs.pstate == PST_PAUSE) && (IS_COP_ENABLE(COP_STEP)) )
{
validRepeat=1;
break;
}
#endif //D_VESTEL_REMOTE
#endif //USE_SKIPF_KEY_FOR_STEPF_KEY_IN_PAUSE_MODE
default:
validRepeat=0;
}
if (repeating)
{
#if defined(D_HOLD_SKIP_2S_AS_FAST_SCAN)||defined(D_HOLD_STOP_3S_AS_EJECT_KEY)
if(IRKC_SKIPB == key || IRKC_SKIPF == key || IRKC_STOP == key)
{
if (lastKey != key)
{
//Restart timeout counting
lastKey = key;
if (hHoldTimer == NULL)
hHoldTimer = timer_service_create(HoldSkipTimerIR, HOLDKEY_TIMEOUT_TIME, TIMER_ONCE |TIMER_DISABLED);
timer_service_enable(hHoldTimer, TRUE);
#ifdef D_HOLD_SKIP_2S_AS_FAST_SCAN
if (IRKC_SKIPF == key || IRKC_SKIPB == key)
holdkey_repeatDelay = SKIPKEY_DELAY;
#endif
#ifdef D_HOLD_STOP_3S_AS_EJECT_KEY
if (IRKC_STOP == key)
holdkey_repeatDelay = STOPKEY_DELAY;
#endif
}
else if (holdkey_repeatDelay != 0)
{
holdkey_repeatDelay--;
//reset the timer
if (hHoldTimer != NULL)
timer_service_enable(hHoldTimer, TRUE);
}
else if(0 == holdkey_repeatDelay)
{
//clear the timer
if (hHoldTimer != NULL)
{
timer_service_delete(hHoldTimer);
hHoldTimer = NULL;
#ifdef D_HOLD_SKIP_2S_AS_FAST_SCAN
if(IRKC_SKIPB == key || IRKC_SKIPF == key)
{
//when enter scan mode, wait for a while to continue changing scan speed
holdkey_repeatDelay = SKIPKEY_DELAY_FAST;
}
#endif
}
//translate the hold key to new key
#ifdef D_HOLD_STOP_3S_AS_EJECT_KEY
if (IRKC_STOP == key)
{
holdkey_repeatDelay = STOPKEY_DELAY * 2; //do not send EJECT repeatedly in a short time
send_remote_event((WORD)KEY_SOURCE_IR|IRKC_EJECT);
}
#endif//D_HOLD_STOP_3S_AS_EJECT_KEY
#ifdef D_HOLD_SKIP_2S_AS_FAST_SCAN
if(!( (SYNC_STILL == g_pDVDNav->dvd.StillType || 0 == g_pDVDNav->dvd.StillType)
&& PST_STILL == gcs.pstate
&& ((MEDIA_TYPE_DVD_VIDEO == CoreAPI_GetCurrentMediaType())
#ifdef DVD_AUDIO_SUPPORT
||(MEDIA_TYPE_DVD_AUDIO == CoreAPI_GetCurrentMediaType())
#endif
#ifdef DVD_VR_SUPPORT
|| (MEDIA_TYPE_DVDVR == CoreAPI_GetCurrentMediaType())
#endif
)))
{
//When scan the DVD, there are some still states among the scan states, timer is not created in these still states.
//After the PST_STILL state end, we send the first scan command, and we should delay the time SKIPKEY_DELAY_FAST to send the second command.
//then we send the scan command continuously.
if (sbIsDVDInterStill)
{
sbIsDVDInterStill = FALSE;
if(IRKC_SKIPB == key || IRKC_SKIPF == key)
{
//when enter scan mode, wait for a while to continue changing scan speed
holdkey_repeatDelay = SKIPKEY_DELAY_FAST;
}
}
if(IRKC_SKIPF == key)
{
send_remote_event((WORD)KEY_STATUS_HOLD|KEY_SOURCE_IR|IRKC_FASTF);
}
else if (IRKC_SKIPB == key)
{
send_remote_event((WORD)KEY_STATUS_HOLD|KEY_SOURCE_IR|IRKC_FASTR);
}
}
#endif//D_HOLD_SKIP_2S_AS_FAST_SCAN
}
}
else
#endif
if(repeatDelay)
{
repeatDelay--;
}
else if (validRepeat)
{
if (!(repeatStep++ % REPEAT_STEP))
send_remote_event((WORD)KEY_STATUS_HOLD|(((WORD)key)&0x00FF));
}
}
else //not repeating
{
repeatDelay = REPEAT_DELAY;
sbIsDVDInterStill = FALSE;
#if defined(D_HOLD_SKIP_2S_AS_FAST_SCAN)||defined(D_HOLD_STOP_3S_AS_EJECT_KEY)
lastKey = key;
if(
#ifdef D_HOLD_SKIP_2S_AS_FAST_SCAN
IRKC_SKIPF == key || IRKC_SKIPB == key ||
#endif
#ifdef D_HOLD_STOP_3S_AS_EJECT_KEY
IRKC_STOP == key
#else
FALSE
#endif
)
{
holdkey_repeatDelay = 0;
#ifdef D_HOLD_STOP_3S_AS_EJECT_KEY
if (IRKC_STOP == key)
{
holdkey_repeatDelay = STOPKEY_DELAY;
}
#endif// D_HOLD_STOP_3S_AS_EJECT_KEY
#ifdef D_HOLD_SKIP_2S_AS_FAST_SCAN
if(IRKC_SKIPF == key || IRKC_SKIPB == key)
{
//when the player is in scan state, just send a fast scan
if(PST_SCAN == gcs.pstate)
{
if(IRKC_SKIPF == key)
{
send_remote_event((WORD)KEY_SOURCE_IR|IRKC_FASTF);
key = IRKC_FASTF;
}
else
{
send_remote_event((WORD)KEY_SOURCE_IR|IRKC_FASTR);
key = IRKC_FASTR;
}
holdkey_repeatDelay = REPEAT_DELAY;
}
else if(!( (SYNC_STILL == g_pDVDNav->dvd.StillType || 0 == g_pDVDNav->dvd.StillType)
&& PST_STILL == gcs.pstate
&& ((MEDIA_TYPE_DVD_VIDEO == CoreAPI_GetCurrentMediaType())
#ifdef DVD_AUDIO_SUPPORT
||(MEDIA_TYPE_DVD_AUDIO == CoreAPI_GetCurrentMediaType())
#endif
#ifdef DVD_VR_SUPPORT
|| (MEDIA_TYPE_DVDVR == CoreAPI_GetCurrentMediaType())
#endif
)))
{
holdkey_repeatDelay = SKIPKEY_DELAY;
}
else
{
holdkey_repeatDelay = SKIPKEY_DELAY;
sbIsDVDInterStill = TRUE;
}
}
#endif// D_HOLD_SKIP_2S_AS_FAST_SCAN
//when press the skipf key or skipb key or stop key first,
//we just ignore it here. It will be sent out when "holdkey" timeout happens.
#ifdef D_HOLD_SKIP_2S_AS_FAST_SCAN
if(IRKC_FASTF != key && IRKC_FASTR != key && !sbIsDVDInterStill)
#endif //D_HOLD_SKIP_2S_AS_FAST_SCAN
{
if (hHoldTimer == NULL)
{
hHoldTimer = timer_service_create(HoldSkipTimerIR, HOLDKEY_TIMEOUT_TIME, TIMER_ONCE |TIMER_DISABLED);
}
timer_service_enable(hHoldTimer, TRUE);
}
}
else
#endif
{
#ifdef I96_CPU_POWER_DOWN
if( key == (BYTE)UI_REMOTE_POWER_KEY_CODE )
{
//FrankMei_2005_1020:Fix bug: When in standby state, press the power key and hole for 2 seconds,
//the platform will power up and then power down.
if ((bWakeFromPowerDown == TRUE) || kernalStatus.bUIInitDone)
{
bPowerUpKeyPressed = TRUE;
}
}
#endif
send_remote_event(((WORD)key)&0x00FF);
}
}
if (bit & 1)
{
// LOW to HIGH transition of clock
state = IDLE; // If_last bit is 1 then this is the last clock edge of stream
ir_interrupt_set_edge( RISING_EDGE );
interruptTypeFlag = 1;
}
else // HIGH to LOW transition of clock
state = RESYNC; // If_last bit is 0 then we need to wait for one more clock edge
}
}
}
break;
case RESYNC:
if (deltaTime - RC6_JITTER < RC6_SHORTPULSE && RC6_SHORTPULSE < deltaTime + RC6_JITTER)
{
state = IDLE;
ir_interrupt_set_edge( RISING_EDGE );
interruptTypeFlag = 1;
}
else if (deltaTime - RC6_JITTER < RC6_LONGPULSE && RC6_LONGPULSE < deltaTime + RC6_JITTER)
{
state = IDLE;
ir_interrupt_set_edge( RISING_EDGE );
interruptTypeFlag = 1;
}
else
{
state = ERROR;
}
break;
default:
state = ERROR;
break;
}
}
#endif // D_REMOTE_RC6_FORMAT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -