📄 keybrd.c
字号:
{
KEYBRD_MESSAGE KeyBrdMsg;
nKeyPadStatus[KeyMapIndex] = KEY_EVENT_DOWN;
KeyBrdMsg.nMsgType = KEY_EVENT_DOWN;
KeyBrdMsg.nKeyCode = nKeyPadMap[KeyMapIndex].nMMIKeyCode;
KeyEventHandler((struct KEYBRD_MESSAGE*)&KeyBrdMsg);
}
else
{
/* Ignore the event */
}
}
else if (MsgType == DRV_WM_ENABLE_TWOKEY_DETECTION || MsgType == DRV_WM_DISABLE_TWOKEY_DETECTION)
{
/* Ignore the event */
}
#endif /* MMI_ON_WIN32 */
else
{
MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_ERROR_PROC_KEYEVENT_HDLR));
MMI_ASSERT(0);
}
}
#ifdef MMI_ON_WIN32
#define CHECK_SIMPLY_HANDLE_MULTIPLEKEY(type, id) \
{ \
static U16 lastId = 0xffff; \
if (mmi_kbd_get_concurrent_mode() == MMI_FALSE) \
{ \
if (type == WM_KEYPRESS) \
{ \
if (lastId == 0xffff) \
{ /* update lastId */ \
lastId = id; \
} \
else if (lastId != id) \
{ /* previous key isn't release but another key is pressed */ \
/* release the previous key first */ \
/* then continue to press the current key */ \
ProcessKeyEvent(WM_KEYRELEASE, lastId); \
lastKeyId = i; \
} \
} \
else /* WM_KEYRELEASE */ \
{ /* reset lastId */ \
lastId = 0xffff; \
} \
} \
}
/*****************************************************************************
* FUNCTION
* ProcessPCKeyEvent
* DESCRIPTION
* This function is to convert the W32 key to MMI keys.
* PARAMETERS
* MsgType [IN] Type of key event
* KeyBrdMsg [?]
* KeyMsg(?) [IN] Key structure
* RETURNS
* void
*****************************************************************************/
U8 ProcessPCKeyEvent(U32 MsgType, KEYBRD_MESSAGE *KeyBrdMsg)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U16 i;
static U16 lastKeyId = 0xffff; /* initial value (magic number) */
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if ((MsgType == WM_KEYBRD_PRESS) || (MsgType == WM_KEYBRD_RELEASE))
{
/*
* handle the key event from the keyboard event
* find keyCode in nHotKey of nKeyPadMap's table
*/
for (i = 0; i < MAX_KEYPADMAP; i++)
{
if (KeyBrdMsg->nKeyCode == nKeyPadMap[i].nHotKey)
{
if (MsgType == WM_KEYBRD_PRESS)
{
MsgType = WM_KEYPRESS;
}
else
{
MsgType = WM_KEYRELEASE;
}
CHECK_SIMPLY_HANDLE_MULTIPLEKEY(MsgType, i) ProcessKeyEvent(MsgType, i);
return MMI_TRUE;
}
}
}
else if ((MsgType == WM_KEYPRESS) || (MsgType == WM_KEYRELEASE))
{
/*
* handle the key event from the mouse event
* find keyCode in nKeyCode of nKeyPadMap's table
*/
for (i = 0; i < MAX_KEYPADMAP; i++)
{
if (KeyBrdMsg->nKeyCode == nKeyPadMap[i].nKeyCode)
{
CHECK_SIMPLY_HANDLE_MULTIPLEKEY(MsgType, i);
ProcessKeyEvent(MsgType, i); /* Msg type press or release & keymap index */
return MMI_TRUE;
}
}
}
/* Not handle this message */
return MMI_FALSE;
}
/*****************************************************************************
* FUNCTION
* mmi_frm_set_key_handle_in_high_frequency
* DESCRIPTION
* The dummy function for PC simulator
* PARAMETERS
* is_enable [IN]
* a(?) [IN] Is_enable
* RETURNS
* void
*****************************************************************************/
void mmi_frm_set_key_handle_in_high_frequency(MMI_BOOL is_enable)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* do nothing */
}
/*****************************************************************************
* FUNCTION
* KeyTimerExpiryProc
* DESCRIPTION
* Timer expiry procedure
* PARAMETERS
* idEvent [?]
* handle(?) [IN] To window
* RETURNS
* void
*****************************************************************************/
void KeyTimerExpiryProc(void *idEvent)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U16 i;
MMI_BOOL bNeedToDo = MMI_FALSE;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* Check the timer ID */
if ((KEY_TIMER_ID0 <= (U32) idEvent) && ((U32) idEvent < UI_TIMER_ID_BASE))
{
for (i = 0; i < MAX_KEYPADMAP; i++)
{
bNeedToDo = MMI_FALSE;
if (((S32) idEvent) == nKeyPadMap[i].nTimerId)
{
/* Check the keypad status. It should not be KEY_EVENT_UP */
if (nKeyPadStatus[i] == KEY_EVENT_DOWN)
{
nKeyPadStatus[i] = KEY_LONG_PRESS;
bNeedToDo = MMI_TRUE;
}
else if ((nKeyPadStatus[i] == KEY_LONG_PRESS) || (nKeyPadStatus[i] == KEY_REPEAT))
{
nKeyPadStatus[i] = KEY_REPEAT;
bNeedToDo = MMI_TRUE;
}
/* stop the timer even the keypad status is KEY_EVENT_UP */
StopTimer(nKeyPadMap[i].nTimerId);
/* Only the */
if (bNeedToDo == MMI_TRUE)
{
KEYBRD_MESSAGE KeyBrdMsg;
KeyBrdMsg.nMsgType = nKeyPadStatus[i];
KeyBrdMsg.nKeyCode = nKeyPadMap[i].nMMIKeyCode;
MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_PROC_TIMER_EVENT_HDLR, KeyBrdMsg.nMsgType,
KeyBrdMsg.nKeyCode));
KeyEventHandler((KEYBRD_MESSAGE*) & KeyBrdMsg);
StartTimer(nKeyPadMap[i].nTimerId, KEYTIMER_REPEAT, (FuncPtr) KeyTimerExpiryProc);
}
break;
}
}
}
else
{
MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_ERROR_KEY_TIMER_EXPIRY_HDLR, (U32) idEvent));
MMI_ASSERT(0);
}
}
/* MTK added, Max to solve power on race condition 0730 */
#else
/*****************************************************************************
* FUNCTION
* InitKeypadBeforePWRON
* DESCRIPTION
* Initializes keypad before power on
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void InitKeypadBeforePWRON(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
SetProtocolEventHandler(KeyHandleBeforePWRON, MSG_ID_MMI_EQ_KEYPAD_DETECT_IND);
}
/*****************************************************************************
* FUNCTION
* KeyHandleBeforePWRON
* DESCRIPTION
* This function detects key presses before power on
* PARAMETERS
* paraBuff [IN]
* RETURNS
* void
*****************************************************************************/
void KeyHandleBeforePWRON(void *paraBuff)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
mmi_eq_keypad_detect_ind_struct *p;
kbd_data k;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
p = (mmi_eq_keypad_detect_ind_struct*) paraBuff;
while ((*(p->func)) (&k) == KAL_TRUE);
}
/*****************************************************************************
* FUNCTION
* mmi_frm_convert_process_key_event
* DESCRIPTION
* convert the driver key event type to MMI key event type
* and process the key event
* PARAMETERS
* Keyevent [IN]
* KeyMapIndex [IN]
* a(?) [IN] ParaBuff
* RETURNS
* void
*****************************************************************************/
#if defined(__MMI_SCREEN_ROTATE__)
static mmi_frm_screen_rotate_enum key_rotate = MMI_FRM_SCREEN_ROTATE_0;
#endif
void mmi_frm_convert_process_key_event(U32 Keyevent, U16 KeyMapIndex)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (Keyevent == WM_KEYPRESS)
{
#ifdef __MMI_SCREEN_ROTATE__
key_rotate = mmi_frm_get_screen_rotate();
#endif
}
#ifdef __MMI_INTERACTIVE_PROFILNG__
if (Keyevent == WM_KEYPRESS)
{
mmi_frm_profiling_interactive_start3();
}
else if (Keyevent == WM_KEYRELEASE)
{
mmi_frm_profiling_interactive_start2();
}
#endif /* __MMI_INTERACTIVE_PROFILNG__ */
#ifdef __MMI_SCREEN_ROTATE__
switch (key_rotate)
{
case MMI_FRM_SCREEN_ROTATE_270:
switch (KeyMapIndex)
{
case DEVICE_KEY_UP:
KeyMapIndex = DEVICE_KEY_LEFT;
break;
case DEVICE_KEY_DOWN:
KeyMapIndex = DEVICE_KEY_RIGHT;
break;
case DEVICE_KEY_LEFT:
KeyMapIndex = DEVICE_KEY_DOWN;
break;
case DEVICE_KEY_RIGHT:
KeyMapIndex = DEVICE_KEY_UP;
break;
}
break;
}
#endif /* __MMI_SCREEN_ROTATE__ */
ProcessKeyEvent(Keyevent, KeyMapIndex);
if (Keyevent == WM_KEYRELEASE)
{
#ifdef __MMI_SCREEN_ROTATE__
key_rotate = MMI_FRM_SCREEN_ROTATE_0;
#endif
}
#ifdef __MMI_INTERACTIVE_PROFILNG__
if (Keyevent == WM_KEYPRESS)
{
mmi_frm_profiling_interactive_end3();
}
else if (Keyevent == WM_KEYRELEASE)
{
mmi_frm_profiling_interactive_end2();
mmi_frm_profiling_interactive_show((U8*) L"K", MMI_FRM_PROFILING_MASK_2 | MMI_FRM_PROFILING_MASK_3);
}
#endif /* __MMI_INTERACTIVE_PROFILNG__ */
}
/*****************************************************************************
* FUNCTION
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -