📄 keypad.c
字号:
been initialized and is ready to be used or already in use.
In case of an initialization failure, which means that the
driver cannot be used, the function returns KBD_INITFAILURE.
After initialization, the driver is ready to handle
keyboard status changes.
*/
GLOBAL UBYTE kbd_Init (drv_SignalCB_Type in_SignalCBPtr)
{
kbd_signal_callback = in_SignalCBPtr; /* store call-back function */
/*
* Initialise TI driver with internal callback functions
*/
KP_Init (kbd_key_pressed, kbd_key_released);
return DRV_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_KBD |
| STATE : code ROUTINE : kbd_Exit |
+--------------------------------------------------------------------+
PURPOSE : The function is called when the driver functionality is
not longer needed. The function "de-allocates" all
allocated resources and finalizes the driver.
*/
GLOBAL void kbd_Exit (void)
{
kbd_signal_callback = NULL;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_KBD |
| STATE : code ROUTINE : kbd_SetConfig |
+--------------------------------------------------------------------+
PURPOSE : This function is used to set the typematic rate settings
of the keyboard driver. After a successful completion,
the driver uses the new configuration on following
keyboard events (e.g. key press). If one of the parameters
included in the driver control block is invalid, the function
returns DRV_INVALID_PARAMS. To retrieve the driver磗 default
configuration, call the function kbd_GetConfig().
*/
GLOBAL UBYTE kbd_SetConfig (kbd_DCB_Type * in_DCB_Ptr)
{
return DRV_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_KBD |
| STATE : code ROUTINE : kbd_GetConfig |
+--------------------------------------------------------------------+
PURPOSE : The function is used to retrieve the typematic rate
settings of the driver. The configuration is returned
in the driver control block to which the pointer provided
out_DCBPtr points. The typematic configuration can be set
by using the kbd_SetConfig() function.
If the driver is not configured, the function returns
KBD_NOTCONFIGURED.
*/
GLOBAL UBYTE kbd_GetConfig (kbd_DCB_Type * out_DCBPtr)
{
return DRV_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_KBD |
| STATE : code ROUTINE : kbd_SetSignal |
+--------------------------------------------------------------------+
PURPOSE : This function is used to define a signal that indicates
keyboard status changes to a process. A keyboard status
change is an event identified in the signal information
data type as SignalType. The only signal that can be set is
the keyboard status change signal as described in the
interface documentation.
*/
GLOBAL UBYTE kbd_SetSignal (drv_SignalID_Type * in_SignalIDPtr)
{
return DRV_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_KBD |
| STATE : code ROUTINE : kbd_ResetSignal |
+--------------------------------------------------------------------+
PURPOSE : This function is used to remove a signal that has previously
set. The signal that is removed is identified by the
signal information data element called SignalType.
*/
GLOBAL UBYTE kbd_ResetSignal (drv_SignalID_Type * in_SignalIDPtr)
{
return DRV_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_KBD |
| STATE : code ROUTINE : kbd_GetStatus |
+--------------------------------------------------------------------+
PURPOSE : This function is used to retrieve the current (latest)
status of the keyboard.
*/
GLOBAL ULONG kbd_GetStatus (void)
{
return 0L;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : TIL_MMI |
| STATE : code ROUTINE : kbd_key_pressed |
+--------------------------------------------------------------------+
PURPOSE : The function is called when a key is pressed.
*/
LOCAL void kbd_key_pressed (UBYTE act_key)
{
drv_SignalID_Type signal_params;
signal_params.SignalType = KBD_SIGTYPE_STATUSCHG;
#if defined (NEW_FRAME)
/*
UserData should not be a pointer, NM 12.10.01
*/
signal_params.UserData = (ULONG*)(0x00010000L | (ULONG)act_key);
#else
signal_params.SignalValue = 0;
signal_params.UserData = 0x00010000L + (ULONG)act_key;
#endif
kbd_act_key = act_key;
if (kbd_signal_callback NEQ NULL)
(*kbd_signal_callback)(&signal_params);
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : TIL_MMI |
| STATE : code ROUTINE : kbd_key_released |
+--------------------------------------------------------------------+
PURPOSE : The function is called when a key is released.
*/
LOCAL void kbd_key_released (UBYTE act_key)
{
drv_SignalID_Type signal_params;
signal_params.SignalType = KBD_SIGTYPE_STATUSCHG;
#if defined (NEW_FRAME)
/*
UserData should be use as a pointer;
The "act_key" wasnt even used in the old frame.
"kbd_act_key" keeps the key_code from the "key-press CB function"
and is used for the key-release CB function as well !!
It seems to be that the key_code for the key-release from the TI driver
isnt correct. This way looks like a work around but it works.
//old
//signal_params.UserData = (ULONG*)(0x00000000L | (ULONG)act_key);
NM 12.10.01
*/
signal_params.UserData = (ULONG*)(0x00000000L | (ULONG)kbd_act_key);
#else
signal_params.SignalValue = 0;
signal_params.UserData = 0x00000000L + (ULONG)kbd_act_key;
#endif
if (kbd_signal_callback NEQ NULL)
(*kbd_signal_callback)(&signal_params);
}
/*******************************************************************
* *
* PART II: Simulation for Windows *
* *
*******************************************************************/
#if defined (WIN32)
/*
* Dummies for driver calls
*/
LOCAL void KP_Init (void (*mmi_key_pressed)(UBYTE),
void (*mmi_key_relesed)(UBYTE))
{
}
#endif
/*
* Stimulation of the keyboard driver
*/
//GLOBAL void kbd_test (UBYTE key)
void kbd_test (UBYTE key)
{
kbd_key_pressed (key);
kbd_key_released (key);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -