comparison src/ui3/mfw/ti1_key.c @ 420:e8ddbb0837ed

src/ui3: initial import of TCS3/LoCosto BMI & MFW code
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 21 Jan 2018 03:09:00 +0000
parents
children
comparison
equal deleted inserted replaced
419:59143cd42ec7 420:e8ddbb0837ed
1 /*
2 +--------------------------------------------------------------------+
3 | PROJECT: MMI-Framework (8417) $Workfile:: ti1_key.c $|
4 | $Author:: Es $ CONDAT GmbH $Revision:: 13 $|
5 | CREATED: 28.01.99 $Modtime:: 21.01.00 15:05 $|
6 | STATE : code |
7 +--------------------------------------------------------------------+
8
9 MODULE : TI1_KEY
10
11 PURPOSE : keyboard driver interface (TI1 VERSION)
12
13 EXPORT :
14
15 TO DO :
16 +--------------------------------------------------------------------+
17 History:
18
19 Sep 18, 2006 REF: OMAPS00094426 - x0039928
20 Description: Locosto - KPD Release event would NOT be generated if a key is pressed
21 several times in a short period of time
22 Solution : If the long press timer expires mmi checks the bsp kpd status and accordingly
23 sets long press bit in the key map.
24
25
26 */
27
28 #define ENTITY_MFW
29
30 #include "typedefs.h"
31 #include "vsi.h"
32 #include "custom.h"
33 #include "gsm.h"
34 #include "prim.h"
35
36 #include <string.h>
37
38 #include "mfw_mfw.h"
39 #include "mfw_sys.h"
40 #include "mfw_kbd.h"
41 #include "gdi.h"
42 #include "kbd.h"
43
44 #include "drv_key.h"
45 #include "ti1_key.h"
46
47 #ifndef NEPTUNE_BOARD
48 #include "kpd/kpd_api.h"
49 #else
50 #define PLATFORM_ARCH_ARM
51 #define PLATFORM_ENDIAN_LITTLE
52 #define PLATFORM tcs3100Evm
53 #include "bspSystem.h"
54 #include "bspKeypad_Gsp.h"
55 #endif
56
57 /* BUG FIX - OMAPS00084167 */
58 #ifdef FF_MMI_MULTIMEDIA
59 #include "typedefs.h"
60 #include "main_system.h"
61 /*#include "dev_Mbox.h" */ /* 04-07-2006 */
62 #endif
63 /* END - OMAPS00084167 */
64
65 BOOL powered_on=FALSE;
66
67 #define POWER_KEY 25
68
69 extern void mmiInit(void);
70
71 //TISH modified for MSIM
72 #ifdef WIN32
73 #define _SIMULATION_
74 #endif
75
76 /*
77 * Marcus: Issue 811: 05:09/2002:
78 * Moved kbd_map, simkbd_map and config_map to \g23m\Condat\COM\SRC\DRIVER\keypad.c
79 */
80 /* driver callback */
81 static void kbdCb (drv_SignalID_Type *signal_params);
82
83 UBYTE keypad_initialize (void);
84
85 void sendKeyInd( T_KPD_VIRTUAL_KEY_ID virtual_key_id,
86 T_KPD_KEY_STATE key_state,
87 T_KPD_PRESS_STATE press_state);
88
89 static void (*sig) (char,char) = 0; /* kbd signaling function */
90 static char *keyMap = (char *) kbd_map; /* current keyboard mapping */
91
92 T_KPD_SUBSCRIBER subscriber_p; /* keep the subscription indentification value */
93
94 // Sep 18, 2006 REF: OMAPS00094426 - x0039928
95 #if (BOARD == 71)
96 extern UBYTE kpd_key;
97 #endif
98
99 typedef struct
100 {
101 U32 msg_id;
102 void (*callback_func)(void *);
103 U16 src_addr_id;
104 U16 dest_addr_id;
105 } T_RV_CHECK;
106
107
108
109 /* JVJ #1874 - new function to initialize the power key*/
110
111
112 /*
113 +--------------------------------------------------------------------+
114 | PROJECT : MMI-Framework (8417) MODULE : key_power_init |
115 | STATE : code ROUTINE : key_power_init |
116 +--------------------------------------------------------------------+
117
118 PURPOSE : initialize the power key handler in the TI driver
119
120 */
121
122
123
124 void key_power_init()
125 {
126 kbd_Init(kbdCb);
127 }
128
129
130
131 /*
132 +--------------------------------------------------------------------+
133 | PROJECT : MMI-Framework (8417) MODULE : ti1_key |
134 | STATE : code ROUTINE : keyInit |
135 +--------------------------------------------------------------------+
136
137 PURPOSE : initialize keyboard driver
138
139 */
140
141 void keyInit (void (*s)(char,char))
142 {
143 sig = s;
144 /*
145 * read keyboard mapping from EEPROM.
146 * if this fails set keyboard mapping with default values.
147 *
148 * EEPROM reading not now !!!
149 */
150 keyMap = (char *) kbd_map;
151
152
153 //new keypad driver
154 #ifdef NEPTUNE_BOARD
155 // Commented by Nitin for Neptune Platfrom. 05/04/2005
156 //keypad_initialize ();
157 #else
158 keypad_initialize ();
159 #endif
160
161
162 }
163
164
165 /*
166 +--------------------------------------------------------------------+
167 | PROJECT : MMI-Framework (8417) MODULE : ti1_key |
168 | STATE : code ROUTINE : keyExit |
169 +--------------------------------------------------------------------+
170
171 PURPOSE : finalize keyboard driver
172
173 */
174
175 void keyExit (void)
176 {
177 sig = 0;
178
179 // by Nitin 05/04/2004
180 #ifndef NEPTUNE_BOARD
181 //unsubscribe the client from the keypad driver
182 #ifndef _SIMULATION_
183 kpd_unsubscribe (&subscriber_p);
184 #endif
185 // Added by Nitin 05/04/2004
186 #else /* NOT defined NEPTUNE_BOARD */
187 kpdMgr_unsubscribe(); // Sumit; commented for time being
188 #endif
189
190 }
191
192 /*
193 +--------------------------------------------------------------------+
194 | PROJECT : MMI-Framework (8417) MODULE : ti1_key |
195 | STATE : code ROUTINE : getKeyIndex |
196 +--------------------------------------------------------------------+
197
198 PURPOSE : returns the index to the key provided (or -1 if no match)
199
200 */
201 char drvGetKeyIndex( char key)
202 {
203 int i;
204
205 #ifndef _SIMULATION_
206 for (i = 0; i < 32; i++)
207 {
208 if (keyMap[i] == key)
209 {
210 return (i);
211 }
212 }
213
214 #else
215 /* TEST only ES!! */
216 for (i = 0; i < NUM_KPD_KEYS; i++)
217 {
218 if (simkbd_map[i] == key)
219 {
220 return (i);
221 }
222 }
223 #endif
224
225 return (char)(0xFE); //No match./*a0393213 warnings removal - -1 changed to 0xFE*/
226
227
228 }
229
230
231 /*
232 +--------------------------------------------------------------------+
233 | PROJECT : MMI-Framework (8417) MODULE : ti1_key |
234 | STATE : code ROUTINE : drvKeyUpDown |
235 +--------------------------------------------------------------------+
236
237 PURPOSE : handle key event (called from keyboard)
238
239 */
240
241 void drvKeyUpDown (char upDown, char key)
242 {
243 TRACE_EVENT_P2("drvKeyUpDown : key = %d : state = %x", key, upDown);
244 /* JVJ #1705 The first KEY event can only be the Power Key*/
245 /* This will start MMI */
246 if ((!powered_on))
247 {
248 powered_on =TRUE;
249
250 /* ADDED BY RAVI - 22-11-2005 - OMAPS00056702 FIX */
251 #if (BOARD!=61)
252 /* JVJ #1705 MMI will be started here */
253 mmiInit();
254 return;
255 #endif
256 /* END RAVI - 22-11-2005 */
257 }
258
259 if (key != (char)0)
260 {
261 if ((key >= 48) && (key <=57))
262 {
263 key -= 47;
264 }
265 else
266 {
267 switch(key)
268 {
269 case 35:
270 key = (char)18;
271 break;
272
273 case 42:
274 key = (char)17;
275 break;
276
277 case 45:
278 key = (char)11;
279 break;
280
281 case 67:
282 key = (char)13;
283 break;
284
285 case 69:
286 key = (char)25;
287 break;
288
289 case 86:
290 key = (char)16;
291 break;
292
293 case 94:
294 key = (char)14;
295 break;
296
297 case 97:
298 key = (char)15;
299 break;
300
301 case 98:
302 key = (char)12;
303 break;
304
305 default:
306 key = (char)0;
307 break;
308 }
309 }
310
311 kbd_putMakeAndKey( upDown, key);
312 }
313
314 if (!sig) return; /* no event handler */
315
316 sig((char)(!upDown),0);
317
318 return;
319
320 }
321
322
323
324 /*
325 +--------------------------------------------------------------------+
326 | PROJECT : MMI-Framework (8417) MODULE : ti1_key |
327 | STATE : code ROUTINE : mfw_keystroke |
328 +--------------------------------------------------------------------+
329
330 PURPOSE : handle keystroke primitive (called from aci-pei)
331 keystroke sent via 'PEI-CONFIG'-primitive
332 used in Test cases and by RT;
333
334 */
335
336 void mfw_keystroke (char * key)
337 {
338 char i; //, number; // RAVI
339
340 if (!sig) return; /* no event handler */
341 if (!key) return; /* no valid key */
342
343 // number = 0; // RAVI
344 while (*key)
345 {
346 if (!strcmp(key,"#*43*1#"))
347 {
348 // EF we need to place the key code into the buffer
349 // together with the inverse of the key status, and then call sig
350 kbd_putMakeAndKey(0,19); /* simulate HUP */
351 sig(0,0);
352 kbd_putMakeAndKey(1,19);
353 sig(0,0);
354 key += 7;
355 continue;
356 }
357
358 if (!strcmp(key,"#*43*0#"))
359 {
360 kbd_putMakeAndKey(0,18); /* simulate CALL */
361 sig(0,0);
362 kbd_putMakeAndKey(1,18);
363 sig(0,0);
364 key += 7;
365 continue;
366 }
367
368 for (i = 0; i < NUM_KPD_KEYS; i++)
369 {
370 if (!strncmp(key, config_map[i], strlen(config_map[i])))
371 {
372 kbd_putMakeAndKey(0,i); /* add key down event */
373 sig(0,0);
374 kbd_putMakeAndKey(1,i); /* assume key down event */
375 sig(0,0);
376 key += strlen(config_map[i]);
377 break;
378 }
379 }
380 if (i < NUM_KPD_KEYS)
381 continue; /* found config code */
382
383 key++;
384 }
385 }
386
387 void mfw_keystroke_long (char * key, UBYTE mode) /* long pressed key */
388 {
389 char i; // , number; // RAVI
390
391 if (!sig) return; /* no event handler */
392 if (!key) return; /* no valid key */
393
394 // number = 0; // RAVI
395 while (strlen(key))
396 {
397 for (i = 0; i < NUM_KPD_KEYS; i++)
398 {
399 if (!strcmp(key,config_map[i]))
400 {
401 if (mode)
402 {
403 kbd_putMakeAndKey(0,i); /* assume key down event */
404 sig(0,0);
405 }
406 else
407 {
408 kbd_putMakeAndKey(1,i); /* assume key up event */
409 sig(0,0);
410 }
411 return;
412 }
413 }
414 return;
415 }
416 }
417
418
419 /*
420 +--------------------------------------------------------------------+
421 | PROJECT : MMI-Framework (8417) MODULE : ti1_key |
422 | STATE : code ROUTINE : kbd_callback |
423 +--------------------------------------------------------------------+
424
425 PURPOSE : Called by keyboard driver
426
427 */
428
429 #define hCommACI _ENTITY_PREFIXED(hCommACI)
430
431 static void kbdCb (drv_SignalID_Type *signal_params)
432 {
433 #if defined (NEW_FRAME)
434 ULONG signal_raw;
435
436 #endif
437
438 U16 signal_high;
439 U16 signal_low;
440 U8 key_code;
441 U8 key_state;
442
443 int nPresses; //Number of key presses still in the queue
444
445
446
447
448
449 #if defined (NEW_FRAME)
450 signal_raw = (ULONG)signal_params->UserData;
451 signal_high = (U16) (signal_raw >> 16);
452 signal_low = (U16) (signal_raw & 0xFFFF);
453 #else
454 signal_high = (U16) (signal_params->UserData >> 16);
455 signal_low = (U16) (signal_params->UserData & 0xFFFF);
456 #endif
457
458 key_code = (U8) (signal_low & 0xFF);
459 if (signal_high == 1)
460 key_state = KEY_STAT_PRS;
461 else
462 key_state = KEY_STAT_REL;
463
464 /*JVJ #1705 When the first POWER KEY event arrives, an event is sent to MMI */
465 /*to start it */
466 if ((!powered_on)&&(key_code==POWER_KEY))
467 {
468 sendKeyInd(key_code, key_state, 0);
469 return;
470 }
471
472
473 //Add keypress to queue of key presses
474 nPresses = kbd_getNumElements();
475
476
477 kbd_putMakeAndKey( (char)key_state, (char)key_code);
478
479 if ((!kbd_stillProcessingKeys()) && (nPresses == 0))
480 { //Only this element present - create and send message.
481 sendKeyInd(key_code, key_state, 0);
482
483 }
484
485 }
486
487 /*
488 +--------------------------------------------------------------------+
489 | PROJECT : MMI-Framework (8417) MODULE : ti1_key |
490 | STATE : code ROUTINE : keypad_cb |
491 +--------------------------------------------------------------------+
492
493 PURPOSE : This CB function is called by the driver when a key is pressed/released
494 or a status of an asynch. process is requested.
495
496 */
497
498 void keypad_cb (void* parameter)
499 {
500 // NITIN
501 #ifndef NEPTUNE_BOARD
502 T_KPD_KEY_EVENT_MSG* event;
503 T_KPD_STATUS_MSG* status;
504 T_RV_CHECK* check;
505
506
507
508
509
510
511 check = (T_RV_CHECK*)parameter;
512
513 if (check->msg_id EQ KPD_STATUS_MSG)
514 {
515 //status message is used
516 status = (T_KPD_STATUS_MSG*) parameter;
517
518
519
520 if (status->status_value EQ KPD_PROCESS_OK)
521 {
522 //ok
523 }
524 else
525 {
526 //failed !
527 return;
528 }
529 }
530 else
531 {
532 int nPresses; //Number of key presses still in the queue
533 //event message is used
534 event = (T_KPD_KEY_EVENT_MSG*) parameter;
535
536
537 //Add keypress to queue of key presses
538 nPresses = kbd_getNumElements();
539
540 if (event->key_info.press_state EQ KPD_INSIGNIFICANT_VALUE)
541 {
542 kbd_putMakeAndKey( (char)event->key_info.state, (char)event->key_info.virtual_key_id );
543 }
544 else
545 {
546
547 //key_ind->key_stat (U8):
548 // 00xx 0000 = KEY_PRESSED
549 // 00xx 0001 = KEY_RELEASED
550 // 0000 00xx = KPD_FIRST_PRESS
551 // 0001 00xx = KPD_LONG_PRESS
552 // 0010 00xx = KPD_REPEAT_PRESS
553 //
554 // x = anystate
555 // Sep 18, 2006 REF: OMAPS00094426 - x0039928
556 // Fix : Store the virtual key info in the global variable kpd_key for later use
557 #if (BOARD == 71)
558 kpd_key = (char)event->key_info.virtual_key_id;
559 #endif
560 kbd_putMakeAndKey( (char)(event->key_info.state | (event->key_info.press_state << 4)),
561 (char)event->key_info.virtual_key_id );
562 }
563
564 if ((!kbd_stillProcessingKeys()) && (nPresses == 0))
565
566 { //Only this element present - create and send message.
567
568
569
570 sendKeyInd(event->key_info.virtual_key_id, event->key_info.state, event->key_info.press_state);
571
572 }
573
574 }
575 #endif // NEPTUNE_BOARD
576 return;
577
578 }
579
580
581 /*
582 +--------------------------------------------------------------------+
583 | PROJECT : MMI-Framework (8417) MODULE : ti1_key |
584 | STATE : code ROUTINE : keypad_initialize |
585 +--------------------------------------------------------------------+
586
587 PURPOSE : initialize keyboard driver
588
589 */
590 // Commented by Nitin for Neptune Platfrom. 05/04/2005
591
592 #ifndef NEPTUNE_BOARD
593 UBYTE keypad_initialize (void)
594 {
595 T_KPD_MODE mode;
596 T_KPD_VIRTUAL_KEY_TABLE notified_keys;
597 T_RV_RETURN return_path;
598 T_RV_RET return_value;
599
600 U16 long_press_time = 30; // 3.0s
601 U16 repeat_time = 50; // 5.0s <not used>
602
603 T_KPD_NOTIF_LEVEL notif_level;
604 mode = KPD_DEFAULT_MODE;
605
606 return_path.callback_func = keypad_cb;
607 return_path.addr_id = 0;
608
609 notified_keys.nb_notified_keys = KPD_NB_PHYSICAL_KEYS;
610
611 notified_keys.notified_keys [0] = KPD_KEY_0;
612 notified_keys.notified_keys [1] = KPD_KEY_1;
613 notified_keys.notified_keys [2] = KPD_KEY_2;
614 notified_keys.notified_keys [3] = KPD_KEY_3;
615 notified_keys.notified_keys [4] = KPD_KEY_4;
616 notified_keys.notified_keys [5] = KPD_KEY_5;
617 notified_keys.notified_keys [6] = KPD_KEY_6;
618 notified_keys.notified_keys [7] = KPD_KEY_7;
619 notified_keys.notified_keys [8] = KPD_KEY_8;
620 notified_keys.notified_keys [9] = KPD_KEY_9;
621 notified_keys.notified_keys [10] = KPD_KEY_UP;
622 notified_keys.notified_keys [11] = KPD_KEY_DOWN;
623 notified_keys.notified_keys [12] = KPD_KEY_LEFT;
624 notified_keys.notified_keys [13] = KPD_KEY_RIGHT;
625 notified_keys.notified_keys [14] = KPD_KEY_CONNECT;
626 notified_keys.notified_keys [15] = KPD_KEY_DISCONNECT;
627 notified_keys.notified_keys [16] = KPD_KEY_STAR;
628 notified_keys.notified_keys [17] = KPD_KEY_DIESE;
629
630 if (KPD_NB_PHYSICAL_KEYS > 22)
631 {
632 notified_keys.notified_keys [18] = KPD_KEY_SOFT_LEFT;
633 notified_keys.notified_keys [19] = KPD_KEY_SOFT_RIGHT;
634 notified_keys.notified_keys [20] = KPD_KEY_VOL_UP;
635 notified_keys.notified_keys [21] = KPD_KEY_VOL_DOWN;
636 notified_keys.notified_keys [22] = KPD_KEY_ENTER;
637 //? #define KPD_KEY_RECORD (24)
638 }
639
640 #ifndef _SIMULATION_
641 return_value = kpd_subscribe (&subscriber_p, mode, &notified_keys, return_path);
642 #else
643 return_value = RV_OK; /* do some faking here, to get it compileable */
644 #endif
645
646 if (return_value EQ RV_INTERNAL_ERR ||
647 return_value EQ RV_INVALID_PARAMETER ||
648 return_value EQ RV_MEMORY_ERR)
649 {
650 //failed
651
652 //- RV_INTERNAL_ERR if
653 // - the max of subscriber is reached,
654 // - the software entity is not started, not yet initialized or initialization has
655 // failed
656 //- RV_INVALID_PARAMETER if number of virtual keys is not correct.
657 //- RV_MEMORY_ERR if memory reach its size limit.
658
659 return 1;
660 }
661
662 //Subscribe to key press and key release (at the moment)
663 //subscribe to KPD_LONG_KEY_PRESS_NOTIF once implemented.
664 notif_level = KPD_FIRST_PRESS_NOTIF | KPD_RELEASE_NOTIF;
665
666 #ifndef _SIMULATION_
667 return_value = kpd_define_key_notification( subscriber_p, &notified_keys, notif_level,
668 long_press_time, repeat_time );
669 #else
670 return_value = RV_OK;
671 #endif
672
673 if (return_value EQ RV_INVALID_PARAMETER ||
674 return_value EQ RV_MEMORY_ERR)
675 { //failed
676 return 1;
677 }
678 return 0;
679 }
680 // Commented by Nitin for Neptune Platfrom. 05/04/2005
681 #endif /* NEPTUNE_BOARD*/
682
683
684 /*
685 +--------------------------------------------------------------------+
686 | PROJECT : MMI-Framework (8417) MODULE : ti1_key |
687 | STATE : code ROUTINE : sendKeyInd |
688 +--------------------------------------------------------------------+
689
690 PURPOSE : Sends an MMI_KEYPAD_IND to the protocol stack
691 */
692 void sendKeyInd( T_KPD_VIRTUAL_KEY_ID virtual_key_id,
693 T_KPD_KEY_STATE key_state,
694 T_KPD_PRESS_STATE press_state)
695 {
696 #if defined (NEW_FRAME)
697 EXTERN T_HANDLE hCommACI;
698
699
700
701
702 // ULONG signal_raw; // RAVI
703 #else
704 EXTERN T_VSI_CHANDLE hCommACI;
705 #endif
706
707 PALLOC(key_ind,MMI_KEYPAD_IND);
708
709 key_ind->key_code = (U8)0;
710
711 key_ind->key_stat = 0;
712
713 #if defined (NEW_FRAME)
714 PSENDX(ACI,key_ind);
715 #else
716 #if defined (_TMS470)
717 vsi_c_send("",hCommACI,D2P(key_ind),
718 sizeof(T_PRIM_HEADER)+sizeof(T_MMI_KEYPAD_IND));
719 #else
720 PSEND(ACI,key_ind);
721 #endif
722 #endif
723
724 return;
725
726 }
727
728
729
730
731
732
733