1 /* $Id: joydefs.c,v 1.2 2003-10-10 09:36:35 btb Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
17 * Joystick Settings Stuff
20 * Revision 1.10 1995/10/18 22:21:21 allender
21 * fixed bug with gravis mousestick and call key_flush when
22 * calibrating joystick since it used keystrokes for the trigger
23 * (at least most of them do)
25 * Revision 1.9 1995/10/17 13:12:32 allender
26 * fixed up controller support for mac world
28 * Revision 1.8 1995/10/15 19:27:04 allender
29 * new Dave Denhart controller code
31 * Revision 1.7 1995/10/15 16:14:59 allender
32 * fixed axis value for Thrustmaster rudders
34 * Revision 1.6 1995/09/13 11:39:39 allender
35 * made joystick cal menu all text so buttons will work properly
37 * Revision 1.5 1995/09/01 13:13:13 allender
38 * added close box on controls menu
40 * Revision 1.4 1995/08/18 10:22:47 allender
41 * if thrustmaster choosen, set joystick at thrustmaster type
42 * for proper reading in joyc.c
44 * Revision 1.3 1995/07/26 17:00:34 allender
45 * put back in code to make joysticks work
47 * Revision 1.2 1995/07/17 08:52:21 allender
48 * put back in code that was taken out previously
50 * Revision 1.1 1995/05/16 15:26:48 allender
53 * Revision 2.2 1995/06/30 12:30:22 john
54 * Added -Xname command line.
56 * Revision 2.1 1995/04/06 12:13:20 john
57 * Made so you can calibrate Gravis Gamepad.
59 * Revision 2.0 1995/02/27 11:30:27 john
60 * New version 2.0, which has no anonymous unions, builds with
61 * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
63 * Revision 1.71 1995/02/12 02:06:10 john
64 * Fixed bug with joystick incorrectly asking for
67 * Revision 1.70 1995/01/28 15:58:07 john
68 * Made joystick calibration be only when wrong detected in
69 * menu or joystick axis changed.
71 * Revision 1.69 1995/01/25 14:37:55 john
72 * Made joystick only prompt for calibration once...
74 * Revision 1.68 1995/01/24 16:34:29 john
75 * Made so that if you reconfigure joystick and
76 * add or subtract an axis, it asks for a recalibration
79 * Revision 1.67 1994/12/29 11:08:51 john
80 * Fixed Thrustmaster and Logitech Wingman extreme
81 * Hat by reading the y2 axis during the center stage
82 * of the calibration, and using 75, 50, 27, and 3 %
83 * as values for the 4 positions.
85 * Revision 1.66 1994/12/15 18:17:39 john
86 * Fixed warning with previous.
88 * Revision 1.65 1994/12/15 18:15:48 john
89 * Made the joy cal only write the .cfg file, not
92 * Revision 1.64 1994/12/13 14:43:35 john
93 * Took out the code in kconfig to build direction array.
94 * Called kc_set_controls after selecting a new control type.
96 * Revision 1.63 1994/12/10 12:08:47 john
97 * Changed some delays to use TICKER instead of timer_get_fixed_seconds.
99 * Revision 1.62 1994/12/09 11:01:07 mike
100 * force calibration of joystick on joystick selection from Controls... menu.
102 * Revision 1.61 1994/12/07 21:50:27 john
103 * Put stop/start time around joystick delay.
105 * Revision 1.60 1994/12/07 19:34:39 john
108 * Revision 1.59 1994/12/07 18:12:14 john
109 * NEatened up joy cal.,
111 * Revision 1.58 1994/12/07 17:07:51 john
114 * Revision 1.57 1994/12/07 16:48:53 yuan
117 * Revision 1.56 1994/12/07 16:05:55 john
118 * Changed the way joystick calibration works.
120 * Revision 1.55 1994/12/06 20:15:22 john
121 * Took out code that unpauses songs that were never paused.
123 * Revision 1.54 1994/12/06 15:14:09 yuan
126 * Revision 1.53 1994/12/05 16:29:16 john
127 * Took out music pause around the cheat menu.
129 * Revision 1.52 1994/12/04 12:39:10 john
130 * MAde so that FCS calibration doesn't ask for axis #2.
132 * Revision 1.51 1994/12/03 15:14:59 john
133 * Took out the delay mentioned previosuly cause it would
134 * cause bigger problems than it helps, especially with netgames.
136 * Revision 1.50 1994/12/03 14:16:14 john
137 * Put a delay between screens in joy cal to keep Yuan from
140 * Revision 1.49 1994/12/03 11:04:06 john
141 * Changed newmenu code a bit to fix bug with bogus
142 * backgrounds occcasionally.
144 * Revision 1.48 1994/12/02 11:03:44 yuan
147 * Revision 1.47 1994/12/02 10:50:33 yuan
150 * Revision 1.46 1994/12/01 12:21:59 john
151 * Added code to calibrate 2 joysticks separately.
153 * Revision 1.45 1994/12/01 11:52:31 john
154 * Added message when you select FCS to say that if
155 * you have WCS, see manuel.
157 * Revision 1.44 1994/11/29 02:26:28 john
158 * Made the prompts for upper-left, lower right for joy
159 * calibration more obvious.
161 * Revision 1.43 1994/11/26 13:13:59 matt
162 * Changed "none" option to "keyboard only"
164 * Revision 1.42 1994/11/21 19:35:13 john
165 * Replaced calls to joy_init with if (joy_present)
167 * Revision 1.41 1994/11/21 19:28:34 john
168 * Changed warning for no joystick to use nm_messagebox..
170 * Revision 1.40 1994/11/21 19:06:25 john
171 * Made it so that it only stops sound when your in game mode.
173 * Revision 1.39 1994/11/21 11:47:18 john
174 * Made sound pause during joystick calibration.
176 * Revision 1.38 1994/11/10 20:34:18 rob
177 * Removed menu-specific network mode support in favor in new stuff
180 * Revision 1.37 1994/11/08 21:21:38 john
181 * Made Esc exit joystick calibration.
183 * Revision 1.36 1994/11/08 15:14:42 john
184 * Added more calls so net doesn't die in net game.
186 * Revision 1.35 1994/11/08 14:59:12 john
187 * Added code to respond to network while in menus.
189 * Revision 1.34 1994/10/24 19:56:32 john
190 * Made the new user setup prompt for config options.
192 * Revision 1.33 1994/10/22 14:11:52 mike
193 * Suppress compiler warning message.
195 * Revision 1.32 1994/10/19 12:44:24 john
196 * Added hours field to player structure.
198 * Revision 1.31 1994/10/17 13:07:13 john
199 * Moved the descent.cfg info into the player config file.
201 * Revision 1.30 1994/10/13 21:41:12 john
202 * MAde Esc exit out of joystick calibration.
204 * Revision 1.29 1994/10/13 19:22:27 john
205 * Added separate config saves for different devices.
206 * Made all the devices work together better, such as mice won't
207 * get read when you're playing with the joystick.
209 * Revision 1.28 1994/10/13 11:40:18 john
212 * Revision 1.27 1994/10/13 11:35:23 john
213 * Made Thrustmaster FCS Hat work. Put a background behind the
214 * keyboard configure. Took out turn_sensitivity. Changed sound/config
215 * menu to new menu. Made F6 be calibrate joystick.
217 * Revision 1.26 1994/10/11 21:29:03 matt
218 * Made a bunch of menus have good initial selected values
220 * Revision 1.25 1994/10/11 17:08:39 john
221 * Added sliders for volume controls.
223 * Revision 1.24 1994/10/10 17:59:21 john
226 * Revision 1.23 1994/10/10 17:57:59 john
229 * Revision 1.22 1994/10/10 17:56:11 john
230 * Added messagebox that tells that config has been saved.
232 * Revision 1.21 1994/09/30 12:37:26 john
233 * Added midi,digi volume to configuration.
235 * Revision 1.20 1994/09/22 16:14:14 john
236 * Redid intro sequecing.
238 * Revision 1.19 1994/09/19 18:50:15 john
239 * Added switch to disable joystick.
241 * Revision 1.18 1994/09/12 11:47:36 john
242 * Made stupid cruise work better. Make kconfig values get
243 * read/written to disk.
245 * Revision 1.17 1994/09/10 15:46:47 john
246 * First version of new keyboard configuration.
248 * Revision 1.16 1994/09/06 19:35:44 john
249 * Fixed bug that didn';t load new size .cal file.
251 * Revision 1.15 1994/09/06 14:51:58 john
252 * Added sensitivity adjustment, fixed bug with joystick button not
255 * Revision 1.14 1994/09/02 16:13:47 john
256 * Made keys fill in position.
258 * Revision 1.13 1994/08/31 17:58:50 john
259 * Made a bit simpler.
261 * Revision 1.12 1994/08/31 14:17:54 john
262 * *** empty log message ***
264 * Revision 1.11 1994/08/31 14:10:56 john
265 * Made keys not work when KEY_DELETE pressed.
267 * Revision 1.10 1994/08/31 13:40:47 mike
270 * Revision 1.9 1994/08/31 12:56:27 john
271 * *** empty log message ***
273 * Revision 1.8 1994/08/30 20:38:29 john
274 * Add more config stuff..
276 * Revision 1.7 1994/08/30 16:37:25 john
277 * Added menu options to set controls.
279 * Revision 1.6 1994/08/30 09:27:18 john
280 * *** empty log message ***
282 * Revision 1.5 1994/08/30 09:12:01 john
283 * *** empty log message ***
285 * Revision 1.4 1994/08/29 21:18:32 john
286 * First version of new keyboard/oystick remapping stuff.
288 * Revision 1.3 1994/08/24 19:00:29 john
289 * Changed key_down_time to return fixed seconds instead of
292 * Revision 1.2 1994/08/17 16:50:37 john
293 * Added damaging fireballs, missiles.
295 * Revision 1.1 1994/08/17 10:07:12 john
302 static char rcsid[] = "$Id: joydefs.c,v 1.2 2003-10-10 09:36:35 btb Exp $";
327 #include "controls.h"
339 #include "playsave.h"
341 int joydefs_calibrate_flag = 0;
344 ubyte joydefs_calibrating = 0; // stupid hack all because of silly mouse cursor emulation
351 //delay(250); // changed by allender because 1) more portable
352 // 2) was totally broken on PC
358 int joycal_message( char * title, char * text )
362 MAC(joydefs_calibrating = 1;)
363 m[0].type = NM_TYPE_TEXT; m[0].text = text;
364 m[1].type = NM_TYPE_MENU; m[1].text = TXT_OK;
365 i = newmenu_do( title, NULL, 2, m, NULL );
366 MAC(joydefs_calibrating = 0;)
372 extern int WriteConfigFile();
374 void joydefs_calibrate(void)
377 if ( (Config_control_type!=CONTROL_JOYSTICK) && (Config_control_type!=CONTROL_FLIGHTSTICK_PRO) && (Config_control_type!=CONTROL_THRUSTMASTER_FCS) )
380 if ( (Config_control_type == CONTROL_NONE) || (Config_control_type == CONTROL_MOUSE) )
385 apply_modified_palette();
388 gr_palette_load(gr_palette);
390 joydefs_calibrate2();
401 void joydefs_calibrate2()
405 int org_axis_center[4];
408 int axis_min[4] = { 0, 0, 0, 0 };
409 int axis_cen[4] = { 0, 0, 0, 0 };
410 int axis_max[4] = { 0, 0, 0, 0 };
417 joydefs_calibrate_flag = 0;
419 joy_get_cal_vals(org_axis_min, org_axis_center, org_axis_max);
422 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
425 nm_messagebox( NULL, 1, TXT_OK, TXT_NO_JOYSTICK );
429 masks = joy_get_present_mask();
432 if ( masks == JOY_ALL_AXIS )
440 if (Config_control_type == CONTROL_THRUSTMASTER_FCS)
441 nsticks = 1; //ignore for now the Sidewinder Pro X2 axis
443 if ( nsticks == 2 ) {
444 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
445 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
447 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
448 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
451 if (joycal_message( title, text )) {
452 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
455 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
456 axis_min[0] = temp_values[0];
457 axis_min[1] = temp_values[1];
460 if ( nsticks == 2 ) {
461 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
462 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
464 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
465 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
467 if (joycal_message( title, text)) {
468 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
471 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
472 axis_max[0] = temp_values[0];
473 axis_max[1] = temp_values[1];
476 if ( nsticks == 2 ) {
477 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_CENTER);
478 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
480 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_CENTER);
481 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
483 if (joycal_message( title, text)) {
484 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
487 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
488 axis_cen[0] = temp_values[0];
489 axis_cen[1] = temp_values[1];
490 axis_cen[2] = temp_values[2];
493 // The fcs uses axes 3 for hat, so don't calibrate it.
494 if ( Config_control_type == CONTROL_THRUSTMASTER_FCS ) {
496 //set Y2 axis, which is hat
498 axis_cen[3] = temp_values[3]/2;
499 axis_max[3] = temp_values[3];
502 //if X2 exists, calibrate it (for Sidewinder Pro)
503 if ( kconfig_is_axes_used(2) && (masks & JOY_2_X_AXIS) ) {
504 sprintf( title, "Joystick X2 axis\nLEFT");
505 sprintf( text, "Move joystick X2 axis\nall the way left");
506 if (joycal_message( title, text )) {
507 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
510 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
511 axis_min[2] = temp_values[2];
512 axis_min[3] = temp_values[3];
515 sprintf( title, "Joystick X2 axis\nRIGHT");
516 sprintf( text, "Move joystick X2 axis\nall the way right");
517 if (joycal_message( title, text )) {
518 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
521 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
522 axis_max[2] = temp_values[2];
523 axis_max[3] = temp_values[3];
528 masks = joy_get_present_mask();
530 if ( nsticks == 2 ) {
531 if ( kconfig_is_axes_used(2) || kconfig_is_axes_used(3) ) {
532 sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
533 sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
534 if (joycal_message( title, text )) {
535 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
538 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
539 axis_min[2] = temp_values[2];
540 axis_min[3] = temp_values[3];
543 sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
544 sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
545 if (joycal_message( title, text )) {
546 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
549 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
550 axis_max[2] = temp_values[2];
551 axis_max[3] = temp_values[3];
554 sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_CENTER);
555 sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
556 if (joycal_message( title, text )) {
557 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
560 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
561 axis_cen[2] = temp_values[2];
562 axis_cen[3] = temp_values[3];
567 else if ( (!(masks & JOY_2_X_AXIS)) && (masks & JOY_2_Y_AXIS) ) {
568 if ( kconfig_is_axes_used(3) ) {
569 // A throttle axis!!!!!
570 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_FORWARD);
571 if (joycal_message( title, TXT_MOVE_THROTTLE_F)) {
572 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
575 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
576 axis_min[3] = temp_values[3];
579 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_REVERSE);
580 if (joycal_message( title, TXT_MOVE_THROTTLE_R)) {
581 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
584 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
585 axis_max[3] = temp_values[3];
588 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_CENTER);
589 if (joycal_message( title, TXT_MOVE_THROTTLE_C)) {
590 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
593 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
594 axis_cen[3] = temp_values[3];
600 joy_set_cal_vals(axis_min, axis_cen, axis_max);
605 void joydefs_calibrate2()
609 int org_axis_center[4];
612 int axis_min[4] = { 0, 0, 0, 0 };
613 int axis_cen[4] = { 0, 0, 0, 0 };
614 int axis_max[4] = { 0, 0, 0, 0 };
621 joydefs_calibrate_flag = 0;
623 if ( Config_control_type == CONTROL_THRUSTMASTER_FCS ) {
624 axis_cen[0] = axis_cen[1] = axis_cen[2] = 0;
625 axis_min[0] = axis_min[1] = axis_min[2] = -127;
626 axis_max[0] = axis_max[1] = axis_max[2] = 127;
630 joy_set_cal_vals(axis_min, axis_cen, axis_max);
634 if ( Config_control_type == CONTROL_FLIGHTSTICK_PRO ) // no calibration needed
637 joy_get_cal_vals(org_axis_min, org_axis_center, org_axis_max);
640 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
643 nm_messagebox( NULL, 1, TXT_OK, TXT_NO_JOYSTICK );
647 masks = joy_get_present_mask();
649 if ( masks == JOY_ALL_AXIS )
654 if ( (Config_control_type == CONTROL_THRUSTMASTER_FCS) || (Config_control_type == CONTROL_FLIGHTSTICK_PRO) )
655 nsticks = 1; //ignore for now the Sidewinder Pro X2 axis
657 if ( nsticks == 2 ) {
658 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
659 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
661 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
662 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
665 if (joycal_message( title, text )) {
666 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
669 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
670 axis_min[0] = temp_values[0];
671 axis_min[1] = temp_values[1];
674 if ( nsticks == 2 ) {
675 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
676 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
678 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
679 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
681 if (joycal_message( title, text)) {
682 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
685 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
686 axis_max[0] = temp_values[0];
687 axis_max[1] = temp_values[1];
690 if ( nsticks == 2 ) {
691 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_CENTER);
692 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
694 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_CENTER);
695 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
697 if (joycal_message( title, text)) {
698 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
701 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
702 axis_cen[0] = temp_values[0];
703 axis_cen[1] = temp_values[1];
704 axis_cen[2] = temp_values[2];
707 masks = joy_get_present_mask();
709 if ( nsticks == 2 ) {
710 if ( kconfig_is_axes_used(2) || kconfig_is_axes_used(3) ) {
711 sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
712 sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
713 if (joycal_message( title, text )) {
714 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
717 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
718 axis_min[2] = temp_values[2];
719 axis_min[3] = temp_values[3];
722 sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
723 sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
724 if (joycal_message( title, text )) {
725 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
728 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
729 axis_max[2] = temp_values[2];
730 axis_max[3] = temp_values[3];
733 sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_CENTER);
734 sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
735 if (joycal_message( title, text )) {
736 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
739 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
740 axis_cen[2] = temp_values[2];
741 axis_cen[3] = temp_values[3];
745 if ( kconfig_is_axes_used(3) ) {
746 // A throttle axis!!!!!
747 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_FORWARD);
748 if (joycal_message( title, TXT_MOVE_THROTTLE_F)) {
749 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
752 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
753 axis_min[3] = temp_values[3];
756 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_REVERSE);
757 if (joycal_message( title, TXT_MOVE_THROTTLE_R)) {
758 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
761 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
762 axis_max[3] = temp_values[3];
765 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_CENTER);
766 if (joycal_message( title, TXT_MOVE_THROTTLE_C)) {
767 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
770 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
771 axis_cen[3] = temp_values[3];
775 joy_set_cal_vals(axis_min, axis_cen, axis_max);
782 //char *control_text[CONTROL_MAX_TYPES] = { "Keyboard only", "Joystick", "Flightstick Pro", "Thrustmaster FCS", "Gravis Gamepad", "Mouse", "Cyberman" };
784 #ifndef MACINTOSH // mac will have own verion of this function
786 #define CONTROL_MAX_TYPES_DOS (CONTROL_MAX_TYPES-1) //last item is windows only
788 void joydef_menuset_1(int nitems, newmenu_item * items, int *last_key, int citem )
791 int oc_type = Config_control_type;
797 for (i=0; i<CONTROL_MAX_TYPES_DOS; i++ )
798 if (items[i].value) Config_control_type = i;
800 if ( (oc_type != Config_control_type) && (Config_control_type == CONTROL_THRUSTMASTER_FCS ) ) {
801 nm_messagebox( TXT_IMPORTANT_NOTE, 1, TXT_OK, TXT_FCS );
804 if (oc_type != Config_control_type) {
805 switch (Config_control_type) {
806 // case CONTROL_NONE:
807 case CONTROL_JOYSTICK:
808 case CONTROL_FLIGHTSTICK_PRO:
809 case CONTROL_THRUSTMASTER_FCS:
810 // case CONTROL_GRAVIS_GAMEPAD:
811 // case CONTROL_MOUSE:
812 // case CONTROL_CYBERMAN:
813 joydefs_calibrate_flag = 1;
820 #else // ifndef MACINTOSH
822 #define MAX_MAC_CONTROL_TYPES 6
824 char *ch_warning = "Choosing this option will\noverride any settings for Descent II\nin the CH control panels. This\noption provides direct programming\nonly. See the readme for details.";
825 char *tm_warning = "Choosing this option might\ncause settings in the Thrustmaster\ncontrol panels to be overridden\ndepending on the direct inhibition\nsetting in that panel.\nSee the readme for details.";
826 char *ms_warning = "When using a Mousestick II,\nbe sure that there is not a stick\nset active for Descent II.\nHaving a stick set active might cause\nundesirable joystick and\nkeyboard behavior. See\nthe readme for detals.";
827 char *joy_warning = "Please use your joystick's\ncontrol panel to customize the\nbuttons and axis for Descent II.\nSee the joystick's manual for\ninstructions.";
829 void joydef_menuset_1(int nitems, newmenu_item * items, int *last_key, int citem )
832 int oc_type = Config_control_type;
833 char *warning_text = NULL;
839 for (i=0; i<MAX_MAC_CONTROL_TYPES; i++ )
840 if (items[i].value) Config_control_type = i;
842 if ( (oc_type != Config_control_type) && (Config_control_type == CONTROL_FLIGHTSTICK_PRO ) ) {
843 warning_text = ch_warning;
846 if ( (oc_type != Config_control_type) && (Config_control_type == CONTROL_THRUSTMASTER_FCS ) ) {
847 warning_text = tm_warning;
850 if ( (oc_type != Config_control_type) && (Config_control_type == CONTROL_GRAVIS_GAMEPAD ) ) {
851 warning_text = ms_warning;
856 nm_messagebox( TXT_IMPORTANT_NOTE, 1, TXT_OK, warning_text );
860 if (oc_type != Config_control_type) {
861 switch (Config_control_type) {
862 case CONTROL_JOYSTICK:
863 case CONTROL_FLIGHTSTICK_PRO:
864 case CONTROL_THRUSTMASTER_FCS:
865 case CONTROL_GRAVIS_GAMEPAD: // this really means a firebird or mousestick
866 joydefs_calibrate_flag = 1;
869 joydefs_set_type( Config_control_type );
876 extern ubyte kc_use_external_control;
877 extern ubyte kc_enable_external_control;
878 extern ubyte *kc_external_name;
885 void joydefs_config()
887 int i, old_masks, masks,nitems;
893 m[0].type = NM_TYPE_RADIO; m[0].text = CONTROL_TEXT(0); m[0].value = 0; m[0].group = 0;
894 m[1].type = NM_TYPE_RADIO; m[1].text = CONTROL_TEXT(1); m[1].value = 0; m[1].group = 0;
895 m[2].type = NM_TYPE_RADIO; m[2].text = CONTROL_TEXT(2); m[2].value = 0; m[2].group = 0;
896 m[3].type = NM_TYPE_RADIO; m[3].text = CONTROL_TEXT(3); m[3].value = 0; m[3].group = 0;
897 // change the text for the thrustmaster
898 m[3].text = "Thrustmaster";
899 m[4].type = NM_TYPE_RADIO; m[4].text = CONTROL_TEXT(4); m[4].value = 0; m[4].group = 0;
900 // change the text of the gravis gamepad to be the mac gravis sticks
901 m[4].text = "Gravis Firebird/MouseStick II";
902 m[5].type = NM_TYPE_RADIO; m[5].text = CONTROL_TEXT(5); m[5].value = 0; m[5].group = 0;
904 m[6].type = NM_TYPE_MENU; m[6].text=TXT_CUST_ABOVE;
905 m[7].type = NM_TYPE_TEXT; m[7].text="";
906 m[8].type = NM_TYPE_SLIDER; m[8].text=TXT_JOYS_SENSITIVITY; m[8].value=Config_joystick_sensitivity; m[8].min_value =0; m[8].max_value = 8;
907 m[9].type = NM_TYPE_TEXT; m[9].text="";
908 m[10].type = NM_TYPE_MENU; m[10].text=TXT_CUST_KEYBOARD;
911 m[Config_control_type].value = 1;
913 i1 = newmenu_do1( NULL, TXT_CONTROLS, nitems, m, joydef_menuset_1, i1 );
914 Config_joystick_sensitivity = m[8].value;
919 for (i=0; i<4; i++ ) {
920 if (kconfig_is_axes_used(i))
923 if ( Config_control_type==0 )
925 Config_control_type=0;
926 else if ( Config_control_type == 1) // this is just a joystick
927 nm_messagebox( TXT_IMPORTANT_NOTE, 1, TXT_OK, joy_warning );
928 else if ( Config_control_type<5 ) {
931 if (Config_control_type == 3)
932 strcpy(title, "Thrustmaster");
933 else if (Config_control_type == 4)
934 strcpy(title, "Gravis Firebird/Mousestick II");
936 strcpy(title, CONTROL_TEXT(Config_control_type) );
941 kconfig(2, CONTROL_TEXT(Config_control_type) );
944 for (i=0; i<4; i++ ) {
945 if (kconfig_is_axes_used(i))
949 switch (Config_control_type) {
950 case CONTROL_JOYSTICK:
951 case CONTROL_FLIGHTSTICK_PRO:
952 case CONTROL_THRUSTMASTER_FCS:
953 case CONTROL_GRAVIS_GAMEPAD:
955 for (i=0; i<4; i++ ) {
956 if ( (masks&(1<<i)) && (!(old_masks&(1<<i))))
957 joydefs_calibrate_flag = 1;
965 kconfig(0, TXT_KEYBOARD);
971 switch (Config_control_type) {
972 case CONTROL_JOYSTICK:
973 // case CONTROL_FLIGHTSTICK_PRO:
974 case CONTROL_THRUSTMASTER_FCS:
975 case CONTROL_GRAVIS_GAMEPAD:
976 if ( joydefs_calibrate_flag )
983 // silly routine to tell the joystick handler which type of control
985 void joydefs_set_type(ubyte type)
991 case CONTROL_NONE: joy_type = JOY_AS_NONE; break;
992 case CONTROL_JOYSTICK: joy_type = JOY_AS_MOUSE; break;
993 case CONTROL_FLIGHTSTICK_PRO: joy_type = JOY_AS_JOYMANAGER; break;
994 case CONTROL_THRUSTMASTER_FCS: joy_type = JOY_AS_THRUSTMASTER; break;
995 case CONTROL_GRAVIS_GAMEPAD: joy_type = JOY_AS_MOUSESTICK; break;
996 case CONTROL_MOUSE: joy_type = JOY_AS_MOUSE; break;
998 joy_set_type(joy_type);
1001 #else // #ifdef MACINTOSH
1003 //NOTE: UNIX/DOS VERSION
1004 void joydefs_config()
1006 int i, old_masks, masks,nitems;
1013 m[0].type = NM_TYPE_RADIO; m[0].text = CONTROL_TEXT(0); m[0].value = 0; m[0].group = 0;
1014 m[1].type = NM_TYPE_RADIO; m[1].text = CONTROL_TEXT(1); m[1].value = 0; m[1].group = 0;
1015 m[2].type = NM_TYPE_RADIO; m[2].text = CONTROL_TEXT(2); m[2].value = 0; m[2].group = 0;
1016 m[3].type = NM_TYPE_RADIO; m[3].text = CONTROL_TEXT(3); m[3].value = 0; m[3].group = 0;
1017 m[4].type = NM_TYPE_RADIO; m[4].text = CONTROL_TEXT(4); m[4].value = 0; m[4].group = 0;
1018 m[5].type = NM_TYPE_RADIO; m[5].text = CONTROL_TEXT(5); m[5].value = 0; m[5].group = 0;
1019 m[6].type = NM_TYPE_RADIO; m[6].text = CONTROL_TEXT(6); m[6].value = 0; m[6].group = 0;
1021 m[ 7].type = NM_TYPE_MENU; m[ 7].text=TXT_CUST_ABOVE;
1022 m[ 8].type = NM_TYPE_TEXT; m[ 8].text="";
1023 m[ 9].type = NM_TYPE_SLIDER; m[ 9].text=TXT_JOYS_SENSITIVITY; m[9].value=Config_joystick_sensitivity; m[9].min_value =0; m[9].max_value = 8;
1024 m[10].type = NM_TYPE_TEXT; m[10].text="";
1025 m[11].type = NM_TYPE_MENU; m[11].text=TXT_CUST_KEYBOARD;
1027 m[Config_control_type].value = 1;
1029 if ( kc_use_external_control ) {
1030 sprintf( xtext, "Enable %s", kc_external_name );
1031 m[12].type = NM_TYPE_CHECK; m[12].text = xtext; m[12].value = kc_enable_external_control;
1035 m[nitems].type = NM_TYPE_MENU; m[nitems].text="CUSTOMIZE D2X KEYS"; nitems++;
1037 i1 = newmenu_do1( NULL, TXT_CONTROLS, nitems, m, joydef_menuset_1, i1 );
1038 Config_joystick_sensitivity = m[9].value;
1043 for (i=0; i<4; i++ ) {
1044 if (kconfig_is_axes_used(i))
1045 old_masks |= (1<<i);
1047 if ( Config_control_type==0 )
1048 kconfig(0, TXT_KEYBOARD);
1049 else if ( Config_control_type<5 )
1050 kconfig(1, CONTROL_TEXT(Config_control_type) );
1052 kconfig(2, CONTROL_TEXT(Config_control_type) );
1055 for (i=0; i<4; i++ ) {
1056 if (kconfig_is_axes_used(i))
1060 switch (Config_control_type) {
1061 case CONTROL_JOYSTICK:
1062 case CONTROL_FLIGHTSTICK_PRO:
1063 case CONTROL_THRUSTMASTER_FCS:
1065 for (i=0; i<4; i++ ) {
1066 if ( (masks&(1<<i)) && (!(old_masks&(1<<i))))
1067 joydefs_calibrate_flag = 1;
1075 kconfig(0, TXT_KEYBOARD);
1078 kconfig(4, "D2X KEYS");
1082 if ( kc_use_external_control ) {
1083 kc_enable_external_control = m[12].value;
1088 switch (Config_control_type) {
1089 case CONTROL_JOYSTICK:
1090 case CONTROL_FLIGHTSTICK_PRO:
1091 case CONTROL_THRUSTMASTER_FCS:
1092 if ( joydefs_calibrate_flag )
1093 joydefs_calibrate();
1099 #endif // ifdef MACINTOSH
1101 #else //ifndef WINDOWS
1103 void joydef_menuset_win(int nitems, newmenu_item * items, int *last_key, int citem )
1106 int oc_type = Config_control_type;
1108 Int3(); //need to make this code work for windows
1111 last_key = last_key;
1114 for (i=0; i<CONTROL_MAX_TYPES; i++ )
1115 if (items[i].value) Config_control_type = i;
1117 if ( (oc_type != Config_control_type) && (Config_control_type == CONTROL_THRUSTMASTER_FCS ) ) {
1118 nm_messagebox( TXT_IMPORTANT_NOTE, 1, TXT_OK, TXT_FCS );
1121 if (oc_type != Config_control_type) {
1122 switch (Config_control_type) {
1123 // case CONTROL_NONE:
1124 case CONTROL_JOYSTICK:
1125 case CONTROL_FLIGHTSTICK_PRO:
1126 case CONTROL_THRUSTMASTER_FCS:
1127 // case CONTROL_GRAVIS_GAMEPAD:
1128 // case CONTROL_MOUSE:
1129 // case CONTROL_CYBERMAN:
1130 joydefs_calibrate_flag = 1;
1137 //NOTE: WINDOWS VERSION
1138 void joydefs_config()
1140 int i, old_masks, masks,nitems;
1145 Int3(); //this routine really needs to be cleaned up
1149 m[0].type = NM_TYPE_RADIO; m[0].text = CONTROL_TEXT(0); m[0].value = 0; m[0].group = 0;
1150 m[1].type = NM_TYPE_RADIO; m[1].text = CONTROL_TEXT(1); m[1].value = 0; m[1].group = 0;
1151 m[2].type = NM_TYPE_RADIO; m[2].text = CONTROL_TEXT(2); m[2].value = 0; m[2].group = 0;
1152 m[3].type = NM_TYPE_RADIO; m[3].text = CONTROL_TEXT(3); m[3].value = 0; m[3].group = 0;
1153 m[4].type = NM_TYPE_RADIO; m[4].text = CONTROL_TEXT(4); m[4].value = 0; m[4].group = 0;
1154 m[5].type = NM_TYPE_RADIO; m[5].text = CONTROL_TEXT(5); m[5].value = 0; m[5].group = 0;
1155 m[6].type = NM_TYPE_RADIO; m[6].text = CONTROL_TEXT(6); m[6].value = 0; m[6].group = 0;
1156 m[7].type = NM_TYPE_RADIO; m[7].text = CONTROL_TEXT(7); m[7].value = 0; m[7].group = 0;
1158 m[8].type = NM_TYPE_MENU; m[8].text=TXT_CUST_ABOVE;
1159 m[9].type = NM_TYPE_TEXT; m[9].text="";
1160 m[10].type = NM_TYPE_SLIDER; m[10].text=TXT_JOYS_SENSITIVITY; m[10].value=Config_joystick_sensitivity; m[10].min_value =0; m[10].max_value = 8;
1161 m[11].type = NM_TYPE_TEXT; m[11].text="";
1162 m[12].type = NM_TYPE_MENU; m[12].text=TXT_CUST_KEYBOARD;
1164 m[Config_control_type].value = 1;
1166 if ( kc_use_external_control ) {
1167 sprintf( xtext, "Enable %s", kc_external_name );
1168 m[13].type = NM_TYPE_CHECK; m[13].text = xtext; m[13].value = kc_enable_external_control;
1172 i1 = newmenu_do1( NULL, TXT_CONTROLS, nitems, m, joydef_menuset_win, i1 );
1173 Config_joystick_sensitivity = m[10].value;
1178 for (i=0; i<4; i++ ) {
1179 if (kconfig_is_axes_used(i))
1180 old_masks |= (1<<i);
1182 if ( Config_control_type==0 )
1184 Config_control_type=0;
1185 else if ( Config_control_type<5 )
1186 kconfig(1, CONTROL_TEXT(Config_control_type) );
1188 kconfig(2, CONTROL_TEXT(Config_control_type) );
1191 for (i=0; i<4; i++ ) {
1192 if (kconfig_is_axes_used(i))
1196 switch (Config_control_type) {
1197 case CONTROL_JOYSTICK:
1198 case CONTROL_FLIGHTSTICK_PRO:
1199 case CONTROL_THRUSTMASTER_FCS:
1201 for (i=0; i<4; i++ ) {
1202 if ( (masks&(1<<i)) && (!(old_masks&(1<<i))))
1203 joydefs_calibrate_flag = 1;
1211 kconfig(0, TXT_KEYBOARD);
1215 if ( kc_use_external_control ) {
1216 kc_enable_external_control = m[13].value;
1221 switch (Config_control_type) {
1222 case CONTROL_JOYSTICK:
1223 case CONTROL_FLIGHTSTICK_PRO:
1224 case CONTROL_THRUSTMASTER_FCS:
1225 if ( joydefs_calibrate_flag )
1226 joydefs_calibrate();
1232 #endif //ifndef WINDOWS