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.
50 int joydefs_calibrate_flag = 0;
52 int Joy_is_Sidewinder = 0;
57 int t1 = TICKER + 19/4; // Wait 1/4 second...
66 int joycal_message( char * title, char * text )
70 m[0].type = NM_TYPE_TEXT; m[0].text = text;
71 m[1].type = NM_TYPE_MENU; m[1].text = TXT_OK;
72 i = newmenu_do( title, NULL, 2, m, NULL );
78 extern int WriteConfigFile();
80 void joydefs_calibrate()
84 int org_axis_center[4];
87 int axis_min[4] = { 0, 0, 0, 0 };
88 int axis_cen[4] = { 0, 0, 0, 0 };
89 int axis_max[4] = { 0, 0, 0, 0 };
96 joydefs_calibrate_flag = 0;
98 if ( (Config_control_type.intval != CONTROL_JOYSTICK) &&
99 (Config_control_type.intval != CONTROL_FLIGHTSTICK_PRO) &&
100 (Config_control_type.intval != CONTROL_THRUSTMASTER_FCS) &&
101 (Config_control_type.intval != CONTROL_GRAVIS_GAMEPAD) )
104 joy_get_cal_vals(org_axis_min, org_axis_center, org_axis_max);
107 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
110 nm_messagebox( NULL, 1, TXT_OK, TXT_NO_JOYSTICK );
114 masks = joy_get_present_mask();
116 if ( masks == JOY_ALL_AXIS )
121 if ( nsticks == 2 && !Joy_is_Sidewinder) {
122 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
123 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
125 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
126 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
128 if (joycal_message( title, text )) {
129 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
132 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
133 axis_min[0] = temp_values[0];
134 axis_min[1] = temp_values[1];
137 if ( nsticks == 2 && !Joy_is_Sidewinder) {
138 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
139 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
141 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
142 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
144 if (joycal_message( title, text)) {
145 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
148 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
149 axis_max[0] = temp_values[0];
150 axis_max[1] = temp_values[1];
153 if ( nsticks == 2 && !Joy_is_Sidewinder) {
154 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_CENTER);
155 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
157 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_CENTER);
158 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
160 if (joycal_message( title, text)) {
161 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
164 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
165 axis_cen[0] = temp_values[0];
166 axis_cen[1] = temp_values[1];
169 // The fcs uses axes 3 for hat, so don't calibrate it.
170 if (Config_control_type.intval == CONTROL_THRUSTMASTER_FCS) {
172 axis_cen[3] = temp_values[3]/2;
173 axis_max[3] = temp_values[3];
177 if (Joy_is_Sidewinder || Config_control_type.intval != CONTROL_THRUSTMASTER_FCS) {
178 // masks = joy_get_present_mask();
180 if ( nsticks == 2 ) {
181 if ( kconfig_is_axes_used(2) || kconfig_is_axes_used(3) ) {
182 if(Joy_is_Sidewinder)
184 sprintf( title, "%s\nTWIST-LEFT", TXT_JOYSTICK);
185 sprintf( text, "Twist Joystick to \nthe left side");
189 sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
190 sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
192 if (joycal_message( title, text )) {
193 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
196 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
197 axis_min[2] = temp_values[2];
198 axis_min[3] = temp_values[3];
201 if(Joy_is_Sidewinder)
203 sprintf( title, "%s\nTWIST-RIGHT", TXT_JOYSTICK);
204 sprintf( text, "Twist Joystick to \nthe right side");
208 sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
209 sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
211 if (joycal_message( title, text )) {
212 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
215 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
216 axis_max[2] = temp_values[2];
217 axis_max[3] = temp_values[3];
221 if(Joy_is_Sidewinder)
223 sprintf( title, "%s\nCENTER", TXT_JOYSTICK);
224 sprintf( text, "%s %s",TXT_MOVE_JOYSTICK, TXT_TO_C);
228 sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_CENTER);
229 sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
232 if (joycal_message( title, text )) {
233 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
236 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
237 axis_cen[2] = temp_values[2];
238 axis_cen[3] = temp_values[3];
241 } else if ( (!(masks & JOY_2_X_AXIS)) && (masks & JOY_2_Y_AXIS) ) {
242 if ( kconfig_is_axes_used(3) ) {
243 // A throttle axis!!!!!
244 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_FORWARD);
245 if (joycal_message( title, TXT_MOVE_THROTTLE_F)) {
246 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
249 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
250 axis_min[3] = temp_values[3];
253 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_REVERSE);
254 if (joycal_message( title, TXT_MOVE_THROTTLE_R)) {
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_max[3] = temp_values[3];
262 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_CENTER);
263 if (joycal_message( title, TXT_MOVE_THROTTLE_C)) {
264 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
267 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
268 axis_cen[3] = temp_values[3];
273 joy_set_cal_vals(axis_min, axis_cen, axis_max);
276 //added 9/1/98 by Victor Rachels to make sidewinder calibratable
277 /* if(Joy_is_Sidewinder)
278 cvar_setint(&Config_control_type, tempstick); */
279 //end this section addition - Victor Rachels
286 void joydef_menuset_1(int nitems, newmenu_item * items, int *last_key, int citem )
289 int oc_type = Config_control_type.intval;
295 for (i=0; i<CONTROL_MAX_TYPES; i++ )
297 cvar_setint(&Config_control_type, i);
299 if ( (oc_type != Config_control_type.intval) && (Config_control_type.intval == CONTROL_THRUSTMASTER_FCS ) ) {
300 nm_messagebox( TXT_IMPORTANT_NOTE, 1, TXT_OK, TXT_FCS );
303 if (oc_type != Config_control_type.intval) {
304 switch (Config_control_type.intval) {
305 // case CONTROL_NONE:
306 case CONTROL_JOYSTICK:
307 case CONTROL_FLIGHTSTICK_PRO:
308 case CONTROL_THRUSTMASTER_FCS:
309 case CONTROL_GRAVIS_GAMEPAD:
310 // case CONTROL_MOUSE:
311 // case CONTROL_CYBERMAN:
312 joydefs_calibrate_flag = 1;
319 extern ubyte kc_use_external_control;
320 extern ubyte kc_enable_external_control;
321 extern ubyte *kc_external_name;
323 void joydefs_config()
326 int i, old_masks, masks;
333 m[0].type = NM_TYPE_RADIO; m[0].text = CONTROL_TEXT(0); m[0].value = 0; m[0].group = 0;
334 m[1].type = NM_TYPE_RADIO; m[1].text = CONTROL_TEXT(1); m[1].value = 0; m[1].group = 0;
335 m[2].type = NM_TYPE_RADIO; m[2].text = CONTROL_TEXT(2); m[2].value = 0; m[2].group = 0;
336 m[3].type = NM_TYPE_RADIO; m[3].text = CONTROL_TEXT(3); m[3].value = 0; m[3].group = 0;
337 m[4].type = NM_TYPE_RADIO; m[4].text = CONTROL_TEXT(4); m[4].value = 0; m[4].group = 0;
338 m[5].type = NM_TYPE_RADIO; m[5].text = CONTROL_TEXT(5); m[5].value = 0; m[5].group = 0;
339 m[6].type = NM_TYPE_RADIO; m[6].text = CONTROL_TEXT(6); m[6].value = 0; m[6].group = 0;
340 m[7].type = NM_TYPE_MENU; m[7].text=TXT_CUST_ABOVE;
341 m[8].type = NM_TYPE_TEXT; m[8].text="";
342 m[9].type = NM_TYPE_MENU; m[9].text=TXT_CUST_KEYBOARD;
343 //added on 2/5/99 by Victor Rachels to add d1x key menu
344 m[10].type = NM_TYPE_MENU; m[10].text="CUSTOMIZE D1X KEYS";
345 //end this section addition - VR
346 m[11].type = NM_TYPE_CHECK; m[11].text= "Joy is Sidewinder"; m[11].value=Joy_is_Sidewinder;
348 if ( kc_use_external_control ) {
349 sprintf( xtext, "Enable %s", kc_external_name );
350 m[12].type = NM_TYPE_CHECK; m[12].text = xtext; m[12].value = kc_enable_external_control;
354 m[Config_control_type.intval].value = 1;
356 i1 = newmenu_do1( NULL, TXT_CONTROLS, nitems, m, joydef_menuset_1, i1 );
358 //added on 9/1/98 by Victor Rachels to add Sidewinder calibration
359 Joy_is_Sidewinder = m[11].value;
360 //end this section addition
365 for (i=0; i<4; i++ ) {
366 if (kconfig_is_axes_used(i))
369 if ( Config_control_type.intval == CONTROL_NONE )
371 cvar_setint(&Config_control_type, CONTROL_NONE);
372 else if ( Config_control_type.intval < CONTROL_MOUSE )
373 kconfig(1, CONTROL_TEXT(Config_control_type.intval) );
375 kconfig(2, CONTROL_TEXT(Config_control_type.intval) );
378 for (i=0; i<4; i++ ) {
379 if (kconfig_is_axes_used(i))
383 switch (Config_control_type.intval) {
384 case CONTROL_JOYSTICK:
385 case CONTROL_FLIGHTSTICK_PRO:
386 case CONTROL_THRUSTMASTER_FCS:
388 for (i=0; i<4; i++ ) {
389 if ( (masks&(1<<i)) && (!(old_masks&(1<<i))))
390 joydefs_calibrate_flag = 1;
398 kconfig(0, TXT_KEYBOARD);
400 //added on 2/5/99 by Victor Rachels to add d1x key menu
402 kconfig(3,"D1X Keys");
404 //end this section addition - VR
407 if ( kc_use_external_control ) {
408 kc_enable_external_control = m[12].value;
413 switch (Config_control_type.intval) {
414 case CONTROL_JOYSTICK:
415 case CONTROL_FLIGHTSTICK_PRO:
416 case CONTROL_THRUSTMASTER_FCS:
417 case CONTROL_GRAVIS_GAMEPAD:
418 if ( joydefs_calibrate_flag )