📄 dual_key.c
字号:
//**********************************************************************************************************
// The Software is proprietary, confidential, and valuable to Realtek Semiconductor
// Corporation ("Realtek"). All rights, including but not limited to copyrights,
// patents, trademarks, trade secrets, mask work rights, and other similar rights and interests,
// are reserved to Realtek. Without prior written consent from Realtek, copying, reproduction,
// modification, distribution, or otherwise is strictly prohibited. The Software shall be
// kept strictly in confidence, and shall not be disclosed to or otherwise accessed by
// any third party. @ <2003> - <2008> The Software is provided "AS IS" without any warranty of any kind,
// express, implied, statutory or otherwise.
//**********************************************************************************************************
//----------------------------------------------------------------------------------------------------
// ID Code : Key.c No.0000
// Update Note :
//
//----------------------------------------------------------------------------------------------------
#define __KEY__
#include "Common\Header\Include.h"
//#if(_OSD_TYPE == _DUAL_OSD)
//----------------------------------------------------------------------------------------------------
// ID Code : Key.c No.0000
// Update Note :
//
//----------------------------------------------------------------------------------------------------
BYTE CKeySacnAdc(BYTE AdcPort);
#define _ADC_PORT_0 (0x01)
#define _ADC_PORT_1 (0x02)
#define _ADC_PORT_2 (0x04)
#define _ADC_PORT_3 (0x08)
#define _ADC_KEY_NONE 0
#define _ADC_KEY_0 1
#define _ADC_KEY_1 2
#define _ADC_KEY_2 3
//--------------------------------------------------
// Description : Key scan process
// Input Value : None
// Output Value : None
//--------------------------------------------------
//-----------------------------------------------------------------------------------------//
void CKeyHandler(void)
{
ucKeyMessage = _NONE_KEY_MESSAGE;
if(CKeyScanReady())
{
ucKeyStatePrev = ucKeyStateCurr;// Store previous key state
ucKeyStateCurr = CKeyScan(); // Get current key state
CKeyMessageProc();
}
}
//--------------------------------------------------
// Description : Check power key process
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CKeyCheckPowerKey(void)
{
ucKeyStatePrev = ucKeyStateCurr;
ucKeyStateCurr = CKeyScan();
CKeyPowerKeyProc();
}
//--------------------------------------------------
// Description : Initial key status
// Input Value : None
// Output Value : None
//--------------------------------------------------
#if(_TOUCH_SENSOR == _ON)
WORD code ONE_TOUCH_KEY_INITIAL[]=
{
0x0004, // values of 0x0000
0x0000, // values of 0x0001
0x0032, // values of 0x0002
0x0000, // values of 0x0003
0x003F, // values of 0x0004
0x0000, // values of 0x0005
0x0000, // values of 0x0006
0x0000, // values of 0x0007
0x0000, // values of 0x0008
0x0000, // values of 0x0009
0x0000, // values of 0x000A
0x0000, // values of 0x000B
0x0000, // values of 0x000C
0x0000, // values of 0x000D
0x0100,//0x0604,//0x0606, // values of 0x000E//for S03
0x0000, // values of 0x000F
0xFFFF,//0xB8C3, // values of 0x0010
0xFFFF,//0x3642, // values of 0x0011
0xFFFF,//0xBABA, // values of 0x0012
0x0000,//0xB5B5, // values of 0x0013
0x0000,//0xAAAA, // values of 0x0014
0x0000,//0xAAAA, // values of 0x0015
0x0000, // values of 0x0016
0x0000, // values of 0x0017
0x0000, // values of 0x0018
0x0000, // values of 0x0019
0x0000, // values of 0x001A
0x0000, // values of 0x001B
0x0000, // values of 0x001C
0x0000, // values of 0x001D
0x0000, // values of 0x001E
0x0000, // values of 0x001F
0x0000, // values of 0x0020
0x0000, // values of 0x0021
0x0000, // values of 0x0022
0x7F00, // values of 0x0023
0x0000, // values of 0x0024
};
void CKeyInitial(void)
{
BYTE i, FailCount=0;
for(i=0;i<=24;i++)
{
CKeyOneTouchSensorWrite(i, ONE_TOUCH_KEY_INITIAL[i]);
if(CKeyOneTouchSensorWrite(i, ONE_TOUCH_KEY_INITIAL[i])==_FAIL)
{
i=0;
if((FailCount++)==3)
break; //double check initial
}
}
CLR_I2C_TOUCH_KEY();
CLR_KEYSCANREADY();
CLR_KEYSCANSTART();
}
#else//_TOUCH_SENSOR == _OFF
void CKeyInitial(void)
{
CLR_KEYSCANREADY();
CLR_KEYSCANSTART();
}
#endif
//--------------------------------------------------
// Description : Key scan ready process. We wait 0.02 sec in order to keep the keypad debounce
// Input Value : None
// Output Value : None
//--------------------------------------------------
bit CKeyScanReady(void)
{
if(GET_KEYSCANSTART() && GET_KEYSCANREADY())
{
return _TRUE;
}
else if(!GET_KEYSCANSTART())
{
// Wait 0.02 sec in order to keep the keypad debounce
SET_KEYSCANSTART();
CTimerReactiveTimerEvent(SEC(0.02), CKeyScanReadyTimerEvent);
}
return _FALSE;
}
//--------------------------------------------------
// Description : Key scan ready timer event
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CKeyScanReadyTimerEvent(void)
{
SET_KEYSCANREADY();
}
//--------------------------------------------------
// Description : Key repeat enable timer event
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CKeyRepeatEnableTimerEvent(void)
{
SET_KEYREPEATSTART();
}
//--------------------------------------------------
// Description : Key message translation
// Input Value : ucKeyMask --> Key mask
// ucKeyMsg --> Key message
// Output Value : None
//--------------------------------------------------
void CKeyMessageConvert(BYTE ucKeyMask, BYTE ucKeyMsg)
{
if((ucKeyStatePrev ^ ucKeyStateCurr) & ucKeyMask)
{
#if(_OSD_TYPE == _BENQ_OSD)
if(ucKeyMsg==_EXIT_KEY_MESSAGE)
{
if((ucCurrState==_ACTIVE_STATE)&&(stGlobalData3.OSDLock==_OSD_LOCK)&&(ucOsdState==_MenuNoneBenq))
{
CTimerActiveTimerEvent(SEC(14),DisplayMenuWhenOsdLock15SecBenq);
bStoreMenuKeyMessage=_TRUE;
}
else
{
ucKeyMessage=_EXIT_KEY_MESSAGE;
}
}
else
{
ucKeyMessage = ucKeyMsg;
}
#else//_GENERIC_OSD
ucKeyMessage = ucKeyMsg;
#endif
CLR_KEYSCANSTART();
CLR_KEYSCANREADY();
}
else
{
if((ucKeyMask==_LEFT_KEY_MASK)||(ucKeyMask==_RIGHT_KEY_MASK))//GET_KEYREPEATENABLE())
{
#if(_OSD_TYPE == _BENQ_OSD)
if((bAdjustMode==_TRUE)||(ucOsdState==_Menu3thResetColorCautionBenq)||(ucOsdState==_Menu3thResetAllCautionBenq))
{
if(GET_KEYREPEATSTART())
{
ucKeyMessage = ucKeyMsg;
}
else
{
CTimerActiveTimerEvent(SEC(_KEY_REPEAT_START_TIME),CKeyRepeatEnableTimerEvent);
}
}
#else//_GENERIC_OSD
if(bAdjustMode==_TRUE)
{
if(GET_KEYREPEATSTART())
{
ucKeyMessage = ucKeyMsg;
}
else
{
CTimerActiveTimerEvent(SEC(_KEY_REPEAT_START_TIME),CKeyRepeatEnableTimerEvent);
}
}
#endif
}
}
}
//--------------------------------------------------
// Description : Power key process
// Input Value : None
// Output Value : Return _TRUE if power key is pressed
//--------------------------------------------------
bit CKeyPowerKeyProc(void)
{
if(ucKeyStateCurr & _POWER_KEY_MASK)
{
if((ucKeyStatePrev ^ ucKeyStateCurr) & _POWER_KEY_MASK)
{
CTimerDelayXms(25);
ucKeyStateCurr = CKeyScan();
if((ucKeyStatePrev ^ ucKeyStateCurr) & _POWER_KEY_MASK)
{
SET_POWERSWITCH();
return _TRUE;
}
}
}
return _FALSE;
}
//--------------------------------------------------
// Description : Convert keypad status into key message, stores in ucKeyNotify
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CKeyMessageProc(void)
{
switch(ucKeyStateCurr)
{
case(_ENTER_KEY_MASK):
#if(_OSD_TYPE == _BENQ_OSD)
if(ucKeyStatePrev ^ ucKeyStateCurr)
{
if(((ucCurrState == _NOSIGNAL_STATE) || (ucCurrState == _NOSUPPORT_STATE)) && (bPressAnyKeytoWakeUp))
{
#if(_TOUCH_SENSOR == _ON)
CKeyBuzzerBeep();
#endif
CTimerCancelTimerEvent(DisplayBurnInPatternBenq);
CTimerCancelTimerEvent(CModePowerSavingEvent);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -