📄 mfw_kbd.c
字号:
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_KBD |
| STATE : code ROUTINE : toAuto |
+--------------------------------------------------------------------+
PURPOSE : auto repeat timeout handler
*/
static int toAuto (U32 t, void *h)
{
/* 2004/04/16 sunsj modify */
curMap &= ~KEY_LONG;
curMap |= KEY_AUTO;
sigDistribute(curMap,curKey);
timAuto.time = valRepeat;
/* NM p007c*/
if(valRepeat)
timStart(&timAutoH);
/* NM p007c end*/
return 0;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_KBD |
| STATE : code ROUTINE : kbdCommand |
+--------------------------------------------------------------------+
PURPOSE : handle mfw windows command
*/
static int kbdCommand (U32 cmd, void *h)
{
switch(cmd)
{
case MfwCmdDelete: /* delete me */
if(!h)
return 0;
kbdDelete(h);
return 1;
default:
break;
}
return 0;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_KBD |
| STATE : code ROUTINE : kbd_putMakeAndKey |
+--------------------------------------------------------------------+
PURPOSE : places 'make' (key up/down) and key index into a queue
*/
int kbd_putMakeAndKey( char make, char key)
{
keyPressDetails localKP;
SHORT retVal;
localKP.make = make;
localKP.key = key;
retVal = mfw_cbuf_put(mfw_kbd_kpress_buf_id, &localKP);
if(retVal < 0)
TRACE_EVENT_P1("ERROR : mfw_cbuf_put failed with error value %d", retVal);
return(retVal);
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_KBD |
| STATE : code ROUTINE : kbd_getMakeAndKey |
+--------------------------------------------------------------------+
PURPOSE : reads 'make' (key up/down) and key index into a queue
Return +ve number - keys left in buffer
0 - no keys left - last key press returned
-1 - no keys and none in buffer
*/
int kbd_getMakeAndKey( char* make, char* key)
{
keyPressDetails localKP;
SHORT retVal;
retVal = mfw_cbuf_get(mfw_kbd_kpress_buf_id, &localKP);
if(retVal < 0)
{
*key = 0x7F;
*make = 0;
return(-1);
}
*make = !(localKP.make);
*key = drvGetKeyIndex(localKP.key);
return(mfw_cbuf_num_elements(mfw_kbd_kpress_buf_id));
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_KBD |
| STATE : code ROUTINE : kbd_getNumElements |
+--------------------------------------------------------------------+
PURPOSE : returns number of elements in queue
*/
int kbd_getNumElements(void)
{
return((int)mfw_cbuf_num_elements(mfw_kbd_kpress_buf_id));
}
int kbd_stillProcessingKeys(void)
{
return(still_processing_flag);
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_KBD |
| STATE : code ROUTINE : kbd_displayUpdateNeeded |
+--------------------------------------------------------------------+
PURPOSE : returns TRUE if we need to update the display
*/
int displayUpdateNeeded; //used for output every 'n' key presses
int kbd_displayUpdateNeeded(void)
{
if(kbd_processKeyInput()==PROCESS_EVERY_KEY)
return(TRUE);//Processing each key press - always update screen
else if(displayUpdateNeeded==0)
return(TRUE);//need to update the display (1 in 6 output)
else if(mfw_cbuf_num_elements(mfw_kbd_kpress_buf_id) > 1)
return(FALSE);//keys in queue - do not update
else
return(TRUE);//only 1 key up/down in queue - update display
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_KBD |
| STATE : code ROUTINE : kbd_setDisplayUpdateNeeded |
+--------------------------------------------------------------------+
PURPOSE : sets/clears the flag indicating we need to update the display
*/
void kbd_setDisplayUpdateNeeded(int set)
{
displayUpdateNeeded = set;
}
void mfw_TRACE_EVENT(char* str)
{
/* TRACE_EVENT(str);*/
TRACE_FUNCTION(str);
}
void mfw_TRACE_EVENT_data(char* str,int i)
{
char opStr[100];
sprintf(opStr,"%s : %d",str,i);
mfw_TRACE_EVENT(opStr);
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_KBD |
| STATE : code ROUTINE : kbd_processEveryKeyInput |
+--------------------------------------------------------------------+
PURPOSE : indicates if the software should process each keypad input individually
(TRUE) or if it should process keypad inputs one at a time (FALSE)
*/
int kbd_processKeyInput(void)
{
// return (QUEUE_N_KEYS);//We buffer multiple key inputs
return(QUEUE_EVERY_KEY);//We buffer multiple key inputs
// return (PROCESS_EVERY_KEY);//We process each key input
}
int MorethanMaxPressKeyNum(int num)
{
MmiTrace("MorethanMaxPressKeyNum");
MmiTraceInt(g_keypadnum);
if(g_keypadnum > num)
return 1;
return 0;
}
#if 0 // 133s48 version
/*
+--------------------------------------------------------------------+
| PROJECT: MMI-Framework (8417) $Workfile:: mfw_kbd.c $|
| $Author: zhenggl $ CONDAT GmbH $Revision: 1.4 $|
| CREATED: 21.09.98 $Modtime:: 23.03.00 8:24 $|
| STATE : code |
+--------------------------------------------------------------------+
MODULE : MFW_KBD
PURPOSE : keyboard handling functions
EXPORT :
TO DO : adjust PEI/driver interface
$History:: mfw_kbd.c $
*
* ***************** Version 18 *****************
* User: Es Date: 23.03.00 Time: 14:48
* Updated in $/GSM/Condat/MS/SRC/MFW
* no stddefs ???
*
* ***************** Version 17 *****************
* User: Rm Date: 23-02-00 Time: 3:15p
* Updated in $/GSM/Condat/MS/SRC/MFW
* stop Auto and Long timer finishing with kbdAlways
|
| ***************** Version 16 *****************
| User: Le Date: 26.01.00 Time: 12:13
| Updated in $/GSM/Condat/MS/SRC/MFW
| Make definition different for Windows and Target
*
* ***************** Version 15 *****************
* User: Be Date: 25.01.00 Time: 18:20
* Updated in $/GSM/Condat/MS/SRC/MFW
|
| ***************** Version 14 *****************
| User: Le Date: 6.01.00 Time: 9:23
| Updated in $/GSM/Condat/MS/SRC/MFW
| Alignment of MFW versions
*
* ***************** Version 3 *****************
* User: Be Date: 29.11.99 Time: 14:31
* Updated in $/GSM/Condat/SND-MMI/MFW
* target integration
*
* ***************** Version 2 *****************
* User: Es Date: 22.11.99 Time: 10:29
* Updated in $/GSM/Condat/SND-MMI/MFW
*
* ***************** Version 1 *****************
* User: Es Date: 18.11.99 Time: 16:35
* Created in $/GSM/Condat/SND-MMI/MFW
* Initial
*
* ***************** Version 13 *****************
* User: Es Date: 6.07.99 Time: 12:20
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 11 *****************
* User: Es Date: 1.04.99 Time: 17:07
* Updated in $/GSM/DEV/MS/SRC/MFW
* removed lots of traces
*
* ***************** Version 10 *****************
* User: Es Date: 18.02.99 Time: 17:01
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 9 *****************
* User: Es Date: 17.02.99 Time: 19:11
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 8 *****************
* User: Es Date: 14.01.99 Time: 17:19
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 7 *****************
* User: Es Date: 23.12.98 Time: 16:19
* Updated in $/GSM/DEV/MS/SRC/MFW
* data: modifier
* 08/12 zym add in kbdsignal
*/
#if defined (NEW_FRAME)
#include "typedefs.h"
#include "vsi.h"
#include "pei.h"
#include "custom.h"
#include "gsm.h"
#else
#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"
#endif
#include <stdio.h>
#include "mfw_mfw.h"
#include "mfw_sys.h"
#include "mfw_tim.h"
#include "drv_key.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
#include "pwr.h"
#include "r2d.h"
static int kbdCommand (U32 cmd, void *h);
static int toLong (U32 t, void *h);
static int toAuto (U32 t, void *h);
extern MfwHnd gtVibator;
static MfwCb doAlways; /* all cases handler */
static MfwHdr timLongH; /* the long press timer */
static MfwTim timLong;
static MfwHdr timAutoH; /* the auto repeat timer */
static MfwTim timAuto;
static U32 valAuto; /* auto start intervall */
static U32 valRepeat; /* auto repeat intervall */
static U32 curMap; /* current key map */
static U8 curKey; /* current key code */
driver_Parameter drvpara;
// PATCH LE 06.06.00
// current MFW element needed for multiple instances
EXTERN MfwHdr * current_mfw_elem;
extern T_R2D_GC_PTR r2d_g_lcd_gc;
extern int g_keypadnum;
extern INT8 r2d_g_event_was_sent;
int g_kpdnum =0 ; ///zym added 10/18
int g_kpdtim = 0; ///zym added 10/18
#define PRENUMPERSEC 4 //zym added 10/18
// END PATCH LE 06.06.00
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_KBD |
| STATE : code ROUTINE : kbdInit |
+--------------------------------------------------------------------+
PURPOSE : initialize keyboard handler
*/
MfwRes kbdInit (void)
{
timLong.time = 0; /* setup long press timer */
timLong.left = 0;
timLong.handler = toLong;
timLong.next = 0;
timLongH.data = &timLong;
timLongH.type = MfwTypTim;
timAuto.time = 0; /* setup auto repeat timer */
timAuto.left = 0;
timAuto.handler = toAuto;
timAuto.next = 0;
timAutoH.data = &timAuto;
timAutoH.type = MfwTypTim;
valAuto = valRepeat = 0;
keyInit(kbdSignal); /* init keyboard driver */
mfwCommand[MfwTypKbd] = (MfwCb) kbdCommand;
doAlways = 0;
return MfwResOk;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_KBD |
| STATE : code ROUTINE : kbdExit |
+--------------------------------------------------------------------+
PURPOSE : finalize keyboard handler
*/
MfwRes kbdExit (void)
{
mfwCommand[MfwTypKbd] = 0;
keyExit();
return MfwResOk;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_KBD |
| STATE : code ROUTINE : kbdAlways |
+--------------------------------------------------------------------+
PURPOSE : create keyboard control for all events
*/
MfwCb kbdAlways (MfwCb f)
{
MfwCb always = doAlways;
doAlways = f;
if(!f)
{
timStop(&timLongH);
timStop(&timAutoH);
}
return always;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_KBD |
| STATE : code ROUTINE : kbdTime |
+--------------------------------------------------------------------+
PURPOSE : define keyboard timeouts
*/
void kbdTime (long tLong, long tAuto, long tRepeat)
{
timLong.time = tLong; /* setup long press timer */
timAuto.time = tAuto; /* setup auto repeat timer */
valAuto = tAuto; /* save auto start timeout */
valRepeat = tRepeat; /* save repeat intervall */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -