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