ti1_key.c
来自「是一个手机功能的模拟程序」· C语言 代码 · 共 732 行 · 第 1/2 页
C
732 行
/*
+--------------------------------------------------------------------+
| PROJECT: MMI-Framework (8417) $Workfile:: ti1_key.c $|
| $Author: root $ CONDAT GmbH $Revision: 1.1.1.1 $|
| CREATED: 28.01.99 $Modtime:: 21.01.00 15:05 $|
| STATE : code |
+--------------------------------------------------------------------+
MODULE : TI1_KEY
PURPOSE : keyboard driver interface (TI1 VERSION)
EXPORT :
TO DO :
$History:: ti1_key.c $
*
* ***************** Version 13 *****************
* User: Es Date: 21.01.00 Time: 16:15
* Updated in $/GSM/Condat/MS/SRC/MFW
*
|
| ***************** Version 12 *****************
| User: Le Date: 12.01.00 Time: 12:59
| Updated in $/GSM/Condat/MS/SRC/MFW
*
* ***************** Version 11 *****************
* User: Es Date: 9.07.99 Time: 21:29
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 10 *****************
* User: Es Date: 6.07.99 Time: 18:37
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 9 *****************
* User: Es Date: 6.07.99 Time: 12:41
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 8 *****************
* User: Es Date: 14.04.99 Time: 17:34
* Updated in $/GSM/DEV/MS/SRC/MFW
* moved to CST
*
* ***************** Version 7 *****************
* User: Es Date: 1.04.99 Time: 17:07
* Updated in $/GSM/DEV/MS/SRC/MFW
* removed lots of traces
*
* ***************** Version 6 *****************
* User: Es Date: 20.02.99 Time: 19:24
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 5 *****************
* User: Es Date: 20.02.99 Time: 18:22
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 4 *****************
* User: Es Date: 20.02.99 Time: 14:43
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 3 *****************
* User: Es Date: 17.02.99 Time: 20:00
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 2 *****************
* User: Es Date: 10.02.99 Time: 19:51
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 1 *****************
* User: Es Date: 9.02.99 Time: 14:53
* Created in $/GSM/DEV/MS/SRC/MFW
* TI display & keyboard interface for MFW
*/
#define ENTITY_MFW
#define NEW_FRAME
#if defined (NEW_FRAME)
#include "typedefs.h"
#include "vsi.h"
#include "custom.h"
#include "gsm.h"
#include "prim.h"
#else
#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"
#endif
#include <string.h>
#include "mfw_mfw.h"
#include "mfw_tim.h"
#include "mfw_sys.h"
#include "mfw_kbd.h"
#include "gdi.h"
#include "kbd.h"
#include "drv_key.h"
#include "ti1_key.h"
#include "kpd_api.h"
#include "pwr.h"
/*
* Marcus: Issue 811: 05:09/2002:
* Moved kbd_map, simkbd_map and config_map to \g23m\Condat\COM\SRC\DRIVER\keypad.c
*/
/* driver callback */
static void kbdCb (drv_SignalID_Type *signal_params);
UBYTE keypad_initialize (void);
void sendKeyInd( T_KPD_VIRTUAL_KEY_ID virtual_key_id,
T_KPD_KEY_STATE key_state,
T_KPD_PRESS_STATE press_state);
static void (*sig) (char,char) = 0; /* kbd signaling function */
static char *keyMap = (char *) kbd_map; /* current keyboard mapping */
T_KPD_SUBSCRIBER subscriber_p; /* keep the subscription indentification value */
typedef struct
{
U32 msg_id;
void (*callback_func)(void *);
U16 src_addr_id;
U16 dest_addr_id;
} T_RV_CHECK;
extern int MMIStart_completed;
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : ti1_key |
| STATE : code ROUTINE : keyInit |
+--------------------------------------------------------------------+
PURPOSE : initialize keyboard driver
*/
void keyInit (void (*s)(char,char))
{
sig = s;
/*
* read keyboard mapping from EEPROM.
* if this fails set keyboard mapping with default values.
*
* EEPROM reading not now !!!
*/
keyMap = (char *) kbd_map;
//old keypad driver -> need it ONLY for the POWER_KEY !
//still using until we define one or two function to switch off/on the mobile
//will be removed asap
kbd_Init(kbdCb);
//new keypad driver
keypad_initialize ();
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : ti1_key |
| STATE : code ROUTINE : keyExit |
+--------------------------------------------------------------------+
PURPOSE : finalize keyboard driver
*/
void keyExit (void)
{
sig = 0;
//unsubscribe the client from the keypad driver
#ifndef _SIMULATION_
kpd_unsubscribe (&subscriber_p);
#endif
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : ti1_key |
| STATE : code ROUTINE : getKeyIndex |
+--------------------------------------------------------------------+
PURPOSE : returns the index to the key provided (or -1 if no match)
*/
char drvGetKeyIndex( char key)
{
int i;
#ifndef _SIMULATION_
for (i = 0; i < 32; i++)
{
if (keyMap[i] == key)
{
return (i);
}
}
#else
/* TEST only ES!! */
for (i = 0; i < NUM_KPD_KEYS; i++)
{
if (simkbd_map[i] == key)
{
return(i);
}
}
#endif
return (-1); //No match.
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : ti1_key |
| STATE : code ROUTINE : drvKeyUpDown |
+--------------------------------------------------------------------+
PURPOSE : handle key event (called from keyboard)
*/
void drvKeyUpDown (char upDown, char key)
{
char i;
TRACE_EVENT_P2("drvKeyUpDown : key = %d : state = %x", key, upDown);
if(key>=100) //virturl key for Hall AND Low Voltage
{
for (i = 0; i < NUM_KPD_KEYS; i++)
{
if (keyMap[i] == key)
{
sig((char)(!upDown),i);
return;
}
}
}
else
{
if (key != (char)0)
{
if ((key >= 48) && (key <=57))
{
key -= 47;
}
else
{
switch(key)
{
case 35:
key = (char)18;
break;
case 42:
key = (char)17;
break;
case 45:
key = (char)11;
break;
case 67:
key = (char)13;
break;
case 69:
key = (char)25;
break;
case 86:
key = (char)16;
break;
case 94:
key = (char)14;
break;
case 97:
key = (char)15;
break;
case 98:
key = (char)12;
break;
default:
key = (char)0;
break;
}
}
kbd_putMakeAndKey( upDown, key);
}
if (!sig) return; /* no event handler */
sig((char)(!upDown),0);
return;
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : ti1_key |
| STATE : code ROUTINE : mfw_keystroke |
+--------------------------------------------------------------------+
PURPOSE : handle keystroke primitive (called from aci-pei)
keystroke sent via 'PEI-CONFIG'-primitive
used in Test cases and by RT;
*/
void mfw_keystroke (char * key)
{
char i, number;
if (!sig) return; /* no event handler */
if (!key) return; /* no valid key */
number = 0;
while (strlen(key))
{
if (!strcmp(key,"#*43*1#"))
{
#ifdef WIN32
// EF we need to place the key code into the buffer
// together with the inverse of the key status, and then call sig
kbd_putMakeAndKey(0,19);
sig(0,0);
kbd_putMakeAndKey(1,19);
sig(0,0);
#else
sig(1,19); /* simulate HUP */
sig(0,19);
#endif
key += 7;
continue;
}
if (!strcmp(key,"#*43*0#"))
{
#ifdef WIN32
kbd_putMakeAndKey(0,18);
sig(0,0);
kbd_putMakeAndKey(1,18);
sig(0,0);
#else
sig(1,18); /* simulate CALL */
sig(0,18);
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?