]> icculus.org git repositories - btb/d2x.git/blob - arch/dos/joydefs.c
moved includes to include
[btb/d2x.git] / arch / dos / joydefs.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-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14 /*
15  * $Source: /cvs/cvsroot/d2x/arch/dos/joydefs.c,v $
16  * $Revision: 1.3 $
17  * $Author: bradleyb $
18  * $Date: 2001-10-24 09:25:05 $
19  * 
20  * .
21  * 
22  * $Log: not supported by cvs2svn $
23  * Revision 1.2  2001/01/29 14:03:57  bradleyb
24  * Fixed build, minor fixes
25  *
26  * Revision 1.1.1.2  2001/01/19 03:33:52  bradleyb
27  * Import of d2x-0.0.9-pre1
28  *
29  * Revision 1.1.1.1  1999/06/14 21:58:29  donut
30  * Import of d1x 1.37 source.
31  *
32  * Revision 2.2  1995/06/30  12:30:22  john
33  * Added -Xname command line.
34  * 
35  * Revision 2.1  1995/04/06  12:13:20  john
36  * Made so you can calibrate Gravis Gamepad.
37  * 
38  * Revision 2.0  1995/02/27  11:30:27  john
39  * New version 2.0, which has no anonymous unions, builds with
40  * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
41  * 
42  * Revision 1.71  1995/02/12  02:06:10  john
43  * Fixed bug with joystick incorrectly asking for
44  * calibration.
45  * 
46  * Revision 1.70  1995/01/28  15:58:07  john
47  * Made joystick calibration be only when wrong detected in
48  * menu or joystick axis changed.
49  * 
50  * Revision 1.69  1995/01/25  14:37:55  john
51  * Made joystick only prompt for calibration once...
52  * 
53  * Revision 1.68  1995/01/24  16:34:29  john
54  * Made so that if you reconfigure joystick and
55  * add or subtract an axis, it asks for a recalibration
56  * upon leaving.
57  * 
58  * Revision 1.67  1994/12/29  11:08:51  john
59  * Fixed Thrustmaster and Logitech Wingman extreme
60  * Hat by reading the y2 axis during the center stage
61  * of the calibration, and using 75, 50, 27, and 3 %
62  * as values for the 4 positions.
63  * 
64  * Revision 1.66  1994/12/15  18:17:39  john
65  * Fixed warning with previous.
66  * 
67  * Revision 1.65  1994/12/15  18:15:48  john
68  * Made the joy cal only write the .cfg file, not
69  * the player file.
70  * 
71  * Revision 1.64  1994/12/13  14:43:35  john
72  * Took out the code in kconfig to build direction array.
73  * Called kc_set_controls after selecting a new control type.
74  * 
75  * Revision 1.63  1994/12/10  12:08:47  john
76  * Changed some delays to use TICKER instead of timer_get_fixed_seconds.
77  * 
78  * Revision 1.62  1994/12/09  11:01:07  mike
79  * force calibration of joystick on joystick selection from Controls... menu.
80  * 
81  * Revision 1.61  1994/12/07  21:50:27  john
82  * Put stop/start time around joystick delay.
83  * 
84  * Revision 1.60  1994/12/07  19:34:39  john
85  * Added delay.
86  * 
87  * Revision 1.59  1994/12/07  18:12:14  john
88  * NEatened up joy cal.,
89  * 
90  * Revision 1.58  1994/12/07  17:07:51  john
91  * Fixed up joy cal.
92  * 
93  * Revision 1.57  1994/12/07  16:48:53  yuan
94  * localization
95  * 
96  * Revision 1.56  1994/12/07  16:05:55  john
97  * Changed the way joystick calibration works.
98  * 
99  * Revision 1.55  1994/12/06  20:15:22  john
100  * Took out code that unpauses songs that were never paused.
101  * 
102  * Revision 1.54  1994/12/06  15:14:09  yuan
103  * Localization
104  * 
105  * Revision 1.53  1994/12/05  16:29:16  john
106  * Took out music pause around the cheat menu.
107  * 
108  * Revision 1.52  1994/12/04  12:39:10  john
109  * MAde so that FCS calibration doesn't ask for axis #2.
110  * 
111  * Revision 1.51  1994/12/03  15:14:59  john
112  * Took out the delay mentioned previosuly cause it would
113  * cause bigger problems than it helps, especially with netgames.
114  * 
115  * Revision 1.50  1994/12/03  14:16:14  john
116  * Put a delay between screens in joy cal to keep Yuan from
117  * double hitting.
118  * 
119  * Revision 1.49  1994/12/03  11:04:06  john
120  * Changed newmenu code a bit to fix bug with bogus
121  * backgrounds occcasionally.
122  * 
123  * Revision 1.48  1994/12/02  11:03:44  yuan
124  * Localization.
125  * 
126  * Revision 1.47  1994/12/02  10:50:33  yuan
127  * Localization
128  * 
129  * Revision 1.46  1994/12/01  12:21:59  john
130  * Added code to calibrate 2 joysticks separately.
131  * 
132  * Revision 1.45  1994/12/01  11:52:31  john
133  * Added message when you select FCS to say that if
134  * you have WCS, see manuel.
135  * 
136  * Revision 1.44  1994/11/29  02:26:28  john
137  * Made the prompts for upper-left, lower right for joy
138  * calibration more obvious.
139  * 
140  * Revision 1.43  1994/11/26  13:13:59  matt
141  * Changed "none" option to "keyboard only"
142  * 
143  * Revision 1.42  1994/11/21  19:35:13  john
144  * Replaced calls to joy_init with if (joy_present)
145  * 
146  * Revision 1.41  1994/11/21  19:28:34  john
147  * Changed warning for no joystick to use nm_messagebox..
148  * 
149  * Revision 1.40  1994/11/21  19:06:25  john
150  * Made it so that it only stops sound when your in game mode. 
151  * 
152  * Revision 1.39  1994/11/21  11:47:18  john
153  * Made sound pause during joystick calibration.
154  * 
155  * Revision 1.38  1994/11/10  20:34:18  rob
156  * Removed menu-specific network mode support in favor in new stuff
157  * in newmenu.c
158  * 
159  * Revision 1.37  1994/11/08  21:21:38  john
160  * Made Esc exit joystick calibration.
161  * 
162  * Revision 1.36  1994/11/08  15:14:42  john
163  * Added more calls so net doesn't die in net game.
164  * 
165  * Revision 1.35  1994/11/08  14:59:12  john
166  * Added code to respond to network while in menus.
167  * 
168  * Revision 1.34  1994/10/24  19:56:32  john
169  * Made the new user setup prompt for config options.
170  * 
171  * Revision 1.33  1994/10/22  14:11:52  mike
172  * Suppress compiler warning message.
173  * 
174  * Revision 1.32  1994/10/19  12:44:24  john
175  * Added hours field to player structure.
176  * 
177  * Revision 1.31  1994/10/17  13:07:13  john
178  * Moved the descent.cfg info into the player config file.
179  * 
180  * Revision 1.30  1994/10/13  21:41:12  john
181  * MAde Esc exit out of joystick calibration.
182  * 
183  * Revision 1.29  1994/10/13  19:22:27  john
184  * Added separate config saves for different devices.
185  * Made all the devices work together better, such as mice won't
186  * get read when you're playing with the joystick.
187  * 
188  * Revision 1.28  1994/10/13  11:40:18  john
189  * Took out warnings.
190  * 
191  * Revision 1.27  1994/10/13  11:35:23  john
192  * Made Thrustmaster FCS Hat work.  Put a background behind the
193  * keyboard configure.  Took out turn_sensitivity.  Changed sound/config
194  * menu to new menu. Made F6 be calibrate joystick.
195  * 
196  * Revision 1.26  1994/10/11  21:29:03  matt
197  * Made a bunch of menus have good initial selected values
198  * 
199  * Revision 1.25  1994/10/11  17:08:39  john
200  * Added sliders for volume controls.
201  * 
202  * Revision 1.24  1994/10/10  17:59:21  john
203  * Neatend previous.
204  * 
205  * Revision 1.23  1994/10/10  17:57:59  john
206  * Neatend previous.
207  * 
208  * Revision 1.22  1994/10/10  17:56:11  john
209  * Added messagebox that tells that config has been saved.
210  * 
211  * Revision 1.21  1994/09/30  12:37:26  john
212  * Added midi,digi volume to configuration.
213  * 
214  * Revision 1.20  1994/09/22  16:14:14  john
215  * Redid intro sequecing.
216  * 
217  * Revision 1.19  1994/09/19  18:50:15  john
218  * Added switch to disable joystick.
219  * 
220  * Revision 1.18  1994/09/12  11:47:36  john
221  * Made stupid cruise work better.  Make kconfig values get
222  * read/written to disk.
223  * 
224  * Revision 1.17  1994/09/10  15:46:47  john
225  * First version of new keyboard configuration.
226  * 
227  * Revision 1.16  1994/09/06  19:35:44  john
228  * Fixed bug that didn';t load new size .cal file.
229  * 
230  * Revision 1.15  1994/09/06  14:51:58  john
231  * Added sensitivity adjustment, fixed bug with joystick button not
232  * staying down.
233  * 
234  * Revision 1.14  1994/09/02  16:13:47  john
235  * Made keys fill in position.
236  * 
237  * Revision 1.13  1994/08/31  17:58:50  john
238  * Made a bit simpler.
239  * 
240  * Revision 1.12  1994/08/31  14:17:54  john
241  * *** empty log message ***
242  * 
243  * Revision 1.11  1994/08/31  14:10:56  john
244  * Made keys not work when KEY_DELETE pressed.
245  * 
246  * Revision 1.10  1994/08/31  13:40:47  mike
247  * Change constant
248  * 
249  * Revision 1.9  1994/08/31  12:56:27  john
250  * *** empty log message ***
251  * 
252  * Revision 1.8  1994/08/30  20:38:29  john
253  * Add more config stuff..
254  * 
255  * Revision 1.7  1994/08/30  16:37:25  john
256  * Added menu options to set controls.
257  * 
258  * Revision 1.6  1994/08/30  09:27:18  john
259  * *** empty log message ***
260  * 
261  * Revision 1.5  1994/08/30  09:12:01  john
262  * *** empty log message ***
263  * 
264  * Revision 1.4  1994/08/29  21:18:32  john
265  * First version of new keyboard/oystick remapping stuff.
266  * 
267  * Revision 1.3  1994/08/24  19:00:29  john
268  * Changed key_down_time to return fixed seconds instead of
269  * milliseconds.
270  * 
271  * Revision 1.2  1994/08/17  16:50:37  john
272  * Added damaging fireballs, missiles.
273  * 
274  * Revision 1.1  1994/08/17  10:07:12  john
275  * Initial revision
276  * 
277  * 
278  */
279
280 #ifdef HAVE_CONFIG_H
281 #include <conf.h>
282 #endif
283
284 #include <stdlib.h>
285 #include <stdio.h>
286 #include <string.h>
287
288 #include "pstypes.h"
289 #include "mono.h"
290 #include "key.h"
291 #include "joy.h"
292 #include "timer.h"
293 #include "error.h"
294
295 #include "inferno.h"
296 #include "game.h"
297 #include "object.h"
298 #include "player.h"
299
300 #include "controls.h"
301 #include "joydefs.h"
302 #include "render.h"
303 #include "palette.h"
304 #include "newmenu.h"
305 #include "args.h"
306 #include "text.h"
307 #include "kconfig.h"
308 #include "digi.h"
309 #include "playsave.h"
310
311 int joydefs_calibrate_flag = 0;
312
313 int Joy_is_Sidewinder = 0;
314
315 void joy_delay()
316 {
317 #ifdef __MSDOS__
318         int t1 = TICKER + 19/4;                 // Wait 1/4 second...
319         stop_time();
320         while( TICKER < t1 );
321         joy_flush();
322         start_time();
323 #endif
324 }
325
326
327 int joycal_message( char * title, char * text )
328 {
329         int i;
330         newmenu_item    m[2];
331         m[0].type = NM_TYPE_TEXT; m[0].text = text;
332         m[1].type = NM_TYPE_MENU; m[1].text = TXT_OK;
333         i = newmenu_do( title, NULL, 2, m, NULL );
334         if ( i < 0 ) 
335                 return 1;
336         return 0;
337 }
338
339 extern int WriteConfigFile();   
340
341 void joydefs_calibrate()
342 {
343         ubyte masks;
344         int org_axis_min[4];
345         int org_axis_center[4];
346         int org_axis_max[4];
347
348         int axis_min[4] = { 0, 0, 0, 0 };
349         int axis_cen[4] = { 0, 0, 0, 0 };
350         int axis_max[4] = { 0, 0, 0, 0 };
351
352         int temp_values[4];
353         char title[50];
354         char text[50];
355         int nsticks = 0;
356
357         joydefs_calibrate_flag = 0;
358
359         if ( (Config_control_type!=CONTROL_JOYSTICK) && (Config_control_type!=CONTROL_FLIGHTSTICK_PRO) && (Config_control_type!=CONTROL_THRUSTMASTER_FCS) && (Config_control_type!=CONTROL_GRAVIS_GAMEPAD) )    
360                 return;
361
362         joy_get_cal_vals(org_axis_min, org_axis_center, org_axis_max);
363
364         joy_set_cen();
365         joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
366
367         if (!joy_present)       {
368                 nm_messagebox( NULL, 1, TXT_OK, TXT_NO_JOYSTICK );
369                 return;
370         }
371         
372         masks = joy_get_present_mask();
373
374         if ( masks == JOY_ALL_AXIS )
375                 nsticks = 2;
376         else
377                 nsticks = 1;
378
379         if ( nsticks == 2 && !Joy_is_Sidewinder)     {
380                 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
381                 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
382         } else {
383                 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
384                 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
385         }
386         if (joycal_message( title, text )) {
387                 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
388                 return;
389         }
390         joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
391         axis_min[0] = temp_values[0];
392         axis_min[1] = temp_values[1];
393         joy_delay();
394
395         if ( nsticks == 2 && !Joy_is_Sidewinder)     {
396                 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
397                 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
398         } else {
399                 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
400                 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
401         }
402         if (joycal_message( title, text)) {
403                 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
404                 return;
405         }
406         joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
407         axis_max[0] = temp_values[0];
408         axis_max[1] = temp_values[1];
409         joy_delay();
410
411         if ( nsticks == 2 && !Joy_is_Sidewinder)     {
412                 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_CENTER);
413                 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
414         } else {
415                 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_CENTER);
416                 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
417         }
418         if (joycal_message( title, text)) {
419                 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
420                 return;
421         }
422         joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
423         axis_cen[0] = temp_values[0];
424         axis_cen[1] = temp_values[1];
425         joy_delay();
426
427         // The fcs uses axes 3 for hat, so don't calibrate it.
428         if (Config_control_type == CONTROL_THRUSTMASTER_FCS)  {
429                 axis_min[3] = 0;
430                 axis_cen[3] = temp_values[3]/2;
431                 axis_max[3] = temp_values[3];
432                 joy_delay();
433         }
434
435         if (Joy_is_Sidewinder || Config_control_type != CONTROL_THRUSTMASTER_FCS) {
436             //    masks = joy_get_present_mask();
437
438                 if ( nsticks == 2 )     {
439                         if ( kconfig_is_axes_used(2) || kconfig_is_axes_used(3) )       {
440                                 if(Joy_is_Sidewinder)
441                                  {
442                                   sprintf( title, "%s\nTWIST-LEFT", TXT_JOYSTICK);
443                                   sprintf( text, "Twist Joystick to \nthe left side");
444                                  }
445                                 else
446                                  {
447                                   sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
448                                   sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
449                                  }
450                                 if (joycal_message( title, text )) {
451                                         joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
452                                         return;
453                                 }
454                                 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
455                                 axis_min[2] = temp_values[2];
456                                 axis_min[3] = temp_values[3];
457                                 joy_delay();
458
459                                 if(Joy_is_Sidewinder)
460                                  {
461                                   sprintf( title, "%s\nTWIST-RIGHT", TXT_JOYSTICK);
462                                   sprintf( text, "Twist Joystick to \nthe right side");
463                                  }
464                                 else
465                                  {
466                                   sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
467                                   sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
468                                  }
469                                 if (joycal_message( title, text ))      {
470                                         joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max); 
471                                         return;
472                                 }
473                                 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
474                                 axis_max[2] = temp_values[2];
475                                 axis_max[3] = temp_values[3];
476                                 joy_delay();
477
478                                 
479                                 if(Joy_is_Sidewinder)
480                                  {
481                                   sprintf( title, "%s\nCENTER", TXT_JOYSTICK);
482                                   sprintf( text, "%s %s",TXT_MOVE_JOYSTICK, TXT_TO_C);
483                                  }
484                                 else
485                                  {
486                                    sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_CENTER);
487                                    sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
488                                  }
489
490                                 if (joycal_message( title, text ))      {
491                                         joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
492                                         return;
493                                 }
494                                 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
495                                 axis_cen[2] = temp_values[2];
496                                 axis_cen[3] = temp_values[3];   
497                                 joy_delay();
498                         }
499                 } else if ( (!(masks & JOY_2_X_AXIS)) && (masks & JOY_2_Y_AXIS) )       {
500                         if ( kconfig_is_axes_used(3) )  {
501                                 // A throttle axis!!!!!
502                                 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_FORWARD);
503                                 if (joycal_message( title, TXT_MOVE_THROTTLE_F))        {
504                                         joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
505                                         return;
506                                 }
507                                 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
508                                 axis_min[3] = temp_values[3];
509                                 joy_delay();
510                 
511                                 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_REVERSE);
512                                 if (joycal_message( title, TXT_MOVE_THROTTLE_R)) {
513                                         joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
514                                         return;
515                                 }
516                                 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
517                                 axis_max[3] = temp_values[3];
518                                 joy_delay();
519                 
520                                 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_CENTER);
521                                 if (joycal_message( title, TXT_MOVE_THROTTLE_C)) {
522                                         joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
523                                         return;
524                                 }
525                                 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
526                                 axis_cen[3] = temp_values[3];
527                                 joy_delay();
528                         }
529                 }
530         }
531         joy_set_cal_vals(axis_min, axis_cen, axis_max);
532
533
534 //added 9/1/98 by Victor Rachels to make sidewinder calibratable
535 /*         if(Joy_is_Sidewinder)
536           Config_control_type=tempstick; */
537 //end this section addition - Victor Rachels
538
539
540         WriteConfigFile();
541 }
542
543
544 //char *control_text[CONTROL_MAX_TYPES] = { "Keyboard only", "Joystick", "Flightstick Pro", "Thrustmaster FCS", "Gravis Gamepad", "Mouse", "Cyberman" };
545
546 void joydef_menuset_1(int nitems, newmenu_item * items, int *last_key, int citem )
547 {
548         int i;
549         int oc_type = Config_control_type;
550
551         nitems = nitems;
552         last_key = last_key;
553         citem = citem;          
554
555         for (i=0; i<CONTROL_MAX_TYPES; i++ )
556                 if (items[i].value) Config_control_type = i;
557
558         if ( (oc_type != Config_control_type) && (Config_control_type == CONTROL_THRUSTMASTER_FCS ) )   {
559                 nm_messagebox( TXT_IMPORTANT_NOTE, 1, TXT_OK, TXT_FCS );
560         }
561
562         if (oc_type != Config_control_type) {
563                 switch (Config_control_type) {
564         //              case    CONTROL_NONE:
565                         case    CONTROL_JOYSTICK:
566                         case    CONTROL_FLIGHTSTICK_PRO:
567                         case    CONTROL_THRUSTMASTER_FCS:
568                         case    CONTROL_GRAVIS_GAMEPAD:
569         //              case    CONTROL_MOUSE:
570         //              case    CONTROL_CYBERMAN:
571                                 joydefs_calibrate_flag = 1;
572                 }
573                 kc_set_controls();
574         }
575
576 }
577
578 extern ubyte kc_use_external_control;
579 extern ubyte kc_enable_external_control;
580 extern ubyte *kc_external_name;
581
582 void joydefs_config()
583 {
584         char xtext[128];
585         int i, old_masks, masks;
586         newmenu_item m[13];
587         int i1=9;
588         int nitems;
589
590         do {
591                 nitems = 12;
592                 m[0].type = NM_TYPE_RADIO; m[0].text = CONTROL_TEXT(0); m[0].value = 0; m[0].group = 0;
593                 m[1].type = NM_TYPE_RADIO; m[1].text = CONTROL_TEXT(1); m[1].value = 0; m[1].group = 0;
594                 m[2].type = NM_TYPE_RADIO; m[2].text = CONTROL_TEXT(2); m[2].value = 0; m[2].group = 0;
595                 m[3].type = NM_TYPE_RADIO; m[3].text = CONTROL_TEXT(3); m[3].value = 0; m[3].group = 0;
596                 m[4].type = NM_TYPE_RADIO; m[4].text = CONTROL_TEXT(4); m[4].value = 0; m[4].group = 0;
597                 m[5].type = NM_TYPE_RADIO; m[5].text = CONTROL_TEXT(5); m[5].value = 0; m[5].group = 0;
598                 m[6].type = NM_TYPE_RADIO; m[6].text = CONTROL_TEXT(6); m[6].value = 0; m[6].group = 0;
599                 m[7].type = NM_TYPE_MENU; m[7].text=TXT_CUST_ABOVE;
600                 m[8].type = NM_TYPE_TEXT; m[8].text="";
601                 m[9].type = NM_TYPE_MENU; m[9].text=TXT_CUST_KEYBOARD;
602 //added on 2/5/99 by Victor Rachels to add d1x key menu
603                 m[10].type = NM_TYPE_MENU; m[10].text="CUSTOMIZE D1X KEYS";
604 //end this section addition - VR
605                 m[11].type = NM_TYPE_CHECK; m[11].text= "Joy is Sidewinder"; m[11].value=Joy_is_Sidewinder;
606         
607                 if ( kc_use_external_control )  {
608                         sprintf( xtext, "Enable %s", kc_external_name );
609                         m[12].type = NM_TYPE_CHECK; m[12].text = xtext; m[12].value = kc_enable_external_control;
610                         nitems = nitems + 1;
611                 }
612                 
613                 m[Config_control_type].value = 1;
614          
615                 i1 = newmenu_do1( NULL, TXT_CONTROLS, nitems, m, joydef_menuset_1, i1 );
616
617 //added on 9/1/98 by Victor Rachels to add Sidewinder calibration
618                 Joy_is_Sidewinder = m[11].value;
619 //end this section addition
620
621                 switch(i1)      {
622                 case 7: {
623                                 old_masks = 0;
624                                 for (i=0; i<4; i++ )            {
625                                         if (kconfig_is_axes_used(i))
626                                                 old_masks |= (1<<i);
627                                 }
628                                 if ( Config_control_type==0 )
629                                         // nothing...
630                                         Config_control_type=0;
631                                 else if ( Config_control_type<5 ) 
632                                         kconfig(1, CONTROL_TEXT(Config_control_type) );
633                                 else 
634                                         kconfig(2, CONTROL_TEXT(Config_control_type) ); 
635
636                                 masks = 0;
637                                 for (i=0; i<4; i++ )            {
638                                         if (kconfig_is_axes_used(i))
639                                                 masks |= (1<<i);
640                                 }
641
642                                 switch (Config_control_type) {
643                                 case    CONTROL_JOYSTICK:
644                                 case    CONTROL_FLIGHTSTICK_PRO:
645                                 case    CONTROL_THRUSTMASTER_FCS:       
646                                         {
647                                                 for (i=0; i<4; i++ )    {
648                                                         if ( (masks&(1<<i)) && (!(old_masks&(1<<i))))
649                                                                 joydefs_calibrate_flag = 1;
650                                                 }
651                                         }
652                                         break;
653                                 }
654                         }
655                         break;
656                 case 9: 
657                         kconfig(0, TXT_KEYBOARD); 
658                         break;
659 //added on 2/5/99 by Victor Rachels to add d1x key menu
660                 case 10:
661                         kconfig(3,"D1X Keys");
662                         break;
663 //end this section addition - VR
664                 }
665
666                 if ( kc_use_external_control )  {
667                         kc_enable_external_control = m[12].value;
668                 }
669
670         } while(i1>-1);
671
672         switch (Config_control_type) {
673         case    CONTROL_JOYSTICK:
674         case    CONTROL_FLIGHTSTICK_PRO:
675         case    CONTROL_THRUSTMASTER_FCS:
676         case    CONTROL_GRAVIS_GAMEPAD:
677                 if ( joydefs_calibrate_flag )
678                         joydefs_calibrate();
679                 break;
680         }
681
682 }