]> icculus.org git repositories - btb/d2x.git/blob - ui/keypad.c
remove rcs tags
[btb/d2x.git] / ui / keypad.c
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14 #ifdef HAVE_CONFIG_H
15 #include "conf.h"
16 #endif
17
18 #include <stdlib.h>
19 #include <math.h>
20 #include <string.h>
21
22
23 #include "fix.h"
24 #include "pstypes.h"
25 #include "gr.h"
26 #include "key.h"
27 #include "cfile.h"
28
29 #include "mono.h"
30
31 #include "ui.h"
32
33 #include "u_mem.h"
34 //#include "cflib.h"
35 #include "func.h"
36 #include "error.h"
37
38 #define MAX_NUM_PADS 20
39
40 static UI_GADGET_BUTTON * Pad[17];
41 static UI_KEYPAD * KeyPad[MAX_NUM_PADS];
42 static int active_pad;
43
44 static int desc_x, desc_y;
45
46 static int HotKey[17];
47 static int HotKey1[17];
48
49 #define REMOVE_EOL(s)     (*(strstr( (s), "\n" ))='\0')
50
51 int ui_pad_get_current()
52 {
53         return active_pad;
54 }
55
56 void ui_pad_init()
57 {
58         int i;
59
60         for (i=0; i< MAX_NUM_PADS; i++ )
61                 KeyPad[i] = NULL;
62
63         active_pad = -1;
64 }
65
66 void ui_pad_close()
67 {
68         int i, j;
69
70         for (i=0; i< MAX_NUM_PADS; i++ )
71                 if (KeyPad[i])
72                 {
73                         for (j=0; j<17; j++ )
74                                 d_free(KeyPad[i]->buttontext[j]);
75                         d_free( KeyPad[i] );
76                         KeyPad[i] = NULL;       
77                 }
78
79 }
80
81
82 void LineParse( int n, char * dest, char * source )
83 {
84         int i = 0, j=0, cn = 0;
85
86         // Go to the n'th line
87         while (cn < n )
88                 if ((unsigned char) source[i++] == 179)
89                         cn++;
90
91         // Read up until the next comma
92         while ((unsigned char) source[i] != 179)
93         {
94                 dest[j] = source[i++];
95                 j++;            
96         }
97
98         // Null-terminate       
99         dest[j++] = 0;
100 }
101
102 void ui_pad_activate( UI_WINDOW * wnd, int x, int y )
103 {
104         int w,h,row,col, n;
105         int bh, bw;
106
107         bw = 56; bh = 30;
108
109         gr_set_current_canvas( wnd->canvas );
110         ui_draw_box_in( x, y, x+(bw*4)+10 + 200, y+(bh*5)+45 );
111
112         x += 5;
113         y += 20;
114
115         desc_x = x+2;
116         desc_y = y-17;
117                 
118         n=0; row = 0; col = 0; w = 1; h = 1;
119         Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
120         Pad[n]->canvas->cv_font = ui_small_font;
121         n=1; row = 0; col = 1; w = 1; h = 1;
122         Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
123         Pad[n]->canvas->cv_font = ui_small_font;
124         n=2; row = 0; col = 2; w = 1; h = 1;
125         Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
126         Pad[n]->canvas->cv_font = ui_small_font;
127         n=3; row = 0; col = 3; w = 1; h = 1;
128         Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
129         Pad[n]->canvas->cv_font = ui_small_font;
130         n=4; row = 1; col = 0; w = 1; h = 1; 
131         Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
132         Pad[n]->canvas->cv_font = ui_small_font;
133         n=5; row = 1; col = 1; w = 1; h = 1; 
134         Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
135         Pad[n]->canvas->cv_font = ui_small_font;
136         n=6; row = 1; col = 2; w = 1; h = 1; 
137         Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
138         Pad[n]->canvas->cv_font = ui_small_font;
139         n=7; row = 1; col = 3; w = 1; h = 2; 
140         Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
141         Pad[n]->canvas->cv_font = ui_small_font;
142         n=8; row = 2; col = 0; w = 1; h = 1; 
143         Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
144         Pad[n]->canvas->cv_font = ui_small_font;
145         n=9; row = 2; col = 1; w = 1; h = 1; 
146         Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
147         Pad[n]->canvas->cv_font = ui_small_font;
148         n=10; row = 2; col = 2; w = 1; h = 1;
149         Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
150         Pad[n]->canvas->cv_font = ui_small_font;
151         n=11; row = 3; col = 0; w = 1; h = 1;
152         Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
153         Pad[n]->canvas->cv_font = ui_small_font;
154         n=12; row = 3; col = 1; w = 1; h = 1;
155         Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
156         Pad[n]->canvas->cv_font = ui_small_font;
157         n=13; row = 3; col = 2; w = 1; h = 1;
158         Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
159         Pad[n]->canvas->cv_font = ui_small_font;
160         n=14; row = 3; col = 3; w = 1; h = 2; 
161         Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
162         Pad[n]->canvas->cv_font = ui_small_font;
163         n=15; row = 4; col = 0; w = 2; h = 1;
164         Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
165         Pad[n]->canvas->cv_font = ui_small_font;
166         n=16; row = 4; col = 2; w = 1; h = 1; 
167         Pad[n] = ui_add_gadget_button( wnd, x+(bw*col), y+(bh*row), bw*w, bh*h, NULL, NULL );
168         Pad[n]->canvas->cv_font = ui_small_font;
169
170         HotKey[0] = KEY_CTRLED + KEY_NUMLOCK;
171         HotKey[1] = KEY_CTRLED + KEY_PADDIVIDE;
172         HotKey[2] = KEY_CTRLED + KEY_PADMULTIPLY;
173         HotKey[3] = KEY_CTRLED + KEY_PADMINUS;
174         HotKey[4] = KEY_CTRLED + KEY_PAD7;
175         HotKey[5] = KEY_CTRLED + KEY_PAD8;
176         HotKey[6] = KEY_CTRLED + KEY_PAD9;
177         HotKey[7] = KEY_CTRLED + KEY_PADPLUS;
178         HotKey[8] = KEY_CTRLED + KEY_PAD4;
179         HotKey[9] = KEY_CTRLED + KEY_PAD5;
180         HotKey[10] = KEY_CTRLED + KEY_PAD6;
181         HotKey[11] = KEY_CTRLED + KEY_PAD1;
182         HotKey[12] = KEY_CTRLED + KEY_PAD2;
183         HotKey[13] = KEY_CTRLED + KEY_PAD3;
184         HotKey[14] = KEY_CTRLED + KEY_PADENTER;
185         HotKey[15] = KEY_CTRLED + KEY_PAD0;
186         HotKey[16] = KEY_CTRLED + KEY_PADPERIOD;
187
188         HotKey1[0] = KEY_SHIFTED + KEY_CTRLED + KEY_NUMLOCK;
189         HotKey1[1] = KEY_SHIFTED + KEY_CTRLED + KEY_PADDIVIDE;
190         HotKey1[2] = KEY_SHIFTED + KEY_CTRLED + KEY_PADMULTIPLY;
191         HotKey1[3] = KEY_SHIFTED + KEY_CTRLED + KEY_PADMINUS;
192         HotKey1[4] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD7;
193         HotKey1[5] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD8;
194         HotKey1[6] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD9;
195         HotKey1[7] = KEY_SHIFTED + KEY_CTRLED + KEY_PADPLUS;
196         HotKey1[8] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD4;
197         HotKey1[9] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD5;
198         HotKey1[10] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD6;
199         HotKey1[11] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD1;
200         HotKey1[12] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD2;
201         HotKey1[13] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD3;
202         HotKey1[14] = KEY_SHIFTED + KEY_CTRLED + KEY_PADENTER;
203         HotKey1[15] = KEY_SHIFTED + KEY_CTRLED + KEY_PAD0;
204         HotKey1[16] = KEY_SHIFTED + KEY_CTRLED + KEY_PADPERIOD;
205
206         active_pad = -1;
207
208 }
209
210
211 void ui_pad_deactivate()
212 {
213         int i;
214
215         for (i=0; i<17; i++ )
216         {
217                 Pad[i]->text = NULL;
218         }
219 }
220
221 static void ui_pad_set_active( int n )
222 {
223         int np;
224         char * name;
225         int i, j;
226
227         
228
229         gr_set_current_canvas( NULL );
230         gr_setcolor( CWHITE );
231         gr_urect( desc_x, desc_y, desc_x+ 56*4-1, desc_y+15 );
232         gr_set_fontcolor( CBLACK, CWHITE );
233         gr_ustring( desc_x, desc_y, KeyPad[n]->description );
234                 
235         for (i=0; i<17; i++ )
236         {
237                 Pad[i]->text = KeyPad[n]->buttontext[i];
238                 Pad[i]->status = 1;
239                 Pad[i]->user_function = NULL;
240                 Pad[i]->dim_if_no_function = 1;
241                 Pad[i]->hotkey = -1;
242                                 
243                 for (j=0; j< KeyPad[n]->numkeys; j++ )
244                 {
245                         if (HotKey[i] == KeyPad[n]->keycode[j] )
246                         {
247                                 Pad[i]->hotkey =  HotKey[i];
248                                 Pad[i]->user_function = func_nget( KeyPad[n]->function_number[j], &np, &name );
249                         }
250                         if (HotKey1[i] == KeyPad[n]->keycode[j] )
251                         {
252                                 Pad[i]->hotkey1 =  HotKey1[i];
253                                 Pad[i]->user_function1 = func_nget( KeyPad[n]->function_number[j], &np, &name );
254                         }
255                 }
256         }
257
258         active_pad = n;
259 }
260
261 void ui_pad_goto(int n)
262 {
263         if ( KeyPad[n] != NULL )
264                 ui_pad_set_active(n);
265 }
266
267 void ui_pad_goto_next()
268 {
269         int i, si;
270
271         i = active_pad + 1;
272         si = i;
273         
274         while( KeyPad[i]==NULL )
275         {
276                 i++;
277                 if (i >= MAX_NUM_PADS)
278                         i = 0;
279                 if (i == si )
280                         break;
281         }
282         ui_pad_set_active(i);
283 }
284
285 void ui_pad_goto_prev()
286 {
287         int i, si;
288
289         if (active_pad == -1 ) 
290                 active_pad = MAX_NUM_PADS;
291         
292         i = active_pad - 1;
293         if (i<0) i= MAX_NUM_PADS - 1;
294         si = i;
295         
296         while( KeyPad[i]==NULL )
297         {
298                 i--;
299                 if (i < 0)
300                         i = MAX_NUM_PADS-1;
301                 if (i == active_pad )
302                         break;
303         }
304         ui_pad_set_active(i);
305 }
306
307 void ui_pad_read( int n, char * filename )
308 {
309         char * ptr;
310         char buffer[100];
311         char text[100];
312         char line_buffer[200];
313         CFILE * infile;
314         int linenumber = 0;
315         int i;
316         int keycode, functionnumber;
317
318         infile = cfopen( filename, "rt" );
319         if (!infile) {
320                 Warning( "Couldn't find %s", filename );
321                 return;
322         }
323                                           
324         MALLOC( KeyPad[n], UI_KEYPAD, 1 );
325                         
326         for (i=0; i < 17; i++ ) {
327                 MALLOC( KeyPad[n]->buttontext[i], char, 100 );
328         }
329
330         KeyPad[n]->numkeys = 0;
331
332         for (i=0; i<100; i++ )
333         {
334                 KeyPad[n]->keycode[i] = -1;
335                 KeyPad[n]->function_number[i] = 0;
336         }
337
338         while ( linenumber < 22)
339         {
340                 cfgets( buffer, 100, infile );
341
342                 switch( linenumber+1 )
343                 {
344                 case 1:
345                         strncpy( KeyPad[n]->description, buffer, 100 );
346                         break;
347                 //===================== ROW 0 ==============================
348                 case 3:
349                         LineParse( 1, text, buffer );
350                         sprintf( KeyPad[n]->buttontext[0], "%s\n", text );
351                         LineParse( 2, text, buffer );
352                         sprintf( KeyPad[n]->buttontext[1], "%s\n", text );
353                         LineParse( 3, text, buffer );
354                         sprintf( KeyPad[n]->buttontext[2], "%s\n", text );
355                         LineParse( 4, text, buffer );
356                         sprintf( KeyPad[n]->buttontext[3], "%s\n", text );
357                         break;
358                 case 4:
359                         LineParse( 1, text, buffer );
360                         sprintf( KeyPad[n]->buttontext[0], "%s%s\n", KeyPad[n]->buttontext[0],text );
361                         LineParse( 2, text, buffer );    
362                         sprintf( KeyPad[n]->buttontext[1], "%s%s\n", KeyPad[n]->buttontext[1],text );
363                         LineParse( 3, text, buffer );
364                         sprintf( KeyPad[n]->buttontext[2], "%s%s\n", KeyPad[n]->buttontext[2],text );
365                         LineParse( 4, text, buffer );
366                         sprintf( KeyPad[n]->buttontext[3], "%s%s\n", KeyPad[n]->buttontext[3],text );
367                         break;
368                 case 5:
369                         LineParse( 1, text, buffer );
370                         sprintf( KeyPad[n]->buttontext[0], "%s%s", KeyPad[n]->buttontext[0],text );
371                         LineParse( 2, text, buffer );    
372                         sprintf( KeyPad[n]->buttontext[1], "%s%s", KeyPad[n]->buttontext[1],text );
373                         LineParse( 3, text, buffer );
374                         sprintf( KeyPad[n]->buttontext[2], "%s%s", KeyPad[n]->buttontext[2],text );
375                         LineParse( 4, text, buffer );
376                         sprintf( KeyPad[n]->buttontext[3], "%s%s", KeyPad[n]->buttontext[3],text );
377                         break;
378                 //===================== ROW 1 ==============================
379                 case 7:
380                         LineParse( 1, text, buffer );
381                         sprintf( KeyPad[n]->buttontext[4], "%s\n", text );
382                         LineParse( 2, text, buffer );    
383                         sprintf( KeyPad[n]->buttontext[5], "%s\n", text );
384                         LineParse( 3, text, buffer);       
385                         sprintf( KeyPad[n]->buttontext[6], "%s\n", text );
386                         LineParse( 4, text, buffer );
387                         sprintf( KeyPad[n]->buttontext[7], "%s\n", text );
388                         break;
389                 case 8:
390                         LineParse( 1, text, buffer );
391                         sprintf( KeyPad[n]->buttontext[4], "%s%s\n", KeyPad[n]->buttontext[4],text );
392                         LineParse( 2, text, buffer );    
393                         sprintf( KeyPad[n]->buttontext[5], "%s%s\n", KeyPad[n]->buttontext[5],text );
394                         LineParse( 3, text, buffer );
395                         sprintf( KeyPad[n]->buttontext[6], "%s%s\n", KeyPad[n]->buttontext[6],text );
396                         LineParse( 4, text, buffer );
397                         sprintf( KeyPad[n]->buttontext[7], "%s%s\n", KeyPad[n]->buttontext[7],text );
398                         break;
399                 case 9:
400                         LineParse( 1, text, buffer );
401                         sprintf( KeyPad[n]->buttontext[4], "%s%s", KeyPad[n]->buttontext[4],text );
402                         LineParse( 2, text, buffer );    
403                         sprintf( KeyPad[n]->buttontext[5], "%s%s", KeyPad[n]->buttontext[5],text );
404                         LineParse( 3, text, buffer );
405                         sprintf( KeyPad[n]->buttontext[6], "%s%s", KeyPad[n]->buttontext[6],text );
406                         LineParse( 4, text, buffer );
407                         sprintf( KeyPad[n]->buttontext[7], "%s%s\n", KeyPad[n]->buttontext[7],text );
408                         break;
409                 case 10:
410                         ptr = strrchr( buffer, (char) 179 );
411                         *ptr = 0;
412                         ptr = strrchr( buffer, (char) 180 );    ptr++;
413                         sprintf( KeyPad[n]->buttontext[7], "%s%s\n", KeyPad[n]->buttontext[7],ptr );
414                         break;
415                 //======================= ROW 2 ==============================
416                 case 11:
417                         LineParse( 1, text, buffer );
418                         sprintf( KeyPad[n]->buttontext[8], "%s\n", text );
419                         LineParse( 2, text, buffer );    
420                         sprintf( KeyPad[n]->buttontext[9], "%s\n", text );
421                         LineParse( 3, text, buffer);       
422                         sprintf( KeyPad[n]->buttontext[10], "%s\n", text );
423                         LineParse( 4, text, buffer );
424                         sprintf( KeyPad[n]->buttontext[7], "%s%s\n", KeyPad[n]->buttontext[7],text );
425                         break;
426                 case 12:
427                         LineParse( 1, text, buffer );
428                         sprintf( KeyPad[n]->buttontext[8], "%s%s\n", KeyPad[n]->buttontext[8],text );
429                         LineParse( 2, text, buffer );    
430                         sprintf( KeyPad[n]->buttontext[9], "%s%s\n", KeyPad[n]->buttontext[9],text );
431                         LineParse( 3, text, buffer );
432                         sprintf( KeyPad[n]->buttontext[10], "%s%s\n", KeyPad[n]->buttontext[10],text );
433                         LineParse( 4, text, buffer );
434                         sprintf( KeyPad[n]->buttontext[7], "%s%s\n", KeyPad[n]->buttontext[7],text );
435                         break;
436                 case 13:
437                         LineParse( 1, text, buffer );
438                         sprintf( KeyPad[n]->buttontext[8], "%s%s", KeyPad[n]->buttontext[8],text );
439                         LineParse( 2, text, buffer );    
440                         sprintf( KeyPad[n]->buttontext[9], "%s%s", KeyPad[n]->buttontext[9],text );
441                         LineParse( 3, text, buffer );
442                         sprintf( KeyPad[n]->buttontext[10], "%s%s", KeyPad[n]->buttontext[10],text );
443                         LineParse( 4, text, buffer );
444                         sprintf( KeyPad[n]->buttontext[7], "%s%s", KeyPad[n]->buttontext[7],text );
445                         break;
446                 // ====================== ROW 3 =========================
447                 case 15:
448                         LineParse( 1, text, buffer );
449                         sprintf( KeyPad[n]->buttontext[11], "%s\n", text );
450                         LineParse( 2, text, buffer );    
451                         sprintf( KeyPad[n]->buttontext[12], "%s\n", text );
452                         LineParse( 3, text, buffer);       
453                         sprintf( KeyPad[n]->buttontext[13], "%s\n", text );
454                         LineParse( 4, text, buffer );
455                         sprintf( KeyPad[n]->buttontext[14], "%s\n", text );
456                         break;
457                 case 16:
458                         LineParse( 1, text, buffer );
459                         sprintf( KeyPad[n]->buttontext[11], "%s%s\n", KeyPad[n]->buttontext[11],text );
460                         LineParse( 2, text, buffer );    
461                         sprintf( KeyPad[n]->buttontext[12], "%s%s\n", KeyPad[n]->buttontext[12],text );
462                         LineParse( 3, text, buffer );
463                         sprintf( KeyPad[n]->buttontext[13], "%s%s\n", KeyPad[n]->buttontext[13],text );
464                         LineParse( 4, text, buffer );
465                         sprintf( KeyPad[n]->buttontext[14], "%s%s\n", KeyPad[n]->buttontext[14],text );
466                         break;
467                 case 17:
468                         LineParse( 1, text, buffer );
469                         sprintf( KeyPad[n]->buttontext[11], "%s%s", KeyPad[n]->buttontext[11],text );
470                         LineParse( 2, text, buffer );    
471                         sprintf( KeyPad[n]->buttontext[12], "%s%s", KeyPad[n]->buttontext[12],text );
472                         LineParse( 3, text, buffer );
473                         sprintf( KeyPad[n]->buttontext[13], "%s%s", KeyPad[n]->buttontext[13],text );
474                         LineParse( 4, text, buffer );
475                         sprintf( KeyPad[n]->buttontext[14], "%s%s\n", KeyPad[n]->buttontext[14],text );
476                         break;
477                 case 18:
478                         ptr = strrchr( buffer, (char) 179 );
479                         *ptr = 0;
480                         ptr = strrchr( buffer, (char) 180 ); ptr++;
481                         sprintf( KeyPad[n]->buttontext[14], "%s%s\n", KeyPad[n]->buttontext[14], ptr );
482                         break;
483                 //======================= ROW 4 =========================
484                 case 19:
485                         LineParse( 1, text, buffer );
486                         sprintf( KeyPad[n]->buttontext[15], "%s\n", text );
487                         LineParse( 2, text, buffer );    
488                         sprintf( KeyPad[n]->buttontext[16], "%s\n", text );
489                         LineParse( 3, text, buffer );
490                         sprintf( KeyPad[n]->buttontext[14], "%s%s\n", KeyPad[n]->buttontext[14],text );
491                         break;
492                 case 20:
493                         LineParse( 1, text, buffer );
494                         sprintf( KeyPad[n]->buttontext[15], "%s%s\n", KeyPad[n]->buttontext[15],text );
495                         LineParse( 2, text, buffer );    
496                         sprintf( KeyPad[n]->buttontext[16], "%s%s\n", KeyPad[n]->buttontext[16],text );
497                         LineParse( 3, text, buffer );
498                         sprintf( KeyPad[n]->buttontext[14], "%s%s\n", KeyPad[n]->buttontext[14],text );
499                         break;
500                 case 21:
501                         LineParse( 1, text, buffer );
502                         sprintf( KeyPad[n]->buttontext[15], "%s%s", KeyPad[n]->buttontext[15],text );
503                         LineParse( 2, text, buffer );    
504                         sprintf( KeyPad[n]->buttontext[16], "%s%s", KeyPad[n]->buttontext[16],text );
505                         LineParse( 3, text, buffer );
506                         sprintf( KeyPad[n]->buttontext[14], "%s%s", KeyPad[n]->buttontext[14],text );
507                         break;
508                 }
509                                                                                 
510                 linenumber++;   
511         }
512
513         // Get the keycodes...
514
515         while (cfgets(line_buffer, 200, infile))
516         {
517                 sscanf(line_buffer, " %s %s ", text, buffer);
518                 keycode = DecodeKeyText(text);
519                 functionnumber = func_get_index(buffer);
520                 if (functionnumber==-1)
521                 {
522                         Error( "Unknown function, %s, in %s\n", buffer, filename );
523                 } else if (keycode==-1)
524                 {
525                         Error( "Unknown keystroke, %s, in %s\n", text, filename );
526                         //MessageBox( -2, -2, 1, buffer, "Ok" );
527
528                 } else {
529                         KeyPad[n]->keycode[KeyPad[n]->numkeys] = keycode;
530                         KeyPad[n]->function_number[KeyPad[n]->numkeys] = functionnumber;
531                         KeyPad[n]->numkeys++;
532                 }
533         }
534         
535         cfclose(infile);
536
537 }