📄 irremotepoint.c
字号:
else
eventDesc |= LO_WIDTHX; /* unexpected width */
/****************************************************/
/* Execute the state machine. */
/****************************************************/
switch( pss -> fsmState | eventDesc )
{
case MS_IDLE | HI_WIDTH2:
pss -> fsmState = MS_SYNC;
pss -> bitCount = 0;
break;
case MS_SYNC | LO_WIDTH1:
pss -> fsmState = MS_BGN1;
break;
case MS_SYNC | LO_WIDTH2:
pss -> fsmState = MS_MID0;
pss -> bitRegister = ( pss -> bitRegister << 1 );
pss -> bitCount++;
break;
case MS_BGN0 | LO_WIDTH1:
pss -> fsmState = MS_MID0;
pss -> bitRegister = ( pss -> bitRegister << 1 );
pss -> bitCount++;
break;
case MS_BGN1 | HI_WIDTH1:
pss -> fsmState = MS_MID1;
pss -> bitRegister = ( pss -> bitRegister << 1 ) | 0x0001;
pss -> bitCount++;
break;
case MS_MID0 | HI_WIDTH1:
pss -> fsmState = MS_BGN0;
break;
case MS_MID0 | HI_WIDTH2:
pss -> fsmState = MS_MID1;
pss -> bitRegister = ( pss -> bitRegister << 1 ) | 0x0001;
pss -> bitCount++;
break;
case MS_MID1 | LO_WIDTH1:
pss -> fsmState = MS_BGN1;
break;
case MS_MID1 | LO_WIDTH2:
pss -> fsmState = MS_MID0;
pss -> bitRegister = ( pss -> bitRegister << 1 );
pss -> bitCount++;
break;
default:
pss -> fsmState = MS_IDLE;
return NULL;
}
/****************************************************/
/* Return report when message is complete. */
/****************************************************/
if( 16 == pss -> bitCount )
{
pss -> fsmState = MS_IDLE;
pss -> bitCount = 0;
return testCode( report, pss );
}
return FALSE;
}
/****************************************************************************/
/* Format report. */
/****************************************************************************/
static BOOL testCode( UIREP *report,IRSTATE *pss )
{
int16 xmouse = (int16)RPM_GET_XMOUSE( pss -> bitRegister );
int16 ymouse = (int16)RPM_GET_YMOUSE( pss -> bitRegister );
KCODE_ENUM thisKey; /* current key code */
BOOL mouseKey; /* mouse mode key change */
uint32 timeSince; /* time since last key report was sent */
/********************************************/
/* remotePoint is in keypad menu mode. */
/********************************************/
if( isKeyMode )
{
int08 absx = ABS( xmouse );
int08 absy = ABS( ymouse );
if( RPM_GET_LRCLICK( pss -> bitRegister )) /* both mouse button */
{
thisKey = KCODE_IR_MM_LEFTRIGHT;
}
else if( RPM_GET_RCLICK( pss -> bitRegister )) /* rt mouse button */
{
thisKey = KCODE_IR_MM_RIGHTCLICK;
}
else if( RPM_GET_LCLICK( pss -> bitRegister )) /* left mouse button */
{
thisKey = KCODE_IR_MM_LEFTCLICK;
}
else if( absx / ( absy + 2 ) >= 2 ) /* predominant X */
{
if( xmouse > 0 )
thisKey = KCODE_IR_MM_RIGHT;
else
thisKey = KCODE_IR_MM_LEFT;
}
else if( absy / ( absx + 2 ) >= 2 ) /* predominant Y */
{
if( ymouse > 0 )
thisKey = KCODE_IR_MM_UP;
else
thisKey = KCODE_IR_MM_DOWN;
}
else /* no key */
{
return FALSE;
}
/********************************************/
/* Handle repeats and delays. */
/********************************************/
if( thisKey == pss -> keyPrior ) /* if same as last returned */
{
timeSince = irfunc_MsecTime() - pss -> keyTime;
pss -> keyTime = irfunc_MsecTime();
if( timeSince < RPM_KEY_SEPARATE ) /* if pressed recently */
{
if( pss -> keyRepeat ) /* if key is repeatable */
{
timeSince = irfunc_MsecTime() - pss -> keyFirstTime;
if( timeSince > RPM_KEY_REPDELAY )
{
if( 0x0001 & ++pss -> keyRepCount )
return reportRPKey( report, pss, thisKey );
else
return FALSE;
}
}
}
else /* same key, but not recently */
{
pss -> keyFirstTime = irfunc_MsecTime();
return reportRPKey( report, pss, thisKey );
}
}
else /* return new keycode */
{
pss -> keyFirstTime = irfunc_MsecTime();
pss -> keyRepCount = 0;
return reportRPKey( report, pss, thisKey );
}
}
/********************************************/
/* remotePoint is in mouse mode. */
/********************************************/
else
{
if( RPM_GET_LRCLICK( pss -> bitRegister ))
thisKey = KCODE_IR_LEFTRIGHT;
else if( RPM_GET_RCLICK( pss -> bitRegister ))
thisKey = KCODE_IR_RIGHTCLICK;
else if( RPM_GET_LCLICK( pss -> bitRegister ))
thisKey = KCODE_IR_LEFTCLICK;
else
thisKey = KCODE_IR_NOBUTTON;
mouseKey = thisKey != pss -> keyPrior;
pss -> keyPrior = thisKey;
report -> key = thisKey;
report -> mouse = mouseKey || ( 0 != ( xmouse | ymouse ));
report -> mouse_x = (int08)xmouse;
report -> mouse_y = (int08)ymouse;
return mouseKey;
}
return FALSE; /* no key to report */
}
/****************************************************************************/
/* Report keycode. */
/****************************************************************************/
static BOOL reportRPKey( UIREP *report, IRSTATE *pss, KCODE_ENUM thisKey )
{
pss -> keyPrior = thisKey; /* keycode */
pss -> keyTime = irfunc_MsecTime();
pss -> keyRepeat = TRUE;
report -> key = thisKey; /* keycode */
report -> mouse = FALSE; /* no mouse data */
report -> mouse_x = 0;
report -> mouse_y = 0;
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -