📄 ti1_key.c
字号:
kbd_putMakeAndKey(1,18);
sig(0,0);
key += 7;
continue;
}
for (i = 0; i < NUM_KPD_KEYS; i++)
{
if (!strcmp(key,config_map[i]))
{
kbd_putMakeAndKey(0,i); /* add key down event */
sig(0,0);
kbd_putMakeAndKey(1,i); /* assume key down event */
sig(0,0);
key += strlen(config_map[i]);
break;
}
}
if (i < NUM_KPD_KEYS)
continue; /* found config code */
if (*key >= '0' && *key <= '9')
{
number = 1;
kbd_putMakeAndKey(0,(char) (*key-'0'));
sig(0,0);
kbd_putMakeAndKey(1,(char) (*key-'0')); /* assume a dial number */
sig(0,0);
}
key++;
}
if (number)
{
kbd_putMakeAndKey(0,18);
sig(0,0);
kbd_putMakeAndKey(1,18); /* simulate CALL */
sig(0,0);
}
}
void mfw_keystroke_long (char * key, UBYTE mode) /* long pressed key */
{
char i, number;
if (!sig) return; /* no event handler */
if (!key) return; /* no valid key */
number = 0;
while (strlen(key))
{
for (i = 0; i < NUM_KPD_KEYS; i++)
{
if (!strcmp(key,config_map[i]))
{
if (mode)
{
kbd_putMakeAndKey(0,i); /* assume key down event */
sig(0,0);
}
else
{
kbd_putMakeAndKey(1,i); /* assume key down event */
sig(0,0);
}
return;
}
}
return;
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : ti1_key |
| STATE : code ROUTINE : kbd_callback |
+--------------------------------------------------------------------+
PURPOSE : Called by keyboard driver
*/
#define hCommACI _ENTITY_PREFIXED(hCommACI)
static void kbdCb (drv_SignalID_Type *signal_params)
{
#if defined (NEW_FRAME)
ULONG signal_raw;
#endif
U16 signal_high;
U16 signal_low;
U8 key_code;
U8 key_state;
int nPresses; //Number of key presses still in the queue
#if defined (NEW_FRAME)
signal_raw = (ULONG)signal_params->UserData;
signal_high = (U16) (signal_raw >> 16);
signal_low = (U16) (signal_raw & 0xFFFF);
#else
signal_high = (U16) (signal_params->UserData >> 16);
signal_low = (U16) (signal_params->UserData & 0xFFFF);
#endif
key_code = (U8) (signal_low & 0xFF);
if (signal_high == 1)
key_state = KEY_STAT_PRS;
else
key_state = KEY_STAT_REL;
/*JVJ #1705 When the first POWER KEY event arrives, an event is sent to MMI */
/*to start it */
if ((!powered_on)&&(key_code==POWER_KEY))
{
sendKeyInd(key_code, key_state, 0);
return;
}
//Add keypress to queue of key presses
nPresses = kbd_getNumElements();
kbd_putMakeAndKey( (char)key_state, (char)key_code);
if ((!kbd_stillProcessingKeys()) && (nPresses == 0))
{ //Only this element present - create and send message.
sendKeyInd(key_code, key_state, 0);
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : ti1_key |
| STATE : code ROUTINE : keypad_cb |
+--------------------------------------------------------------------+
PURPOSE : This CB function is called by the driver when a key is pressed/released
or a status of an asynch. process is requested.
*/
void keypad_cb (void* parameter)
{
T_KPD_KEY_EVENT_MSG* event;
T_KPD_STATUS_MSG* status;
T_RV_CHECK* check;
int k,m;
check = (T_RV_CHECK*)parameter;
if (check->msg_id EQ KPD_STATUS_MSG)
{
//status message is used
status = (T_KPD_STATUS_MSG*) parameter;
if (status->status_value EQ KPD_PROCESS_OK)
{
//ok
}
else
{
//failed !
return;
}
}
else
{
int nPresses; //Number of key presses still in the queue
//event message is used
event = (T_KPD_KEY_EVENT_MSG*) parameter;
//Add keypress to queue of key presses
nPresses = kbd_getNumElements();
if (event->key_info.press_state EQ KPD_INSIGNIFICANT_VALUE)
{
kbd_putMakeAndKey( (char)event->key_info.state, (char)event->key_info.virtual_key_id );
}
else
{
//key_ind->key_stat (U8):
// 00xx 0000 = KEY_PRESSED
// 00xx 0001 = KEY_RELEASED
// 0000 00xx = KPD_FIRST_PRESS
// 0001 00xx = KPD_LONG_PRESS
// 0010 00xx = KPD_REPEAT_PRESS
//
// x = anystate
kbd_putMakeAndKey( (char)(event->key_info.state | (event->key_info.press_state << 4)),
(char)event->key_info.virtual_key_id );
}
if ((!kbd_stillProcessingKeys()) && (nPresses == 0))
{ //Only this element present - create and send message.
sendKeyInd(event->key_info.virtual_key_id, event->key_info.state, event->key_info.press_state);
}
}
return;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : ti1_key |
| STATE : code ROUTINE : keypad_initialize |
+--------------------------------------------------------------------+
PURPOSE : initialize keyboard driver
*/
UBYTE keypad_initialize (void)
{
T_KPD_MODE mode;
T_KPD_VIRTUAL_KEY_TABLE notified_keys;
T_RV_RETURN return_path;
T_RV_RET return_value;
U16 long_press_time = 30; // 3.0s
U16 repeat_time = 50; // 5.0s <not used>
T_KPD_NOTIF_LEVEL notif_level;
mode = KPD_DEFAULT_MODE;
return_path.callback_func = keypad_cb;
return_path.addr_id = 0;
notified_keys.nb_notified_keys = KPD_NB_PHYSICAL_KEYS;
notified_keys.notified_keys [0] = KPD_KEY_0;
notified_keys.notified_keys [1] = KPD_KEY_1;
notified_keys.notified_keys [2] = KPD_KEY_2;
notified_keys.notified_keys [3] = KPD_KEY_3;
notified_keys.notified_keys [4] = KPD_KEY_4;
notified_keys.notified_keys [5] = KPD_KEY_5;
notified_keys.notified_keys [6] = KPD_KEY_6;
notified_keys.notified_keys [7] = KPD_KEY_7;
notified_keys.notified_keys [8] = KPD_KEY_8;
notified_keys.notified_keys [9] = KPD_KEY_9;
notified_keys.notified_keys [10] = KPD_KEY_UP;
notified_keys.notified_keys [11] = KPD_KEY_DOWN;
notified_keys.notified_keys [12] = KPD_KEY_LEFT;
notified_keys.notified_keys [13] = KPD_KEY_RIGHT;
notified_keys.notified_keys [14] = KPD_KEY_CONNECT;
notified_keys.notified_keys [15] = KPD_KEY_DISCONNECT;
notified_keys.notified_keys [16] = KPD_KEY_STAR;
notified_keys.notified_keys [17] = KPD_KEY_DIESE;
if (KPD_NB_PHYSICAL_KEYS > 22)
{
notified_keys.notified_keys [18] = KPD_KEY_SOFT_LEFT;
notified_keys.notified_keys [19] = KPD_KEY_SOFT_RIGHT;
notified_keys.notified_keys [20] = KPD_KEY_VOL_UP;
notified_keys.notified_keys [21] = KPD_KEY_VOL_DOWN;
notified_keys.notified_keys [22] = KPD_KEY_ENTER;
//? #define KPD_KEY_RECORD (24)
}
#ifndef _SIMULATION_
return_value = kpd_subscribe (&subscriber_p, mode, ¬ified_keys, return_path);
#else
return_value = RV_OK; /* do some faking here, to get it compileable */
#endif
if (return_value EQ RV_INTERNAL_ERR ||
return_value EQ RV_INVALID_PARAMETER ||
return_value EQ RV_MEMORY_ERR)
{
//failed
//- RV_INTERNAL_ERR if
// - the max of subscriber is reached,
// - the software entity is not started, not yet initialized or initialization has
// failed
//- RV_INVALID_PARAMETER if number of virtual keys is not correct.
//- RV_MEMORY_ERR if memory reach its size limit.
return 1;
}
//Subscribe to key press and key release (at the moment)
//subscribe to KPD_LONG_KEY_PRESS_NOTIF once implemented.
notif_level = KPD_FIRST_PRESS_NOTIF | KPD_RELEASE_NOTIF;
#ifndef _SIMULATION_
return_value = kpd_define_key_notification( subscriber_p, ¬ified_keys, notif_level,
long_press_time, repeat_time );
#else
return_value = RV_OK;
#endif
if (return_value EQ RV_INVALID_PARAMETER ||
return_value EQ RV_MEMORY_ERR)
{ //failed
return 1;
}
return 0;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : ti1_key |
| STATE : code ROUTINE : sendKeyInd |
+--------------------------------------------------------------------+
PURPOSE : Sends an MMI_KEYPAD_IND to the protocol stack
*/
void sendKeyInd( T_KPD_VIRTUAL_KEY_ID virtual_key_id,
T_KPD_KEY_STATE key_state,
T_KPD_PRESS_STATE press_state)
{
#if defined (NEW_FRAME)
EXTERN T_HANDLE hCommACI;
ULONG signal_raw;
#else
EXTERN T_VSI_CHANDLE hCommACI;
#endif
PALLOC(key_ind,MMI_KEYPAD_IND);
key_ind->key_code = (U8)0;
key_ind->key_stat = 0;
#if defined (NEW_FRAME)
PSENDX(ACI,key_ind);
#else
#if defined (_TMS470)
vsi_c_send("",hCommACI,D2P(key_ind),
sizeof(T_PRIM_HEADER)+sizeof(T_MMI_KEYPAD_IND));
#else
PSEND(ACI,key_ind);
#endif
#endif
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -