comparison g23m/condat/ms/src/mfw/win_key.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: MMI-Framework (8417) $Workfile:: win_key.c $|
4 | $Author:: Kk $ CONDAT GmbH $Revision:: 1 $|
5 | CREATED: 28.01.99 $Modtime:: 3.01.00 19:35 $|
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:: win_key.c $
18 *
19 * ***************** Version 1 *****************
20 * User: Kk Date: 6.01.00 Time: 12:22
21 * Created in $/GSM/Condat/MS/SRC/MFW
22 *
23 * ***************** Version 11 *****************
24 * User: Es Date: 9.07.99 Time: 21:29
25 * Updated in $/GSM/DEV/MS/SRC/MFW
26 *
27 * ***************** Version 10 *****************
28 * User: Es Date: 6.07.99 Time: 18:37
29 * Updated in $/GSM/DEV/MS/SRC/MFW
30 *
31 * ***************** Version 9 *****************
32 * User: Es Date: 6.07.99 Time: 12:41
33 * Updated in $/GSM/DEV/MS/SRC/MFW
34 *
35 * ***************** Version 8 *****************
36 * User: Es Date: 14.04.99 Time: 17:34
37 * Updated in $/GSM/DEV/MS/SRC/MFW
38 * moved to CST
39 *
40 * ***************** Version 7 *****************
41 * User: Es Date: 1.04.99 Time: 17:07
42 * Updated in $/GSM/DEV/MS/SRC/MFW
43 * removed lots of traces
44 *
45 * ***************** Version 6 *****************
46 * User: Es Date: 20.02.99 Time: 19:24
47 * Updated in $/GSM/DEV/MS/SRC/MFW
48 *
49 * ***************** Version 5 *****************
50 * User: Es Date: 20.02.99 Time: 18:22
51 * Updated in $/GSM/DEV/MS/SRC/MFW
52 *
53 * ***************** Version 4 *****************
54 * User: Es Date: 20.02.99 Time: 14:43
55 * Updated in $/GSM/DEV/MS/SRC/MFW
56 *
57 * ***************** Version 3 *****************
58 * User: Es Date: 17.02.99 Time: 20:00
59 * Updated in $/GSM/DEV/MS/SRC/MFW
60 *
61 * ***************** Version 2 *****************
62 * User: Es Date: 10.02.99 Time: 19:51
63 * Updated in $/GSM/DEV/MS/SRC/MFW
64 *
65 * ***************** Version 1 *****************
66 * User: Es Date: 9.02.99 Time: 14:53
67 * Created in $/GSM/DEV/MS/SRC/MFW
68 * TI display & keyboard interface for MFW
69 */
70
71 #include <string.h>
72 #include "STDDEFS.H"
73 #include "mfw_mfw.h"
74 #include "mfw_sys.h"
75 #include "gdi.h"
76 #include "kbd.h"
77
78 #include "drv_key.h"
79 #include "win_key.h"
80
81
82 static const U8 kbd_map [32] = /* ti mapping */
83 { /* default keyboard mapping */
84 /* KEY_0 */ 0x30,
85 /* KEY_1 */ 0x31,
86 /* KEY_2 */ 0x32,
87 /* KEY_3 */ 0x33,
88 /* KEY_4 */ 0x34,
89 /* KEY_5 */ 0x35,
90 /* KEY_6 */ 0x36,
91 /* KEY_7 */ 0x37,
92 /* KEY_8 */ 0x38,
93 /* KEY_9 */ 0x39,
94 /* KEY_STAR */ 0x2a,
95 /* KEY_HASH */ 0x23,
96 /* KEY_VOLUP */ 0xFE,
97 /* KEY_VOLDOWN */ 0xFE,
98 /* KEY_MNUUP */ 0x2d,
99 /* KEY_MNUDOWN */ 0x62,
100 /* KEY_LEFT */ 0x43,
101 /* KEY_RIGHT */ 0x5e,
102 /* KEY_CALL */ 0x61,
103 /* KEY_HUP */ 0x56,
104 /* KEY_OK */ 0xFE/*'f'*/,
105 /* KEY_CLEAR */ 0xFE,
106 /* KEY_ABC */ 0xFE,
107 /* KEY_POWER */ 0x45,
108 /* KEY_F1 */ 0xFE,
109 /* KEY_F2 */ 0xFE,
110 /* KEY_F3 */ 0xFE,
111 /* KEY_F4 */ 0xFE,
112 /* KEY_MAX */ 0xFE,
113 /* KEY_UNDEFINED */ 0xFE,
114 /* KEY_UNDEFINED */ 0xFE,
115 /* KEY_UNDEFINED */ 0xFE
116 };
117
118 static const U8 simkbd_map [32] = /* MOB SIM mapping */
119 { /* default keyboard mapping */
120 /* KEY_0 0 */ 0,
121 /* KEY_1 1 */ 1,
122 /* KEY_2 2 */ 2,
123 /* KEY_3 3 */ 3,
124 /* KEY_4 4 */ 4,
125 /* KEY_5 5 */ 5,
126 /* KEY_6 6 */ 6,
127 /* KEY_7 7 */ 7,
128 /* KEY_8 8 */ 8,
129 /* KEY_9 9 */ 9,
130 /* KEY_STAR 10 */ 10,
131 /* KEY_HASH 11 */ 11,
132 /* KEY_VOLUP 12 */ 12,
133 /* KEY_VOLDOWN 13 */ 13,
134 /* KEY_MNUUP 14 */ 14,
135 /* KEY_MNUDOWN 15 */ 15,
136 /* KEY_LEFT 16 */ 16,
137 /* KEY_RIGHT 17 */ 17,
138 /* KEY_CALL 18 */ 18,
139 /* KEY_HUP 19 */ 19,
140 /* KEY_OK 20 */ 20,
141 /* KEY_CLEAR 21 */ 21,
142 /* KEY_ABC 22 */ 22,
143 /* KEY_POWER 23 */ 23,
144 /* KEY_F1 24 */ 24,
145 /* KEY_F2 25 */ 25,
146 /* KEY_F3 26 */ 26,
147 /* KEY_F4 27 */ 27,
148 /* KEY_MAX 28 */ 28,
149 /* KEY_AUTO 29 */ 29,
150 /* KEY_LONG 30 */ 30,
151 /* KEY_MAKE 31 */ 31
152 };
153
154 static const char * config_map [32] =
155 { /* CONFIG prim key names */
156 /* KEY_0 */ "0",
157 /* KEY_1 */ "1",
158 /* KEY_2 */ "2",
159 /* KEY_3 */ "3",
160 /* KEY_4 */ "4",
161 /* KEY_5 */ "5",
162 /* KEY_6 */ "6",
163 /* KEY_7 */ "7",
164 /* KEY_8 */ "8",
165 /* KEY_9 */ "9",
166 /* KEY_STAR */ "STAR",
167 /* KEY_HASH */ "HASH",
168 /* KEY_VOLUP */ "VOL_PLUS",
169 /* KEY_VOLDOWN */ "VOL_MINUS",
170 /* KEY_MNUUP */ "UP",
171 /* KEY_MNUDOWN */ "DOWN",
172 /* KEY_LEFT */ "LEFT",
173 /* KEY_RIGHT */ "RIGHT",
174 /* KEY_CALL */ "SEND",
175 /* KEY_HUP */ "END",
176 /* KEY_OK */ "OK",
177 /* KEY_CLEAR */ "CLEAR",
178 /* KEY_ABC */ "ABC",
179 /* KEY_POWER */ "POWER",
180 /* KEY_F1 */ "F1",
181 /* KEY_F2 */ "F2",
182 /* KEY_F3 */ "F3",
183 /* KEY_F4 */ "F4",
184 /* KEY_MAX */ "",
185 /* KEY_UNDEFINED */ "",
186 /* KEY_UNDEFINED */ "",
187 /* KEY_UNDEFINED */ ""
188 };
189
190 /* driver callback */
191 static void kbdCb (drv_SignalID_Type *signal_params);
192
193 static void (*sig) (char,char) = 0; /* kbd signaling function */
194 static char *keyMap = (char *) kbd_map; /* current keyboard mapping */
195
196
197 /*
198 +--------------------------------------------------------------------+
199 | PROJECT : MMI-Framework (8417) MODULE : ti1_key |
200 | STATE : code ROUTINE : keyInit |
201 +--------------------------------------------------------------------+
202
203 PURPOSE : initialize keyboard driver
204
205 */
206
207 void keyInit (void (*s)(char,char))
208 {
209 sig = s;
210 /*
211 * read keyboard mapping from EEPROM.
212 * if this fails set keyboard mapping with default values.
213 *
214 * EEPROM reading not now !!!
215 */
216 keyMap = (char *) kbd_map;
217 kbd_Init(kbdCb);
218 }
219
220
221 /*
222 +--------------------------------------------------------------------+
223 | PROJECT : MMI-Framework (8417) MODULE : ti1_key |
224 | STATE : code ROUTINE : keyExit |
225 +--------------------------------------------------------------------+
226
227 PURPOSE : finalize keyboard driver
228
229 */
230
231 void keyExit (void)
232 {
233 sig = 0;
234 }
235
236
237 /*
238 +--------------------------------------------------------------------+
239 | PROJECT : MMI-Framework (8417) MODULE : ti1_key |
240 | STATE : code ROUTINE : drvKeyUpDown |
241 +--------------------------------------------------------------------+
242
243 PURPOSE : handle key event (called from keyboard)
244
245 */
246
247 void drvKeyUpDown (char upDown, char key)
248 {
249 char i;
250
251 if (!sig) return; /* no event handler */
252 //kk test if (!key) return; /* no valid key */
253
254 for (i = 0; i < 32; i++)
255 {
256 if (keyMap[i] == key)
257 {
258 sig(!upDown,i);
259 return;
260 }
261 }
262 /* TEST only ES!! */
263 for (i = 0; i < 32; i++)
264 {
265 if (simkbd_map[i] == key)
266 {
267 sig(!upDown,i);
268 return;
269 }
270 }
271 }
272
273
274 /*
275 +--------------------------------------------------------------------+
276 | PROJECT : MMI-Framework (8417) MODULE : ti1_key |
277 | STATE : code ROUTINE : mfw_keystroke |
278 +--------------------------------------------------------------------+
279
280 PURPOSE : handle keystroke primitive (called from aci-pei)
281 keystroke sent via 'PEI-CONFIG'-primitive
282 used in Test cases and by RT;
283
284 */
285
286 void mfw_keystroke (char * key)
287 {
288 char i, number;
289
290 if (!sig) return; /* no event handler */
291 if (!key) return; /* no valid key */
292
293 number = 0;
294 while (strlen(key))
295 {
296 if (!strcmp(key,"#*43*1#"))
297 {
298 sig(1,19); /* simulate HUP */
299 sig(0,19);
300 key += 7;
301 continue;
302 }
303 if (!strcmp(key,"#*43*0#"))
304 {
305 sig(1,18); /* simulate CALL */
306 sig(0,18);
307 key += 7;
308 continue;
309 }
310 for (i = 0; i < 32; i++)
311 {
312 if (!strcmp(key,config_map[i]))
313 {
314 sig(1,i); /* assume key down event */
315 sig(0,i); /* add key down event */
316 key += strlen(config_map[i]);
317 break;
318 }
319 }
320 if (i < 32)
321 continue; /* found config code */
322
323 if (*key >= '0' && *key <= '9')
324 {
325 number = 1;
326 sig(1,(char) (*key-'0')); /* assume a dial number */
327 sig(0,(char) (*key-'0'));
328 }
329 key++;
330 }
331 if (number)
332 {
333 sig(1,18); /* simulate CALL */
334 sig(0,18);
335 }
336 }
337
338
339 /*
340 +--------------------------------------------------------------------+
341 | PROJECT : MMI-Framework (8417) MODULE : ti1_key |
342 | STATE : code ROUTINE : kbd_callback |
343 +--------------------------------------------------------------------+
344
345 PURPOSE : Called by keyboard driver
346
347 */
348
349 #include "prim.h"
350 #define hCommACI _ENTITY_PREFIXED(hCommACI)
351
352 static void kbdCb (drv_SignalID_Type *signal_params)
353 {
354 EXTERN T_VSI_CHANDLE hCommACI;
355
356 U16 signal_high;
357 U16 signal_low;
358 PALLOC(key_ind,MMI_KEYPAD_IND);
359
360 signal_high = (U16) (signal_params->UserData >> 16);
361 signal_low = (U16) (signal_params->UserData & 0xFFFF);
362
363 key_ind->key_code = (U8) (signal_low & 0xFF);
364 if (signal_high == 1)
365 key_ind->key_stat = KEY_STAT_PRS;
366
367 else
368 key_ind->key_stat = KEY_STAT_REL;
369
370 #if defined (_TMS470)
371 vsi_c_send("",hCommACI,D2P(key_ind),
372 sizeof(T_PRIM_HEADER)+sizeof(T_MMI_KEYPAD_IND));
373 #else
374 PSEND(ACI,key_ind);
375 #endif
376 }
377