FreeCalypso > hg > fc-magnetite
comparison src/ui3/mfw/mfw_kbd.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:: mfw_kbd.c $| | |
4 | $Author:: Es $ CONDAT GmbH $Revision:: 18 $| | |
5 | CREATED: 21.09.98 $Modtime:: 23.03.00 8:24 $| | |
6 | STATE : code | | |
7 +--------------------------------------------------------------------+ | |
8 | |
9 MODULE : MFW_KBD | |
10 | |
11 PURPOSE : keyboard handling functions | |
12 | |
13 EXPORT : | |
14 | |
15 TO DO : adjust PEI/driver interface | |
16 | |
17 HISTORY : | |
18 | |
19 Sep 14, 2007 REF: OMAPS00145862 Adrian Salido | |
20 Description: FT - MMI: Wrong trace class | |
21 Solution: changed some event traces to function traces because the information content of | |
22 this is low for non-MMI people and against TI coding convention. | |
23 | |
24 Oct 13, 2006 REF: OMAPS00097121 - x0039928 | |
25 Description: Keyboard pressed in a loop. KBP_R after suspend-resume | |
26 Solution : If the Auto press timer expires mmi checks the bsp kpd status and accordingly | |
27 sets auto key in the key map. | |
28 | |
29 Sep 18, 2006 REF: OMAPS00094426 - x0039928 | |
30 Description: Locosto - KPD Release event would NOT be generated if a key is pressed | |
31 several times in a short period of time | |
32 Solution : If the long press timer expires mmi checks the bsp kpd status and accordingly | |
33 sets long press bit in the key map. | |
34 | |
35 xrashmic 22 Aug, 2004 MMI-SPR-32798 | |
36 Adding the support for screen capture using a dynamically assigned key. | |
37 | |
38 Apr 03, 2005 REF: CRR 29988 - xpradipg | |
39 Description: Optimisation 2: Reduce the keyboard buffer and the dtmf buffer | |
40 size | |
41 Solution : The keyboard buffer is reduced to 20 from 50 | |
42 | |
43 */ | |
44 | |
45 #define ENTITY_MFW | |
46 | |
47 #include "typedefs.h" | |
48 #include "vsi.h" | |
49 #include "pei.h" | |
50 #include "custom.h" | |
51 #include "gsm.h" | |
52 | |
53 #include <stdio.h> | |
54 #include <string.h> | |
55 | |
56 #include "mfw_mfw.h" | |
57 #include "mfw_sys.h" | |
58 #include "mfw_tim.h" | |
59 #include "drv_key.h" | |
60 #include "mfw_win.h" | |
61 #include "mfw_kbd.h" | |
62 | |
63 /* BEGIN ADD: Req ID: : Sumit : 14-Mar-05 */ | |
64 #ifndef NEPTUNE_BOARD | |
65 /* END ADD: Req ID: : Sumit : 14-Mar-05 */ | |
66 #include "kpd/kpd_api.h" | |
67 /* BEGIN ADD: Req ID: : Sumit : 14-Mar-05 */ | |
68 #else | |
69 #include "ti1_key.h" | |
70 #endif /* NEPTUNE_BOARD*/ | |
71 /* END ADD: Req ID: : Sumit : 14-Mar-05 */ | |
72 | |
73 #include "mfw_ffs.h" | |
74 #include "mfw_utils.h" | |
75 | |
76 #include "mfw_mme.h" | |
77 | |
78 | |
79 static int kbdCommand (U32 cmd, void *h); | |
80 static int toLong (U32 t, void *h); | |
81 static int toAuto (U32 t, void *h); | |
82 | |
83 static MfwCb doAlways; /* all cases handler */ | |
84 static MfwHdr timLongH; /* the long press timer */ | |
85 static MfwTim timLong; | |
86 static MfwHdr timAutoH; /* the auto repeat timer */ | |
87 static MfwTim timAuto; | |
88 static U32 valAuto; /* auto start intervall */ | |
89 static U32 valRepeat; /* auto repeat intervall */ | |
90 static U32 curMap; /* current key map */ | |
91 static U8 curKey; /* current key code */ | |
92 | |
93 static int still_processing_flag; | |
94 | |
95 // PATCH LE 06.06.00 | |
96 // current MFW element needed for multiple instances | |
97 EXTERN MfwHdr * current_mfw_elem; | |
98 // END PATCH LE 06.06.00 | |
99 | |
100 /* | |
101 ** KeyPress Buffer Macros and Limits | |
102 */ | |
103 // Apr 03, 2005 REF: CRR 29988 - xpradipg | |
104 // Keyboard buffer reduced from 50 to 20 | |
105 #ifdef FF_MMI_REDUCED_KBD_BUFFER | |
106 #define MAX_KPRESS_BFR 20 | |
107 #else | |
108 #define MAX_KPRESS_BFR 50 | |
109 #endif | |
110 typedef struct keyPressDetailsTag { | |
111 char make; | |
112 char key; | |
113 } keyPressDetails; | |
114 | |
115 // Sep 18, 2006 REF: OMAPS00094426 - x0039928 | |
116 #if(BOARD == 71) | |
117 UBYTE kpd_key; | |
118 #endif | |
119 | |
120 static keyPressDetails keyPressBfr[MAX_KPRESS_BFR]; | |
121 static SHORT mfw_kbd_kpress_buf_id; | |
122 | |
123 extern void sendKeyInd( T_KPD_VIRTUAL_KEY_ID virtual_key_id, | |
124 T_KPD_KEY_STATE key_state, | |
125 T_KPD_PRESS_STATE press_state); | |
126 extern char drvGetKeyIndex( char key); | |
127 | |
128 /* | |
129 +--------------------------------------------------------------------+ | |
130 | PROJECT : MMI-Framework (8417) MODULE : MFW_KBD | | |
131 | STATE : code ROUTINE : kbdInit | | |
132 +--------------------------------------------------------------------+ | |
133 | |
134 PURPOSE : initialize keyboard handler | |
135 | |
136 */ | |
137 | |
138 MfwRes kbdInit (void) | |
139 { | |
140 timLong.time = 0; /* setup long press timer */ | |
141 timLong.left = 0; | |
142 timLong.handler = toLong; | |
143 timLong.next = 0; | |
144 timLongH.data = &timLong; | |
145 timLongH.type = MfwTypTim; | |
146 | |
147 timAuto.time = 0; /* setup auto repeat timer */ | |
148 timAuto.left = 0; | |
149 timAuto.handler = toAuto; | |
150 timAuto.next = 0; | |
151 timAutoH.data = &timAuto; | |
152 timAutoH.type = MfwTypTim; | |
153 valAuto = valRepeat = 0; | |
154 | |
155 keyInit(kbdSignal); /* init keyboard driver */ | |
156 | |
157 mfwCommand[MfwTypKbd] = (MfwCb) kbdCommand; | |
158 doAlways = 0; | |
159 | |
160 mfw_kbd_kpress_buf_id = mfw_cbuf_create(MAX_KPRESS_BFR, | |
161 sizeof(keyPressDetails), | |
162 FALSE, | |
163 0xFF, | |
164 TRUE, | |
165 keyPressBfr); | |
166 | |
167 if (mfw_kbd_kpress_buf_id < 0) | |
168 TRACE_EVENT_P1("ERROR : mfw_cbuf_create failed with error value %d", mfw_kbd_kpress_buf_id); | |
169 | |
170 return MfwResOk; | |
171 } | |
172 | |
173 | |
174 /* | |
175 +--------------------------------------------------------------------+ | |
176 | PROJECT : MMI-Framework (8417) MODULE : MFW_KBD | | |
177 | STATE : code ROUTINE : kbdExit | | |
178 +--------------------------------------------------------------------+ | |
179 | |
180 PURPOSE : finalize keyboard handler | |
181 | |
182 */ | |
183 | |
184 MfwRes kbdExit (void) | |
185 { | |
186 mfwCommand[MfwTypKbd] = 0; | |
187 keyExit(); | |
188 | |
189 return MfwResOk; | |
190 } | |
191 | |
192 | |
193 /* | |
194 +--------------------------------------------------------------------+ | |
195 | PROJECT : MMI-Framework (8417) MODULE : MFW_KBD | | |
196 | STATE : code ROUTINE : kbdAlways | | |
197 +--------------------------------------------------------------------+ | |
198 | |
199 PURPOSE : create keyboard control for all events | |
200 | |
201 */ | |
202 | |
203 MfwCb kbdAlways (MfwCb f) | |
204 { | |
205 MfwCb always = doAlways; | |
206 | |
207 doAlways = f; | |
208 if (!f) | |
209 { | |
210 timStop(&timLongH); | |
211 timStop(&timAutoH); | |
212 } | |
213 | |
214 return always; | |
215 } | |
216 | |
217 | |
218 /* | |
219 +--------------------------------------------------------------------+ | |
220 | PROJECT : MMI-Framework (8417) MODULE : MFW_KBD | | |
221 | STATE : code ROUTINE : kbdTime | | |
222 +--------------------------------------------------------------------+ | |
223 | |
224 PURPOSE : define keyboard timeouts | |
225 | |
226 */ | |
227 | |
228 void kbdTime (long tLong, long tAuto, long tRepeat) | |
229 { | |
230 timLong.time = tLong; /* setup long press timer */ | |
231 timAuto.time = tAuto; /* setup auto repeat timer */ | |
232 valAuto = tAuto; /* save auto start timeout */ | |
233 valRepeat = tRepeat; /* save repeat intervall */ | |
234 } | |
235 | |
236 | |
237 /* | |
238 +--------------------------------------------------------------------+ | |
239 | PROJECT : MMI-Framework (8417) MODULE : MFW_KBD | | |
240 | STATE : code ROUTINE : kbdCreate | | |
241 +--------------------------------------------------------------------+ | |
242 | |
243 PURPOSE : create keyboard control | |
244 | |
245 */ | |
246 | |
247 MfwHnd kbdCreate (MfwHnd w, MfwEvt e, MfwCb f) | |
248 { | |
249 MfwHdr *hdr = (MfwHdr *) mfwAlloc(sizeof(MfwHdr)); | |
250 MfwKbd *kbd = (MfwKbd *) mfwAlloc(sizeof(MfwKbd)); | |
251 MfwHdr *insert_status =0; | |
252 | |
253 if (!hdr || !kbd) | |
254 { | |
255 TRACE_ERROR("ERROR: kbdCreate() Mem Alloc Failed."); | |
256 | |
257 if(hdr) | |
258 mfwFree((U8*)hdr,sizeof(MfwHdr)); | |
259 if(kbd) | |
260 mfwFree((U8*)kbd,sizeof(MfwKbd)); | |
261 return 0; | |
262 } | |
263 | |
264 kbd->map = e; | |
265 kbd->key = 0; | |
266 kbd->handler = f; | |
267 | |
268 hdr->data = kbd; | |
269 hdr->type = MfwTypKbd; | |
270 | |
271 insert_status = mfwInsert(w,hdr); | |
272 | |
273 if(!insert_status) | |
274 { | |
275 TRACE_ERROR("ERROR: kbdCreate() Failed to Install Handler. "); | |
276 mfwFree((U8*)hdr,sizeof(MfwHdr)); | |
277 mfwFree((U8*)kbd ,sizeof(MfwKbd)); | |
278 return 0; | |
279 } | |
280 return insert_status; | |
281 } | |
282 | |
283 | |
284 /* | |
285 +--------------------------------------------------------------------+ | |
286 | PROJECT : MMI-Framework (8417) MODULE : MFW_KBD | | |
287 | STATE : code ROUTINE : kbdDelete | | |
288 +--------------------------------------------------------------------+ | |
289 | |
290 PURPOSE : delete keyboard control | |
291 | |
292 */ | |
293 | |
294 MfwRes kbdDelete (MfwHnd h) | |
295 { | |
296 MfwRes res; | |
297 | |
298 if (!h) | |
299 return MfwResIllHnd; | |
300 | |
301 res = (mfwRemove(h)) ? MfwResOk : MfwResIllHnd; | |
302 | |
303 mfwFree(((MfwHdr *) h)->data,sizeof(MfwKbd)); | |
304 mfwFree(h,sizeof(MfwHdr)); | |
305 | |
306 return res; | |
307 } | |
308 | |
309 | |
310 /* | |
311 +--------------------------------------------------------------------+ | |
312 | PROJECT : MMI-Framework (8417) MODULE : MFW_KBD | | |
313 | STATE : code ROUTINE : sigExec | | |
314 +--------------------------------------------------------------------+ | |
315 | |
316 PURPOSE : execute keyboard signal | |
317 if the registered set of keys match the currently | |
318 pressed key, the event handler is called, if the | |
319 registered flags match the current flags according | |
320 to the following table: | |
321 M: Make/Break (key release events wanted) | |
322 L: Long press event (timeout set via kbdTime()) | |
323 A: Auto repeat event (timing defined via kbdTime()) | |
324 | |
325 M 0 0 0 0 1 1 1 1 | |
326 current event flags --------- L 0 0 0 0 0 0 1 1 | |
327 A 0 0 0 0 0 1 0 1 | |
328 M L A ................. | |
329 0 0 0 . 0 0 0 0 1 0 0 0 | |
330 0 0 1 . 0 0 0 0 1 1 0 1 | |
331 registered 0 1 0 . 0 0 0 0 0 0 1 1 | |
332 event ----------- 0 1 1 . 0 0 0 0 0 1 1 1 | |
333 flags 1 0 0 . 1 1 1 1 1 0 0 0 | |
334 1 0 1 . 1 1 1 1 1 1 0 1 | |
335 1 1 0 . 1 1 1 1 0 0 1 1 | |
336 1 1 1 . 1 1 1 1 0 1 1 1 | |
337 | |
338 */ | |
339 | |
340 static int sigExec (MfwHdr *curElem, U32 map, U8 key) | |
341 { | |
342 MfwKbd *kc; | |
343 | |
344 while (curElem) | |
345 { | |
346 if (curElem->type == MfwTypKbd) | |
347 { | |
348 kc = curElem->data; | |
349 if (kc->map & map & ~KEY_FLAGS) | |
350 { /* keys match */ | |
351 kc->code = key; /* set current key code */ | |
352 if (map & KEY_MAKE) | |
353 { | |
354 kc->key |= map; /* set key in control block */ | |
355 } | |
356 else | |
357 { | |
358 kc->key &= ~map; /* del key in control block */ | |
359 kc->key &= ~KEY_MAKE; /* del make/break flag */ | |
360 } | |
361 if ((KEY_MAKE & ~map & kc->map) || | |
362 (KEY_MAKE & map && | |
363 ((KEY_LONG & map & kc->map) || | |
364 (!(KEY_LONG & kc->map) | |
365 && (KEY_AUTO & kc->map & map)) || | |
366 (!(KEY_LONG & map) | |
367 && !(KEY_AUTO & map) | |
368 && !(KEY_LONG & kc->map)) || | |
369 (!(KEY_LONG & map) | |
370 && (KEY_AUTO & map) | |
371 && (KEY_AUTO & kc->map))))) | |
372 { | |
373 if (kc->handler) /* handler valid */ | |
374 { | |
375 // PATCH LE 06.06.00 | |
376 // store current mfw elem | |
377 current_mfw_elem = curElem; | |
378 // END PATCH LE 06.06.00 | |
379 if ((*(kc->handler))(map,kc)) | |
380 return 1; /* event consumed */ | |
381 } | |
382 } | |
383 } | |
384 } | |
385 curElem = curElem->next; | |
386 } | |
387 | |
388 return 0; | |
389 } | |
390 | |
391 | |
392 /* | |
393 +--------------------------------------------------------------------+ | |
394 | PROJECT : MMI-Framework (8417) MODULE : MFW_KBD | | |
395 | STATE : code ROUTINE : sigDistribute | | |
396 +--------------------------------------------------------------------+ | |
397 | |
398 PURPOSE : distribute keyboard event | |
399 | |
400 */ | |
401 | |
402 static void sigDistribute (U32 map, U8 key) | |
403 { | |
404 int res = 0; | |
405 | |
406 TRACE_EVENT("sigDistribute"); | |
407 | |
408 if (doAlways) | |
409 if (doAlways(map,(void*) -1)) | |
410 return; /* event consumed */ | |
411 | |
412 if (mfwSignallingMethod == 0) | |
413 { | |
414 if (mfwFocus) | |
415 res = sigExec(mfwFocus,map,key); | |
416 if (!res && mfwRoot) | |
417 res = sigExec(mfwRoot,map,key); | |
418 } | |
419 else | |
420 { | |
421 MfwHdr *h = mfwFocus; | |
422 if (!h) | |
423 h = mfwRoot; | |
424 while (h) | |
425 { | |
426 res = sigExec(h,map,key); /* Warning correction - x0020906 - 14-08-2006*/ | |
427 if (res) | |
428 break; | |
429 if (h == mfwRoot) | |
430 break; | |
431 h = mfwParent(mfwParent(h)); | |
432 if (h) | |
433 h = ((MfwWin *)(h->data))->elems; | |
434 } | |
435 if (!res && mfwRoot && h != mfwRoot) | |
436 res = sigExec(mfwRoot,map,key); | |
437 } | |
438 | |
439 if (doAlways) | |
440 (void)(doAlways(map,(void*) res));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/ | |
441 | |
442 return; | |
443 } | |
444 | |
445 | |
446 /* | |
447 +--------------------------------------------------------------------+ | |
448 | PROJECT : MMI-Framework (8417) MODULE : MFW_KBD | | |
449 | STATE : code ROUTINE : kbdSignal | | |
450 +--------------------------------------------------------------------+ | |
451 | |
452 PURPOSE : keyboard event (called by driver/PEI) | |
453 | |
454 */ | |
455 | |
456 #define MAX_CONSEC_KEYS 6 // Maximum number of keys which can be processed before | |
457 // allowing the protocol stack processing time | |
458 //xrashmic 22 Aug, 2004 MMI-SPR-32798 | |
459 #ifdef MMI_EM_ENABLED | |
460 #ifndef NEPTUNE_BOARD | |
461 /* This is not valid for Neptune Engineering Mode, hence*/ | |
462 extern U8 screenCaptureKey; | |
463 void screen_capture(void); | |
464 #endif /* ifndef NEPTUNE_BOARD */ | |
465 #endif | |
466 | |
467 void kbdSignal (char make, char key) | |
468 { | |
469 U32 map; | |
470 UBYTE temp=0 ; | |
471 USHORT numElem; | |
472 | |
473 int loopNo; | |
474 int keyNo; | |
475 | |
476 | |
477 if ((kbd_processKeyInput()== QUEUE_EVERY_KEY) || | |
478 (kbd_processKeyInput()== QUEUE_N_KEYS)) | |
479 temp = dspl_Enable(0); | |
480 | |
481 mme_backlightEvent(BL_KEY_PRESS); | |
482 | |
483 loopNo = 0; | |
484 keyNo = 0; | |
485 | |
486 while (kbd_getMakeAndKey(&make,&key) != -1) | |
487 { | |
488 #ifdef MMI_EM_ENABLED | |
489 #ifndef NEPTUNE_BOARD | |
490 /* This is not valid for Neptune Engineering Mode, hence*/ | |
491 | |
492 //xrashmic 22 Aug, 2004 MMI-SPR-32798 | |
493 //If screen capture is enabled the key pressed is the screen capture key, | |
494 //we write the LCD buffer into the FFS and and consume the key | |
495 //event here itself without sending it to BMI | |
496 // Also the screen capture key will be disabled here | |
497 if(key== screenCaptureKey && make==1) | |
498 { | |
499 TRACE_EVENT("*****Capturing the screen"); | |
500 screenCaptureKey=KCD_NONE; | |
501 screen_capture(); | |
502 dspl_Enable(temp); | |
503 return; | |
504 } | |
505 #endif /* ifndef NEPTUNE_BOARD*/ | |
506 #endif | |
507 | |
508 still_processing_flag = 1; | |
509 TRACE_EVENT_P2("NDH : KbdSignal - key %d, state %02x", key, make); | |
510 | |
511 if (key <= KCD_MAX) /*a0393213 compiler warnings removal - comparison of key with 0 removed*/ | |
512 { | |
513 loopNo++; | |
514 keyNo++; | |
515 | |
516 map = 1L << key; | |
517 | |
518 if (make) | |
519 { | |
520 map |= KEY_MAKE; | |
521 curMap = map; | |
522 curKey = key; | |
523 timStart(&timLongH); | |
524 timAuto.time = valAuto; | |
525 | |
526 /*NM, p007a*/ | |
527 if (valAuto) | |
528 timStart(&timAutoH); | |
529 /*NM, p007a end*/ | |
530 | |
531 } | |
532 else | |
533 { | |
534 map &= ~KEY_MAKE; | |
535 curMap = map; //ES!! | |
536 curKey = key; //ES!! | |
537 timStop(&timLongH); | |
538 | |
539 if (valAuto) | |
540 timStop(&timAutoH); | |
541 } | |
542 | |
543 //Select when we update the display | |
544 switch (kbd_processKeyInput()) | |
545 { | |
546 case QUEUE_EVERY_KEY: | |
547 sigDistribute(map,key); | |
548 break; | |
549 | |
550 case PROCESS_EVERY_KEY: | |
551 temp = dspl_Enable(0); | |
552 sigDistribute(map,key); | |
553 dspl_Enable(temp); | |
554 break; | |
555 | |
556 case QUEUE_N_KEYS: | |
557 if ((loopNo %(NUM_QUEUE_KEYS*2))==0) | |
558 { | |
559 kbd_setDisplayUpdateNeeded(1); | |
560 sigDistribute(map,key); | |
561 dspl_Enable(temp); | |
562 temp = dspl_Enable(0); | |
563 kbd_setDisplayUpdateNeeded(0); | |
564 } | |
565 else | |
566 sigDistribute(map,key); | |
567 break; | |
568 } | |
569 } | |
570 | |
571 if (keyNo == MAX_CONSEC_KEYS) | |
572 { | |
573 still_processing_flag = FALSE; | |
574 break; | |
575 } | |
576 | |
577 still_processing_flag = FALSE; | |
578 } | |
579 | |
580 numElem = mfw_cbuf_num_elements(mfw_kbd_kpress_buf_id); | |
581 | |
582 /* x0083025 on Sep 14, 2007 for OMAPS00145862 (adrian) */ | |
583 MMI_TRACE_EVENT_P2("NDH >>> Kbd :- There are %d elements in the buffer (id : %d)" , | |
584 numElem, mfw_kbd_kpress_buf_id); | |
585 | |
586 if ((keyNo == MAX_CONSEC_KEYS) && (numElem > 0)) | |
587 { | |
588 sendKeyInd(0, 0, 0); // dummy values to trigger another keypress_ind | |
589 /* | |
590 ** This delay is required to slow down the BMI when no trace is being output in order | |
591 ** to permit the Protocol Stack & other tasks to function correctly | |
592 */ | |
593 vsi_t_sleep (VSI_CALLER 30); | |
594 } | |
595 | |
596 if ((kbd_processKeyInput()== QUEUE_EVERY_KEY) || | |
597 (kbd_processKeyInput()== QUEUE_N_KEYS)) | |
598 dspl_Enable(temp); | |
599 | |
600 return; | |
601 } | |
602 | |
603 | |
604 /* | |
605 +--------------------------------------------------------------------+ | |
606 | PROJECT : MMI-Framework (8417) MODULE : MFW_KBD | | |
607 | STATE : code ROUTINE : toLong | | |
608 +--------------------------------------------------------------------+ | |
609 | |
610 PURPOSE : long press timeout handler | |
611 | |
612 */ | |
613 static int toLong (U32 t, void *h) | |
614 { | |
615 // Sep 18, 2006 REF: OMAPS00094426 - x0039928 | |
616 // Fix: On long key press timer expiry bsp kpd status is checked to see if the state is | |
617 // in in Kpd pressed state and sets the long key bit. | |
618 #if(BOARD == 71) | |
619 UBYTE state; | |
620 kpd_retrieve_key_status(kpd_key, KPD_DEFAULT_MODE, &state); | |
621 if(!state) | |
622 #endif | |
623 curMap |= KEY_LONG; | |
624 sigDistribute(curMap,curKey); | |
625 | |
626 return 0; | |
627 } | |
628 | |
629 | |
630 /* | |
631 +--------------------------------------------------------------------+ | |
632 | PROJECT : MMI-Framework (8417) MODULE : MFW_KBD | | |
633 | STATE : code ROUTINE : toAuto | | |
634 +--------------------------------------------------------------------+ | |
635 | |
636 PURPOSE : auto repeat timeout handler | |
637 | |
638 */ | |
639 | |
640 static int toAuto (U32 t, void *h) | |
641 { | |
642 #if(BOARD == 71) | |
643 UBYTE state; | |
644 kpd_retrieve_key_status(kpd_key, KPD_DEFAULT_MODE, &state); | |
645 if(!state) | |
646 { | |
647 #endif | |
648 curMap |= KEY_AUTO; | |
649 sigDistribute(curMap,curKey); | |
650 | |
651 timAuto.time = valRepeat; | |
652 /* NM p007c*/ | |
653 if (valRepeat) | |
654 timStart(&timAutoH); | |
655 /* NM p007c end*/ | |
656 #if(BOARD == 71) | |
657 } | |
658 #endif | |
659 return 0; | |
660 } | |
661 | |
662 | |
663 /* | |
664 +--------------------------------------------------------------------+ | |
665 | PROJECT : MMI-Framework (8417) MODULE : MFW_KBD | | |
666 | STATE : code ROUTINE : kbdCommand | | |
667 +--------------------------------------------------------------------+ | |
668 | |
669 PURPOSE : handle mfw windows command | |
670 | |
671 */ | |
672 | |
673 static int kbdCommand (U32 cmd, void *h) | |
674 { | |
675 switch (cmd) | |
676 { | |
677 case MfwCmdDelete: /* delete me */ | |
678 if (!h) | |
679 return 0; | |
680 kbdDelete(h); | |
681 return 1; | |
682 default: | |
683 break; | |
684 } | |
685 | |
686 return 0; | |
687 } | |
688 | |
689 | |
690 /* | |
691 +--------------------------------------------------------------------+ | |
692 | PROJECT : MMI-Framework (8417) MODULE : MFW_KBD | | |
693 | STATE : code ROUTINE : kbd_putMakeAndKey | | |
694 +--------------------------------------------------------------------+ | |
695 | |
696 PURPOSE : places 'make' (key up/down) and key index into a queue | |
697 | |
698 */ | |
699 | |
700 int kbd_putMakeAndKey( char make, char key) | |
701 { | |
702 keyPressDetails localKP; | |
703 SHORT retVal; | |
704 | |
705 localKP.make = make; | |
706 localKP.key = key; | |
707 | |
708 retVal = mfw_cbuf_put(mfw_kbd_kpress_buf_id, &localKP); | |
709 | |
710 if (retVal < 0) | |
711 TRACE_EVENT_P1("ERROR : mfw_cbuf_put failed with error value %d", retVal); | |
712 | |
713 return (retVal); | |
714 } | |
715 | |
716 /* | |
717 +--------------------------------------------------------------------+ | |
718 | PROJECT : MMI-Framework (8417) MODULE : MFW_KBD | | |
719 | STATE : code ROUTINE : kbd_getMakeAndKey | | |
720 +--------------------------------------------------------------------+ | |
721 | |
722 PURPOSE : reads 'make' (key up/down) and key index into a queue | |
723 Return +ve number - keys left in buffer | |
724 0 - no keys left - last key press returned | |
725 -1 - no keys and none in buffer | |
726 */ | |
727 | |
728 int kbd_getMakeAndKey( char* make, char* key) | |
729 { | |
730 keyPressDetails localKP; | |
731 SHORT retVal; | |
732 | |
733 retVal = mfw_cbuf_get(mfw_kbd_kpress_buf_id, &localKP); | |
734 | |
735 if (retVal < 0) | |
736 { | |
737 *key = 0x7F; | |
738 *make = 0; | |
739 return (-1); | |
740 } | |
741 | |
742 *make = !(localKP.make); | |
743 *key = drvGetKeyIndex(localKP.key); | |
744 return (mfw_cbuf_num_elements(mfw_kbd_kpress_buf_id)); | |
745 } | |
746 | |
747 /* | |
748 +--------------------------------------------------------------------+ | |
749 | PROJECT : MMI-Framework (8417) MODULE : MFW_KBD | | |
750 | STATE : code ROUTINE : kbd_getNumElements | | |
751 +--------------------------------------------------------------------+ | |
752 | |
753 PURPOSE : returns number of elements in queue | |
754 | |
755 */ | |
756 int kbd_getNumElements(void) | |
757 { | |
758 return ((int)mfw_cbuf_num_elements(mfw_kbd_kpress_buf_id)); | |
759 } | |
760 | |
761 int kbd_stillProcessingKeys(void) | |
762 { | |
763 return (still_processing_flag); | |
764 } | |
765 | |
766 int mfwKey_skipDisplay( void ) | |
767 { | |
768 if ((mfw_cbuf_num_elements(mfw_kbd_kpress_buf_id) > 2) && (still_processing_flag == 1)) | |
769 return (TRUE); | |
770 else | |
771 return (FALSE); | |
772 } | |
773 | |
774 /* | |
775 +--------------------------------------------------------------------+ | |
776 | PROJECT : MMI-Framework (8417) MODULE : MFW_KBD | | |
777 | STATE : code ROUTINE : kbd_displayUpdateNeeded | | |
778 +--------------------------------------------------------------------+ | |
779 | |
780 PURPOSE : returns TRUE if we need to update the display | |
781 | |
782 */ | |
783 int displayUpdateNeeded; //used for output every 'n' key presses | |
784 int kbd_displayUpdateNeeded(void) | |
785 { | |
786 if (kbd_processKeyInput()==PROCESS_EVERY_KEY) | |
787 return (TRUE);//Processing each key press - always update screen | |
788 else if (displayUpdateNeeded==0) | |
789 return (TRUE);//need to update the display (1 in 6 output) | |
790 else if (mfw_cbuf_num_elements(mfw_kbd_kpress_buf_id) > 1) | |
791 return (FALSE);//keys in queue - do not update | |
792 else | |
793 return (TRUE);//only 1 key up/down in queue - update display | |
794 } | |
795 /* | |
796 +--------------------------------------------------------------------+ | |
797 | PROJECT : MMI-Framework (8417) MODULE : MFW_KBD | | |
798 | STATE : code ROUTINE : kbd_setDisplayUpdateNeeded | | |
799 +--------------------------------------------------------------------+ | |
800 | |
801 PURPOSE : sets/clears the flag indicating we need to update the display | |
802 | |
803 */ | |
804 void kbd_setDisplayUpdateNeeded(int set) | |
805 { | |
806 displayUpdateNeeded = set; | |
807 } | |
808 | |
809 /* | |
810 +--------------------------------------------------------------------+ | |
811 | PROJECT : MMI-Framework (8417) MODULE : MFW_KBD | | |
812 | STATE : code ROUTINE : kbd_processEveryKeyInput | | |
813 +--------------------------------------------------------------------+ | |
814 | |
815 PURPOSE : indicates if the software should process each keypad input individually | |
816 (TRUE) or if it should process keypad inputs one at a time (FALSE) | |
817 | |
818 */ | |
819 int kbd_processKeyInput(void) | |
820 { | |
821 return (QUEUE_EVERY_KEY);//We buffer multiple key inputs | |
822 | |
823 } | |
824 | |
825 | |
826 | |
827 | |
828 | |
829 | |
830 |