]> git.jsancho.org Git - lugaru.git/blob - Source/WinInput.cpp
Build fixes.
[lugaru.git] / Source / WinInput.cpp
1 /**> HEADER FILES <**/
2 #include "WinInput.h"
3
4 #ifdef WIN32
5 #include "String.h"
6 #else
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #endif
11
12 extern bool keyboardfrozen;
13 extern bool buttons[3];
14 /********************> IsKeyDown() <*****/
15 Boolean IsKeyDown( unsigned char *keyMap, unsigned short theKey )
16 {
17         if(keyboardfrozen)return 0;
18         if(theKey< 0x80 /*1000*/){
19                 static long     keyMapIndex;
20                 static Boolean  isKeyDown;
21                 static short    bitToCheck;
22
23                 // Calculate the key map index
24                 keyMapIndex = keyMap[theKey/8];
25
26                 // Calculate the individual bit to check
27                 bitToCheck = theKey%8;
28
29                 // Check the status of the key
30                 isKeyDown = ( keyMapIndex >> bitToCheck ) & 0x01;
31
32                 // Return the status of the key
33                 return isKeyDown;
34         }
35         else if(theKey==MAC_MOUSEBUTTON1)
36                 return buttons[0];
37         else if(theKey==MAC_MOUSEBUTTON2)
38                 return buttons[1];
39
40         return 0;
41 }
42
43 unsigned short  CharToKey(char* which)
44 {
45         // alphabetic keys
46         if(!stricmp(which,"a")){
47                 return MAC_A_KEY;
48         }
49         if(!stricmp(which,"b")){
50                 return MAC_B_KEY;
51         }
52         if(!stricmp(which,"c")){
53                 return MAC_C_KEY;
54         }
55         if(!stricmp(which,"d")){
56                 return MAC_D_KEY;
57         }
58         if(!stricmp(which,"e")){
59                 return MAC_E_KEY;
60         }
61         if(!stricmp(which,"f")){
62                 return MAC_F_KEY;
63         }
64         if(!stricmp(which,"g")){
65                 return MAC_G_KEY;
66         }
67         if(!stricmp(which,"h")){
68                 return MAC_H_KEY;
69         }
70         if(!stricmp(which,"i")){
71                 return MAC_I_KEY;
72         }
73         if(!stricmp(which,"j")){
74                 return MAC_J_KEY;
75         }
76         if(!stricmp(which,"k")){
77                 return MAC_K_KEY;
78         }
79         if(!stricmp(which,"l")){
80                 return MAC_L_KEY;
81         }
82         if(!stricmp(which,"m")){
83                 return MAC_M_KEY;
84         }
85         if(!stricmp(which,"n")){
86                 return MAC_N_KEY;
87         }
88         if(!stricmp(which,"o")){
89                 return MAC_O_KEY;
90         }
91         if(!stricmp(which,"p")){
92                 return MAC_P_KEY;
93         }
94         if(!stricmp(which,"q")){
95                 return MAC_Q_KEY;
96         }
97         if(!stricmp(which,"r")){
98                 return MAC_R_KEY;
99         }
100         if(!stricmp(which,"s")){
101                 return MAC_S_KEY;
102         }
103         if(!stricmp(which,"t")){
104                 return MAC_T_KEY;
105         }
106         if(!stricmp(which,"u")){
107                 return MAC_U_KEY;
108         }
109         if(!stricmp(which,"v")){
110                 return MAC_V_KEY;
111         }
112         if(!stricmp(which,"w")){
113                 return MAC_W_KEY;
114         }
115         if(!stricmp(which,"x")){
116                 return MAC_X_KEY;
117         }
118         if(!stricmp(which,"y")){
119                 return MAC_Y_KEY;
120         }
121         if(!stricmp(which,"z")){
122                 return MAC_Z_KEY;
123         }
124
125         // keypad keys
126         if(!stricmp(which,"KP0")){
127                 return MAC_NUMPAD_0_KEY;
128         }
129         if(!stricmp(which,"KP1")){
130                 return MAC_NUMPAD_1_KEY;
131         }
132         if(!stricmp(which,"KP2")){
133                 return MAC_NUMPAD_2_KEY;
134         }
135         if(!stricmp(which,"KP3")){
136                 return MAC_NUMPAD_3_KEY;
137         }
138         if(!stricmp(which,"KP4")){
139                 return MAC_NUMPAD_4_KEY;
140         }
141         if(!stricmp(which,"KP5")){
142                 return MAC_NUMPAD_5_KEY;
143         }
144         if(!stricmp(which,"KP6")){
145                 return MAC_NUMPAD_6_KEY;
146         }
147         if(!stricmp(which,"KP7")){
148                 return MAC_NUMPAD_7_KEY;
149         }
150         if(!stricmp(which,"KP8")){
151                 return MAC_NUMPAD_8_KEY;
152         }
153         if(!stricmp(which,"KP9")){
154                 return MAC_NUMPAD_9_KEY;
155         }
156
157         // enter
158         if(!stricmp(which,"enter")){
159                 return MAC_ENTER_KEY;
160         }
161
162         // number keys
163         if(!stricmp(which,"0")){
164                 return MAC_0_KEY;
165         }
166         if(!stricmp(which,"1")){
167                 return MAC_1_KEY;
168         }
169         if(!stricmp(which,"2")){
170                 return MAC_2_KEY;
171         }
172         if(!stricmp(which,"3")){
173                 return MAC_3_KEY;
174         }
175         if(!stricmp(which,"4")){
176                 return MAC_4_KEY;
177         }
178         if(!stricmp(which,"5")){
179                 return MAC_5_KEY;
180         }
181         if(!stricmp(which,"6")){
182                 return MAC_6_KEY;
183         }
184         if(!stricmp(which,"7")){
185                 return MAC_7_KEY;
186         }
187         if(!stricmp(which,"8")){
188                 return MAC_8_KEY;
189         }
190         if(!stricmp(which,"9")){
191                 return MAC_9_KEY;
192         }
193
194         // function keys
195         if(!stricmp(which,"F1")){
196                 return MAC_F1_KEY;
197         }
198         if(!stricmp(which,"F2")){
199                 return MAC_F2_KEY;
200         }
201         if(!stricmp(which,"F3")){
202                 return MAC_F3_KEY;
203         }
204         if(!stricmp(which,"F4")){
205                 return MAC_F4_KEY;
206         }
207         if(!stricmp(which,"F5")){
208                 return MAC_F5_KEY;
209         }
210         if(!stricmp(which,"F6")){
211                 return MAC_F6_KEY;
212         }
213         if(!stricmp(which,"F7")){
214                 return MAC_F7_KEY;
215         }
216         if(!stricmp(which,"F8")){
217                 return MAC_F8_KEY;
218         }
219         if(!stricmp(which,"F9")){
220                 return MAC_F9_KEY;
221         }
222         if(!stricmp(which,"F10")){
223                 return MAC_F10_KEY;
224         }
225         if(!stricmp(which,"F11")){
226                 return MAC_F11_KEY;
227         }
228         if(!stricmp(which,"F12")){
229                 return MAC_F12_KEY;
230         }
231
232         // escape
233         if(!stricmp(which,"escape")){
234                 return MAC_ESCAPE_KEY;
235         }
236         if(!stricmp(which,"backspace")){
237                 return MAC_DELETE_KEY;
238         }
239         if(!stricmp(which,"tab")){
240                 return MAC_TAB_KEY;
241         }
242         if(!stricmp(which,"`")){
243                 return MAC_TILDE_KEY;
244         }
245         if(!stricmp(which,"caps_lock")){
246                 return MAC_CAPS_LOCK_KEY;
247         }
248 //      if(which==){
249 //              return "";
250 //      }
251         if(!stricmp(which,"command")){
252                 return MAC_COMMAND_KEY;
253         }
254         if(!stricmp(which,"option")){
255                 return MAC_OPTION_KEY;
256         }
257         if(!stricmp(which,"delete")){
258                 return MAC_DEL_KEY;
259         }
260         if(!stricmp(which,"insert")){
261                 return MAC_INSERT_KEY;
262         }
263         if(!stricmp(which,"home")){
264                 return MAC_HOME_KEY;
265         }
266         if(!stricmp(which,"end")){
267                 return MAC_END_KEY;
268         }
269         if(!stricmp(which,"page_up")){
270                 return MAC_PAGE_UP_KEY;
271         }
272         if(!stricmp(which,"page_down")){
273                 return MAC_PAGE_DOWN_KEY;
274         }
275         if(!stricmp(which,"clear")){
276                 return MAC_NUMPAD_CLEAR_KEY;
277         }
278
279         if(!stricmp(which,"control")){
280                 return MAC_CONTROL_KEY;
281         }
282         if(!stricmp(which,"return")){
283                 return MAC_RETURN_KEY;
284         }
285         if(!stricmp(which,"space")){
286                 return MAC_SPACE_KEY;
287         }
288         if(!stricmp(which,"shift")){
289                 return MAC_SHIFT_KEY;
290         }
291         if(!stricmp(which,"uparrow")){
292                 return MAC_ARROW_UP_KEY;
293         }
294         if(!stricmp(which,"downarrow")){
295                 return MAC_ARROW_DOWN_KEY;
296         }
297         if(!stricmp(which,"leftarrow")){
298                 return MAC_ARROW_LEFT_KEY;
299         }
300         if(!stricmp(which,"rightarrow")){
301                 return MAC_ARROW_RIGHT_KEY;
302         }
303         if(!stricmp(which,"mouse1")){
304                 return MAC_MOUSEBUTTON1;
305         }
306         if(!stricmp(which,"mouse2")){
307                 return MAC_MOUSEBUTTON2;
308         }
309         if(!stricmp(which,"+")){
310                 return MAC_NUMPAD_PLUS_KEY;
311         }
312         if(!stricmp(which,"*")){
313                 return MAC_NUMPAD_ASTERISK_KEY;
314         }
315         if(!stricmp(which,"/")){
316                 return MAC_SLASH_KEY;
317         }
318         if(!stricmp(which,"\\")){
319                 return MAC_BACKSLASH_KEY;
320         }
321         if(!stricmp(which,"[")){
322                 return MAC_LEFTBRACKET_KEY;
323         }
324         if(!stricmp(which,"]")){
325                 return MAC_RIGHTBRACKET_KEY;
326         }
327         if(!stricmp(which,".")){
328                 return MAC_PERIOD_KEY;
329         }
330         if(!stricmp(which,",")){
331                 return MAC_COMMA_KEY;
332         }
333         if(!stricmp(which,"\"")){
334                 return MAC_APOSTROPHE_KEY;
335         }
336         if(!stricmp(which,";")){
337                 return MAC_SEMICOLON_KEY;
338         }
339         return UNKNOWN_KEY;
340 }
341
342 char*   KeyToChar(unsigned short which)
343 {
344         static int i;
345
346         // alphabetic keys
347         if(which==MAC_A_KEY){
348                 return "a";
349         }
350         if(which==MAC_B_KEY){
351                 return "b";
352         }
353         if(which==MAC_C_KEY){
354                 return "c";
355         }
356         if(which==MAC_D_KEY){
357                 return "d";
358         }
359         if(which==MAC_E_KEY){
360                 return "e";
361         }
362         if(which==MAC_F_KEY){
363                 return "f";
364         }
365         if(which==MAC_G_KEY){
366                 return "g";
367         }
368         if(which==MAC_H_KEY){
369                 return "h";
370         }
371         if(which==MAC_I_KEY){
372                 return "i";
373         }
374         if(which==MAC_J_KEY){
375                 return "j";
376         }
377         if(which==MAC_K_KEY){
378                 return "k";
379         }
380         if(which==MAC_L_KEY){
381                 return "l";
382         }
383         if(which==MAC_M_KEY){
384                 return "m";
385         }
386         if(which==MAC_N_KEY){
387                 return "n";
388         }
389         if(which==MAC_O_KEY){
390                 return "o";
391         }
392         if(which==MAC_P_KEY){
393                 return "p";
394         }
395         if(which==MAC_Q_KEY){
396                 return "q";
397         }
398         if(which==MAC_R_KEY){
399                 return "r";
400         }
401         if(which==MAC_S_KEY){
402                 return "s";
403         }
404         if(which==MAC_T_KEY){
405                 return "t";
406         }
407         if(which==MAC_U_KEY){
408                 return "u";
409         }
410         if(which==MAC_V_KEY){
411                 return "v";
412         }
413         if(which==MAC_W_KEY){
414                 return "w";
415         }
416         if(which==MAC_X_KEY){
417                 return "x";
418         }
419         if(which==MAC_Y_KEY){
420                 return "y";
421         }
422         if(which==MAC_Z_KEY){
423                 return "z";
424         }
425
426         // keypad keys
427         if(which==MAC_NUMPAD_1_KEY){
428                 return "KP1";
429         }
430         if(which==MAC_NUMPAD_2_KEY){
431                 return "KP2";
432         }
433         if(which==MAC_NUMPAD_3_KEY){
434                 return "KP3";
435         }
436         if(which==MAC_NUMPAD_4_KEY){
437                 return "KP4";
438         }
439         if(which==MAC_NUMPAD_5_KEY){
440                 return "KP5";
441         }
442         if(which==MAC_NUMPAD_6_KEY){
443                 return "KP6";
444         }
445         if(which==MAC_NUMPAD_7_KEY){
446                 return "KP7";
447         }
448         if(which==MAC_NUMPAD_8_KEY){
449                 return "KP8";
450         }
451         if(which==MAC_NUMPAD_9_KEY){
452                 return "KP9";
453         }
454         if(which==MAC_NUMPAD_0_KEY){
455                 return "KP0";
456         }
457
458         // enter
459         if(which==MAC_ENTER_KEY){
460                 return "enter";
461         }
462
463         // number keys
464         if(which==MAC_1_KEY){
465                 return "1";
466         }
467         if(which==MAC_2_KEY){
468                 return "2";
469         }
470         if(which==MAC_3_KEY){
471                 return "3";
472         }
473         if(which==MAC_4_KEY){
474                 return "4";
475         }
476         if(which==MAC_5_KEY){
477                 return "5";
478         }
479         if(which==MAC_6_KEY){
480                 return "6";
481         }
482         if(which==MAC_7_KEY){
483                 return "7";
484         }
485         if(which==MAC_8_KEY){
486                 return "8";
487         }
488         if(which==MAC_9_KEY){
489                 return "9";
490         }
491         if(which==MAC_0_KEY){
492                 return "0";
493         }
494
495         // function keys
496         if(which==MAC_F1_KEY){
497                 return "F1";
498         }
499         if(which==MAC_F2_KEY){
500                 return "F2";
501         }
502         if(which==MAC_F3_KEY){
503                 return "F3";
504         }
505         if(which==MAC_F4_KEY){
506                 return "F4";
507         }
508         if(which==MAC_F5_KEY){
509                 return "F5";
510         }
511         if(which==MAC_F6_KEY){
512                 return "F6";
513         }
514         if(which==MAC_F7_KEY){
515                 return "F7";
516         }
517         if(which==MAC_F8_KEY){
518                 return "F8";
519         }
520         if(which==MAC_F9_KEY){
521                 return "F9";
522         }
523         if(which==MAC_F10_KEY){
524                 return "F10";
525         }
526         if(which==MAC_F11_KEY){
527                 return "F11";
528         }
529         if(which==MAC_F12_KEY){
530                 return "F12";
531         }
532
533         // escape
534         if(which==MAC_ESCAPE_KEY){
535                 return "escape";
536         }
537         if(which==MAC_DELETE_KEY){
538                 return "backspace";
539         }
540         if(which==MAC_TAB_KEY){
541                 return "tab";
542         }
543         if(which==MAC_TILDE_KEY){
544                 return "`";
545         }
546         if(which==MAC_CAPS_LOCK_KEY){
547                 return "caps_lock";
548         }
549         if(which==MAC_COMMAND_KEY){
550                 return "command";
551         }
552         if(which==MAC_OPTION_KEY){
553                 return "option";
554         }
555         if(which==MAC_DEL_KEY){
556                 return "delete";
557         }
558         if(which==MAC_INSERT_KEY){
559                 return "insert";
560         }
561         if(which==MAC_HOME_KEY){
562                 return "home";
563         }
564         if(which==MAC_END_KEY){
565                 return "end";
566         }
567         if(which==MAC_PAGE_UP_KEY){
568                 return "page_up";
569         }
570         if(which==MAC_PAGE_DOWN_KEY){
571                 return "page_down";
572         }
573         if(which==MAC_NUMPAD_CLEAR_KEY){
574                 return "clear";
575         }
576         if(which==MAC_CONTROL_KEY){
577                 return "control";
578         }
579         if(which==MAC_SPACE_KEY){
580                 return "space";
581         }
582         if(which==MAC_RETURN_KEY){
583                 return "return";
584         }
585         if(which==MAC_SHIFT_KEY){
586                 return "shift";
587         }
588         if(which==MAC_ARROW_UP_KEY){
589                 return "uparrow";
590         }
591         if(which==MAC_ARROW_DOWN_KEY){
592                 return "downarrow";
593         }
594         if(which==MAC_ARROW_LEFT_KEY){
595                 return "leftarrow";
596         }
597         if(which==MAC_ARROW_RIGHT_KEY){
598                 return "rightarrow";
599         }
600         if(which==MAC_MOUSEBUTTON1){
601                 return "mouse1";
602         }
603         if(which==MAC_MOUSEBUTTON2){
604                 return "mouse2";
605         }
606         if(which==MAC_ARROW_RIGHT_KEY){
607                 return "rightarrow";
608         }
609         if(which==MAC_MINUS_KEY||which==MAC_NUMPAD_MINUS_KEY){
610                 return "-";
611         }
612         if(which==MAC_PLUS_KEY||which==MAC_NUMPAD_EQUALS_KEY){
613                 return "=";
614         }
615         if(which==MAC_NUMPAD_PLUS_KEY){
616                 return "+";
617         }
618         if(which==MAC_NUMPAD_ASTERISK_KEY){
619                 return "*";
620         }
621         if(which==MAC_SLASH_KEY||which==MAC_NUMPAD_SLASH_KEY){
622                 return "/";
623         }
624         if(which==MAC_BACKSLASH_KEY){
625                 return "\\";
626         }
627         if(which==MAC_LEFTBRACKET_KEY){
628                 return "[";
629         }
630         if(which==MAC_RIGHTBRACKET_KEY){
631                 return "]";
632         }
633         if(which==MAC_PERIOD_KEY||which==MAC_NUMPAD_PERIOD_KEY){
634                 return ".";
635         }
636         if(which==MAC_COMMA_KEY){
637                 return ",";
638         }
639         if(which==MAC_APOSTROPHE_KEY){
640                 return "\"";
641         }
642         if(which==MAC_SEMICOLON_KEY){
643                 return ";";
644         }
645         return "unknown";
646 }
647
648 char    KeyToSingleChar(unsigned short which)
649 {
650         static int i;
651
652         if(which==MAC_A_KEY){
653                 return 'a';
654         }
655         if(which==MAC_B_KEY){
656                 return 'b';
657         }
658         if(which==MAC_C_KEY){
659                 return 'c';
660         }
661         if(which==MAC_D_KEY){
662                 return 'd';
663         }
664         if(which==MAC_E_KEY){
665                 return 'e';
666         }
667         if(which==MAC_F_KEY){
668                 return 'f';
669         }
670         if(which==MAC_G_KEY){
671                 return 'g';
672         }
673         if(which==MAC_H_KEY){
674                 return 'h';
675         }
676         if(which==MAC_I_KEY){
677                 return 'i';
678         }
679         if(which==MAC_J_KEY){
680                 return 'j';
681         }
682         if(which==MAC_K_KEY){
683                 return 'k';
684         }
685         if(which==MAC_L_KEY){
686                 return 'l';
687         }
688         if(which==MAC_M_KEY){
689                 return 'm';
690         }
691         if(which==MAC_N_KEY){
692                 return 'n';
693         }
694         if(which==MAC_O_KEY){
695                 return 'o';
696         }
697         if(which==MAC_P_KEY){
698                 return 'p';
699         }
700         if(which==MAC_Q_KEY){
701                 return 'q';
702         }
703         if(which==MAC_R_KEY){
704                 return 'r';
705         }
706         if(which==MAC_S_KEY){
707                 return 's';
708         }
709         if(which==MAC_T_KEY){
710                 return 't';
711         }
712         if(which==MAC_U_KEY){
713                 return 'u';
714         }
715         if(which==MAC_V_KEY){
716                 return 'v';
717         }
718         if(which==MAC_W_KEY){
719                 return 'w';
720         }
721         if(which==MAC_X_KEY){
722                 return 'x';
723         }
724         if(which==MAC_Y_KEY){
725                 return 'y';
726         }
727         if(which==MAC_Z_KEY){
728                 return 'z';
729         }
730         if(which==MAC_NUMPAD_1_KEY){
731                 return '1';
732         }
733         if(which==MAC_NUMPAD_2_KEY){
734                 return '2';
735         }
736         if(which==MAC_NUMPAD_3_KEY){
737                 return '3';
738         }
739         if(which==MAC_NUMPAD_4_KEY){
740                 return '4';
741         }
742         if(which==MAC_NUMPAD_5_KEY){
743                 return '5';
744         }
745         if(which==MAC_NUMPAD_6_KEY){
746                 return '6';
747         }
748         if(which==MAC_NUMPAD_7_KEY){
749                 return '7';
750         }
751         if(which==MAC_NUMPAD_8_KEY){
752                 return '8';
753         }
754         if(which==MAC_NUMPAD_9_KEY){
755                 return '9';
756         }
757         if(which==MAC_NUMPAD_0_KEY){
758                 return '0';
759         }
760         if(which==MAC_1_KEY){
761                 return '1';
762         }
763         if(which==MAC_2_KEY){
764                 return '2';
765         }
766         if(which==MAC_3_KEY){
767                 return '3';
768         }
769         if(which==MAC_4_KEY){
770                 return '4';
771         }
772         if(which==MAC_5_KEY){
773                 return '5';
774         }
775         if(which==MAC_6_KEY){
776                 return '6';
777         }
778         if(which==MAC_7_KEY){
779                 return '7';
780         }
781         if(which==MAC_8_KEY){
782                 return '8';
783         }
784         if(which==MAC_9_KEY){
785                 return '9';
786         }
787         if(which==MAC_0_KEY){
788                 return '0';
789         }
790         if(which==MAC_SPACE_KEY){
791                 return ' ';
792         }
793         if(which==MAC_MINUS_KEY||which==MAC_NUMPAD_MINUS_KEY){
794                 return '-';
795         }
796         if(which==MAC_PLUS_KEY||which==MAC_NUMPAD_EQUALS_KEY){
797                 return '=';
798         }
799         if(which==MAC_NUMPAD_PLUS_KEY){
800                 return '+';
801         }
802         if(which==MAC_NUMPAD_ASTERISK_KEY){
803                 return '*';
804         }
805         if(which==MAC_SLASH_KEY||which==MAC_NUMPAD_SLASH_KEY){
806                 return '/';
807         }
808         if(which==MAC_BACKSLASH_KEY){
809                 return '\\';
810         }
811         if(which==MAC_LEFTBRACKET_KEY){
812                 return '[';
813         }
814         if(which==MAC_RIGHTBRACKET_KEY){
815                 return ']';
816         }
817         if(which==MAC_PERIOD_KEY||which==MAC_NUMPAD_PERIOD_KEY){
818                 return '.';
819         }
820         if(which==MAC_COMMA_KEY){
821                 return ',';
822         }
823         if(which==MAC_APOSTROPHE_KEY){
824                 return '\'';
825         }
826         if(which==MAC_SEMICOLON_KEY){
827                 return ';';
828         }
829         return '\0';
830 }
831
832 char    Shift(char which)
833 {
834         static int i;
835
836         if(which=='a'){
837                 return 'A';
838         }
839         if(which=='b'){
840                 return 'B';
841         }
842         if(which=='c'){
843                 return 'C';
844         }
845         if(which=='d'){
846                 return 'D';
847         }
848         if(which=='e'){
849                 return 'E';
850         }
851         if(which=='f'){
852                 return 'F';
853         }
854         if(which=='g'){
855                 return 'G';
856         }
857         if(which=='h'){
858                 return 'H';
859         }
860         if(which=='e'){
861                 return 'E';
862         }
863         if(which=='f'){
864                 return 'F';
865         }
866         if(which=='g'){
867                 return 'G';
868         }
869         if(which=='h'){
870                 return 'H';
871         }
872         if(which=='i'){
873                 return 'I';
874         }
875         if(which=='j'){
876                 return 'J';
877         }
878         if(which=='k'){
879                 return 'K';
880         }
881         if(which=='l'){
882                 return 'L';
883         }
884         if(which=='m'){
885                 return 'M';
886         }
887         if(which=='n'){
888                 return 'N';
889         }
890         if(which=='o'){
891                 return 'O';
892         }
893         if(which=='p'){
894                 return 'P';
895         }
896         if(which=='q'){
897                 return 'Q';
898         }
899         if(which=='r'){
900                 return 'R';
901         }
902         if(which=='s'){
903                 return 'S';
904         }
905         if(which=='t'){
906                 return 'T';
907         }
908         if(which=='u'){
909                 return 'U';
910         }
911         if(which=='v'){
912                 return 'V';
913         }
914         if(which=='w'){
915                 return 'W';
916         }
917         if(which=='x'){
918                 return 'X';
919         }
920         if(which=='y'){
921                 return 'Y';
922         }
923         if(which=='z'){
924                 return 'Z';
925         }
926         if(which=='1'){
927                 return '!';
928         }
929         if(which=='2'){
930                 return '@';
931         }
932         if(which=='3'){
933                 return '#';
934         }
935         if(which=='4'){
936                 return '$';
937         }
938         if(which=='5'){
939                 return '%';
940         }
941         if(which=='6'){
942                 return '^';
943         }
944         if(which=='7'){
945                 return '&';
946         }
947         if(which=='8'){
948                 return '*';
949         }
950         if(which=='9'){
951                 return '(';
952         }
953         if(which=='0'){
954                 return ')';
955         }
956         if(which=='-'){
957                 return '_';
958         }
959         if(which=='='){
960                 return '+';
961         }
962         if(which=='['){
963                 return '{';
964         }
965         if(which==']'){
966                 return '}';
967         }
968         if(which=='\\'){
969                 return '|';
970         }
971         if(which=='.'){
972                 return '>';
973         }
974         if(which==','){
975                 return '<';
976         }
977         if(which=='/'){
978                 return '?';
979         }
980         if(which==';'){
981                 return ':';
982         }
983         if(which=='\''){
984                 return '\"';
985         }
986         return which;
987 }
988
989 bool    Compare(char *thestring, char *tocompare, int start, int end)
990 {
991         static int i;
992         for(i=start;i<=end;i++){
993                 if(thestring[i]!=tocompare[i-start]&&thestring[i]!=tocompare[i-start]+'A'-'a')return 0;
994         }
995         return 1;
996 }