📄 keyremo.c
字号:
case POWERKEY : dPuts("\r\nPOWER key pressed"); break;
case MENUKEY: dPuts("\r\nMENU key pressed"); break;
case INPUTSOURCEKEY: dPuts("\r\nINPUTSOURCE key pressed"); break;
case UPKEY: dPuts("\r\nUP key pressed"); break;
case DOWNKEY: dPuts("\r\nDOWN key pressed"); break;
case LEFTKEY: dPuts("\r\nLEFT key pressed"); break;
case RIGHTKEY: dPuts("\r\nRIGHT key pressed"); break;
default: dPuts("\r\nNOT ASSIGNED key pressed"); break;
}
#endif
#if (defined SUPPORT_PC) || (defined SUPPORT_DTV)
if( (PcMode==EE_PC_NO_SIGNAL) && (GetInputSelection()==PC || GetInputSelection()==DTV) ) {
if( PcMode==EE_PC_NO_SIGNAL ) {
switch (ikey) {
case INPUTSOURCEKEY:
//case POWERKEY:
break;
default:
tic_pc = 0;
return 1;
}
}
}
#endif // SUPPORT_PC
SetOSDLastKeyInTime();
switch( ikey ) {
#ifdef POWERKEY
case POWERKEY :
ret = ActionRemo( REMO_STANDBY, RepeatKey ); break;
#endif
case MENUKEY:
ret = ActionRemo( REMO_MENU, RepeatKey ); break;
//------------------------------------------------------------------------
#ifdef SUPPORT_SELECTKEY
case UPKEY:
if( GetDisplayedOSD() & MENU )
if( OnChangingValue ) OSDValueUpDn(UP );
else OSDCursorMove( UP );
else
return 1;
break;
case DOWNKEY:
if( GetDisplayedOSD() & MENU )
if( OnChangingValue ) OSDValueUpDn(DN );
else OSDCursorMove( DN );
else
return 1;
break;
case SELECTKEY:
if( GetDisplayedOSD() & MENU ) {
if( OnChangingValue ) SaveValue1();
else OSDSelect();
}
break;
#else
//------------------------------------------------------------------------
case UPKEY: ret = ActionRemo( REMO_CHNUP, RepeatKey ); break;
case DOWNKEY: ret = ActionRemo( REMO_CHNDN, RepeatKey ); break;
case LEFTKEY: ret = ActionRemo( REMO_VOLDN, RepeatKey ); break;
case RIGHTKEY: ret = ActionRemo( REMO_VOLUP, RepeatKey ); break;
#endif
//------------------------------------------------------------------------
case INPUTSOURCEKEY:
ret = ActionRemo( REMO_INPUT, RepeatKey ); break;
}
// WaitKeyClear(ikey);
}
return (ret);
}
#ifdef INTERNAL_MCU
BYTE GetLAD0( void )
{
BYTE page, value;
page = ReadTW88(REG_PAGE);
WriteTW88(REG_PAGE, 0x00);
value = ReadTW88(LAD0);
WriteTW88(REG_PAGE,page);
return( value);
}
extern DATA BYTE tic01;
extern DATA BYTE keytic;
BYTE ReadKey( void )
{
BYTE i, j;
BYTE min, max;
WORD key_in;
/*
if( GetLAD0() < 0x10 ) {
keytic = 0;
return (0);
}
else
if ( keytic
keytic = tic01;
if( keytic==3 ) {
Key = _ReadKey();
RepeatKey = 0;
KeyReady = 1;
}
else if( keytic==100 ) {
Key = _ReadKey();
RepeatKey = 1;
KeyReady = 1;
keytic = 80;
}
keytic++;
}
*/
i = GetLAD0();
if ( i<0x10 ) return (0);
i = tic01;
do {
j = tic01 - i;
} while ( j < 3 ); //wait 30ms
i = GetLAD0();
if ( i<0x10 ) return (0);
key_in = i;
min = i; max = i;
for ( j=0; j<17; j++ ) {
i = GetLAD0();
if ( i<0x10 ) return (0);
key_in += i;
if ( i < min ) min = i;
else if ( i > max ) max = i;
}
key_in -= min;
key_in -= max;
key_in >>= 4; // divide by 16
#ifdef DEBUG_KEYREMO
if (key_in >= 0x10)
dPrintf("\r\nKeyIn ADC Value is: 0x%2x", (WORD)key_in );
//return (0);
#endif
if ( key_in < 0x10 )
return( 0 );
else if ( key_in < 0x33 )
return( INPUTSOURCEKEY );
else if ( key_in < 0x5a )
return( RIGHTKEY );
else if ( key_in < 0x80 )
return( UPKEY );
else if ( key_in < 0xa0 )
return( MENUKEY );
else if ( key_in < 0xcc )
return( DOWNKEY );
else if ( key_in < 0xf5 )
return( LEFTKEY );
else
return( POWERKEY );
}
#endif
//=============================================================================
// Get Key
//=============================================================================
BYTE GetKey(BYTE repeat)
{
#ifdef INTERNAL_MCU
BYTE i;
i = repeat;
i = ReadKey();
if ( i == 0 ) {
RepeatKey = 0;
Key = 0;
KeyReady = 0;
keytic = 0;
return (0);
}
if ( Key == 0 ) { // first pressed?
Key = i;
keytic++;
return (i);
}
else if ( i != Key) { // same key pressed check for repeat function
RepeatKey = 0;
KeyReady = 0;
keytic = 0;
return (0);
}
else {
keytic++;
if ( keytic < 30 ) {
return (0);
}
else {
RepeatKey = 1;
KeyReady = 1;
keytic = 24;
return (i);
}
}
#else
bit ready;
ready = KeyReady;
KeyReady = 0;
if( !ready ) return 0;
if( repeat ) return Key;
if( !RepeatKey ) return Key;
return 0;
#endif
}
//=============================================================================
// CheckRemo
//=============================================================================
#ifdef REMO_RC5
BYTE IsRemoDataReady(BYTE *DataCode, BYTE *AutoKey)
{
bit togglebit;
static bit LastToggle=0;
static BYTE AutoWait=0;
BYTE _RemoSystemCode, _RemoDataCode, _RemoDataReady;
if( !RemoDataReady ) return 0;
_RemoDataReady = RemoDataReady;
_RemoDataCode = RemoDataCode;
_RemoSystemCode = RemoSystemCode;
*AutoKey = 0;
EnableRemoconInt();
#ifdef DEBUG_KEYREMO
dPrintf("\r\n(CheckRemo)R-S:%02x, R-D:%02x", (WORD)_RemoSystemCode, (WORD)_RemoDataCode);
#endif
if( (_RemoSystemCode & 0xc0) != 0xc0 ) return 0;
if( (_RemoSystemCode & 0x1f) != REMO_CUSTOM ) return 0;
togglebit = LastToggle;
if( _RemoSystemCode & 0x20 ) LastToggle = 1;
else LastToggle = 0;
#ifdef DEBUG_KEYREMO
dPrintf("**** %d %d ", (WORD)LastToggle, (WORD)_RemoDataReady);
#endif
if( LastToggle != togglebit ) { // new key
AutoWait = 0;
}
else if( AutoWait>=4 ) { // auto key
AutoWait++;
if( AutoWait>=6 ) {
AutoWait = 4;
*AutoKey = 1;
}
else return 0;
}
else { // wait auto key
AutoWait++;
return 0;
}
#ifdef DEBUG_KEYREMO
if( *AutoKey ) {
dPuts(" ---> AutoKey ");
}
else {
dPuts(" ---> New Key ");
}
#endif
*DataCode = _RemoDataCode;
return 1;
}
#elif defined REMO_NEC
extern DATA BYTE RemoData[4];
BYTE IsRemoDataReady(BYTE *DataCode, BYTE *AutoKey)
{
static BYTE AutoWait=0;
static IDATA BYTE LastDataCode=0xff;
static IDATA BYTE repeatcnt=0;
BYTE ret =0 ;
*AutoKey = 0;
switch ( RemoDataReady ) {
case 0: return 0;
case 1:
#ifdef DEBUG_KEYREMO
dPrintf("\r\nNEC RemoData = %02x %02x %02x %02x", (WORD)RemoData[0], (WORD)RemoData[1], (WORD)RemoData[2], (WORD)RemoData[3] );
#endif
if( (RemoData[0]==REMO_CUSTOM1) && (RemoData[1]==REMO_CUSTOM2 ) && (RemoData[2]+RemoData[3])==0xff ) {
RemoDataCode = RemoData[2];
LastDataCode = RemoDataCode;
AutoWait = 0;
*AutoKey = 0;
repeatcnt = 0;
}
else {
RemoDataCode = 0xff;
LastDataCode = 0xff;
EnableRemoconInt(); //
return 0;
}
break;
case 2:
AutoWait++;
if( AutoWait>=6 ) {
RemoDataCode = LastDataCode;
repeatcnt++;
if( repeatcnt>=5 ) {
AutoWait = 5;
}
else
AutoWait = 4;
*AutoKey = 1;
}
else {
EnableRemoconInt(); //
return 0;
}
break;
}
EnableRemoconInt(); ////LJY052902
if( RemoDataCode==0xff ) return 0;
#ifdef DEBUG_KEYREMO
dPrintf("(R-D:%02x) ", (WORD)RemoDataCode);
#endif
*DataCode = RemoDataCode;
return 1;
}
#endif // REMO_NEC
BYTE CheckRemo(void)
{
BYTE AutoKey, ret=1, _RemoDataCode;
if( IsRemoDataReady(&_RemoDataCode, &AutoKey) ) {
ret = ActionRemo( _RemoDataCode, (BYTE)AutoKey) ;
}
return ret;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -