-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.c
2136 lines (1927 loc) · 60.4 KB
/
config.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <stdio.h>
#include "typedefs.h"
#include <dplay.h>
#include "new3d.h"
#include "quat.h"
#include "CompObjects.h"
#include "bgobjects.h"
#include "Object.h"
#include "mydplay.h"
#include "controls.h"
#define WIN32_EXTRA_LEAN
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <memory.h>
#include <string.h>
#include "dinput.h"
#include "models.h"
#include "mxaload.h"
#include "config.h"
#include "force.h"
#include "XMem.h"
extern int Num_Joysticks;
extern LIST BikeList;
extern LIST BikeComputer;
extern JOYSTICKINFO JoystickInfo[MAX_JOYSTICKS];
extern TEXT MacroText1;
extern TEXT MacroText2;
extern TEXT MacroText3;
extern LIST BikeComputerList;
void DebugPrintf( const char * format, ... );
#if 1
extern int total_malloced;
extern void *mem;
extern BOOL CD_OK;
#if 0
#define X_malloc( THINGAMAJIG )\
( DebugPrintf( "malloc( %s ) total_malloced = %d address %X\n", #THINGAMAJIG, ++total_malloced , (int) (mem = malloc( THINGAMAJIG ) ) ), mem)
#define X_free( THINGAMAJIG ) \
( DebugPrintf( "address %X free( %s ) total_malloced = %d\n", (int)THINGAMAJIG, #THINGAMAJIG, --total_malloced ), free( THINGAMAJIG ) )
#endif
#endif
extern void ConfigureSpaceorbAxis( int joystick );
typedef int (*ReadConfig)( FILE *, USERCONFIG *, char * );
typedef struct {
char *keyword;
ReadConfig handle;
} READCONFIGTABLE;
extern char *JoystickPOVDirections[];
USERCONFIG default_config = {
"Player", // player name
1, // bike (1=Beard)
#ifdef WIN98SHAREWARE
0, // bike computer ( 0 = Brenda )
#else
1, // bike computer ( 1 = Brenda )
#endif
0.6F, // mouse x sensitivity
0.6F, // mouse y sensitivity
0, // pilot control (pitch forward = down, backward = up)
0, // roll control...
0.05F, // autolevel rate
// { num_keys, { key list [ num_keys ] } },
{ 2, { DIK_UP, DIK_NUMPAD8 } }, // pitch forward
{ 2, { DIK_DOWN, DIK_NUMPAD2 } }, // pitch backward
{ 2, { DIK_LEFT, DIK_NUMPAD4 } }, // yaw left
{ 2, { DIK_RIGHT, DIK_NUMPAD6 } }, // yaw right
{ 2, { DIK_Q, DIK_NUMPAD7 } }, // roll left
{ 2, { DIK_E, DIK_NUMPAD9 } }, // roll right
{ 1, { DIK_NUMPAD1 } }, // slide left
{ 1, { DIK_NUMPAD3 } }, // slide right
{ 1, { DIK_SUBTRACT } }, // slide up
{ 1, { DIK_ADD } }, // slide down
{ 1, { DIK_A } }, // forward
{ 1, { DIK_Z } }, // backward
{ 1, { DIK_LMENU } }, // slide
{ 0 }, // roll
{ 1, { DIK_S } }, // turbo
{ 0 }, // cruise faster
{ 0 }, // cruise slower
{ 2, { DIK_LBUTTON, DIK_LCONTROL } }, // fire primary
{ 2, { DIK_RBUTTON, DIK_SPACE } }, // fire secondary
{ 1, { DIK_B } }, // fire mine
{ 1, { DIK_NEXT } }, // select next primary
{ 1, { DIK_PRIOR } }, // select prev primary
{ 1, { DIK_HOME } }, // select next secondary
{ 1, { DIK_END } }, // select prev secondary
{ 1, { DIK_R } }, // select rear view
{ 1, { DIK_H } }, // toggle headlights
{
{ 1, { DIK_GRAVE } }, // select primary #1
{ 1, { DIK_1 } }, // select primary #2
{ 1, { DIK_4 } }, // select primary #3
{ 1, { DIK_3 } }, // select primary #4
{ 1, { DIK_2 } }, // select primary #5
{ 1, { DIK_5 } }, // select primary #6
},
{
{ 1, { DIK_6 } }, // select secondary #1
{ 1, { DIK_7 } }, // select secondary #2
{ 0 }, // select secondary #3 (thief missile -- not used)
{ 1, { DIK_8 } }, // select secondary #4
{ 1, { DIK_9 } }, // select secondary #5
{ 1, { DIK_0 } }, // select secondary #6
{ 1, { DIK_MINUS } }, // select secondary #7
{ 1, { DIK_Y } }, // select secondary #8
{ 1, { DIK_U } }, // select secondary #9
{ 1, { DIK_I } }, // select secondary #10
{ 0 }, // select secondary #11 (spider mine -- not used)
},
{ 0 }, // drop primary
{ 0 }, // drop secondary
{ 0 }, // drop shield
{ 0 }, // drop ammo
{ 1, { DIK_RETURN } }, // send text message
#ifdef PLAYER_SPEECH_TAUNTS
{ 0 }, // send speech taunt
#endif
// weapon selection priorities and orders
{
5, // primary #1 priority
2, // primary #2 priority
3, // primary #3 priority
4, // primary #4 priority
1, // primary #5 priority
0, // primary #6 priority
},
{
5, // primary order #1
4, // primary order #2
1, // primary order #3
2, // primary order #4
3, // primary order #5
0, // primary order #6
},
{
6, // secondary #1 priority
5, // secondary #2 priority
-1, // secondary #3 priority
1, // secondary #4 priority
3, // secondary #5 priority
2, // secondary #6 priority
0, // secondary #7 priority
8, // secondary #8 priority
7, // secondary #9 priority
6, // secondary #10 priority
-1, // secondary #11 priority
},
{
6, // secondary order #1
3, // secondary order #2
5, // secondary order #3
4, // secondary order #4
1, // secondary order #5
0, // secondary order #6
9, // secondary order #7
8, // secondary order #8
7, // secondary order #9
-1, // secondary order #10
-1, // secondary order #11
},
"you ugly son of a bitch...", // taunt 1 ( F9 )
"Time to die...", // taunt 2 ( F10 )
"I will tear your soul apart...", // taunt 3 ( F11 )
};
USERCONFIG my_controls = {
"Player", // player name
1, // bike (1=Beard)
#ifdef WIN98SHAREWARE
0, // bike computer ( 0 = Brenda )
#else
1, // bike computer ( 1 = Brenda )
#endif
0.6F, // mouse x sensitivity
0.6F, // mouse y sensitivity
0, // pilot control (pitch forward = down, backward = up)
0, // roll control...
0.05F, // autolevel rate
// { num_keys, { key list [ num_keys ] } },
{ 2, { DIK_UP, DIK_NUMPAD8 } }, // pitch forward
{ 2, { DIK_DOWN, DIK_NUMPAD2 } }, // pitch backward
{ 2, { DIK_LEFT, DIK_NUMPAD4 } }, // yaw left
{ 2, { DIK_RIGHT, DIK_NUMPAD6 } }, // yaw right
{ 2, { DIK_Q, DIK_NUMPAD7 } }, // roll left
{ 2, { DIK_E, DIK_NUMPAD9 } }, // roll right
{ 1, { DIK_NUMPAD1 } }, // slide left
{ 1, { DIK_NUMPAD3 } }, // slide right
{ 1, { DIK_SUBTRACT } }, // slide up
{ 1, { DIK_ADD } }, // slide down
{ 1, { DIK_A } }, // forward
{ 1, { DIK_Z } }, // backward
{ 1, { DIK_LMENU } }, // slide
{ 0 }, // roll
{ 1, { DIK_S } }, // turbo
{ 0 }, // cruise faster
{ 0 }, // cruise slower
{ 2, { DIK_LBUTTON, DIK_LCONTROL } }, // fire primary
{ 2, { DIK_RBUTTON, DIK_SPACE } }, // fire secondary
{ 1, { DIK_B } }, // fire mine
{ 1, { DIK_NEXT } }, // select next primary
{ 1, { DIK_PRIOR } }, // select prev primary
{ 1, { DIK_HOME } }, // select next secondary
{ 1, { DIK_END } }, // select prev secondary
{ 1, { DIK_R } }, // select rear view
{ 1, { DIK_H } }, // toggle headlights
{
{ 1, { DIK_GRAVE } }, // select primary #1
{ 1, { DIK_1 } }, // select primary #2
{ 1, { DIK_4 } }, // select primary #3
{ 1, { DIK_3 } }, // select primary #4
{ 1, { DIK_2 } }, // select primary #5
{ 1, { DIK_5 } }, // select primary #6
},
{
{ 1, { DIK_6 } }, // select secondary #1
{ 1, { DIK_7 } }, // select secondary #2
{ 0 }, // select secondary #3 (thief missile -- not used)
{ 1, { DIK_8 } }, // select secondary #4
{ 1, { DIK_9 } }, // select secondary #5
{ 1, { DIK_0 } }, // select secondary #6
{ 1, { DIK_MINUS } }, // select secondary #7
{ 1, { DIK_Y } }, // select secondary #8
{ 1, { DIK_U } }, // select secondary #9
{ 1, { DIK_I } }, // select secondary #10
{ 0 }, // select secondary #11 (spider mine -- not used)
},
{ 0 }, // drop primary
{ 0 }, // drop secondary
{ 0 }, // drop shield
{ 0 }, // drop ammo
{ 1, { DIK_RETURN } }, // send text message
#ifdef PLAYER_SPEECH_TAUNTS
{ 0 }, // send speech taunt
#endif
// weapon selection priorities and orders
{
5, // primary #1 priority
2, // primary #2 priority
3, // primary #3 priority
4, // primary #4 priority
1, // primary #5 priority
0, // primary #6 priority
},
{
5, // primary order #1
4, // primary order #2
1, // primary order #3
2, // primary order #4
3, // primary order #5
0, // primary order #6
},
{
6, // secondary #1 priority
5, // secondary #2 priority
-1, // secondary #3 priority
1, // secondary #4 priority
3, // secondary #5 priority
2, // secondary #6 priority
0, // secondary #7 priority
8, // secondary #8 priority
7, // secondary #9 priority
6, // secondary #10 priority
-1, // secondary #11 priority
},
{
6, // secondary order #1
3, // secondary order #2
5, // secondary order #3
4, // secondary order #4
1, // secondary order #5
0, // secondary order #6
9, // secondary order #7
8, // secondary order #8
7, // secondary order #9
-1, // secondary order #10
-1, // secondary order #11
},
"you ugly son of a bitch...", // taunt 1 ( F9 )
"Time to die...", // taunt 2 ( F10 )
"I will tear your soul apart...", // taunt 3 ( F11 )
};
USERCONFIG *player_config = &my_controls;
VIRTUALKEYMAP vkey_map[] = {
{ "DIK_ESCAPE", DIK_ESCAPE },
{ "DIK_ESC", DIK_ESCAPE },
{ "DIK_1", DIK_1 },
{ "DIK_2", DIK_2 },
{ "DIK_3", DIK_3 },
{ "DIK_4", DIK_4 },
{ "DIK_5", DIK_5 },
{ "DIK_6", DIK_6 },
{ "DIK_7", DIK_7 },
{ "DIK_8", DIK_8 },
{ "DIK_9", DIK_9 },
{ "DIK_0", DIK_0 },
{ "DIK_-", DIK_MINUS }, /* - on main keyboard */
{ "DIK_MINUS", DIK_MINUS }, /* - on main keyboard */
{ "DIK_=", DIK_EQUALS },
{ "DIK_EQUALS", DIK_EQUALS },
{ "DIK_BACKSPACE", DIK_BACK }, /* backspace */
{ "DIK_BACK", DIK_BACK }, /* backspace */
{ "DIK_TAB", DIK_TAB },
{ "DIK_Q", DIK_Q },
{ "DIK_W", DIK_W },
{ "DIK_E", DIK_E },
{ "DIK_R", DIK_R },
{ "DIK_T", DIK_T },
{ "DIK_Y", DIK_Y },
{ "DIK_U", DIK_U },
{ "DIK_I", DIK_I },
{ "DIK_O", DIK_O },
{ "DIK_P", DIK_P },
{ "DIK_[", DIK_LBRACKET },
{ "DIK_LBRACKET", DIK_LBRACKET },
{ "DIK_]", DIK_RBRACKET },
{ "DIK_RBRACKET", DIK_RBRACKET },
{ "DIK_ENTER", DIK_RETURN }, /* Enter on main keyboard */
{ "DIK_RETURN", DIK_RETURN }, /* Enter on main keyboard */
{ "DIK_LEFT_CONTROL", DIK_LCONTROL },
{ "DIK_LCTRL", DIK_LCONTROL },
{ "DIK_LCONTROL", DIK_LCONTROL },
{ "DIK_A", DIK_A },
{ "DIK_S", DIK_S },
{ "DIK_D", DIK_D },
{ "DIK_F", DIK_F },
{ "DIK_G", DIK_G },
{ "DIK_H", DIK_H },
{ "DIK_J", DIK_J },
{ "DIK_K", DIK_K },
{ "DIK_L", DIK_L },
{ "DIK_;", DIK_SEMICOLON },
{ "DIK_SEMICOLON", DIK_SEMICOLON },
{ "DIK_'", DIK_APOSTROPHE },
{ "DIK_APOSTROPHE", DIK_APOSTROPHE },
{ "DIK_GRAVE", DIK_GRAVE }, /* accent grave */
{ "DIK_LEFT_SHIFT", DIK_LSHIFT },
{ "DIK_LSHFT", DIK_LSHIFT },
{ "DIK_LSHIFT", DIK_LSHIFT },
{ "DIK_BACKSLASH", DIK_BACKSLASH },
{ "DIK_BACK/", DIK_BACKSLASH },
{ "DIK_Z", DIK_Z },
{ "DIK_X", DIK_X },
{ "DIK_C", DIK_C },
{ "DIK_V", DIK_V },
{ "DIK_B", DIK_B },
{ "DIK_N", DIK_N },
{ "DIK_M", DIK_M },
{ "DIK_,", DIK_COMMA },
{ "DIK_COMMA", DIK_COMMA },
{ "DIK_.", DIK_PERIOD }, /* . on main keyboard */
{ "DIK_PERIOD", DIK_PERIOD }, /* . on main keyboard */
{ "DIK_/", DIK_SLASH }, /* / on main keyboard */
{ "DIK_SLASH", DIK_SLASH }, /* / on main keyboard */
{ "DIK_RIGHT_SHIFT", DIK_RSHIFT },
{ "DIK_RSHFT", DIK_RSHIFT },
{ "DIK_RSHIFT", DIK_RSHIFT },
{ "DIK_NUMPAD_*", DIK_MULTIPLY }, /* * on numeric keypad */
{ "DIK_NUM*", DIK_MULTIPLY }, /* * on numeric keypad */
{ "DIK_MULTIPLY", DIK_MULTIPLY }, /* * on numeric keypad */
{ "DIK_LEFT_ALT", DIK_LMENU }, /* left Alt */
{ "DIK_LALT", DIK_LMENU }, /* left Alt */
{ "DIK_LMENU", DIK_LMENU }, /* left Alt */
{ "DIK_SPACE", DIK_SPACE },
{ "DIK_ ", DIK_SPACE },
{ "DIK_CAPS_LOCK", DIK_CAPITAL },
{ "DIK_CAPS", DIK_CAPITAL },
{ "DIK_CAPITAL", DIK_CAPITAL },
{ "DIK_F1", DIK_F1 },
{ "DIK_F2", DIK_F2 },
{ "DIK_F3", DIK_F3 },
{ "DIK_F4", DIK_F4 },
{ "DIK_F5", DIK_F5 },
{ "DIK_F6", DIK_F6 },
{ "DIK_F7", DIK_F7 },
{ "DIK_F8", DIK_F8 },
{ "DIK_F9", DIK_F9 },
{ "DIK_F10", DIK_F10 },
{ "DIK_NUM_LOCK", DIK_NUMLOCK },
{ "DIK_NUMLK", DIK_NUMLOCK },
{ "DIK_NUMLOCK", DIK_NUMLOCK },
{ "DIK_SCROLL_LOCK", DIK_SCROLL }, /* Scroll Lock */
{ "DIK_SCRLL", DIK_SCROLL }, /* Scroll Lock */
{ "DIK_SCROLL", DIK_SCROLL }, /* Scroll Lock */
{ "DIK_NUMPAD_7", DIK_NUMPAD7 },
{ "DIK_NUM7", DIK_NUMPAD7 },
{ "DIK_NUMPAD_8", DIK_NUMPAD8 },
{ "DIK_NUM8", DIK_NUMPAD8 },
{ "DIK_NUMPAD_9", DIK_NUMPAD9 },
{ "DIK_NUM9", DIK_NUMPAD9 },
{ "DIK_NUMPAD_-", DIK_SUBTRACT }, /* - on numeric keypad */
{ "DIK_NUM-", DIK_SUBTRACT }, /* - on numeric keypad */
{ "DIK_SUBTRACT", DIK_SUBTRACT }, /* - on numeric keypad */
{ "DIK_NUMPAD_4", DIK_NUMPAD4 },
{ "DIK_NUM4", DIK_NUMPAD4 },
{ "DIK_NUMPAD_5", DIK_NUMPAD5 },
{ "DIK_NUM5", DIK_NUMPAD5 },
{ "DIK_NUMPAD_6", DIK_NUMPAD6 },
{ "DIK_NUM6", DIK_NUMPAD6 },
{ "DIK_NUMPAD_+", DIK_ADD }, /* + on numeric keypad */
{ "DIK_NUM+", DIK_ADD }, /* + on numeric keypad */
{ "DIK_ADD", DIK_ADD }, /* + on numeric keypad */
{ "DIK_NUMPAD_1", DIK_NUMPAD1 },
{ "DIK_NUM1", DIK_NUMPAD1 },
{ "DIK_NUMPAD_2", DIK_NUMPAD2 },
{ "DIK_NUM2", DIK_NUMPAD2 },
{ "DIK_NUMPAD_3", DIK_NUMPAD3 },
{ "DIK_NUM3", DIK_NUMPAD3 },
{ "DIK_NUMPAD_0", DIK_NUMPAD0 },
{ "DIK_NUM0", DIK_NUMPAD0 },
{ "DIK_NUMPAD_.", DIK_DECIMAL }, /* . on numeric keypad */
{ "DIK_NUM.", DIK_DECIMAL }, /* . on numeric keypad */
{ "DIK_DECIMAL", DIK_DECIMAL }, /* . on numeric keypad */
{ "DIK_F11", DIK_F11 },
{ "DIK_F12", DIK_F12 },
{ "DIK_F13", DIK_F13 }, /* (NEC PC98) */
{ "DIK_F14", DIK_F14 }, /* (NEC PC98) */
{ "DIK_F15", DIK_F15 }, /* (NEC PC98) */
{ "DIK_KANA", DIK_KANA }, /* (Japanese keyboard) */
{ "DIK_CONVERT", DIK_CONVERT }, /* (Japanese keyboard) */
{ "DIK_NOCONVERT", DIK_NOCONVERT }, /* (Japanese keyboard) */
{ "DIK_YEN", DIK_YEN }, /* (Japanese keyboard) */
{ "DIK_NUMPAD=", DIK_NUMPADEQUALS }, /* = on numeric keypad (NEC PC98) */
{ "DIK_NUMPADEQUALS", DIK_NUMPADEQUALS }, /* = on numeric keypad (NEC PC98) */
{ "DIK_CIRCUMFLEX", DIK_CIRCUMFLEX }, /* (Japanese keyboard) */
{ "DIK_AT", DIK_AT }, /* (NEC PC98) */
{ "DIK_COLON", DIK_COLON }, /* (NEC PC98) */
{ "DIK_UNDERLINE", DIK_UNDERLINE }, /* (NEC PC98) */
{ "DIK_KANJI", DIK_KANJI }, /* (Japanese keyboard) */
{ "DIK_STOP", DIK_STOP }, /* (NEC PC98) */
{ "DIK_AX", DIK_AX }, /* (Japan AX) */
{ "DIK_UNLABELED", DIK_UNLABELED }, /* (J3100) */
{ "DIK_NUMPAD_ENTER", DIK_NUMPADENTER }, /* Enter on numeric keypad */
{ "DIK_NUMENT", DIK_NUMPADENTER }, /* Enter on numeric keypad */
{ "DIK_RIGHT_CONTROL", DIK_RCONTROL },
{ "DIK_RCTRL", DIK_RCONTROL },
{ "DIK_RCONTROL", DIK_RCONTROL },
{ "DIK_NUMPAD_,", DIK_NUMPADCOMMA }, /* , on numeric keypad (NEC PC98) */
{ "DIK_NUM,", DIK_NUMPADCOMMA }, /* , on numeric keypad (NEC PC98) */
{ "DIK_NUMPADCOMMA", DIK_NUMPADCOMMA }, /* , on numeric keypad (NEC PC98) */
{ "DIK_NUMPAD_/", DIK_DIVIDE }, /* / on numeric keypad */
{ "DIK_NUM/", DIK_DIVIDE }, /* / on numeric keypad */
{ "DIK_DIVIDE", DIK_DIVIDE }, /* / on numeric keypad */
{ "DIK_SYSRQ", DIK_SYSRQ },
{ "DIK_RIGHT_ALT", DIK_RMENU }, /* right Alt */
{ "DIK_RALT", DIK_RMENU }, /* right Alt */
{ "DIK_RMENU", DIK_RMENU }, /* right Alt */
{ "DIK_HOME", DIK_HOME }, /* Home on arrow keypad */
{ "DIK_CURSOR_UP", DIK_UP }, /* UpArrow on arrow keypad */
{ "DIK_UP", DIK_UP }, /* UpArrow on arrow keypad */
{ "DIK_PAGE_UP", DIK_PRIOR }, /* PgUp on arrow keypad */
{ "DIK_PGUP", DIK_PRIOR }, /* PgUp on arrow keypad */
{ "DIK_PRIOR", DIK_PRIOR }, /* PgUp on arrow keypad */
{ "DIK_CURSOR_LEFT", DIK_LEFT }, /* LeftArrow on arrow keypad */
{ "DIK_LEFT", DIK_LEFT }, /* LeftArrow on arrow keypad */
{ "DIK_CURSOR_RIGHT", DIK_RIGHT }, /* RightArrow on arrow keypad */
{ "DIK_RIGHT", DIK_RIGHT }, /* RightArrow on arrow keypad */
{ "DIK_END", DIK_END }, /* End on arrow keypad */
{ "DIK_CURSOR_DOWN", DIK_DOWN }, /* DownArrow on arrow keypad */
{ "DIK_DOWN", DIK_DOWN }, /* DownArrow on arrow keypad */
{ "DIK_PAGE_DOWN", DIK_NEXT }, /* PgDn on arrow keypad */
{ "DIK_PGDN", DIK_NEXT }, /* PgDn on arrow keypad */
{ "DIK_NEXT", DIK_NEXT }, /* PgDn on arrow keypad */
{ "DIK_INSERT", DIK_INSERT }, /* Insert on arrow keypad */
{ "DIK_INS", DIK_INSERT }, /* Insert on arrow keypad */
{ "DIK_DELETE", DIK_DELETE }, /* Delete on arrow keypad */
{ "DIK_DEL", DIK_DELETE }, /* Delete on arrow keypad */
{ "DIK_LWIN", DIK_LWIN }, /* Left Windows key */
{ "DIK_RWIN", DIK_RWIN }, /* Right Windows key */
{ "DIK_APPS", DIK_APPS }, /* AppMenu key */
{ "DIK_BACKSPACE", DIK_BACK }, /* backspace */
{ "DIK_NUMPADSTAR", DIK_MULTIPLY }, /* * on numeric keypad */
{ "DIK_CAPSLOCK", DIK_CAPITAL }, /* CapsLock */
{ "DIK_NUMPADMINUS", DIK_SUBTRACT }, /* - on numeric keypad */
{ "DIK_NUMPADPLUS", DIK_ADD }, /* + on numeric keypad */
{ "DIK_NUMPADPERIOD", DIK_DECIMAL }, /* . on numeric keypad */
{ "DIK_NUMPADSLASH", DIK_DIVIDE }, /* / on numeric keypad */
{ "DIK_UPARROW", DIK_UP }, /* UpArrow on arrow keypad */
{ "DIK_LEFTARROW", DIK_LEFT }, /* LeftArrow on arrow keypad */
{ "DIK_RIGHTARROW", DIK_RIGHT }, /* RightArrow on arrow keypad */
{ "DIK_DOWNARROW", DIK_DOWN }, /* DownArrow on arrow keypad */
// my own "pseudo-DIK" codes for mouse controls
{ "DIK_MOUSE_1", DIK_LBUTTON }, // Left mouse button
{ "DIK_MB1", DIK_LBUTTON }, // Left mouse button
{ "DIK_LBUTTON", DIK_LBUTTON }, // Left mouse button
{ "DIK_MOUSE_2", DIK_RBUTTON }, // Right mouse button
{ "DIK_MB2", DIK_RBUTTON }, // Right mouse button
{ "DIK_RBUTTON", DIK_RBUTTON }, // Right mouse button
{ "DIK_MOUSE_3", DIK_MBUTTON }, // Middle mouse button
{ "DIK_MB3", DIK_MBUTTON }, // Middle mouse button
{ "DIK_MBUTTON", DIK_MBUTTON }, // Middle mouse button
{ "DIK_MOUSE_4", DIK_MBUTTON }, // Middle mouse button
{ "DIK_MB4", DIK_MBUTTON }, // Middle mouse button
{ "DIK_TBUTTON", DIK_MBUTTON }, // Middle mouse button
{ "DIK_WHEEL_UP", DIK_WHEELUP }, // Mouse wheel up
{ "DIK_MWUP", DIK_WHEELUP }, // Mouse wheel up
{ "DIK_WHEELUP", DIK_WHEELUP }, // Mouse wheel up
{ "DIK_WHEEL_DOWN", DIK_WHEELDOWN }, // Mouse wheel down
{ "DIK_MWDN", DIK_WHEELDOWN }, // Mouse wheel down
{ "DIK_WHEELDOWN", DIK_WHEELDOWN }, // Mouse wheel down
// virtual keycodes retained from original for compatibility
{ "VK_LBUTTON", DIK_LBUTTON }, // Left mouse button
{ "VK_RBUTTON", DIK_RBUTTON }, // Right mouse button
// { "VK_CANCEL", DIK_CANCEL }, // Control-break processing
{ "VK_MBUTTON", DIK_MBUTTON }, // Middle mouse button (three-button mouse)
{ "VK_BACK", DIK_BACK }, // BACKSPACE key
{ "VK_TAB", DIK_TAB }, // TAB key
// { "VK_CLEAR", DIK_CLEAR }, // CLEAR key
{ "VK_RETURN", DIK_RETURN }, // ENTER key
{ "VK_SHIFT", DIK_LSHIFT }, // SHIFT key *** defaults to LEFT SHIFT
{ "VK_CONTROL", DIK_LCONTROL }, // CTRL key *** defaults to LEFT CONTROL
{ "VK_MENU", DIK_LMENU }, // ALT key **** defaults to LEFT ALT
// { "VK_PAUSE", DIK_PAUSE }, // PAUSE key
{ "VK_CAPITAL", DIK_CAPITAL }, // CAPS LOCK key
{ "VK_ESCAPE", DIK_ESCAPE }, // ESC key
{ "VK_SPACE", DIK_SPACE }, // SPACEBAR
{ "VK_PRIOR", DIK_PRIOR }, // PAGE UP key
{ "VK_NEXT", DIK_NEXT }, // PAGE DOWN key
{ "VK_END", DIK_END }, // END key
{ "VK_HOME", DIK_HOME }, // HOME key
{ "VK_LEFT", DIK_LEFT }, // LEFT ARROW key
{ "VK_UP", DIK_UP }, // UP ARROW key
{ "VK_RIGHT", DIK_RIGHT }, // RIGHT ARROW key
{ "VK_DOWN", DIK_DOWN }, // DOWN ARROW key
// { "VK_SELECT", DIK_SELECT }, // SELECT key
// { "VK_EXECUTE", DIK_EXECUTE }, // EXECUTE key
// { "VK_SNAPSHOT", DIK_SNAPSHOT }, // PRINT SCREEN key for Windows 3.0 and later
{ "VK_INSERT", DIK_INSERT }, // INS key
{ "VK_DELETE", DIK_DELETE }, // DEL key
// { "VK_HELP", DIK_HELP }, // HELP key
{ "VK_0", DIK_0 }, // 0 key
{ "VK_1", DIK_1 }, // 1 key
{ "VK_2", DIK_2 }, // 2 key
{ "VK_3", DIK_3 }, // 3 key
{ "VK_4", DIK_4 }, // 4 key
{ "VK_5", DIK_5 }, // 5 key
{ "VK_6", DIK_6 }, // 6 key
{ "VK_7", DIK_7 }, // 7 key
{ "VK_8", DIK_8 }, // 8 key
{ "VK_9", DIK_9 }, // 9 key
{ "VK_A", DIK_A }, // A key
{ "VK_B", DIK_B }, // B key
{ "VK_C", DIK_C }, // C key
{ "VK_D", DIK_D }, // D key
{ "VK_E", DIK_E }, // E key
{ "VK_F", DIK_F }, // F key
{ "VK_G", DIK_G }, // G key
{ "VK_H", DIK_H }, // H key
{ "VK_I", DIK_I }, // I key
{ "VK_J", DIK_J }, // J key
{ "VK_K", DIK_K }, // K key
{ "VK_L", DIK_L }, // L key
{ "VK_M", DIK_M }, // M key
{ "VK_N", DIK_N }, // N key
{ "VK_O", DIK_O }, // O key
{ "VK_P", DIK_P }, // P key
{ "VK_Q", DIK_Q }, // Q key
{ "VK_R", DIK_R }, // R key
{ "VK_S", DIK_S }, // S key
{ "VK_T", DIK_T }, // T key
{ "VK_U", DIK_U }, // U key
{ "VK_V", DIK_V }, // V key
{ "VK_W", DIK_W }, // W key
{ "VK_X", DIK_X }, // X key
{ "VK_Y", DIK_Y }, // Y key
{ "VK_Z", DIK_Z }, // Z key
{ "VK_NUMPAD0", DIK_NUMPAD0 }, // Numeric keypad 0 key
{ "VK_NUMPAD1", DIK_NUMPAD1 }, // Numeric keypad 1 key
{ "VK_NUMPAD2", DIK_NUMPAD2 }, // Numeric keypad 2 key
{ "VK_NUMPAD3", DIK_NUMPAD3 }, // Numeric keypad 3 key
{ "VK_NUMPAD4", DIK_NUMPAD4 }, // Numeric keypad 4 key
{ "VK_NUMPAD5", DIK_NUMPAD5 }, // Numeric keypad 5 key
{ "VK_NUMPAD6", DIK_NUMPAD6 }, // Numeric keypad 6 key
{ "VK_NUMPAD7", DIK_NUMPAD7 }, // Numeric keypad 7 key
{ "VK_NUMPAD8", DIK_NUMPAD8 }, // Numeric keypad 8 key
{ "VK_NUMPAD9", DIK_NUMPAD9 }, // Numeric keypad 9 key
{ "VK_MULTIPLY", DIK_MULTIPLY }, // Multiply key
{ "VK_ADD", DIK_ADD }, // Add key
// { "VK_SEPARATOR", DIK_SEPARATOR }, // Separator key
{ "VK_SUBTRACT", DIK_SUBTRACT }, // Subtract key
{ "VK_DECIMAL", DIK_DECIMAL }, // Decimal key
{ "VK_DIVIDE", DIK_DIVIDE }, // Divide key
{ "VK_F1", DIK_F1 }, // F1 key
{ "VK_F2", DIK_F2 }, // F2 key
{ "VK_F3", DIK_F3 }, // F3 key
{ "VK_F4", DIK_F4 }, // F4 key
{ "VK_F5", DIK_F5 }, // F5 key
{ "VK_F6", DIK_F6 }, // F6 key
{ "VK_F7", DIK_F7 }, // F7 key
{ "VK_F8", DIK_F8 }, // F8 key
{ "VK_F9", DIK_F9 }, // F9 key
{ "VK_F10", DIK_F10 }, // F10 key
{ "VK_F11", DIK_F11 }, // F11 key
{ "VK_F12", DIK_F12 }, // F12 key
{ "VK_F13", DIK_F13 }, // F13 key
{ "VK_F14", DIK_F14 }, // F14 key
{ "VK_F15", DIK_F15 }, // F15 key
// { "VK_F16", DIK_F16 }, // F16 key
// { "VK_F17", DIK_F17 }, // F17 key
// { "VK_F18", DIK_F18 }, // F18 key
// { "VK_F19", DIK_F19 }, // F19 key
// { "VK_F20", DIK_F20 }, // F20 key
// { "VK_F21", DIK_F21 }, // F21 key
// { "VK_F22", DIK_F22 }, // F22 key
// { "VK_F23", DIK_F23 }, // F23 key
// { "VK_F24", DIK_F24 }, // F24 key
{ "VK_NUMLOCK", DIK_NUMLOCK }, // NUM LOCK key
{ "VK_SCROLL", DIK_SCROLL }, // SCROLL LOCK key
{ NULL, 0x00 } // (end of table marker)
};
/* read user defined controls from config file */
static int
read_keydef( FILE *f, USERKEY *k, char *last_token )
{
USERKEY save_key;
VIRTUALKEYMAP *vk;
int j;
int keys_defined;
keys_defined = 0;
for ( j = 0; j < MAX_KEYS_PER_CONTROL; j++ )
{
save_key.key[ j ] = k->key[ j ]; // save old definition in case of failure
k->key[ j ] = 0; // clear any existing key definitions
}
while ( fscanf( f, " %80s", last_token ) == 1 )
{
for ( vk = vkey_map; vk->keyword; vk++ )
{
if ( !_stricmp( last_token, vk->keyword ) )
break;
}
if ( vk->keyword )
{
for ( j = 0; j < MAX_KEYS_PER_CONTROL; j++ )
{
if ( !k->key[ j ] )
{
k->key[ j ] = vk->keycode;
keys_defined++;
break;
}
}
}
else
break;
}
if ( keys_defined )
{
k->keys = keys_defined;
}
else
{
for ( j = 0; j < MAX_KEYS_PER_CONTROL; j++ )
k->key[ j ] = save_key.key[ j ];
}
return keys_defined;
}
static int
read_keydef_indexed( FILE *f, USERKEY *k, char *last_token, int max_index )
{
int index;
if ( fscanf( f, " %d", &index ) == 1 && index > 0 && index <= max_index )
return read_keydef( f, k + index - 1, last_token );
else
return 0;
}
static int
read_up( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->up, last_token );
}
static int
read_down( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->down, last_token );
}
static int
read_left( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->left, last_token );
}
static int
read_right( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->right, last_token );
}
static int
read_forward( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->move_forward, last_token );
}
static int
read_backward( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->move_backward, last_token );
}
static int
read_cruise_faster( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->cruise_faster, last_token );
}
static int
read_cruise_slower( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->cruise_slower, last_token );
}
static int
read_roll_left( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->roll_left, last_token );
}
static int
read_roll_right( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->roll_right, last_token );
}
static int
read_move_left( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->move_left, last_token );
}
static int
read_move_right( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->move_right, last_token );
}
static int
read_move_up( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->move_up, last_token );
}
static int
read_move_down( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->move_down, last_token );
}
static int
read_move( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->move, last_token );
}
static int
read_roll( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->roll, last_token );
}
static int
read_turbo( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->turbo, last_token );
}
static int
read_fire_primary( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->fire_primary, last_token );
}
static int
read_fire_secondary( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->fire_secondary, last_token );
}
static int
read_fire_mine( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->fire_mine, last_token );
}
static int
read_select_next_primary( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->select_next_primary, last_token );
}
static int
read_select_prev_primary( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->select_prev_primary, last_token );
}
static int
read_select_primary( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef_indexed( f, &u->select_primary[ 0 ], last_token, MAX_PRIMARY_WEAPONS );
}
static int
read_select_next_secondary( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->select_next_secondary, last_token );
}
static int
read_select_prev_secondary( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->select_prev_secondary, last_token );
}
static int
read_select_secondary( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef_indexed( f, &u->select_secondary[ 0 ], last_token, MAX_SECONDARY_WEAPONS );
}
static int
read_drop_primary( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->drop_primary, last_token );
}
static int
read_drop_secondary( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->drop_secondary, last_token );
}
static int
read_drop_shield( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->drop_shield, last_token );
}
static int
read_drop_ammo( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->drop_ammo, last_token );
}
static int
read_send_text( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->send_msg, last_token );
}
#ifdef PLAYER_SPEECH_TAUNTS
static int
read_send_speech( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->send_speech, last_token );
}
#endif
static int
read_full_rearview( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->full_rear_view, last_token );
}
static int
read_headlights( FILE *f, USERCONFIG *u, char *last_token )
{
return read_keydef( f, &u->headlights, last_token );
}
static int
read_general_macro( FILE *f, char *config_macro, char *last_token, TEXT *macro )
{
char tempstr[ MAXTEXTMSG ];
static char fmt[80];
sprintf( fmt, " %%%d[^\n]", MAXTEXTMSG );
fscanf( f, fmt, tempstr );
strncpy( config_macro, tempstr, MAXTEXTMSG );
strncpy( macro->text, tempstr, MAXTEXTMSG );
fscanf( f, " %80s", last_token );
return 1;
}
static int
read_macro1( FILE *f, USERCONFIG *u, char *last_token )
{
read_general_macro( f, u->macro1, last_token, &MacroText1 );
return 1;
}
static int
read_macro2( FILE *f, USERCONFIG *u, char *last_token )
{
read_general_macro( f, u->macro2, last_token, &MacroText2 );
return 1;
}
static int
read_macro3( FILE *f, USERCONFIG *u, char *last_token )
{
read_general_macro( f, u->macro3, last_token, &MacroText3 );
return 1;
}
static int
read_mouse_sensitivity( FILE *f, USERCONFIG *u, char *last_token )
{
float s1, s2;
int num_read;
switch ( fscanf( f, " %f %f", &s1, &s2 ) )
{
case 1:
u->mouse_x_sensitivity = s1;
u->mouse_y_sensitivity = s1;
num_read = 1;
break;
case 2:
u->mouse_x_sensitivity = s1;
u->mouse_y_sensitivity = s2;
num_read = 2;
break;
default:
num_read = 0;
break;
}
fscanf( f, " %80s", last_token );
return num_read;
}
static int
read_name( FILE *f, USERCONFIG *u, char *last_token )
{
char namebuf[80];
int ok;
ok = fscanf( f, " %80s", namebuf );
fscanf( f, " %80s", last_token );
if ( ok == 1 )
{
strncpy( u->name, namebuf, MAX_PLAYER_NAME_LENGTH );
u->name[ MAX_PLAYER_NAME_LENGTH - 1 ] = 0;
return 1;
}
else
return 0;
}
uint32 EncodePlayerName( char *name )
{
uint32 code, temp;
uint8 i;
code = 0;
for ( i = 0; i < strlen( name ); i++ )
{