1 /* $Id: joydefs.c,v 1.2 2003-03-13 00:20:21 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-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
17 * Linux joystick support
55 int joydefs_calibrate_flag = 0;
57 //added 9/6/98 Matt Mueller - not needed at all in linux code but bunches
58 int Joy_is_Sidewinder=0;// of main/* stuff uses it
63 //int t1 = TICKER + 19/4; // Wait 1/4 second...
65 //while( TICKER < t1 );
71 int joycal_message( char * title, char * text )
75 m[0].type = NM_TYPE_TEXT; m[0].text = text;
76 m[1].type = NM_TYPE_MENU; m[1].text = TXT_OK;
77 i = newmenu_do( title, NULL, 2, m, NULL );
83 extern int WriteConfigFile();
85 extern joystick_device j_joystick[4];
86 extern joystick_axis j_axis[MAX_AXES];
87 extern joystick_button j_button[MAX_BUTTONS];
89 void joydefs_calibrate()
93 int temp_values[MAX_AXES];
96 //added/killed on 10/17/98 by Hans de Goede for joystick/mouse # fix
97 //-killed- int nsticks = 0;
98 //end this section kill - Hans
100 joydefs_calibrate_flag = 0;
103 nm_messagebox( NULL, 1, TXT_OK, TXT_NO_JOYSTICK );
107 if (j_joystick[0].version) {
108 joycal_message ("No Calibration", "calibration not required for\njoystick v1.x");
112 for (i = 0; i < j_num_axes; i += 2) {
113 sprintf (title, "js%d Calibration", j_axis[i].joydev);
115 sprintf (text, "center joystick %d", j_axis[i].joydev);
116 joycal_message (title, text);
117 joystick_read_raw_axis (JOY_ALL_AXIS, temp_values);
118 j_axis[i].center_val = temp_values[i];
119 j_axis[i + 1].center_val = temp_values[i + 1];
121 sprintf (text, "move joystick %d to the upper left", j_axis[i].joydev);
122 joycal_message (title, text);
123 joystick_read_raw_axis (JOY_ALL_AXIS, temp_values);
124 j_axis[i].min_val = temp_values[i];
125 j_axis[i + 1].min_val = temp_values[i + 1];
127 sprintf (text, "move joystick %d to the lower right", j_axis[i].joydev);
128 joycal_message (title, text);
129 joystick_read_raw_axis (JOY_ALL_AXIS, temp_values);
130 j_axis[i].max_val = temp_values[i];
131 j_axis[i + 1].max_val = temp_values[i + 1];
139 //char *control_text[CONTROL_MAX_TYPES] = { "Keyboard only", "Joystick", "Flightstick Pro", "Thrustmaster FCS", "Gravis Gamepad", "Mouse", "Cyberman" };
141 void joydef_menuset_1(int nitems, newmenu_item * items, int *last_key, int citem )
144 int oc_type = Config_control_type;
151 if (items[i].value) Config_control_type = i;
153 //added on 10/17/98 by Hans de Goede for joystick/mouse # fix
154 // remap mouse, since "Flightstick Pro", "Thrustmaster FCS"
155 // and "Gravis Gamepad" where removed from the options
156 if (Config_control_type == 2) Config_control_type = CONTROL_MOUSE;
157 //end this section addition - Hans
159 if ( (oc_type != Config_control_type) && (Config_control_type == CONTROL_THRUSTMASTER_FCS ) ) {
160 nm_messagebox( TXT_IMPORTANT_NOTE, 1, TXT_OK, TXT_FCS );
163 if (oc_type != Config_control_type) {
164 switch (Config_control_type) {
165 // case CONTROL_NONE:
166 case CONTROL_JOYSTICK:
167 case CONTROL_FLIGHTSTICK_PRO:
168 case CONTROL_THRUSTMASTER_FCS:
169 case CONTROL_GRAVIS_GAMEPAD:
170 // case CONTROL_MOUSE:
171 // case CONTROL_CYBERMAN:
172 joydefs_calibrate_flag = 1;
179 extern ubyte kc_use_external_control;
180 extern ubyte kc_enable_external_control;
181 extern ubyte *kc_external_name;
183 void joydefs_config()
185 //added/changed/killed on 10/17/98 by Hans de Goede for joystick/mouse # fix
186 //-killed- char xtext[128];
187 //-killed- int i, old_masks, masks;
190 //-killed- int nitems;
193 //-killed- nitems = 6;
194 int i, i1=5, j, nitems=7;
195 //end this section kill/change - Hans
197 m[0].type = NM_TYPE_RADIO; m[0].text = "KEYBOARD"; m[0].value = 0; m[0].group = 0;
198 m[1].type = NM_TYPE_RADIO; m[1].text = "JOYSTICK"; m[1].value = 0; m[1].group = 0;
199 m[2].type = NM_TYPE_RADIO; m[2].text = "MOUSE"; m[2].value = 0; m[2].group = 0;
200 m[3].type = NM_TYPE_TEXT; m[3].text="";
201 m[4].type = NM_TYPE_MENU; m[4].text="CUSTOMIZE ABOVE";
202 m[5].type = NM_TYPE_MENU; m[5].text="CUSTOMIZE KEYBOARD";
203 //added on 2/5/99 by Victor Rachels for D1X keys menu
204 m[6].type = NM_TYPE_MENU; m[6].text="CUSTOMIZE D1X KEYS";
205 //end this section addition - VR
207 //added/changed/killed on 10/17/98 by Hans de Goede for joystick/mouse # fix
208 //-killed- m[Config_control_type].value = 1;
213 i = Config_control_type;
214 if(i==CONTROL_MOUSE) i = 2;
217 //end this section change/addition - Hans
219 i1 = newmenu_do1( NULL, TXT_CONTROLS, nitems, m, joydef_menuset_1, i1 );
221 //added 6-15-99 Owen Evans
222 for (j = 0; j <= 2; j++)
224 Config_control_type = j;
225 i = Config_control_type;
226 if (Config_control_type == 2)
227 Config_control_type = CONTROL_MOUSE;
232 //added/changed on 10/17/98 by Hans de Goede for joystick/mouse # fix
233 //-killed- kconfig(Config_control_type, m[Config_control_type].text);
234 kconfig (i, m[i].text);
235 //end this section change - Hans
238 kconfig(0, "KEYBOARD");
240 //added on 2/5/99 by Victor Rachels for D1X keys menu
242 kconfig(3, "D1X KEYS");
244 //end this section addition - VR