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