FreeCalypso > hg > tcs211-fcmodem
comparison g23m/condat/com/src/driver/keypad.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-PS | |
4 | Modul : DRV_KBD | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This Module defines the G23 keyboard driver. | |
18 | | |
19 | The driver has two parts: | |
20 | | |
21 | Part 1 is the driver interface (kbd_... ) | |
22 | Part 2 is the simulation for Windows | |
23 +----------------------------------------------------------------------------- | |
24 */ | |
25 | |
26 #ifndef DRV_KBD_C | |
27 #define DRV_KBD_C | |
28 #endif | |
29 /*==== INCLUDES ===================================================*/ | |
30 #if defined (NEW_FRAME) | |
31 #include <string.h> | |
32 #include "typedefs.h" | |
33 #include "gdi.h" | |
34 #include "kbd.h" | |
35 #else | |
36 #include <string.h> | |
37 #include "stddefs.h" | |
38 #include "gdi.h" | |
39 #include "kbd.h" | |
40 #endif | |
41 /*==== EXPORT =====================================================*/ | |
42 #if defined (_TMS470) | |
43 EXTERN void KP_Init (void (*mmi_key_pressed)(UBYTE key), | |
44 void (*mmi_key_relesed)(UBYTE key)); | |
45 #else | |
46 LOCAL void KP_Init (void (*mmi_key_pressed)(UBYTE key), | |
47 void (*mmi_key_relesed)(UBYTE key)); | |
48 #endif | |
49 | |
50 LOCAL void kbd_key_pressed (UBYTE act_key); | |
51 LOCAL void kbd_key_released (UBYTE act_key); | |
52 | |
53 GLOBAL void kbd_test (UBYTE key); | |
54 | |
55 /*==== VARIABLES ==================================================*/ | |
56 drv_SignalCB_Type kbd_signal_callback = NULL; | |
57 UBYTE kbd_act_key; | |
58 | |
59 /* | |
60 * Marcus: Issue 811: 05:09/2002: | |
61 * Moved kbd_map, simkbd_map and config_map from \bmi\Condat\MS\SRC\mfw\ti1_key.c | |
62 */ | |
63 | |
64 const U8 kbd_map [NUM_KPD_KEYS] = /* ti mapping */ | |
65 { /* default keyboard mapping */ | |
66 /* KEY_0 */ 0x01, | |
67 /* KEY_1 */ 0x02, | |
68 /* KEY_2 */ 0x03, | |
69 /* KEY_3 */ 0x04, | |
70 /* KEY_4 */ 0x05, | |
71 /* KEY_5 */ 0x06, | |
72 /* KEY_6 */ 0x07, | |
73 /* KEY_7 */ 0x08, | |
74 /* KEY_8 */ 0x09, | |
75 /* KEY_9 */ 0x0A, | |
76 /* KEY_STAR */ 0x11, | |
77 /* KEY_HASH */ 0x12, | |
78 /* KEY_VOLUP */ 0xFE, | |
79 /* KEY_VOLDOWN */ 0xFE, | |
80 /* KEY_MNUUP */ 0x0B, | |
81 /* KEY_MNUDOWN */0x0C, | |
82 /* KEY_LEFT */ 0x0D, | |
83 /* KEY_RIGHT */ 0x0E, | |
84 /* KEY_CALL */ 0x0F, | |
85 /* KEY_HUP */ 0x10, | |
86 /* KEY_OK */ 0xFE, | |
87 /* KEY_CLEAR */ 0xFE, | |
88 /* KEY_ABC */ 0xFE, | |
89 /* KEY_POWER */ 0x19, | |
90 /* KEY_MNULEFT */ 0x15, | |
91 /* KEY_MNURIGHT */ 0x16, | |
92 /* KEY_MNUSELECT */ 0x17, | |
93 /* KEY_F4 */ 0xFE, | |
94 /* KEY_MAX */ 0xFE, | |
95 /* KEY_AUTO */ 0xFE, | |
96 /* KEY_LONG */ 0xFE, | |
97 /* KEY_MAKE */ 0xFE | |
98 }; | |
99 | |
100 const U8 simkbd_map [NUM_KPD_KEYS] = /* MOB SIM mapping */ | |
101 { /* default keyboard mapping. Same as kbd_map */ | |
102 /* KEY_0 */ 0x01, | |
103 /* KEY_1 */ 0x02, | |
104 /* KEY_2 */ 0x03, | |
105 /* KEY_3 */ 0x04, | |
106 /* KEY_4 */ 0x05, | |
107 /* KEY_5 */ 0x06, | |
108 /* KEY_6 */ 0x07, | |
109 /* KEY_7 */ 0x08, | |
110 /* KEY_8 */ 0x09, | |
111 /* KEY_9 */ 0x0A, | |
112 /* KEY_STAR */ 0x11, | |
113 /* KEY_HASH */ 0x12, | |
114 /* KEY_VOLUP */ 0xFE, | |
115 /* KEY_VOLDOWN */ 0xFE, | |
116 /* KEY_MNUUP */ 0x0B, | |
117 /* KEY_MNUDOWN */0x0C, | |
118 /* KEY_LEFT */ 0x0D, | |
119 /* KEY_RIGHT */ 0x0E, | |
120 /* KEY_CALL */ 0x0F, | |
121 /* KEY_HUP */ 0x10, | |
122 /* KEY_OK */ 0xFE, | |
123 /* KEY_CLEAR */ 0xFE, | |
124 /* KEY_ABC */ 0xFE, | |
125 /* KEY_POWER */ 0x19, | |
126 /* KEY_MNULEFT */ 0x15, | |
127 /* KEY_MNURIGHT */ 0x16, | |
128 /* KEY_MNUSELECT */ 0x17, | |
129 /* KEY_F4 */ 0xFE, | |
130 /* KEY_MAX */ 0xFE, | |
131 /* KEY_AUTO */ 0xFE, | |
132 /* KEY_LONG */ 0xFE, | |
133 /* KEY_MAKE */ 0xFE | |
134 }; | |
135 | |
136 #if 0 | |
137 /* the following codes are at least unuseable for d-sample!!! */ | |
138 const char * const config_map [NUM_KPD_KEYS] = | |
139 { /* CONFIG prim key names */ | |
140 /* KEY_0 */ "0", | |
141 /* KEY_1 */ "1", | |
142 /* KEY_2 */ "2", | |
143 /* KEY_3 */ "3", | |
144 /* KEY_4 */ "4", | |
145 /* KEY_5 */ "5", | |
146 /* KEY_6 */ "6", | |
147 /* KEY_7 */ "7", | |
148 /* KEY_8 */ "8", | |
149 /* KEY_9 */ "9", | |
150 /* KEY_STAR */ "STAR", | |
151 /* KEY_HASH */ "HASH", | |
152 /* KEY_VOLUP */ "VOL_PLUS", | |
153 /* KEY_VOLDOWN */ "VOL_MINUS", | |
154 /* KEY_MNUUP */ "UP", | |
155 /* KEY_MNUDOWN */ "DOWN", | |
156 /* KEY_LEFT */ "LEFT", | |
157 /* KEY_RIGHT */ "RIGHT", | |
158 /* KEY_CALL */ "SEND", | |
159 /* KEY_HUP */ "END", | |
160 /* KEY_OK */ "OK", | |
161 /* KEY_CLEAR */ "CLEAR", | |
162 /* KEY_ABC */ "ABC", | |
163 /* KEY_POWER */ "POWER", | |
164 /* KEY_F1 */ "F1", | |
165 /* KEY_F2 */ "F2", | |
166 /* KEY_F3 */ "F3", | |
167 /* KEY_F4 */ "F4", | |
168 /* KEY_MAX */ "", | |
169 /* KEY_AUTO */ "", | |
170 /* KEY_LONG */ "", | |
171 /* KEY_MAKE */ "" | |
172 }; | |
173 #endif | |
174 | |
175 char * const config_map [NUM_KPD_KEYS] = | |
176 { /* CONFIG prim key names */ | |
177 /* unused */ "X0", /* dummy placeholder */ | |
178 /* KEY_0 */ "0", | |
179 /* KEY_1 */ "1", | |
180 /* KEY_2 */ "2", | |
181 /* KEY_3 */ "3", | |
182 /* KEY_4 */ "4", | |
183 /* KEY_5 */ "5", | |
184 /* KEY_6 */ "6", | |
185 /* KEY_7 */ "7", | |
186 /* KEY_8 */ "8", | |
187 /* KEY_9 */ "9", | |
188 /* KEY_MNUUP */ "UP", | |
189 /* KEY_MNUDOWN */ "DOWN", | |
190 /* KEY_LEFT */ "LSOFT", | |
191 /* KEY_RIGHT */ "RSOFT", | |
192 /* KEY_CALL */ "SEND", | |
193 /* KEY_HUP */ "END", | |
194 /* KEY_STAR */ "*", | |
195 /* KEY_HASH */ "#", | |
196 /* KEY_VOLUP */ "VOL_PLUS", | |
197 /* KEY_VOLDOWN */ "VOL_MINUS", | |
198 /* KEY_MNULEFT */ "LEFT", | |
199 /* KEY_MNURIGHT */ "RIGHT", | |
200 /* KEY_MNUSELECT */ "CENTER", | |
201 /* voice memo ??? */ "EXTRA", | |
202 /* unused */ "X26", /* dummy placeholder */ | |
203 /* unused */ "X27", /* dummy placeholder */ | |
204 /* unused */ "X28", /* dummy placeholder */ | |
205 /* unused */ "X29", /* dummy placeholder */ | |
206 /* unused */ "X30", /* dummy placeholder */ | |
207 /* unused */ "X31", /* dummy placeholder */ | |
208 /* unused */ "X32", /* dummy placeholder */ | |
209 }; | |
210 | |
211 | |
212 | |
213 /*==== FUNCTIONS ==================================================*/ | |
214 | |
215 /*==== CONSTANTS ==================================================*/ | |
216 /******************************************************************* | |
217 * * | |
218 * PART I: Driver Interface * | |
219 * * | |
220 *******************************************************************/ | |
221 /* | |
222 +--------------------------------------------------------------------+ | |
223 | PROJECT : GSM-PS (6103) MODULE : DRV_KBD | | |
224 | STATE : code ROUTINE : kbd_Init | | |
225 +--------------------------------------------------------------------+ | |
226 | |
227 PURPOSE : The function initializes the driverīs internal data. The | |
228 function returns KBD_INITIALIZED if the driver has already | |
229 been initialized and is ready to be used or already in use. | |
230 In case of an initialization failure, which means that the | |
231 driver cannot be used, the function returns KBD_INITFAILURE. | |
232 After initialization, the driver is ready to handle | |
233 keyboard status changes. | |
234 | |
235 */ | |
236 | |
237 GLOBAL UBYTE kbd_Init (drv_SignalCB_Type in_SignalCBPtr) | |
238 { | |
239 kbd_signal_callback = in_SignalCBPtr; /* store call-back function */ | |
240 | |
241 /* | |
242 * Initialise TI driver with internal callback functions | |
243 */ | |
244 KP_Init (kbd_key_pressed, kbd_key_released); | |
245 | |
246 return DRV_OK; | |
247 } | |
248 | |
249 /* | |
250 +--------------------------------------------------------------------+ | |
251 | PROJECT : GSM-PS (6103) MODULE : DRV_KBD | | |
252 | STATE : code ROUTINE : kbd_Exit | | |
253 +--------------------------------------------------------------------+ | |
254 | |
255 PURPOSE : The function is called when the driver functionality is | |
256 not longer needed. The function "de-allocates" all | |
257 allocated resources and finalizes the driver. | |
258 | |
259 */ | |
260 | |
261 GLOBAL void kbd_Exit (void) | |
262 { | |
263 kbd_signal_callback = NULL; | |
264 } | |
265 | |
266 /* | |
267 +--------------------------------------------------------------------+ | |
268 | PROJECT : GSM-PS (6103) MODULE : DRV_KBD | | |
269 | STATE : code ROUTINE : kbd_SetConfig | | |
270 +--------------------------------------------------------------------+ | |
271 | |
272 PURPOSE : This function is used to set the typematic rate settings | |
273 of the keyboard driver. After a successful completion, | |
274 the driver uses the new configuration on following | |
275 keyboard events (e.g. key press). If one of the parameters | |
276 included in the driver control block is invalid, the function | |
277 returns DRV_INVALID_PARAMS. To retrieve the driverīs default | |
278 configuration, call the function kbd_GetConfig(). | |
279 | |
280 */ | |
281 | |
282 GLOBAL UBYTE kbd_SetConfig (kbd_DCB_Type * in_DCB_Ptr) | |
283 { | |
284 return DRV_OK; | |
285 } | |
286 | |
287 /* | |
288 +--------------------------------------------------------------------+ | |
289 | PROJECT : GSM-PS (6103) MODULE : DRV_KBD | | |
290 | STATE : code ROUTINE : kbd_GetConfig | | |
291 +--------------------------------------------------------------------+ | |
292 | |
293 PURPOSE : The function is used to retrieve the typematic rate | |
294 settings of the driver. The configuration is returned | |
295 in the driver control block to which the pointer provided | |
296 out_DCBPtr points. The typematic configuration can be set | |
297 by using the kbd_SetConfig() function. | |
298 If the driver is not configured, the function returns | |
299 KBD_NOTCONFIGURED. | |
300 | |
301 */ | |
302 | |
303 GLOBAL UBYTE kbd_GetConfig (kbd_DCB_Type * out_DCBPtr) | |
304 { | |
305 return DRV_OK; | |
306 } | |
307 | |
308 /* | |
309 +--------------------------------------------------------------------+ | |
310 | PROJECT : GSM-PS (6103) MODULE : DRV_KBD | | |
311 | STATE : code ROUTINE : kbd_SetSignal | | |
312 +--------------------------------------------------------------------+ | |
313 | |
314 PURPOSE : This function is used to define a signal that indicates | |
315 keyboard status changes to a process. A keyboard status | |
316 change is an event identified in the signal information | |
317 data type as SignalType. The only signal that can be set is | |
318 the keyboard status change signal as described in the | |
319 interface documentation. | |
320 | |
321 */ | |
322 | |
323 GLOBAL UBYTE kbd_SetSignal (drv_SignalID_Type * in_SignalIDPtr) | |
324 { | |
325 return DRV_OK; | |
326 } | |
327 | |
328 /* | |
329 +--------------------------------------------------------------------+ | |
330 | PROJECT : GSM-PS (6103) MODULE : DRV_KBD | | |
331 | STATE : code ROUTINE : kbd_ResetSignal | | |
332 +--------------------------------------------------------------------+ | |
333 | |
334 PURPOSE : This function is used to remove a signal that has previously | |
335 set. The signal that is removed is identified by the | |
336 signal information data element called SignalType. | |
337 | |
338 */ | |
339 | |
340 GLOBAL UBYTE kbd_ResetSignal (drv_SignalID_Type * in_SignalIDPtr) | |
341 { | |
342 return DRV_OK; | |
343 } | |
344 | |
345 /* | |
346 +--------------------------------------------------------------------+ | |
347 | PROJECT : GSM-PS (6103) MODULE : DRV_KBD | | |
348 | STATE : code ROUTINE : kbd_GetStatus | | |
349 +--------------------------------------------------------------------+ | |
350 | |
351 PURPOSE : This function is used to retrieve the current (latest) | |
352 status of the keyboard. | |
353 | |
354 */ | |
355 | |
356 GLOBAL ULONG kbd_GetStatus (void) | |
357 { | |
358 return 0L; | |
359 } | |
360 | |
361 | |
362 /* | |
363 +--------------------------------------------------------------------+ | |
364 | PROJECT : GSM-PS (6103) MODULE : TIL_MMI | | |
365 | STATE : code ROUTINE : kbd_key_pressed | | |
366 +--------------------------------------------------------------------+ | |
367 | |
368 PURPOSE : The function is called when a key is pressed. | |
369 | |
370 */ | |
371 | |
372 LOCAL void kbd_key_pressed (UBYTE act_key) | |
373 { | |
374 drv_SignalID_Type signal_params; | |
375 signal_params.SignalType = KBD_SIGTYPE_STATUSCHG; | |
376 | |
377 #if defined (NEW_FRAME) | |
378 /* | |
379 UserData should not be a pointer, NM 12.10.01 | |
380 */ | |
381 signal_params.UserData = (ULONG*)(0x00010000L | (ULONG)act_key); | |
382 #else | |
383 signal_params.SignalValue = 0; | |
384 signal_params.UserData = 0x00010000L + (ULONG)act_key; | |
385 #endif | |
386 | |
387 kbd_act_key = act_key; | |
388 | |
389 if (kbd_signal_callback NEQ NULL) | |
390 (*kbd_signal_callback)(&signal_params); | |
391 } | |
392 | |
393 /* | |
394 +--------------------------------------------------------------------+ | |
395 | PROJECT : GSM-PS (6103) MODULE : TIL_MMI | | |
396 | STATE : code ROUTINE : kbd_key_released | | |
397 +--------------------------------------------------------------------+ | |
398 | |
399 PURPOSE : The function is called when a key is released. | |
400 | |
401 */ | |
402 | |
403 LOCAL void kbd_key_released (UBYTE act_key) | |
404 { | |
405 drv_SignalID_Type signal_params; | |
406 signal_params.SignalType = KBD_SIGTYPE_STATUSCHG; | |
407 | |
408 | |
409 #if defined (NEW_FRAME) | |
410 /* | |
411 UserData should be use as a pointer; | |
412 | |
413 The "act_key" wasnt even used in the old frame. | |
414 "kbd_act_key" keeps the key_code from the "key-press CB function" | |
415 and is used for the key-release CB function as well !! | |
416 It seems to be that the key_code for the key-release from the TI driver | |
417 isnt correct. This way looks like a work around but it works. | |
418 | |
419 //old | |
420 //signal_params.UserData = (ULONG*)(0x00000000L | (ULONG)act_key); | |
421 | |
422 NM 12.10.01 | |
423 */ | |
424 signal_params.UserData = (ULONG*)(0x00000000L | (ULONG)kbd_act_key); | |
425 #else | |
426 signal_params.SignalValue = 0; | |
427 signal_params.UserData = 0x00000000L + (ULONG)kbd_act_key; | |
428 #endif | |
429 | |
430 if (kbd_signal_callback NEQ NULL) | |
431 (*kbd_signal_callback)(&signal_params); | |
432 } | |
433 | |
434 | |
435 /******************************************************************* | |
436 * * | |
437 * PART II: Simulation for Windows * | |
438 * * | |
439 *******************************************************************/ | |
440 | |
441 #if defined (WIN32) | |
442 /* | |
443 * Dummies for driver calls | |
444 */ | |
445 LOCAL void KP_Init (void (*mmi_key_pressed)(UBYTE), | |
446 void (*mmi_key_relesed)(UBYTE)) | |
447 { | |
448 } | |
449 | |
450 /* | |
451 * Stimulation of the keyboard driver | |
452 */ | |
453 GLOBAL void kbd_test (UBYTE key) | |
454 { | |
455 kbd_key_pressed (key); | |
456 kbd_key_released (key); | |
457 } | |
458 | |
459 #endif |