1 /* $Id: joydefs.c,v 1.3 2004-08-28 23:17:45 schaffner 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
22 static char rcsid[] = "$Id: joydefs.c,v 1.3 2004-08-28 23:17:45 schaffner Exp $";
61 int joydefs_calibrate_flag = 0;
64 ubyte joydefs_calibrating = 0; // stupid hack all because of silly mouse cursor emulation
71 //delay(250); // changed by allender because 1) more portable
72 // 2) was totally broken on PC
78 int joycal_message( char * title, char * text )
82 MAC(joydefs_calibrating = 1;)
83 m[0].type = NM_TYPE_TEXT; m[0].text = text;
84 m[1].type = NM_TYPE_MENU; m[1].text = TXT_OK;
85 i = newmenu_do( title, NULL, 2, m, NULL );
86 MAC(joydefs_calibrating = 0;)
92 extern int WriteConfigFile();
94 void joydefs_calibrate(void)
97 if ( (Config_control_type!=CONTROL_JOYSTICK) && (Config_control_type!=CONTROL_FLIGHTSTICK_PRO) && (Config_control_type!=CONTROL_THRUSTMASTER_FCS) )
100 if ( (Config_control_type == CONTROL_NONE) || (Config_control_type == CONTROL_MOUSE) )
105 apply_modified_palette();
108 gr_palette_load(gr_palette);
110 joydefs_calibrate2();
121 void joydefs_calibrate2()
125 int org_axis_center[4];
128 int axis_min[4] = { 0, 0, 0, 0 };
129 int axis_cen[4] = { 0, 0, 0, 0 };
130 int axis_max[4] = { 0, 0, 0, 0 };
137 joydefs_calibrate_flag = 0;
139 joy_get_cal_vals(org_axis_min, org_axis_center, org_axis_max);
142 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
145 nm_messagebox( NULL, 1, TXT_OK, TXT_NO_JOYSTICK );
149 masks = joy_get_present_mask();
152 if ( masks == JOY_ALL_AXIS )
160 if (Config_control_type == CONTROL_THRUSTMASTER_FCS)
161 nsticks = 1; //ignore for now the Sidewinder Pro X2 axis
163 if ( nsticks == 2 ) {
164 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
165 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
167 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
168 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
171 if (joycal_message( title, text )) {
172 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
175 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
176 axis_min[0] = temp_values[0];
177 axis_min[1] = temp_values[1];
180 if ( nsticks == 2 ) {
181 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
182 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
184 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
185 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
187 if (joycal_message( title, text)) {
188 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
191 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
192 axis_max[0] = temp_values[0];
193 axis_max[1] = temp_values[1];
196 if ( nsticks == 2 ) {
197 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_CENTER);
198 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
200 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_CENTER);
201 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
203 if (joycal_message( title, text)) {
204 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
207 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
208 axis_cen[0] = temp_values[0];
209 axis_cen[1] = temp_values[1];
210 axis_cen[2] = temp_values[2];
213 // The fcs uses axes 3 for hat, so don't calibrate it.
214 if ( Config_control_type == CONTROL_THRUSTMASTER_FCS ) {
216 //set Y2 axis, which is hat
218 axis_cen[3] = temp_values[3]/2;
219 axis_max[3] = temp_values[3];
222 //if X2 exists, calibrate it (for Sidewinder Pro)
223 if ( kconfig_is_axes_used(2) && (masks & JOY_2_X_AXIS) ) {
224 sprintf( title, "Joystick X2 axis\nLEFT");
225 sprintf( text, "Move joystick X2 axis\nall the way left");
226 if (joycal_message( title, text )) {
227 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
230 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
231 axis_min[2] = temp_values[2];
232 axis_min[3] = temp_values[3];
235 sprintf( title, "Joystick X2 axis\nRIGHT");
236 sprintf( text, "Move joystick X2 axis\nall the way right");
237 if (joycal_message( title, text )) {
238 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
241 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
242 axis_max[2] = temp_values[2];
243 axis_max[3] = temp_values[3];
248 masks = joy_get_present_mask();
250 if ( nsticks == 2 ) {
251 if ( kconfig_is_axes_used(2) || kconfig_is_axes_used(3) ) {
252 sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
253 sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
254 if (joycal_message( title, text )) {
255 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
258 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
259 axis_min[2] = temp_values[2];
260 axis_min[3] = temp_values[3];
263 sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
264 sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
265 if (joycal_message( title, text )) {
266 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
269 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
270 axis_max[2] = temp_values[2];
271 axis_max[3] = temp_values[3];
274 sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_CENTER);
275 sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
276 if (joycal_message( title, text )) {
277 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
280 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
281 axis_cen[2] = temp_values[2];
282 axis_cen[3] = temp_values[3];
287 else if ( (!(masks & JOY_2_X_AXIS)) && (masks & JOY_2_Y_AXIS) ) {
288 if ( kconfig_is_axes_used(3) ) {
289 // A throttle axis!!!!!
290 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_FORWARD);
291 if (joycal_message( title, TXT_MOVE_THROTTLE_F)) {
292 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
295 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
296 axis_min[3] = temp_values[3];
299 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_REVERSE);
300 if (joycal_message( title, TXT_MOVE_THROTTLE_R)) {
301 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
304 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
305 axis_max[3] = temp_values[3];
308 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_CENTER);
309 if (joycal_message( title, TXT_MOVE_THROTTLE_C)) {
310 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
313 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
314 axis_cen[3] = temp_values[3];
320 joy_set_cal_vals(axis_min, axis_cen, axis_max);
325 void joydefs_calibrate2()
329 int org_axis_center[4];
332 int axis_min[4] = { 0, 0, 0, 0 };
333 int axis_cen[4] = { 0, 0, 0, 0 };
334 int axis_max[4] = { 0, 0, 0, 0 };
341 joydefs_calibrate_flag = 0;
343 if ( Config_control_type == CONTROL_THRUSTMASTER_FCS ) {
344 axis_cen[0] = axis_cen[1] = axis_cen[2] = 0;
345 axis_min[0] = axis_min[1] = axis_min[2] = -127;
346 axis_max[0] = axis_max[1] = axis_max[2] = 127;
350 joy_set_cal_vals(axis_min, axis_cen, axis_max);
354 if ( Config_control_type == CONTROL_FLIGHTSTICK_PRO ) // no calibration needed
357 joy_get_cal_vals(org_axis_min, org_axis_center, org_axis_max);
360 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
363 nm_messagebox( NULL, 1, TXT_OK, TXT_NO_JOYSTICK );
367 masks = joy_get_present_mask();
369 if ( masks == JOY_ALL_AXIS )
374 if ( (Config_control_type == CONTROL_THRUSTMASTER_FCS) || (Config_control_type == CONTROL_FLIGHTSTICK_PRO) )
375 nsticks = 1; //ignore for now the Sidewinder Pro X2 axis
377 if ( nsticks == 2 ) {
378 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
379 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
381 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
382 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
385 if (joycal_message( title, text )) {
386 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
389 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
390 axis_min[0] = temp_values[0];
391 axis_min[1] = temp_values[1];
394 if ( nsticks == 2 ) {
395 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
396 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
398 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
399 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
401 if (joycal_message( title, text)) {
402 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
405 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
406 axis_max[0] = temp_values[0];
407 axis_max[1] = temp_values[1];
410 if ( nsticks == 2 ) {
411 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_CENTER);
412 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
414 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_CENTER);
415 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
417 if (joycal_message( title, text)) {
418 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
421 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
422 axis_cen[0] = temp_values[0];
423 axis_cen[1] = temp_values[1];
424 axis_cen[2] = temp_values[2];
427 masks = joy_get_present_mask();
429 if ( nsticks == 2 ) {
430 if ( kconfig_is_axes_used(2) || kconfig_is_axes_used(3) ) {
431 sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
432 sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
433 if (joycal_message( title, text )) {
434 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
437 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
438 axis_min[2] = temp_values[2];
439 axis_min[3] = temp_values[3];
442 sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
443 sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
444 if (joycal_message( title, text )) {
445 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
448 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
449 axis_max[2] = temp_values[2];
450 axis_max[3] = temp_values[3];
453 sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_CENTER);
454 sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
455 if (joycal_message( title, text )) {
456 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
459 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
460 axis_cen[2] = temp_values[2];
461 axis_cen[3] = temp_values[3];
465 if ( kconfig_is_axes_used(3) ) {
466 // A throttle axis!!!!!
467 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_FORWARD);
468 if (joycal_message( title, TXT_MOVE_THROTTLE_F)) {
469 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
472 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
473 axis_min[3] = temp_values[3];
476 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_REVERSE);
477 if (joycal_message( title, TXT_MOVE_THROTTLE_R)) {
478 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
481 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
482 axis_max[3] = temp_values[3];
485 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_CENTER);
486 if (joycal_message( title, TXT_MOVE_THROTTLE_C)) {
487 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
490 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
491 axis_cen[3] = temp_values[3];
495 joy_set_cal_vals(axis_min, axis_cen, axis_max);
502 //char *control_text[CONTROL_MAX_TYPES] = { "Keyboard only", "Joystick", "Flightstick Pro", "Thrustmaster FCS", "Gravis Gamepad", "Mouse", "Cyberman" };
504 #ifndef MACINTOSH // mac will have own verion of this function
506 #define CONTROL_MAX_TYPES_DOS (CONTROL_MAX_TYPES-1) //last item is windows only
508 void joydef_menuset_1(int nitems, newmenu_item * items, int *last_key, int citem )
511 int oc_type = Config_control_type;
517 for (i=0; i<CONTROL_MAX_TYPES_DOS; i++ )
518 if (items[i].value) Config_control_type = i;
520 if ( (oc_type != Config_control_type) && (Config_control_type == CONTROL_THRUSTMASTER_FCS ) ) {
521 nm_messagebox( TXT_IMPORTANT_NOTE, 1, TXT_OK, TXT_FCS );
524 if (oc_type != Config_control_type) {
525 switch (Config_control_type) {
526 // case CONTROL_NONE:
527 case CONTROL_JOYSTICK:
528 case CONTROL_FLIGHTSTICK_PRO:
529 case CONTROL_THRUSTMASTER_FCS:
530 // case CONTROL_GRAVIS_GAMEPAD:
531 // case CONTROL_MOUSE:
532 // case CONTROL_CYBERMAN:
533 joydefs_calibrate_flag = 1;
540 #else // ifndef MACINTOSH
542 #define MAX_MAC_CONTROL_TYPES 6
544 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.";
545 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.";
546 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.";
547 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.";
549 void joydef_menuset_1(int nitems, newmenu_item * items, int *last_key, int citem )
552 int oc_type = Config_control_type;
553 char *warning_text = NULL;
559 for (i=0; i<MAX_MAC_CONTROL_TYPES; i++ )
560 if (items[i].value) Config_control_type = i;
562 if ( (oc_type != Config_control_type) && (Config_control_type == CONTROL_FLIGHTSTICK_PRO ) ) {
563 warning_text = ch_warning;
566 if ( (oc_type != Config_control_type) && (Config_control_type == CONTROL_THRUSTMASTER_FCS ) ) {
567 warning_text = tm_warning;
570 if ( (oc_type != Config_control_type) && (Config_control_type == CONTROL_GRAVIS_GAMEPAD ) ) {
571 warning_text = ms_warning;
576 nm_messagebox( TXT_IMPORTANT_NOTE, 1, TXT_OK, warning_text );
580 if (oc_type != Config_control_type) {
581 switch (Config_control_type) {
582 case CONTROL_JOYSTICK:
583 case CONTROL_FLIGHTSTICK_PRO:
584 case CONTROL_THRUSTMASTER_FCS:
585 case CONTROL_GRAVIS_GAMEPAD: // this really means a firebird or mousestick
586 joydefs_calibrate_flag = 1;
589 joydefs_set_type( Config_control_type );
596 extern ubyte kc_use_external_control;
597 extern ubyte kc_enable_external_control;
598 extern ubyte *kc_external_name;
605 void joydefs_config()
607 int i, old_masks, masks,nitems;
613 m[0].type = NM_TYPE_RADIO; m[0].text = CONTROL_TEXT(0); m[0].value = 0; m[0].group = 0;
614 m[1].type = NM_TYPE_RADIO; m[1].text = CONTROL_TEXT(1); m[1].value = 0; m[1].group = 0;
615 m[2].type = NM_TYPE_RADIO; m[2].text = CONTROL_TEXT(2); m[2].value = 0; m[2].group = 0;
616 m[3].type = NM_TYPE_RADIO; m[3].text = CONTROL_TEXT(3); m[3].value = 0; m[3].group = 0;
617 // change the text for the thrustmaster
618 m[3].text = "Thrustmaster";
619 m[4].type = NM_TYPE_RADIO; m[4].text = CONTROL_TEXT(4); m[4].value = 0; m[4].group = 0;
620 // change the text of the gravis gamepad to be the mac gravis sticks
621 m[4].text = "Gravis Firebird/MouseStick II";
622 m[5].type = NM_TYPE_RADIO; m[5].text = CONTROL_TEXT(5); m[5].value = 0; m[5].group = 0;
624 m[6].type = NM_TYPE_MENU; m[6].text=TXT_CUST_ABOVE;
625 m[7].type = NM_TYPE_TEXT; m[7].text="";
626 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;
627 m[9].type = NM_TYPE_TEXT; m[9].text="";
628 m[10].type = NM_TYPE_MENU; m[10].text=TXT_CUST_KEYBOARD;
631 m[Config_control_type].value = 1;
633 i1 = newmenu_do1( NULL, TXT_CONTROLS, nitems, m, joydef_menuset_1, i1 );
634 Config_joystick_sensitivity = m[8].value;
639 for (i=0; i<4; i++ ) {
640 if (kconfig_is_axes_used(i))
643 if ( Config_control_type==0 )
645 Config_control_type=0;
646 else if ( Config_control_type == 1) // this is just a joystick
647 nm_messagebox( TXT_IMPORTANT_NOTE, 1, TXT_OK, joy_warning );
648 else if ( Config_control_type<5 ) {
651 if (Config_control_type == 3)
652 strcpy(title, "Thrustmaster");
653 else if (Config_control_type == 4)
654 strcpy(title, "Gravis Firebird/Mousestick II");
656 strcpy(title, CONTROL_TEXT(Config_control_type) );
661 kconfig(2, CONTROL_TEXT(Config_control_type) );
664 for (i=0; i<4; i++ ) {
665 if (kconfig_is_axes_used(i))
669 switch (Config_control_type) {
670 case CONTROL_JOYSTICK:
671 case CONTROL_FLIGHTSTICK_PRO:
672 case CONTROL_THRUSTMASTER_FCS:
673 case CONTROL_GRAVIS_GAMEPAD:
675 for (i=0; i<4; i++ ) {
676 if ( (masks&(1<<i)) && (!(old_masks&(1<<i))))
677 joydefs_calibrate_flag = 1;
685 kconfig(0, TXT_KEYBOARD);
691 switch (Config_control_type) {
692 case CONTROL_JOYSTICK:
693 // case CONTROL_FLIGHTSTICK_PRO:
694 case CONTROL_THRUSTMASTER_FCS:
695 case CONTROL_GRAVIS_GAMEPAD:
696 if ( joydefs_calibrate_flag )
703 // silly routine to tell the joystick handler which type of control
705 void joydefs_set_type(ubyte type)
711 case CONTROL_NONE: joy_type = JOY_AS_NONE; break;
712 case CONTROL_JOYSTICK: joy_type = JOY_AS_MOUSE; break;
713 case CONTROL_FLIGHTSTICK_PRO: joy_type = JOY_AS_JOYMANAGER; break;
714 case CONTROL_THRUSTMASTER_FCS: joy_type = JOY_AS_THRUSTMASTER; break;
715 case CONTROL_GRAVIS_GAMEPAD: joy_type = JOY_AS_MOUSESTICK; break;
716 case CONTROL_MOUSE: joy_type = JOY_AS_MOUSE; break;
718 joy_set_type(joy_type);
721 #else // #ifdef MACINTOSH
723 //NOTE: UNIX/DOS VERSION
724 void joydefs_config()
726 int i, old_masks, masks,nitems;
733 m[0].type = NM_TYPE_RADIO; m[0].text = CONTROL_TEXT(0); m[0].value = 0; m[0].group = 0;
734 m[1].type = NM_TYPE_RADIO; m[1].text = CONTROL_TEXT(1); m[1].value = 0; m[1].group = 0;
735 m[2].type = NM_TYPE_RADIO; m[2].text = CONTROL_TEXT(2); m[2].value = 0; m[2].group = 0;
736 m[3].type = NM_TYPE_RADIO; m[3].text = CONTROL_TEXT(3); m[3].value = 0; m[3].group = 0;
737 m[4].type = NM_TYPE_RADIO; m[4].text = CONTROL_TEXT(4); m[4].value = 0; m[4].group = 0;
738 m[5].type = NM_TYPE_RADIO; m[5].text = CONTROL_TEXT(5); m[5].value = 0; m[5].group = 0;
739 m[6].type = NM_TYPE_RADIO; m[6].text = CONTROL_TEXT(6); m[6].value = 0; m[6].group = 0;
741 m[ 7].type = NM_TYPE_MENU; m[ 7].text=TXT_CUST_ABOVE;
742 m[ 8].type = NM_TYPE_TEXT; m[ 8].text="";
743 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;
744 m[10].type = NM_TYPE_TEXT; m[10].text="";
745 m[11].type = NM_TYPE_MENU; m[11].text=TXT_CUST_KEYBOARD;
747 m[Config_control_type].value = 1;
749 if ( kc_use_external_control ) {
750 sprintf( xtext, "Enable %s", kc_external_name );
751 m[12].type = NM_TYPE_CHECK; m[12].text = xtext; m[12].value = kc_enable_external_control;
755 m[nitems].type = NM_TYPE_MENU; m[nitems].text="CUSTOMIZE D2X KEYS"; nitems++;
757 i1 = newmenu_do1( NULL, TXT_CONTROLS, nitems, m, joydef_menuset_1, i1 );
758 Config_joystick_sensitivity = m[9].value;
763 for (i=0; i<4; i++ ) {
764 if (kconfig_is_axes_used(i))
767 if ( Config_control_type==0 )
768 kconfig(0, TXT_KEYBOARD);
769 else if ( Config_control_type<5 )
770 kconfig(1, CONTROL_TEXT(Config_control_type) );
772 kconfig(2, CONTROL_TEXT(Config_control_type) );
775 for (i=0; i<4; i++ ) {
776 if (kconfig_is_axes_used(i))
780 switch (Config_control_type) {
781 case CONTROL_JOYSTICK:
782 case CONTROL_FLIGHTSTICK_PRO:
783 case CONTROL_THRUSTMASTER_FCS:
785 for (i=0; i<4; i++ ) {
786 if ( (masks&(1<<i)) && (!(old_masks&(1<<i))))
787 joydefs_calibrate_flag = 1;
795 kconfig(0, TXT_KEYBOARD);
798 kconfig(4, "D2X KEYS");
802 if ( kc_use_external_control ) {
803 kc_enable_external_control = m[12].value;
808 switch (Config_control_type) {
809 case CONTROL_JOYSTICK:
810 case CONTROL_FLIGHTSTICK_PRO:
811 case CONTROL_THRUSTMASTER_FCS:
812 if ( joydefs_calibrate_flag )
819 #endif // ifdef MACINTOSH
821 #else //ifndef WINDOWS
823 void joydef_menuset_win(int nitems, newmenu_item * items, int *last_key, int citem )
826 int oc_type = Config_control_type;
828 Int3(); //need to make this code work for windows
834 for (i=0; i<CONTROL_MAX_TYPES; i++ )
835 if (items[i].value) Config_control_type = i;
837 if ( (oc_type != Config_control_type) && (Config_control_type == CONTROL_THRUSTMASTER_FCS ) ) {
838 nm_messagebox( TXT_IMPORTANT_NOTE, 1, TXT_OK, TXT_FCS );
841 if (oc_type != Config_control_type) {
842 switch (Config_control_type) {
843 // case CONTROL_NONE:
844 case CONTROL_JOYSTICK:
845 case CONTROL_FLIGHTSTICK_PRO:
846 case CONTROL_THRUSTMASTER_FCS:
847 // case CONTROL_GRAVIS_GAMEPAD:
848 // case CONTROL_MOUSE:
849 // case CONTROL_CYBERMAN:
850 joydefs_calibrate_flag = 1;
857 //NOTE: WINDOWS VERSION
858 void joydefs_config()
860 int i, old_masks, masks,nitems;
865 Int3(); //this routine really needs to be cleaned up
869 m[0].type = NM_TYPE_RADIO; m[0].text = CONTROL_TEXT(0); m[0].value = 0; m[0].group = 0;
870 m[1].type = NM_TYPE_RADIO; m[1].text = CONTROL_TEXT(1); m[1].value = 0; m[1].group = 0;
871 m[2].type = NM_TYPE_RADIO; m[2].text = CONTROL_TEXT(2); m[2].value = 0; m[2].group = 0;
872 m[3].type = NM_TYPE_RADIO; m[3].text = CONTROL_TEXT(3); m[3].value = 0; m[3].group = 0;
873 m[4].type = NM_TYPE_RADIO; m[4].text = CONTROL_TEXT(4); m[4].value = 0; m[4].group = 0;
874 m[5].type = NM_TYPE_RADIO; m[5].text = CONTROL_TEXT(5); m[5].value = 0; m[5].group = 0;
875 m[6].type = NM_TYPE_RADIO; m[6].text = CONTROL_TEXT(6); m[6].value = 0; m[6].group = 0;
876 m[7].type = NM_TYPE_RADIO; m[7].text = CONTROL_TEXT(7); m[7].value = 0; m[7].group = 0;
878 m[8].type = NM_TYPE_MENU; m[8].text=TXT_CUST_ABOVE;
879 m[9].type = NM_TYPE_TEXT; m[9].text="";
880 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;
881 m[11].type = NM_TYPE_TEXT; m[11].text="";
882 m[12].type = NM_TYPE_MENU; m[12].text=TXT_CUST_KEYBOARD;
884 m[Config_control_type].value = 1;
886 if ( kc_use_external_control ) {
887 sprintf( xtext, "Enable %s", kc_external_name );
888 m[13].type = NM_TYPE_CHECK; m[13].text = xtext; m[13].value = kc_enable_external_control;
892 i1 = newmenu_do1( NULL, TXT_CONTROLS, nitems, m, joydef_menuset_win, i1 );
893 Config_joystick_sensitivity = m[10].value;
898 for (i=0; i<4; i++ ) {
899 if (kconfig_is_axes_used(i))
902 if ( Config_control_type==0 )
904 Config_control_type=0;
905 else if ( Config_control_type<5 )
906 kconfig(1, CONTROL_TEXT(Config_control_type) );
908 kconfig(2, CONTROL_TEXT(Config_control_type) );
911 for (i=0; i<4; i++ ) {
912 if (kconfig_is_axes_used(i))
916 switch (Config_control_type) {
917 case CONTROL_JOYSTICK:
918 case CONTROL_FLIGHTSTICK_PRO:
919 case CONTROL_THRUSTMASTER_FCS:
921 for (i=0; i<4; i++ ) {
922 if ( (masks&(1<<i)) && (!(old_masks&(1<<i))))
923 joydefs_calibrate_flag = 1;
931 kconfig(0, TXT_KEYBOARD);
935 if ( kc_use_external_control ) {
936 kc_enable_external_control = m[13].value;
941 switch (Config_control_type) {
942 case CONTROL_JOYSTICK:
943 case CONTROL_FLIGHTSTICK_PRO:
944 case CONTROL_THRUSTMASTER_FCS:
945 if ( joydefs_calibrate_flag )
952 #endif //ifndef WINDOWS