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.
45 int joydefs_calibrate_flag = 0;
47 int Joy_is_Sidewinder = 0;
52 int t1 = TICKER + 19/4; // Wait 1/4 second...
61 int joycal_message( char * title, char * text )
65 m[0].type = NM_TYPE_TEXT; m[0].text = text;
66 m[1].type = NM_TYPE_MENU; m[1].text = TXT_OK;
67 i = newmenu_do( title, NULL, 2, m, NULL );
73 extern int WriteConfigFile();
75 void joydefs_calibrate()
79 int org_axis_center[4];
82 int axis_min[4] = { 0, 0, 0, 0 };
83 int axis_cen[4] = { 0, 0, 0, 0 };
84 int axis_max[4] = { 0, 0, 0, 0 };
91 joydefs_calibrate_flag = 0;
93 if ( (Config_control_type!=CONTROL_JOYSTICK) && (Config_control_type!=CONTROL_FLIGHTSTICK_PRO) && (Config_control_type!=CONTROL_THRUSTMASTER_FCS) && (Config_control_type!=CONTROL_GRAVIS_GAMEPAD) )
96 joy_get_cal_vals(org_axis_min, org_axis_center, org_axis_max);
99 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
102 nm_messagebox( NULL, 1, TXT_OK, TXT_NO_JOYSTICK );
106 masks = joy_get_present_mask();
108 if ( masks == JOY_ALL_AXIS )
113 if ( nsticks == 2 && !Joy_is_Sidewinder) {
114 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
115 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
117 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
118 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
120 if (joycal_message( title, text )) {
121 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
124 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
125 axis_min[0] = temp_values[0];
126 axis_min[1] = temp_values[1];
129 if ( nsticks == 2 && !Joy_is_Sidewinder) {
130 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
131 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
133 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
134 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
136 if (joycal_message( title, text)) {
137 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
140 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
141 axis_max[0] = temp_values[0];
142 axis_max[1] = temp_values[1];
145 if ( nsticks == 2 && !Joy_is_Sidewinder) {
146 sprintf( title, "%s #1\n%s", TXT_JOYSTICK, TXT_CENTER);
147 sprintf( text, "%s #1 %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
149 sprintf( title, "%s\n%s", TXT_JOYSTICK, TXT_CENTER);
150 sprintf( text, "%s %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
152 if (joycal_message( title, text)) {
153 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
156 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
157 axis_cen[0] = temp_values[0];
158 axis_cen[1] = temp_values[1];
161 // The fcs uses axes 3 for hat, so don't calibrate it.
162 if (Config_control_type == CONTROL_THRUSTMASTER_FCS) {
164 axis_cen[3] = temp_values[3]/2;
165 axis_max[3] = temp_values[3];
169 if (Joy_is_Sidewinder || Config_control_type != CONTROL_THRUSTMASTER_FCS) {
170 // masks = joy_get_present_mask();
172 if ( nsticks == 2 ) {
173 if ( kconfig_is_axes_used(2) || kconfig_is_axes_used(3) ) {
174 if(Joy_is_Sidewinder)
176 sprintf( title, "%s\nTWIST-LEFT", TXT_JOYSTICK);
177 sprintf( text, "Twist Joystick to \nthe left side");
181 sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_UPPER_LEFT);
182 sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_UL);
184 if (joycal_message( title, text )) {
185 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
188 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
189 axis_min[2] = temp_values[2];
190 axis_min[3] = temp_values[3];
193 if(Joy_is_Sidewinder)
195 sprintf( title, "%s\nTWIST-RIGHT", TXT_JOYSTICK);
196 sprintf( text, "Twist Joystick to \nthe right side");
200 sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_LOWER_RIGHT);
201 sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_LR);
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_max[2] = temp_values[2];
209 axis_max[3] = temp_values[3];
213 if(Joy_is_Sidewinder)
215 sprintf( title, "%s\nCENTER", TXT_JOYSTICK);
216 sprintf( text, "%s %s",TXT_MOVE_JOYSTICK, TXT_TO_C);
220 sprintf( title, "%s #2\n%s", TXT_JOYSTICK, TXT_CENTER);
221 sprintf( text, "%s #2 %s", TXT_MOVE_JOYSTICK, TXT_TO_C);
224 if (joycal_message( title, text )) {
225 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
228 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
229 axis_cen[2] = temp_values[2];
230 axis_cen[3] = temp_values[3];
233 } else if ( (!(masks & JOY_2_X_AXIS)) && (masks & JOY_2_Y_AXIS) ) {
234 if ( kconfig_is_axes_used(3) ) {
235 // A throttle axis!!!!!
236 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_FORWARD);
237 if (joycal_message( title, TXT_MOVE_THROTTLE_F)) {
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_min[3] = temp_values[3];
245 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_REVERSE);
246 if (joycal_message( title, TXT_MOVE_THROTTLE_R)) {
247 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
250 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
251 axis_max[3] = temp_values[3];
254 sprintf( title, "%s\n%s", TXT_THROTTLE, TXT_CENTER);
255 if (joycal_message( title, TXT_MOVE_THROTTLE_C)) {
256 joy_set_cal_vals(org_axis_min, org_axis_center, org_axis_max);
259 joystick_read_raw_axis( JOY_ALL_AXIS, temp_values );
260 axis_cen[3] = temp_values[3];
265 joy_set_cal_vals(axis_min, axis_cen, axis_max);
268 //added 9/1/98 by Victor Rachels to make sidewinder calibratable
269 /* if(Joy_is_Sidewinder)
270 Config_control_type=tempstick; */
271 //end this section addition - Victor Rachels
278 //char *control_text[CONTROL_MAX_TYPES] = { "Keyboard only", "Joystick", "Flightstick Pro", "Thrustmaster FCS", "Gravis Gamepad", "Mouse", "Cyberman" };
280 void joydef_menuset_1(int nitems, newmenu_item * items, int *last_key, int citem )
283 int oc_type = Config_control_type;
289 for (i=0; i<CONTROL_MAX_TYPES; i++ )
290 if (items[i].value) Config_control_type = i;
292 if ( (oc_type != Config_control_type) && (Config_control_type == CONTROL_THRUSTMASTER_FCS ) ) {
293 nm_messagebox( TXT_IMPORTANT_NOTE, 1, TXT_OK, TXT_FCS );
296 if (oc_type != Config_control_type) {
297 switch (Config_control_type) {
298 // case CONTROL_NONE:
299 case CONTROL_JOYSTICK:
300 case CONTROL_FLIGHTSTICK_PRO:
301 case CONTROL_THRUSTMASTER_FCS:
302 case CONTROL_GRAVIS_GAMEPAD:
303 // case CONTROL_MOUSE:
304 // case CONTROL_CYBERMAN:
305 joydefs_calibrate_flag = 1;
312 extern ubyte kc_use_external_control;
313 extern ubyte kc_enable_external_control;
314 extern ubyte *kc_external_name;
316 void joydefs_config()
319 int i, old_masks, masks;
326 m[0].type = NM_TYPE_RADIO; m[0].text = CONTROL_TEXT(0); m[0].value = 0; m[0].group = 0;
327 m[1].type = NM_TYPE_RADIO; m[1].text = CONTROL_TEXT(1); m[1].value = 0; m[1].group = 0;
328 m[2].type = NM_TYPE_RADIO; m[2].text = CONTROL_TEXT(2); m[2].value = 0; m[2].group = 0;
329 m[3].type = NM_TYPE_RADIO; m[3].text = CONTROL_TEXT(3); m[3].value = 0; m[3].group = 0;
330 m[4].type = NM_TYPE_RADIO; m[4].text = CONTROL_TEXT(4); m[4].value = 0; m[4].group = 0;
331 m[5].type = NM_TYPE_RADIO; m[5].text = CONTROL_TEXT(5); m[5].value = 0; m[5].group = 0;
332 m[6].type = NM_TYPE_RADIO; m[6].text = CONTROL_TEXT(6); m[6].value = 0; m[6].group = 0;
333 m[7].type = NM_TYPE_MENU; m[7].text=TXT_CUST_ABOVE;
334 m[8].type = NM_TYPE_TEXT; m[8].text="";
335 m[9].type = NM_TYPE_MENU; m[9].text=TXT_CUST_KEYBOARD;
336 //added on 2/5/99 by Victor Rachels to add d1x key menu
337 m[10].type = NM_TYPE_MENU; m[10].text="CUSTOMIZE D1X KEYS";
338 //end this section addition - VR
339 m[11].type = NM_TYPE_CHECK; m[11].text= "Joy is Sidewinder"; m[11].value=Joy_is_Sidewinder;
341 if ( kc_use_external_control ) {
342 sprintf( xtext, "Enable %s", kc_external_name );
343 m[12].type = NM_TYPE_CHECK; m[12].text = xtext; m[12].value = kc_enable_external_control;
347 m[Config_control_type].value = 1;
349 i1 = newmenu_do1( NULL, TXT_CONTROLS, nitems, m, joydef_menuset_1, i1 );
351 //added on 9/1/98 by Victor Rachels to add Sidewinder calibration
352 Joy_is_Sidewinder = m[11].value;
353 //end this section addition
358 for (i=0; i<4; i++ ) {
359 if (kconfig_is_axes_used(i))
362 if ( Config_control_type==0 )
364 Config_control_type=0;
365 else if ( Config_control_type<5 )
366 kconfig(1, CONTROL_TEXT(Config_control_type) );
368 kconfig(2, CONTROL_TEXT(Config_control_type) );
371 for (i=0; i<4; i++ ) {
372 if (kconfig_is_axes_used(i))
376 switch (Config_control_type) {
377 case CONTROL_JOYSTICK:
378 case CONTROL_FLIGHTSTICK_PRO:
379 case CONTROL_THRUSTMASTER_FCS:
381 for (i=0; i<4; i++ ) {
382 if ( (masks&(1<<i)) && (!(old_masks&(1<<i))))
383 joydefs_calibrate_flag = 1;
391 kconfig(0, TXT_KEYBOARD);
393 //added on 2/5/99 by Victor Rachels to add d1x key menu
395 kconfig(3,"D1X Keys");
397 //end this section addition - VR
400 if ( kc_use_external_control ) {
401 kc_enable_external_control = m[12].value;
406 switch (Config_control_type) {
407 case CONTROL_JOYSTICK:
408 case CONTROL_FLIGHTSTICK_PRO:
409 case CONTROL_THRUSTMASTER_FCS:
410 case CONTROL_GRAVIS_GAMEPAD:
411 if ( joydefs_calibrate_flag )
419 #endif // __ENV_DJGPP__