1 /* $Id: kconfig.c,v 1.40 2005-08-02 06:13:56 chris 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 * Routines to configure keyboard, joystick, etc..
26 static char rcsid[] = "$Id: kconfig.c,v 1.40 2005-08-02 06:13:56 chris Exp $";
80 ubyte ExtGameStatus=1;
82 vms_vector ExtForceVec;
83 vms_matrix ExtApplyForceMatrix;
85 int ExtJoltInfo[3]={0,0,0};
86 int ExtXVibrateInfo[2]={0,0};
87 int ExtYVibrateInfo[2]={0,0};
88 ubyte ExtXVibrateClear=0;
89 ubyte ExtYVibrateClear=0;
91 #define TABLE_CREATION 1
93 // Array used to 'blink' the cursor while waiting for a keypress.
94 sbyte fades[64] = { 1,1,1,2,2,3,4,4,5,6,8,9,10,12,13,15,16,17,19,20,22,23,24,26,27,28,28,29,30,30,31,31,31,31,31,30,30,29,28,28,27,26,24,23,22,20,19,17,16,15,13,12,10,9,8,6,5,4,4,3,2,2,1,1 };
96 //char * invert_text[2] = { "N", "Y" };
97 //char * joybutton_text[28] = { "BTN 1", "BTN 2", "BTN 3", "BTN 4", "", "TRIG", "LEFT", "HAT \x81", "RIGHT", "", "", "HAT \x80", "MID", "", "", "HAT \x7f", "", "", "", "HAT \x82", "TRIG", "LEFT", "RIGHT", "", "UP","DOWN","LEFT", "RIGHT" };
98 //char * joyaxis_text[4] = { "X1", "Y1", "X2", "Y2" };
99 //char * mouseaxis_text[2] = { "L/R", "F/B" };
100 //char * mousebutton_text[3] = { "Left", "Right", "Mid" };
102 int invert_text[2] = { TNUM_N, TNUM_Y };
104 #ifndef USE_LINUX_JOY
106 int joybutton_text[28] =
107 { TNUM_BTN_1, TNUM_BTN_2, TNUM_BTN_3, TNUM_BTN_4,
111 TNUM_HAT_L, TNUM_HAT_R, TNUM_HAT_U, TNUM_HAT_D,
115 int joyaxis_text[7] = { TNUM_X1, TNUM_Y1, TNUM_Z1, TNUM_UN, TNUM_P1,TNUM_R1,TNUM_YA1 };
116 #elif defined(SDL_INPUT)
117 char *joybutton_text[JOY_MAX_BUTTONS];
118 char *joyaxis_text[JOY_MAX_AXES];
120 int joybutton_text[28] =
121 { TNUM_BTN_1, TNUM_BTN_2, TNUM_BTN_3, TNUM_BTN_4,
122 -1, TNUM_TRIG, TNUM_LEFT, TNUM_HAT_L,
123 TNUM_RIGHT, -1, TNUM_HAT2_D, TNUM_HAT_R,
124 TNUM_MID, -1, TNUM_HAT2_R, TNUM_HAT_U,
125 TNUM_HAT2_L, -1, TNUM_HAT2_U, TNUM_HAT_D,
126 TNUM_TRIG, TNUM_LEFT, TNUM_RIGHT, -1,
127 TNUM_UP, TNUM_DOWN, TNUM_LEFT, TNUM_RIGHT };
129 int joyaxis_text[7] = { TNUM_X1, TNUM_Y1, TNUM_Z1, TNUM_UN, TNUM_P1,TNUM_R1,TNUM_YA1 };
130 // int joyaxis_text[4] = { TNUM_X1, TNUM_Y1, TNUM_X2, TNUM_Y2 };
134 int mouseaxis_text[3] = { TNUM_L_R, TNUM_F_B, TNUM_Z1 };
136 int mousebutton_text[3] = { TNUM_LEFT, TNUM_RIGHT, TNUM_MID };
137 char * mousebutton_textra[13] = { "M4", "M5", "M6", "M7", "M8", "M9", "M10","M11","M12","M13","M14","M15","M16" };//text for buttons above 3. -MPM
139 char *mousebutton_text[3] = { "Btn", "", "" }; // only one silly mouse button on the mac
143 char * key_text[256] = {
144 "","S","D","F","H","G","Z","X","C","V","","B","Q", "W", "E", "R",
145 "Y","T","1","2","3","4","6","5","=","9","7","-", "8", "0", "]", "O",
146 "U","[","I","P","RET","L","J","'","K", ";", "\\", ",", "/", "N", "M", ".",
147 "TAB","SPC","`","DEL","","ESC","","APL","SHIFT","CAPSL","OPTN","CTRL","","","","A",
148 "","PAD.","","PAD*","","PAD+","","NMLCK","","","","PAD/","ENTER","","PAD-","",
149 "","PAD=","PAD0","PAD1","PAD2","PAD3","PAD4","PAD5","PAD6","PAD7","","PAD8","PAD9","","","",
150 "F5","F6","F7","","F8","F9","","F11","","F13","","F14","","F10","","F12",
151 "","PAUSE","HELP","HOME","PGUP","DEL","","END","F2","","F1","LARW","RARW","DARW","UARW","",
152 "","","","","","","","","","","","","","","","",
153 "","","","","","","","","","","","","","","","",
154 "","","","","","","","","","","","","","","","",
155 "","","","","","","","","","","","","","","","",
156 "","","","","","","","","","","","","","","","",
157 "","","","","","","","","","","","","","","","",
158 "","","","","","","","","","","","","","","","",
159 "","","","","","","","","","","","","","","",""};
161 #if !defined OGL && !defined SDL_INPUT
162 char * key_text[256] = { \
163 "","ESC","1","2","3","4","5","6","7","8","9","0","-", \
164 "=","BSPC","TAB","Q","W","E","R","T","Y","U","I","O", \
165 "P","[","]","\x83","LCTRL","A","S","D","F", \
166 "G","H","J","K","L",";","'","`", \
167 "LSHFT","\\","Z","X","C","V","B","N","M",",", \
168 ".","/","RSHFT","PAD*","LALT","SPC", \
169 "CPSLK","F1","F2","F3","F4","F5","F6","F7","F8","F9", \
170 "F10","NMLCK","SCLK","PAD7","PAD8","PAD9","PAD-", \
171 "PAD4","PAD5","PAD6","PAD+","PAD1","PAD2","PAD3","PAD0", \
172 "PAD.","","","","F11","F12","","","","","","","","","", \
173 "","","","","","","","","","","","","","","","","","","","", \
174 "","","","","","","","","","","","","","","","","","","","", \
175 "","","","","","","","","","","","","","","","","","", \
176 "PAD\x83","RCTRL","","","","","","","","","","","","","", \
177 "","","","","","","","","","","PAD/","","","RALT","", \
178 "","","","","","","","","","","","","","HOME","\x82","PGUP", \
179 "","\x81","","\x7f","","END","\x80","PGDN","INS", \
180 "DEL","","","","","","","","","","","","","","","","","", \
181 "","","","","","","","","","","","","","","","","","","","", \
182 "","","","","","","" };
187 //added/removed by Victor Rachels for adding rebindable keys for these
188 // KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0
189 ubyte system_keys[] = { KEY_ESC, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_MINUS, KEY_EQUAL, KEY_PRINT_SCREEN };
191 ubyte system_keys[] = { KEY_ESC, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, KEY_MINUS, KEY_EQUAL, KEY_PRINT_SCREEN };
194 //extern void GameLoop(int, int );
196 extern void transfer_energy_to_shield(fix);
197 extern void CyclePrimary(),CycleSecondary(),InitMarkerInput();
198 extern ubyte DefiningMarkerMessage;
199 extern char CybermouseActive;
202 extern int joydefsw_do_button();
203 extern int joydefsw_do_winjoybutton(int *axis);
204 extern joydefsw_win_joyselect(char *title);
207 control_info Controls;
211 // macros for drawing lo/hi res kconfig screens (see scores.c as well)
213 #define LHX(x) ((x)*(MenuHires?2:1))
214 #define LHY(y) ((y)*(MenuHires?2.4:1))
218 #define BT_MOUSE_BUTTON 1
219 #define BT_MOUSE_AXIS 2
220 #define BT_JOY_BUTTON 3
221 #define BT_JOY_AXIS 4
224 char *btype_text[] = { "BT_KEY", "BT_MOUSE_BUTTON", "BT_MOUSE_AXIS", "BT_JOY_BUTTON", "BT_JOY_AXIS", "BT_INVERT" };
228 typedef struct kc_item {
229 short id; // The id of this item
237 ubyte value; // what key,button,etc
243 ubyte kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS];
245 //added on 2/4/99 by Victor Rachels to add d1x new keys
246 ubyte kconfig_d2x_settings[MAX_D2X_CONTROLS];
247 //end this section addition - VR
249 //----------- WARNING!!!!!!! -------------------------------------------
250 // THESE NEXT FOUR BLOCKS OF DATA ARE GENERATED BY PRESSING DEL+F12 WHEN
251 // IN THE KEYBOARD CONFIG SCREEN. BASICALLY, THAT PROCEDURE MODIFIES THE
252 // U,D,L,R FIELDS OF THE ARRAYS AND DUMPS THE NEW ARRAYS INTO KCONFIG.COD
253 //-------------------------------------------------------------------------
254 /*ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
255 {0xc8,0x48,0xd0,0x50,0xcb,0x4b,0xcd,0x4d,0x38,0xff,0xff,0x4f,0xff,0x51,0xff,0x4a,0xff,0x4e,0xff,0xff,0x10,0x47,0x12,0x49,0x1d,0x9d,0x39,0xff,0x21,0xff,0x1e,0xff,0x2c,0xff,0x30,0xff,0x13,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf,0xff,0x1f,0xff,0x33,0xff,0x34,0xff,0x23,0xff,0x14,0xff,0xff,0xff,0x0,0x0},
256 {0x0,0x1,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
257 {0x5,0xc,0xff,0xff,0xff,0xff,0x7,0xf,0x13,0xb,0xff,0x6,0x8,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
258 {0x0,0x1,0xff,0xff,0x2,0xff,0x7,0xf,0x13,0xb,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0x3,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
259 {0x3,0x0,0x1,0x2,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
260 {0x0,0x1,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
261 {0x0,0x1,0xff,0xff,0x2,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
265 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
266 {0xc8,0x48,0xd0,0x50,0xcb,0x4b,0xcd,0x4d,0x38,0xff,0xff,0x4f,0xff,0x51,0xff,0x4a,0xff,0x4e,0xff,0xff,0x10,0x47,0x12,0x49,0x1d,0x9d,0x39,0xff,0x21,0xff,0x1e,0xff,0x2c,0xff,0x30,0xff,0x13,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf,0xff,0x1f,0xff,0x33,0xff,0x34,0xff,0x23,0xff,0x14,0xff,0xff,0xff,0x0,0x0},
267 {0x0,0x1,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0},
268 {0x5,0xc,0xff,0xff,0xff,0xff,0x7,0xf,0x13,0xb,0xff,0x6,0x8,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0},
269 {0x0,0x1,0xff,0xff,0x2,0xff,0x7,0xf,0x13,0xb,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x3,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0},
270 {0x3,0x0,0x1,0x2,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0},
271 {0x0,0x1,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0},
272 {0x0,0x1,0xff,0xff,0x2,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0},
274 {0x0,0x1,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0},
280 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
281 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
282 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
283 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
284 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
285 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
286 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
287 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
288 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
289 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
290 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
291 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
292 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
293 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
294 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
295 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
296 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
297 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
298 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
299 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
300 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
301 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
302 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
303 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
304 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
305 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
306 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
307 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
308 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
309 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
310 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
311 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
312 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
313 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
314 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
315 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
316 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
317 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
318 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
319 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
320 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
321 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
322 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
323 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
324 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
325 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
326 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
327 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
328 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
329 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
330 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
331 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
332 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
333 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
334 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
335 { 54,158,171, 83, 26, 52, 56, 51, 55,"Energy->Shield", BT_KEY, 255 },
336 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
337 { 56,158,179,83, 26, 54, 0, 0, 0, "Toggle Bomb", BT_KEY,255},
339 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
340 { 0, 25, 46, 85, 40, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
341 { 1, 25, 54, 85, 40, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
342 { 2, 25, 85, 85, 40, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
343 { 3, 25, 93, 85, 40, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
344 { 4, 25, 62, 85, 40, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
345 { 5,180, 46, 79, 40, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
346 { 6,180, 54, 79, 40, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
347 { 7,180, 62, 79, 40, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
348 { 8,180, 70, 79, 40, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
349 { 9,180, 78, 79, 40, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
350 { 10,180, 90, 79, 40, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
351 { 11,180, 98, 79, 40, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
352 { 12,180,106, 79, 40, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
353 { 13, 22,154, 51, 40, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
354 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
355 { 15, 22,162, 51, 40, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
356 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
357 { 17,164,154, 58, 40, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
358 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
359 { 19,164,162, 58, 40, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
360 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
361 { 21,164,172, 58, 40, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
362 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
363 { 23,164,180, 58, 40, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
364 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
365 { 25, 25,109, 85, 40, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
366 { 26, 25, 70, 85, 40, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
367 { 27, 25,117, 85, 40, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
368 { 28,180,114, 79, 40, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
369 { 29,180,122, 79, 40, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
370 { 30, 25,125, 85, 40, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
372 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
373 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
374 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
375 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
376 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
377 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
378 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
379 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
380 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
381 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
382 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
383 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
384 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
385 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
386 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
387 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
388 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
389 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
390 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
391 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
392 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
393 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
394 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
395 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
396 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
397 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
398 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
399 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
400 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
401 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
402 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
403 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
406 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
407 { 0, 25, 46, 85, 26, 12, 1, 24, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
408 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
409 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
410 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
411 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
412 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
413 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
414 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
415 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
416 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
417 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
418 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
419 { 12,180,106, 59, 26, 11, 0, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
420 { 13,103,138, 58, 26, 27, 15, 25, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
421 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
422 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
423 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
424 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
425 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
426 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
427 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
428 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
429 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
430 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
431 { 24,103,182,106, 8, 22, 5, 23, 0,"throttle", BT_INVERT, 255 },
432 { 25, 25,109, 85, 26, 3, 27, 12, 13,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
433 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
434 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
438 //added on 2/4/99 by Victor Rachels to add d1x new keys
439 kc_item kc_d2x[NUM_D2X_CONTROLS] = {
440 // id,x,y,w1,w2,u,d,l,r,text_num1,type,value
441 { 0, 15, 49, 71, 26, 27, 2, 27, 1, "WEAPON 1", BT_KEY, 255},
442 { 1, 15, 49,100, 26, 26, 3, 0, 2, "WEAPON 1", BT_JOY_BUTTON, 255},
443 { 2, 15, 57, 71, 26, 0, 4, 1, 3, "WEAPON 2", BT_KEY, 255},
444 { 3, 15, 57,100, 26, 1, 5, 2, 4, "WEAPON 2", BT_JOY_BUTTON, 255},
445 { 4, 15, 65, 71, 26, 2, 6, 3, 5, "WEAPON 3", BT_KEY, 255},
446 { 5, 15, 65,100, 26, 3, 7, 4, 6, "WEAPON 3", BT_JOY_BUTTON, 255},
447 { 6, 15, 73, 71, 26, 4, 8, 5, 7, "WEAPON 4", BT_KEY, 255},
448 { 7, 15, 73,100, 26, 5, 9, 6, 8, "WEAPON 4", BT_JOY_BUTTON, 255},
449 { 8, 15, 81, 71, 26, 6, 10, 7, 9, "WEAPON 5", BT_KEY, 255},
450 { 9, 15, 81,100, 26, 7, 11, 8, 10, "WEAPON 5", BT_JOY_BUTTON, 255},
452 { 10, 15, 89, 71, 26, 8, 12, 9, 11, "WEAPON 6", BT_KEY, 255},
453 { 11, 15, 89,100, 26, 9, 13, 10, 12, "WEAPON 6", BT_JOY_BUTTON, 255},
454 { 12, 15, 97, 71, 26, 10, 14, 11, 13, "WEAPON 7", BT_KEY, 255},
455 { 13, 15, 97,100, 26, 11, 15, 12, 14, "WEAPON 7", BT_JOY_BUTTON, 255},
456 { 14, 15,105, 71, 26, 12, 16, 13, 15, "WEAPON 8", BT_KEY, 255},
457 { 15, 15,105,100, 26, 13, 17, 14, 16, "WEAPON 8", BT_JOY_BUTTON, 255},
458 { 16, 15,113, 71, 26, 14, 18, 15, 17, "WEAPON 9", BT_KEY, 255},
459 { 17, 15,113,100, 26, 15, 19, 16, 18, "WEAPON 9", BT_JOY_BUTTON, 255},
460 { 18, 15,121, 71, 26, 16, 20, 17, 19, "WEAPON 0", BT_KEY, 255},
461 { 19, 15,121,100, 26, 17, 21, 18, 20, "WEAPON 0", BT_JOY_BUTTON, 255},
463 //{ 20, 15,131, 71, 26, 18, 22, 19, 21, "CYC PRIMARY", BT_KEY, 255},
464 //{ 21, 15,131,100, 26, 19, 23, 20, 22, "CYC PRIMARY", BT_JOY_BUTTON, 255},
465 //{ 22, 15,139, 71, 26, 20, 24, 21, 23, "CYC SECONDARY", BT_KEY, 255},
466 //{ 23, 15,139,100, 26, 21, 25, 22, 24, "CYC SECONDARY", BT_JOY_BUTTON, 255},
467 //{ 24, 8,147, 78, 26, 22, 26, 23, 25, "TOGGLE_PRIM AUTO", BT_KEY, 255},
468 //{ 25, 8,147,107, 26, 23, 27, 24, 26, "TOGGLE_PRIM_AUTO", BT_JOY_BUTTON, 255},
469 //{ 26, 8,155, 78, 26, 24, 1, 25, 27, "TOGGLE SEC AUTO", BT_KEY, 255},
470 //{ 27, 8,155,107, 26, 25, 0, 26, 0, "TOGGLE SEC AUTO", BT_JOY_BUTTON, 255},
472 //end this section addition - VR
475 #else // ifndef MACINTOSH (following are macintosh controls)
477 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
478 {0x5b,0x7e,0x54,0x7d,0x56,0x7b,0x58,0x7c,0x3a,0xff,0xff,0x53,0xff,0x55,0xff,0x4e,0xff,0x45,0xff,0xff,0xc,0x59,0xe,0x5c,0x3b,0x24,0x31,0xff,0x3,0xff,0x3f,0xff,0x6,0xff,0xb,0xff,0xf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x30,0xff,0x1,0xff,0x2b,0xff,0x2f,0xff,0x4,0xff,0x11,0xff,0xff,0xff,0x0,0x0},
479 {0x0,0x1,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0},
480 {0x0,0x3,0xff,0xff,0xff,0xff,0xb,0xc,0x9,0xa,0xff,0x1,0x2,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0},
481 {0x5,0x4,0xff,0xff,0x6,0xff,0x3,0x2,0x0,0x1,0xff,0x8,0xa,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0x3,0x1,0xb,0x7,0xd,0xe,0xf,0xc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0},
482 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0},
483 {0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0},
484 {0x0,0x1,0xff,0xff,0x2,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0},
487 ubyte default_firebird_settings[MAX_CONTROLS] =
488 {0x0,0x1,0xff,0xff,0x2,0xff,0x4,0x6,0x5,0x7,0xff,0xb,0xc,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0x03,0x0,0xff,0x3,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0};
490 ubyte default_mousestick_settings[MAX_CONTROLS] =
491 {0x2,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3,0x4,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0};
493 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
494 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
495 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
496 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
497 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
498 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
499 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
500 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
501 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
502 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
503 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
504 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
505 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
506 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
507 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
508 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
509 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
510 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
511 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
512 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
513 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
514 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
515 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
516 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
517 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
518 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
519 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
520 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
521 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
522 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
523 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
524 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
525 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
526 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
527 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
528 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
529 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
530 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
531 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
532 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
533 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
534 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
535 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
536 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
537 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
538 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
539 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
540 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
541 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
542 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
543 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
544 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
545 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
546 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
547 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
548 { 54,158,171, 83, 26, 52, 25, 51, 55,"Energy->Shield", BT_KEY, 255 },
549 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
551 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
552 { 0, 25, 46, 85, 28, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
553 { 1, 25, 54, 85, 28, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
554 { 2, 25, 85, 85, 28, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
555 { 3, 25, 93, 85, 28, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
556 { 4, 25, 62, 85, 28, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
557 { 5,180, 46, 79, 28, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
558 { 6,180, 54, 79, 28, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
559 { 7,180, 62, 79, 28, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
560 { 8,180, 70, 79, 28, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
561 { 9,180, 78, 79, 28, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
562 { 10,180, 90, 79, 28, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
563 { 11,180, 98, 79, 28, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
564 { 12,180,106, 79, 28, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
565 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
566 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
567 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
568 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
569 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
570 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
571 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
572 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
573 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
574 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
575 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
576 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
577 { 25, 25,109, 85, 28, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
578 { 26, 25, 70, 85, 28, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
579 { 27, 25,117, 85, 28, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
580 { 28,180,114, 79, 28, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
581 { 29,180,122, 79, 28, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
582 { 30, 25,125, 85, 28, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
584 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
585 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
586 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
587 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
588 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
589 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
590 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
591 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
592 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
593 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
594 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
595 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
596 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
597 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
598 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
599 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
600 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
601 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
602 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
603 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
604 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
605 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
606 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
607 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
608 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
609 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
610 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
611 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
612 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
613 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
614 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
615 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
618 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
619 { 0, 25, 46, 85, 26, 28, 1, 28, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
620 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
621 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
622 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
623 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
624 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
625 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
626 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
627 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
628 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
629 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
630 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
631 { 12,180,106, 59, 26, 11, 28, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
632 { 13,103,138, 58, 26, 27, 15, 27, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
633 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
634 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
635 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
636 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
637 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
638 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
639 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
640 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
641 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
642 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
643 { 24,103,182,106, 8, 22, 5, 23, 28,"throttle", BT_INVERT, 255 },
644 { 25, 25,109, 85, 26, 3, 27, 12, 27,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
645 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
646 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
651 //added on 2/4/99 by Victor Rachels to add new keys system
652 ubyte default_kconfig_d2x_settings[MAX_D2X_CONTROLS] = {
653 0x2 ,0xff,0x3 ,0xff,0x4 ,0xff,0x5 ,0xff,0x6 ,0xff,0x7 ,0xff,0x8 ,0xff,0x9 ,
654 0xff,0xa ,0xff,0xb ,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
655 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff };
656 //end this section addition - VR
658 void kc_drawitem( kc_item *item, int is_current );
659 void kc_change_key( kc_item * item );
660 void kc_change_joybutton( kc_item * item );
661 void kc_change_mousebutton( kc_item * item );
662 void kc_next_joyaxis(kc_item *item); //added by WraithX on 11/22/00
663 void kc_change_joyaxis( kc_item * item );
664 void kc_change_mouseaxis( kc_item * item );
665 void kc_change_invert( kc_item * item );
666 void kconfig_read_fcs( int raw_axis );
667 void kconfig_set_fcs_button( int btn, int button );
668 void kconfig_read_external_controls( void );
670 // the following methods added by WraithX, 4/17/00
671 int isJoyRotationKey(int test_key)
673 if (test_key == kc_joystick[11].value ||
674 test_key == kc_joystick[12].value)
681 }// method isJoyRotationKey
683 int isMouseRotationKey(int test_key)
685 if (test_key == kc_mouse[11].value ||
686 test_key == kc_mouse[12].value)
693 }// method isMouseRotationKey
695 int isKeyboardRotationKey(int test_key)
697 if (test_key == kc_keyboard[0].value ||
698 test_key == kc_keyboard[1].value ||
699 test_key == kc_keyboard[2].value ||
700 test_key == kc_keyboard[3].value ||
701 test_key == kc_keyboard[4].value ||
702 test_key == kc_keyboard[5].value ||
703 test_key == kc_keyboard[6].value ||
704 test_key == kc_keyboard[7].value ||
705 test_key == kc_keyboard[20].value ||
706 test_key == kc_keyboard[21].value ||
707 test_key == kc_keyboard[22].value ||
708 test_key == kc_keyboard[23].value)
715 }// method isKeyboardRotationKey
716 // end addition - WraithX
718 int kconfig_is_axes_used(int axis)
721 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
722 if (( kc_joystick[i].type == BT_JOY_AXIS ) && (kc_joystick[i].value == axis ))
728 #ifdef TABLE_CREATION
729 int find_item_at( kc_item * items, int nitems, int x, int y )
733 for (i=0; i<nitems; i++ ) {
734 if ( ((items[i].x+items[i].w1)==x) && (items[i].y==y))
740 int find_next_item_up( kc_item * items, int nitems, int citem )
745 x = items[citem].x+items[citem].w1;
750 y = grd_curcanv->cv_bitmap.bm_h-1;
753 x = grd_curcanv->cv_bitmap.bm_w-1;
756 i = find_item_at( items, nitems, x, y );
762 int find_next_item_down( kc_item * items, int nitems, int citem )
767 x = items[citem].x+items[citem].w1;
771 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
774 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
778 i = find_item_at( items, nitems, x, y );
784 int find_next_item_right( kc_item * items, int nitems, int citem )
789 x = items[citem].x+items[citem].w1;
793 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
796 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
800 i = find_item_at( items, nitems, x, y );
806 int find_next_item_left( kc_item * items, int nitems, int citem )
811 x = items[citem].x+items[citem].w1;
816 x = grd_curcanv->cv_bitmap.bm_w-1;
819 y = grd_curcanv->cv_bitmap.bm_h-1;
822 i = find_item_at( items, nitems, x, y );
830 int get_item_height(kc_item *item)
835 if (item->value==255) {
838 switch( item->type ) {
840 strncpy( btext, key_text[item->value], 10 ); break;
841 case BT_MOUSE_BUTTON:
843 strncpy( btext, Text_string[mousebutton_text[item->value]], 10); break;
845 strncpy( btext, mousebutton_text[item->value], 10 ); break;
848 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
851 sprintf(btext, "J%d B%d", j_button[item->value].joydev, j_Get_joydev_button_number(item->value));
852 #elif defined(SDL_INPUT)
853 if (joybutton_text[item->value])
854 strncpy(btext, joybutton_text[item->value], 10);
856 sprintf(btext, "BTN%2d", item->value + 1);
858 if ( joybutton_text[item->value] !=-1 )
859 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
861 sprintf( btext, "BTN%d", item->value );
866 sprintf( btext, "J%d A%d", j_axis[item->value].joydev, j_Get_joydev_axis_number (item->value) );
867 #elif defined(SDL_INPUT)
868 if (joyaxis_text[item->value])
869 strncpy(btext, joyaxis_text[item->value], 10);
871 sprintf(btext, "AXIS%2d", item->value + 1);
873 strncpy(btext, Text_string[joyaxis_text[item->value]], 10);
877 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
880 gr_get_string_size(btext, &w, &h, &aw );
886 void kconfig_sub(kc_item * items,int nitems, char * title)
888 grs_canvas * save_canvas;
889 grs_font * save_font;
892 int mouse_state, omouse_state, mx, my, x1, x2, y1, y2;
893 int close_x, close_y, close_size;
896 int i,k,ocitem,citem;
897 int time_stopped = 0;
902 if (!((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence)) )
908 // if (Config_control_type == CONTROL_WINJOYSTICK) {
910 // joydefsw_win_joyselect(title2); title = title2,
912 // ); // Get Samir...
915 save_canvas = grd_curcanv;
918 gr_set_current_canvas(NULL);
919 save_font = grd_curcanv->cv_font;
925 old_keyd_repeat = keyd_repeat;
928 //gr_clear_canvas( BM_XRGB(0,0,0) );
930 nm_draw_background(0, 0, grd_curcanv->cv_bitmap.bm_w - 1, grd_curcanv->cv_bitmap.bm_h - 1);
931 gr_palette_load (gr_palette);
933 grd_curcanv->cv_font = MEDIUM3_FONT;
937 p = strchr( title, '\n' );
939 gr_string( 0x8000, LHY(8), title );
944 // if ( items == kc_keyboard ) {
945 // gr_string( 0x8000, 8, "Keyboard" );
946 // } else if ( items == kc_joystick ) {
947 // gr_string( 0x8000, 8, "Joysticks" );
948 // } else if ( items == kc_mouse ) {
949 // gr_string( 0x8000, 8, "Mouse" );
953 close_x = close_y = MenuHires?15:7;
954 close_size = MenuHires?10:5;
955 gr_setcolor( BM_XRGB(0, 0, 0) );
956 gr_rect(close_x, close_y, close_x + close_size, close_y + close_size);
957 gr_setcolor( BM_XRGB(21, 21, 21) );
958 gr_rect(close_x + LHX(1), close_y + LHX(1), close_x + close_size - LHX(1), close_y + close_size - LHX(1));
961 grd_curcanv->cv_font = GAME_FONT;
962 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
965 gr_string( 0x8000, LHY(20), TXT_KCONFIG_STRING_1 );
967 gr_string( 0x8000, LHY(20), "Enter changes, ctrl-d deletes, ctrl-r resets defaults, ESC exits");
969 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
970 if ( items == kc_keyboard ) {
971 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
972 gr_setcolor( BM_XRGB(31,27,6) );
974 gr_scanline( LHX(98), LHX(106), LHY(42) );
975 gr_scanline( LHX(120), LHX(128), LHY(42) );
976 gr_pixel( LHX(98), LHY(43) );
977 gr_pixel( LHX(98), LHY(44) );
978 gr_pixel( LHX(128), LHY(43) );
979 gr_pixel( LHX(128), LHY(44) );
981 gr_string( LHX(109), LHY(40), "OR" );
983 gr_scanline( LHX(253), LHX(261), LHY(42) );
984 gr_scanline( LHX(274), LHX(283), LHY(42) );
985 gr_pixel( LHX(253), LHY(43) );
986 gr_pixel( LHX(253), LHY(44) );
987 gr_pixel( LHX(283), LHY(43) );
988 gr_pixel( LHX(283), LHY(44) );
990 gr_string( LHX(264), LHY(40), "OR" );
992 } if ( items == kc_joystick ) {
993 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
994 gr_setcolor( BM_XRGB(31,27,6) );
995 gr_scanline( LHX(18), LHX(135), LHY(37) );
996 gr_scanline( LHX(181), LHX(294), LHY(37) );
997 gr_scanline( LHX(18), LHX(144), LHY(119+18) );
998 gr_scanline( LHX(174), LHX(294), LHY(119+18) );
999 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
1000 gr_string( 0x8000,LHY(117+18), TXT_AXES );
1001 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1002 gr_string( LHX(81), LHY(137+8), TXT_AXIS );
1003 gr_string( LHX(111), LHY(137+8), TXT_INVERT );
1004 gr_string( LHX(230), LHY(137+8), TXT_AXIS );
1005 gr_string( LHX(260), LHY(137+8), TXT_INVERT );
1006 } else if ( items == kc_mouse ) {
1007 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
1008 gr_setcolor( BM_XRGB(31,27,6) );
1009 gr_scanline( LHX(18), LHX(135), LHY(37) );
1010 gr_scanline( LHX(181), LHX(294), LHY(37) );
1011 gr_scanline( LHX(18), LHX(144), LHY(119+5) );
1012 gr_scanline( LHX(174), LHX(294), LHY(119+5) );
1013 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
1014 gr_string( 0x8000,LHY(117+5), TXT_AXES );
1015 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1016 gr_string( LHX(169), LHY(129), TXT_AXIS );
1017 gr_string( LHX(199), LHY(129), TXT_INVERT );
1020 else if ( items == kc_d2x )
1022 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
1023 gr_setcolor( BM_XRGB(31,27,6) );
1025 gr_string(LHX( 94), LHY(40), "KB");
1026 gr_string(LHX(121), LHY(40), "JOY");
1030 for (i=0; i<nitems; i++ ) {
1031 kc_drawitem( &items[i], 0 );
1035 kc_drawitem( &items[citem], 1 );
1037 newmenu_show_cursor();
1039 #ifdef NEWMENU_MOUSE
1040 mouse_state = omouse_state = 0;
1044 // Windows addendum to allow for kconfig input.
1047 //see if redbook song needs to be restarted
1048 songs_check_redbook_repeat();
1052 #ifdef NEWMENU_MOUSE
1053 omouse_state = mouse_state;
1054 mouse_state = mouse_button_state(0);
1057 if ( !time_stopped ) {
1059 if (multi_menu_poll() == -1)
1068 case KEY_COMMAND+KEY_SHIFTED+KEY_3:
1069 case KEY_PRINT_SCREEN:
1070 save_screen_shot(0);
1072 case KEY_CTRLED+KEY_D:
1073 items[citem].value = 255;
1074 kc_drawitem( &items[citem], 1 );
1076 case KEY_CTRLED+KEY_R:
1077 if ( items==kc_keyboard ) {
1078 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1079 items[i].value=default_kconfig_settings[0][i];
1080 kc_drawitem( &items[i], 0 );
1083 } else if ( items==kc_d2x ) {
1084 for(i=0;i<NUM_D2X_CONTROLS;i++)
1086 items[i].value=default_kconfig_d2x_settings[i];
1087 kc_drawitem( &items[i], 0 );
1092 // hack for firebire and mousestick default controls since I made
1093 // them the same control type -- dumb dumb dumb
1094 if (joy_have_firebird())
1095 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1096 items[i].value = default_firebird_settings[i];
1097 kc_drawitem( &items[i], 0 );
1099 else if (joy_have_mousestick())
1100 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1101 items[i].value = default_mousestick_settings[i];
1102 kc_drawitem( &items[i], 0 );
1105 #endif // note link to above else
1106 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1107 items[i].value = default_kconfig_settings[Config_control_type][i];
1108 kc_drawitem( &items[i], 0 );
1111 kc_drawitem( &items[citem], 1 );
1114 items[citem].value=255;
1115 kc_drawitem( &items[citem], 1 );
1119 #ifdef TABLE_CREATION
1120 if (items[citem].u==-1) items[citem].u=find_next_item_up( items,nitems, citem);
1122 citem = items[citem].u;
1127 #ifdef TABLE_CREATION
1128 if (items[citem].d==-1) items[citem].d=find_next_item_down( items,nitems, citem);
1130 citem = items[citem].d;
1134 #ifdef TABLE_CREATION
1135 if (items[citem].l==-1) items[citem].l=find_next_item_left( items,nitems, citem);
1137 citem = items[citem].l;
1141 #ifdef TABLE_CREATION
1142 if (items[citem].r==-1) items[citem].r=find_next_item_right( items,nitems, citem);
1144 citem = items[citem].r;
1148 switch( items[citem].type ) {
1149 case BT_KEY: kc_change_key( &items[citem] ); break;
1150 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1151 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1152 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1153 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1154 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1157 //the following case added by WraithX on 11/22/00 to work around the weird joystick bug...
1159 switch(items[citem].type)
1162 kc_next_joyaxis(&items[citem]);
1166 //end addition by WraithX
1169 grd_curcanv->cv_font = save_font;
1171 gr_set_current_canvas( save_canvas );
1172 keyd_repeat = old_keyd_repeat;
1173 game_flush_inputs();
1174 newmenu_hide_cursor();
1178 #ifdef TABLE_CREATION
1179 case KEY_DEBUGGED+KEY_F12: {
1181 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1182 kc_keyboard[i].u = find_next_item_up( kc_keyboard,NUM_KEY_CONTROLS, i);
1183 kc_keyboard[i].d = find_next_item_down( kc_keyboard,NUM_KEY_CONTROLS, i);
1184 kc_keyboard[i].l = find_next_item_left( kc_keyboard,NUM_KEY_CONTROLS, i);
1185 kc_keyboard[i].r = find_next_item_right( kc_keyboard,NUM_KEY_CONTROLS, i);
1187 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1188 kc_joystick[i].u = find_next_item_up( kc_joystick,NUM_OTHER_CONTROLS, i);
1189 kc_joystick[i].d = find_next_item_down( kc_joystick,NUM_OTHER_CONTROLS, i);
1190 kc_joystick[i].l = find_next_item_left( kc_joystick,NUM_OTHER_CONTROLS, i);
1191 kc_joystick[i].r = find_next_item_right( kc_joystick,NUM_OTHER_CONTROLS, i);
1193 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1194 kc_mouse[i].u = find_next_item_up( kc_mouse,NUM_OTHER_CONTROLS, i);
1195 kc_mouse[i].d = find_next_item_down( kc_mouse,NUM_OTHER_CONTROLS, i);
1196 kc_mouse[i].l = find_next_item_left( kc_mouse,NUM_OTHER_CONTROLS, i);
1197 kc_mouse[i].r = find_next_item_right( kc_mouse,NUM_OTHER_CONTROLS, i);
1199 fp = fopen( "kconfig.cod", "wt" );
1201 fprintf( fp, "ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {\n" );
1202 for (i=0; i<CONTROL_MAX_TYPES; i++ ) {
1204 fprintf( fp, "{0x%x", kconfig_settings[i][0] );
1205 for (j=1; j<MAX_CONTROLS; j++ )
1206 fprintf( fp, ",0x%x", kconfig_settings[i][j] );
1207 fprintf( fp, "},\n" );
1209 fprintf( fp, "};\n" );
1211 fprintf( fp, "\nkc_item kc_keyboard[NUM_KEY_CONTROLS] = {\n" );
1212 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1213 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1214 kc_keyboard[i].id, kc_keyboard[i].x, kc_keyboard[i].y, kc_keyboard[i].w1, kc_keyboard[i].w2,
1215 kc_keyboard[i].u, kc_keyboard[i].d, kc_keyboard[i].l, kc_keyboard[i].r,
1216 34, kc_keyboard[i].text, 34, btype_text[kc_keyboard[i].type] );
1218 fprintf( fp, "};" );
1220 fprintf( fp, "\nkc_item kc_joystick[NUM_OTHER_CONTROLS] = {\n" );
1221 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1222 if (kc_joystick[i].type == BT_JOY_BUTTON)
1223 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1224 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1225 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1226 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1228 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1229 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1230 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1231 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1233 fprintf( fp, "};" );
1235 fprintf( fp, "\nkc_item kc_mouse[NUM_OTHER_CONTROLS] = {\n" );
1236 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1237 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1238 kc_mouse[i].id, kc_mouse[i].x, kc_mouse[i].y, kc_mouse[i].w1, kc_mouse[i].w2,
1239 kc_mouse[i].u, kc_mouse[i].d, kc_mouse[i].l, kc_mouse[i].r,
1240 34, kc_mouse[i].text, 34, btype_text[kc_mouse[i].type] );
1242 fprintf( fp, "};" );
1251 #ifdef NEWMENU_MOUSE
1252 if ( (mouse_state && !omouse_state) || (mouse_state && omouse_state) ) {
1255 mouse_get_pos(&mx, &my);
1256 for (i=0; i<nitems; i++ ) {
1257 item_height = get_item_height( &items[i] );
1258 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[i].x) + LHX(items[i].w1);
1259 x2 = x1 + LHX(items[i].w2);
1260 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[i].y);
1261 y2 = y1 + LHX(item_height);
1262 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1268 else if ( !mouse_state && omouse_state ) {
1271 mouse_get_pos(&mx, &my);
1272 item_height = get_item_height( &items[citem] );
1273 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[citem].x) + LHX(items[citem].w1);
1274 x2 = x1 + LHX(items[citem].w2);
1275 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[citem].y);
1276 y2 = y1 + LHY(item_height);
1277 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1278 newmenu_hide_cursor();
1279 switch( items[citem].type ) {
1280 case BT_KEY: kc_change_key( &items[citem] ); break;
1281 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1282 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1283 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1284 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1285 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1287 newmenu_show_cursor();
1289 x1 = grd_curcanv->cv_bitmap.bm_x + close_x + LHX(1);
1290 x2 = x1 + close_size - LHX(1);
1291 y1 = grd_curcanv->cv_bitmap.bm_y + close_y + LHX(1);
1292 y2 = y1 + close_size - LHX(1);
1293 if ( ((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2)) ) {
1294 grd_curcanv->cv_font = save_font;
1295 gr_set_current_canvas( save_canvas );
1296 keyd_repeat = old_keyd_repeat;
1297 game_flush_inputs();
1298 newmenu_hide_cursor();
1306 #endif // NEWMENU_MOUSE
1308 if (ocitem!=citem) {
1309 newmenu_hide_cursor();
1310 kc_drawitem( &items[ocitem], 0 );
1311 kc_drawitem( &items[citem], 1 );
1312 newmenu_show_cursor();
1318 void kc_drawitem( kc_item *item, int is_current )
1324 gr_set_fontcolor( BM_XRGB(20,20,29), -1 );
1326 gr_set_fontcolor( BM_XRGB(15,15,24), -1 );
1327 gr_string( LHX(item->x), LHY(item->y), item->text );
1329 if (item->value==255) {
1330 strcpy( btext, "" );
1332 switch( item->type ) {
1334 strncpy( btext, key_text[item->value], 10 ); break;
1335 case BT_MOUSE_BUTTON:
1337 //strncpy( btext, Text_string[mousebutton_text[item->value]], 10 ); break;
1338 strncpy( btext, (item->value <= 3)?Text_string[mousebutton_text[item->value]]:mousebutton_textra[item->value-3], 10 ); break;
1340 strncpy( btext, mousebutton_text[item->value], 10 ); break;
1343 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
1345 #ifdef USE_LINUX_JOY
1346 sprintf(btext, "J%d B%d", j_button[item->value].joydev, j_Get_joydev_button_number(item->value));
1347 #elif defined(SDL_INPUT)
1348 if (joybutton_text[item->value])
1349 strncpy(btext, joybutton_text[item->value], 10);
1351 sprintf(btext, "BTN%2d", item->value + 1);
1355 if (joybutton_text[item->value] != -1)
1356 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1358 sprintf( btext, "BTN%2d", item->value+1 );
1360 if ( joybutton_text[item->value] !=-1 )
1361 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1363 sprintf( btext, "BTN%d", item->value );
1366 strncpy( btext, joy_btn_name( item->value ), 10);
1368 sprintf( btext, "BTN%d", item->value );
1373 #ifdef USE_LINUX_JOY
1374 sprintf(btext, "J%d A%d", j_axis[item->value].joydev, j_Get_joydev_axis_number(item->value));
1375 #elif defined(SDL_INPUT)
1376 if (joyaxis_text[item->value])
1377 strncpy(btext, joyaxis_text[item->value], 10);
1379 sprintf(btext, "AXIS%2d", item->value + 1);
1381 strncpy(btext, Text_string[joyaxis_text[item->value]], 10);
1385 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
1389 gr_get_string_size(btext, &w, &h, &aw );
1392 gr_setcolor( BM_XRGB(21,0,24) );
1394 gr_setcolor( BM_XRGB(16,0,19) );
1395 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1397 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1399 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1401 gr_string( x, LHY(item->y), btext );
1406 static int looper=0;
1408 void kc_drawquestion( kc_item *item )
1412 gr_get_string_size("?", &w, &h, &aw );
1414 c = BM_XRGB(21,0,24);
1416 //@@gr_setcolor( gr_fade_table[fades[looper]*256+c] );
1417 gr_setcolor(BM_XRGB(21*fades[looper]/31,0,24*fades[looper]/31));
1419 if (looper>63) looper=0;
1421 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1423 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1425 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1427 gr_string( x, LHY(item->y), "?" );
1431 void kc_change_key( kc_item * item )
1436 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1438 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_KEY );
1440 game_flush_inputs();
1444 while( (k!=KEY_ESC) && (keycode==255) )
1447 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1450 // if ( Game_mode & GM_MULTI )
1451 // GameLoop( 0, 0 ); // Continue
1453 timer_delay(f0_1/10);
1454 kc_drawquestion( item );
1456 for (i=0; i<256; i++ ) {
1457 if (keyd_pressed[i] && (strlen(key_text[i])>0)) {
1459 for (n=0; n<sizeof(system_keys); n++ )
1460 if ( system_keys[n] == i )
1469 for (i=0; i<Num_items; i++ ) {
1470 n = item - All_items;
1471 if ( (i!=n) && (All_items[i].type==BT_KEY) && (All_items[i].value==keycode) ) {
1472 All_items[i].value = 255;
1473 kc_drawitem( &All_items[i], 0 );
1476 item->value = keycode;
1478 kc_drawitem( item, 1 );
1480 gr_set_fontcolor( BM_XRGB(28,28,28), BM_XRGB(0,0,0) );
1482 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1484 game_flush_inputs();
1488 void kc_change_joybutton( kc_item * item )
1493 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1495 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_JBUTTON );
1497 game_flush_inputs();
1501 while( (k!=KEY_ESC) && (code==255))
1504 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1507 // if ( Game_mode & GM_MULTI )
1508 // GameLoop( 0, 0 ); // Continue
1510 timer_delay(f0_1/10);
1512 if (k == KEY_PRINT_SCREEN)
1513 save_screen_shot(0);
1515 kc_drawquestion( item );
1517 WIN(code = joydefsw_do_button());
1520 code = joy_do_buttons();
1523 #if !defined(WINDOWS) && !defined(MACINTOSH)
1524 if (Config_control_type==CONTROL_THRUSTMASTER_FCS) {
1526 joystick_read_raw_axis( JOY_ALL_AXIS, axis );
1527 kconfig_read_fcs( axis[3] );
1528 if ( joy_get_button_state(7) ) code = 7;
1529 if ( joy_get_button_state(11) ) code = 11;
1530 if ( joy_get_button_state(15) ) code = 15;
1531 if ( joy_get_button_state(19) ) code = 19;
1532 for (i=0; i<4; i++ ) {
1533 if ( joy_get_button_state(i) )
1536 } else if (Config_control_type==CONTROL_FLIGHTSTICK_PRO) {
1537 for (i=4; i<20; i++ ) {
1538 if ( joy_get_button_state(i) ) {
1540 mprintf(( 0, "JB: %d\n", code ));
1544 for (i = 0; i < JOY_MAX_BUTTONS; i++)
1546 if ( joy_get_button_state(i) )
1553 for (i=0; i<Num_items; i++ ) {
1554 n = item - All_items;
1555 if ( (i!=n) && (All_items[i].type==BT_JOY_BUTTON) && (All_items[i].value==code) ) {
1556 All_items[i].value = 255;
1557 kc_drawitem( &All_items[i], 0 );
1562 kc_drawitem( item, 1 );
1563 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1564 game_flush_inputs();
1567 void kc_change_mousebutton( kc_item * item )
1572 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1574 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_MBUTTON );
1576 game_flush_inputs();
1580 while( (k!=KEY_ESC) && (code==255))
1583 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1586 // if ( Game_mode & GM_MULTI )
1587 // GameLoop( 0, 0 ); // Continue
1589 timer_delay(f0_1/10);
1591 if (k == KEY_PRINT_SCREEN)
1592 save_screen_shot(0);
1594 kc_drawquestion( item );
1596 b = mouse_get_btns();
1597 for (i = 0; i < 16; i++ ) {
1603 for (i=0; i<Num_items; i++ ) {
1604 n = item - All_items;
1605 if ( (i!=n) && (All_items[i].type==BT_MOUSE_BUTTON) && (All_items[i].value==code) ) {
1606 All_items[i].value = 255;
1607 kc_drawitem( &All_items[i], 0 );
1612 kc_drawitem( item, 1 );
1613 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1614 game_flush_inputs();
1619 // the following function added by WraithX on 11/22/00 to work around the weird joystick bug... - modified my Matt Mueller to skip already allocated axes
1620 void kc_next_joyaxis(kc_item *item)
1622 int n, i, k, max, tries;
1629 // I modelled this ifdef after the code in the kc_change_joyaxis method.
1630 // So, if somethin's not workin here, it might not be workin there either.
1633 code = (item->value + 1) % max;
1637 for (i = 0; i < Num_items; i++)
1639 n = item - All_items;
1640 if ((i != n) && (All_items[i].type == BT_JOY_AXIS) && (All_items[i].value == code))
1643 return; // all axes allocated already
1644 i = -1; // -1 so the i++ will push back to 0
1645 code = (item->value + ++tries) % max; // try next axis
1652 kc_drawitem(item, 1);
1653 nm_restore_background(0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h);
1654 game_flush_inputs();
1656 }//method kc_next_joyaxis
1657 //end addition by WraithX
1660 void kc_change_joyaxis( kc_item * item )
1662 int axis[JOY_MAX_AXES];
1663 int old_axis[JOY_MAX_AXES];
1664 int numaxis = joy_num_axes;
1668 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1670 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_JOY_AXIS );
1672 game_flush_inputs();
1677 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, old_axis ),
1678 joystick_read_raw_axis( JOY_ALL_AXIS, old_axis )
1681 while( (k!=KEY_ESC) && (code==255))
1684 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1687 // if ( Game_mode & GM_MULTI )
1688 // GameLoop( 0, 0 ); // Continue
1690 timer_delay(f0_1/10);
1692 if (k == KEY_PRINT_SCREEN)
1693 save_screen_shot(0);
1695 kc_drawquestion( item );
1698 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, axis ),
1699 joystick_read_raw_axis( JOY_ALL_AXIS, axis )
1702 for (i=0; i<numaxis; i++ ) {
1703 #if defined (MACINTOSH)
1704 if ( abs(axis[i]-old_axis[i])>100 )
1705 #elif defined(WINDOWS)
1706 if ( abs(axis[i]-old_axis[i])>1024 )
1708 if ( abs(axis[i]-old_axis[i])>200 )
1712 con_printf(CON_DEBUG, "Axis Movement detected: Axis %i\n", i);
1714 //old_axis[i] = axis[i];
1716 for (i=0; i<Num_items; i++ )
1718 n = item - All_items;
1719 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) )
1725 for (i=0; i<Num_items; i++ ) {
1726 n = item - All_items;
1727 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) ) {
1728 All_items[i].value = 255;
1729 kc_drawitem( &All_items[i], 0 );
1735 kc_drawitem( item, 1 );
1736 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1737 game_flush_inputs();
1741 void kc_change_mouseaxis( kc_item * item )
1750 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1752 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_MSE_AXIS );
1754 game_flush_inputs();
1758 mouse_get_delta( &dx, &dy );
1760 while( (k!=KEY_ESC) && (code==255))
1763 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1766 // if ( Game_mode & GM_MULTI )
1767 // GameLoop( 0, 0 ); // Continue
1769 timer_delay(f0_1/10);
1771 if (k == KEY_PRINT_SCREEN)
1772 save_screen_shot(0);
1774 kc_drawquestion( item );
1777 mouse_get_delta_z( &dx, &dy, &dz );
1779 mouse_get_delta( &dx, &dy );
1781 if ( abs(dx)>20 ) code = 0;
1782 if ( abs(dy)>20 ) code = 1;
1784 if ( abs(dz)>20 ) code = 2;
1788 for (i=0; i<Num_items; i++ ) {
1789 n = item - All_items;
1790 if ( (i!=n) && (All_items[i].type==BT_MOUSE_AXIS) && (All_items[i].value==code) ) {
1791 All_items[i].value = 255;
1792 kc_drawitem( &All_items[i], 0 );
1797 kc_drawitem( item, 1 );
1798 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1799 game_flush_inputs();
1804 void kc_change_invert( kc_item * item )
1806 game_flush_inputs();
1813 kc_drawitem( item, 1 );
1817 #include "screens.h"
1819 void kconfig(int n, char * title)
1822 grs_bitmap *save_bm;
1824 set_screen_mode( SCREEN_MENU );
1829 save_bm = gr_create_bitmap( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
1830 Assert( save_bm != NULL );
1832 gr_bm_bitblt(grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_w,
1833 0, 0, 0, 0, &grd_curcanv->cv_bitmap, save_bm );
1836 case 0:kconfig_sub( kc_keyboard, NUM_KEY_CONTROLS, title );break;
1837 case 1:kconfig_sub( kc_joystick, NUM_OTHER_CONTROLS, title );break;
1838 case 2:kconfig_sub( kc_mouse, NUM_OTHER_CONTROLS, title ); break;
1839 case 3:kconfig_sub( kc_superjoy, NUM_OTHER_CONTROLS, title); break;
1841 //added on 2/4/99 by Victor Rachels for new keys menu
1842 case 4:kconfig_sub( kc_d2x, NUM_D2X_CONTROLS, title ); break;
1843 //end this section addition - VR
1851 gr_bitmap(0, 0, save_bm);
1852 gr_free_bitmap(save_bm);
1854 #if 0 // set_screen_mode always calls this later... right?
1855 reset_cockpit(); //force cockpit redraw next time
1858 // Update save values...
1860 for (i=0; i<NUM_KEY_CONTROLS; i++ )
1861 kconfig_settings[0][i] = kc_keyboard[i].value;
1863 if ( (Config_control_type>0) && (Config_control_type<5)) {
1864 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1865 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
1866 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
1867 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1868 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
1870 else if (Config_control_type == CONTROL_WINJOYSTICK) {
1871 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1872 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
1876 for (i=0; i<NUM_D2X_CONTROLS; i++)
1877 kconfig_d2x_settings[i] = kc_d2x[i].value;
1882 void kconfig_read_fcs( int raw_axis )
1884 int raw_button, button, axis_min[4], axis_center[4], axis_max[4];
1886 if (Config_control_type!=CONTROL_THRUSTMASTER_FCS) return;
1888 joy_get_cal_vals(axis_min, axis_center, axis_max);
1890 if ( axis_max[3] > 1 )
1891 raw_button = (raw_axis*100)/axis_max[3];
1895 if ( raw_button > 88 )
1897 else if ( raw_button > 63 )
1899 else if ( raw_button > 39 )
1901 else if ( raw_button > 15 )
1906 kconfig_set_fcs_button( 19, button );
1907 kconfig_set_fcs_button( 15, button );
1908 kconfig_set_fcs_button( 11, button );
1909 kconfig_set_fcs_button( 7, button );
1913 void kconfig_set_fcs_button( int btn, int button )
1915 int state,time_down,upcount,downcount;
1916 state = time_down = upcount = downcount = 0;
1918 if ( joy_get_button_state(btn) ) {
1919 if ( btn==button ) {
1921 time_down = FrameTime;
1926 if ( btn==button ) {
1928 time_down = FrameTime;
1935 joy_set_btn_values( btn, state, time_down, downcount, upcount );
1941 fix Last_angles_p = 0;
1942 fix Last_angles_b = 0;
1943 fix Last_angles_h = 0;
1944 ubyte Last_angles_read = 0;
1946 extern int VR_sensitivity;
1948 int VR_sense_range[3] = { 25, 50, 75 };
1950 #if 0 //ndef MACINTOSH
1955 fix yaw, pitch, roll;
1958 //------ read vfx1 helmet --------
1959 if (vfx1_installed) {
1960 vfx_get_data(&yaw,&pitch,&roll,&buttons);
1961 } else if (iglasses_headset_installed) {
1962 iglasses_read_headset( &yaw, &pitch, &roll );
1963 } else if (Victor_headset_installed) {
1964 victor_read_headset_filtered( &yaw, &pitch, &roll );
1969 Use_player_head_angles = 0;
1970 if ( Last_angles_read ) {
1974 if ( (Last_angles_h < (F1_0/4) ) && (yaw > ((F1_0*3)/4) ) )
1976 else if ( (yaw < (F1_0/4) ) && (Last_angles_h > ((F1_0*3)/4) ) )
1979 Controls.pitch_time += fixmul((pitch- Last_angles_p)*VR_sense_range[VR_sensitivity],FrameTime);
1980 Controls.heading_time+= fixmul((yaw1 - Last_angles_h)*VR_sense_range[VR_sensitivity],FrameTime);
1981 Controls.bank_time += fixmul((roll - Last_angles_b)*VR_sense_range[VR_sensitivity],FrameTime);
1983 Last_angles_read = 1;
1984 Last_angles_p = pitch;
1985 Last_angles_h = yaw;
1986 Last_angles_b = roll;
1993 #ifndef __MSDOS__ // WINDOWS
1994 #define JOYSTICK_READ_TIME (F1_0/40) // Read joystick at 40 Hz.
1996 #define JOYSTICK_READ_TIME (F1_0/10) // Read joystick at 10 Hz.
1999 fix LastReadTime = 0;
2001 fix joy_axis[JOY_MAX_AXES];
2003 ubyte kc_use_external_control = 0;
2004 ubyte kc_enable_external_control = 0;
2005 ubyte kc_external_intno = 0;
2006 ext_control_info *kc_external_control = NULL;
2007 char *kc_external_name = NULL;
2008 ubyte kc_external_version = 0;
2009 extern int Automap_active;
2011 void kconfig_init_external_controls(int intno, int address)
2014 kc_external_intno = intno;
2015 kc_external_control = (ext_control_info *)address;
2016 kc_use_external_control = 1;
2017 kc_enable_external_control = 1;
2019 i = FindArg ( "-xname" );
2021 kc_external_name = Args[i+1];
2023 kc_external_name = "External Controller";
2025 for (i=0;i<strlen (kc_external_name);i++)
2026 if (kc_external_name[i]=='_')
2027 kc_external_name[i]=' ';
2029 i = FindArg ( "-xver" );
2031 kc_external_version = atoi(Args[i+1]);
2033 printf( "%s int: 0x%x, data: 0x%p, ver:%d\n", kc_external_name, kc_external_intno, kc_external_control, kc_external_version );
2037 #if !defined(MACINTOSH)
2038 /*void kconfig_read_external_controls()
2042 if ( !kc_enable_external_control && !CybermouseActive)
2045 if ( kc_external_version == 0 )
2046 memset( kc_external_control, 0, sizeof(control_info) );
2047 else if ( kc_external_version > 0 ) {
2048 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 );
2049 if ( kc_external_version > 1 ) {
2050 // Write ship pos and angles to external controls...
2051 ubyte *temp_ptr = (ubyte *)kc_external_control;
2052 vms_vector *ship_pos;
2053 vms_matrix *ship_orient;
2054 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
2055 temp_ptr += sizeof(control_info)+sizeof(vms_angvec) + 64;
2056 ship_pos = (vms_vector *)temp_ptr;
2057 temp_ptr += sizeof(vms_vector);
2058 ship_orient = (vms_matrix *)temp_ptr;
2059 // Fill in ship postion...
2060 *ship_pos = Objects[Players[Player_num].objnum].pos;
2061 // Fill in ship orientation...
2062 *ship_orient = Objects[Players[Player_num].objnum].orient;
2066 if ( Automap_active ) // (If in automap...)
2067 kc_external_control->automap_state = 1;
2068 memset(&r,0,sizeof(r));
2072 if (!CybermouseActive)
2073 int386 ( kc_external_intno, &r, &r); // Read external info...
2075 // ReadOWL (kc_external_control);
2079 if ( Player_num > -1 ) {
2080 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
2081 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
2082 Auto_leveling_on = 0;
2084 if ( kc_external_version > 0 ) {
2085 vms_matrix tempm, ViewMatrix;
2086 vms_angvec * Kconfig_abs_movement;
2089 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
2091 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
2092 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
2093 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
2094 Objects[Players[Player_num].objnum].orient = ViewMatrix;
2096 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
2097 if (oem_message[0] != '\0' )
2098 HUD_init_message( oem_message );
2102 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
2103 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
2104 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
2105 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
2106 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
2107 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
2108 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
2109 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
2110 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
2111 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
2112 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
2113 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
2114 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
2115 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
2116 Controls.automap_down_count += kc_external_control->automap_down_count;
2117 Controls.automap_state |= kc_external_control->automap_state;
2122 void controls_read_all_win()
2125 int slide_on, bank_on;
2129 int raw_joy_axis[7];
2131 fix k0, k1, k2, k3, kp;
2132 fix k4, k5, k6, k7, kh;
2133 ubyte channel_masks;
2134 int use_mouse, use_joystick;
2137 if (Game_turbo_mode)
2141 fix temp = Controls.heading_time;
2142 fix temp1 = Controls.pitch_time;
2143 memset( &Controls, 0, sizeof(control_info) );
2144 Controls.heading_time = temp;
2145 Controls.pitch_time = temp1;
2150 ctime = timer_get_fixed_seconds();
2152 // DO JOYSTICK (X,Y,Z R,U,V)
2153 // ----------------------------------------------------------------------------
2154 if ( (LastReadTime + JOYSTICK_READ_TIME) > ctime ) {
2155 if ((ctime < 0) && (LastReadTime > 0))
2156 LastReadTime = ctime;
2158 } else if ((Config_control_type==CONTROL_WINJOYSTICK)) {
2159 LastReadTime = ctime;
2160 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, raw_joy_axis );
2162 for (i=0; i<7; i++ ) {
2163 if (channel_masks&(1<<i)) {
2164 int joy_null_value = 28;
2166 // DO POV if joystick has a hat.
2167 // --------------------------------------------------------------------
2169 joydefsw_do_winjoybutton(raw_joy_axis);
2173 // --------------------------------------------------------------------
2174 // mprintf((0, "(%d)=%d,", i, raw_joy_axis[i]));
2175 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2176 // mprintf((0, "%d ",raw_joy_axis[i]));
2177 // if (i%2) mprintf((0,"\n"));
2180 if (kc_superjoy[23].value==i) // If this is the throttle
2181 joy_null_value = 32; // Then use a larger dead-zone
2183 if (raw_joy_axis[i] > (joy_null_value-2))
2184 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2185 else if (raw_joy_axis[i] < -(joy_null_value+2))
2186 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2188 raw_joy_axis[i] = 0;
2189 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2198 for (i=0; i<6; i++ )
2204 // ----------------------------------------------------------------------------
2205 if (Config_control_type==5) {
2206 mouse_get_delta( &dx, &dy );
2207 mouse_axis[0] = (dx*FrameTime)/35;
2208 mouse_axis[1] = (dy*FrameTime)/25;
2209 mouse_buttons = mouse_get_btns();
2210 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2219 //------------- Read slide_on -------------
2222 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
2223 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
2225 if ((use_joystick)&&(kc_superjoy[5].value<255)) slide_on |= joy_get_button_state( kc_superjoy[5].value );
2227 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
2229 //------------- Read bank_on ---------------
2232 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
2233 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
2235 if ( (use_joystick)&&(kc_superjoy[10].value < 255 )) bank_on |= joy_get_button_state( kc_superjoy[10].value );
2237 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
2239 //------------ Read pitch_time -----------
2241 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2243 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
2244 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
2245 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
2246 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
2249 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
2250 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
2251 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
2252 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
2255 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2256 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
2257 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
2261 Controls.pitch_time = 0;
2263 if (Controls.pitch_time < 0)
2264 Controls.pitch_time = 0;
2266 if (Controls.pitch_time > 0)
2267 Controls.pitch_time = 0;
2268 Controls.pitch_time += kp;
2271 if ( (use_joystick)&&(kc_superjoy[13].value < 255 )) {
2272 if ( !kc_superjoy[14].value ) // If not inverted...
2273 Controls.pitch_time -= (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2275 Controls.pitch_time += (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2279 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
2280 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
2281 if ( !kc_mouse[14].value ) // If not inverted...
2282 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2284 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2287 Controls.pitch_time = 0;
2291 //----------- Read vertical_thrust_time -----------------
2294 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
2295 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
2296 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
2297 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
2300 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
2301 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
2302 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
2303 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
2306 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2307 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
2308 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
2312 if ((use_joystick)&&( kc_superjoy[13].value < 255 )) {
2313 if ( !kc_superjoy[14].value ) // If not inverted...
2314 Controls.vertical_thrust_time += joy_axis[kc_superjoy[13].value];
2316 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[13].value];
2320 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
2321 if ( !kc_mouse[14].value ) // If not inverted...
2322 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
2324 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
2329 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
2330 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
2331 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
2332 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
2335 if ((use_joystick)&&( kc_superjoy[19].value < 255 )) {
2336 if ( !kc_superjoy[20].value ) // If not inverted...
2337 Controls.vertical_thrust_time += joy_axis[kc_superjoy[19].value];
2339 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[19].value];
2342 // From joystick buttons
2343 if ( (use_joystick)&&(kc_superjoy[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_superjoy[8].value );
2344 if ( (use_joystick)&&(kc_superjoy[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_superjoy[9].value );
2346 // From mouse buttons
2347 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
2348 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
2351 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
2352 if ( !kc_mouse[20].value ) // If not inverted...
2353 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
2355 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
2359 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2360 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
2361 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
2364 //---------- Read heading_time -----------
2366 if (!slide_on && !bank_on) {
2367 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2369 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
2370 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
2371 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
2372 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
2375 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
2376 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
2377 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
2378 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
2381 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2382 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
2383 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
2387 Controls.heading_time = 0;
2389 if (Controls.heading_time < 0)
2390 Controls.heading_time = 0;
2392 if (Controls.heading_time > 0)
2393 Controls.heading_time = 0;
2394 Controls.heading_time += kh;
2397 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2398 if ( !kc_superjoy[16].value ) // If not inverted...
2399 Controls.heading_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2401 Controls.heading_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2405 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2406 if ( !kc_mouse[16].value ) // If not inverted...
2407 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2409 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2412 Controls.heading_time = 0;
2415 //----------- Read sideways_thrust_time -----------------
2418 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2419 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2420 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2421 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2424 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
2425 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
2426 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
2427 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
2430 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2431 if ( !kc_superjoy[16].value ) // If not inverted...
2432 Controls.sideways_thrust_time += joy_axis[kc_superjoy[15].value];
2434 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[15].value];
2438 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2439 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
2440 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
2444 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2445 if ( !kc_mouse[16].value ) // If not inverted...
2446 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
2448 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
2453 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
2454 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
2455 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
2456 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
2459 if ( (use_joystick)&&(kc_superjoy[17].value < 255 )) {
2460 if ( !kc_superjoy[18].value ) // If not inverted...
2461 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[17].value];
2463 Controls.sideways_thrust_time += joy_axis[kc_superjoy[17].value];
2466 // From joystick buttons
2467 if ( (use_joystick)&&(kc_superjoy[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_superjoy[6].value );
2468 if ( (use_joystick)&&(kc_superjoy[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_superjoy[7].value );
2470 // From mouse buttons
2471 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
2472 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
2475 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
2476 if ( !kc_mouse[18].value ) // If not inverted...
2477 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
2479 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
2482 //----------- Read bank_time -----------------
2485 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2486 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2487 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2488 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2491 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
2492 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
2493 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
2494 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
2497 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2498 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
2499 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
2503 if ( (use_joystick)&&(kc_superjoy[15].value < 255) ) {
2504 if ( !kc_superjoy[16].value ) // If not inverted...
2505 Controls.bank_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2507 Controls.bank_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2511 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2512 if ( !kc_mouse[16].value ) // If not inverted...
2513 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2515 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2520 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
2521 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
2522 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
2523 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
2526 if ( (use_joystick)&&(kc_superjoy[21].value < 255) ) {
2527 if ( !kc_superjoy[22].value ) // If not inverted...
2528 Controls.bank_time -= joy_axis[kc_superjoy[21].value];
2530 Controls.bank_time += joy_axis[kc_superjoy[21].value];
2533 // From joystick buttons
2534 if ( (use_joystick)&&(kc_superjoy[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_superjoy[11].value );
2535 if ( (use_joystick)&&(kc_superjoy[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_superjoy[12].value );
2537 // From mouse buttons
2538 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
2539 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
2542 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
2543 if ( !kc_mouse[22].value ) // If not inverted...
2544 Controls.bank_time += mouse_axis[kc_mouse[21].value];
2546 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
2550 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2551 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
2552 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
2555 //----------- Read forward_thrust_time -------------
2558 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
2559 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
2560 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
2561 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
2564 if ( (use_joystick)&&(kc_superjoy[23].value < 255 )) {
2565 if ( !kc_superjoy[24].value ) // If not inverted...
2566 Controls.forward_thrust_time -= joy_axis[kc_superjoy[23].value];
2568 Controls.forward_thrust_time += joy_axis[kc_superjoy[23].value];
2571 // From joystick buttons
2572 if ( (use_joystick)&&(kc_superjoy[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_superjoy[2].value );
2573 if ( (use_joystick)&&(kc_superjoy[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_superjoy[3].value );
2576 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
2577 if ( !kc_mouse[24].value ) // If not inverted...
2578 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
2580 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
2583 // From mouse buttons
2584 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
2585 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
2587 //----------- Read afterburner_state -------------
2590 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
2591 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
2593 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
2595 if ( (use_joystick)&&(kc_superjoy[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_superjoy[27].value);
2597 //-------Read headlight key--------------------------
2598 if (kc_keyboard[52].value < 255 )
2599 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
2600 if (kc_keyboard[53].value < 255 )
2601 Controls.headlight_count=key_down_count(kc_keyboard[53].value);
2602 if ((use_joystick)&&(kc_superjoy[30].value < 255 ))
2603 Controls.headlight_count=joy_get_button_down_cnt(kc_superjoy[30].value);
2605 //--------Read Cycle Primary Key------------------
2607 if (kc_keyboard[48].value<255)
2608 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
2609 if (kc_keyboard[49].value<255)
2610 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
2611 if ((use_joystick)&&(kc_superjoy[28].value < 255 ))
2612 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_superjoy[28].value);
2614 //--------Read Cycle Secondary Key------------------
2616 if (kc_keyboard[50].value<255)
2617 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
2618 if (kc_keyboard[51].value<255)
2619 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
2620 if ((use_joystick)&&(kc_superjoy[29].value < 255 ))
2621 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_superjoy[29].value);
2623 //--------Read Toggle Bomb key----------------------
2625 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
2627 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
2629 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
2630 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
2632 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2633 HUD_init_message ("No bombs available!");
2637 if (Players[Player_num].secondary_ammo[bomb]==0)
2639 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2640 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
2644 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
2645 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
2650 //---------Read Energy->Shield key----------
2652 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
2653 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
2654 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
2655 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
2657 //----------- Read fire_primary_down_count
2658 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
2659 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
2660 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_superjoy[0].value);
2661 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
2663 //----------- Read fire_primary_state
2664 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
2665 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
2666 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_superjoy[0].value);
2667 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
2669 //----------- Read fire_secondary_down_count
2670 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
2671 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
2672 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_superjoy[1].value);
2673 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
2675 //----------- Read fire_secondary_state
2676 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
2677 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
2678 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_superjoy[1].value);
2679 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
2681 //----------- Read fire_flare_down_count
2682 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
2683 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
2684 if ((use_joystick)&&(kc_superjoy[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_superjoy[4].value);
2685 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
2687 //----------- Read drop_bomb_down_count
2688 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
2689 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
2690 if ((use_joystick)&&(kc_superjoy[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_superjoy[26].value);
2691 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
2693 //----------- Read rear_view_down_count
2694 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
2695 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
2696 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_superjoy[25].value);
2697 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
2699 //----------- Read rear_view_down_state
2700 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
2701 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
2702 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_superjoy[25].value);
2703 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
2705 //----------- Read automap_down_count
2706 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
2707 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
2709 //----------- Read automap_state
2710 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
2711 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
2713 //----------- Read stupid-cruise-control-type of throttle.
2715 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
2716 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
2717 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
2718 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
2719 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
2721 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
2724 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
2725 if (Cruise_speed < 0 ) Cruise_speed = 0;
2727 if (Controls.forward_thrust_time==0)
2728 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
2731 //read_head_tracker();
2733 // Read external controls
2734 if (kc_use_external_control || CybermouseActive)
2735 kconfig_read_external_controls();
2737 //----------- Clamp values between -FrameTime and FrameTime
2738 if (FrameTime > F1_0 )
2739 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
2741 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
2742 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
2743 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
2744 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
2745 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
2746 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
2747 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
2749 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
2750 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
2751 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
2752 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
2753 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
2754 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
2755 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
2758 //--------- Don't do anything if in debug mode
2760 if ( keyd_pressed[KEY_DELETE] ) {
2761 memset( &Controls, 0, sizeof(control_info) );
2768 fix Next_toggle_time[3]={0,0,0};
2770 int allowed_to_toggle(int i)
2772 //used for keeping tabs of when its ok to toggle headlight,primary,and secondary
2774 if (Next_toggle_time[i] > GameTime)
2775 if (Next_toggle_time[i] < GameTime + (F1_0/8)) // In case time is bogus, never wait > 1 second.
2778 Next_toggle_time[i] = GameTime + (F1_0/8);
2785 //added on 2/7/99 by Victor Rachels for jostick state setting
2786 int d2x_joystick_ostate[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
2787 //end this section adition - VR
2791 void controls_read_all()
2794 int slide_on, bank_on;
2801 fix mouse_axis[3] = {0,0,0};
2802 int raw_joy_axis[JOY_MAX_AXES];
2804 fix k0, k1, k2, k3, kp;
2805 fix k4, k5, k6, k7, kh;
2806 ubyte channel_masks;
2807 int use_mouse, use_joystick;
2813 if (Game_turbo_mode)
2817 fix temp = Controls.heading_time;
2818 fix temp1 = Controls.pitch_time;
2819 memset( &Controls, 0, sizeof(control_info) );
2820 Controls.heading_time = temp;
2821 Controls.pitch_time = temp1;
2826 ctime = timer_get_fixed_seconds();
2828 //--------- Read Joystick -----------
2830 if ( (LastReadTime + JOYSTICK_READ_TIME > ctime) && (Config_control_type!=CONTROL_THRUSTMASTER_FCS) ) {
2832 if ((ctime < 0) && (LastReadTime >= 0))
2834 if ((ctime < 0) && (LastReadTime > 0))
2836 LastReadTime = ctime;
2838 } else if ((Config_control_type>0) && (Config_control_type<5) ) {
2839 LastReadTime = ctime;
2840 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
2842 for (i = 0; i < joy_num_axes; i++)
2845 if (channel_masks&(1<<i)) {
2847 int joy_null_value = 10;
2849 if ( (i==3) && (Config_control_type==CONTROL_THRUSTMASTER_FCS) ) {
2850 kconfig_read_fcs( raw_joy_axis[i] );
2852 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2854 if (kc_joystick[23].value==i) // If this is the throttle
2855 joy_null_value = 20; // Then use a larger dead-zone
2857 if (raw_joy_axis[i] > joy_null_value)
2858 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2859 else if (raw_joy_axis[i] < -joy_null_value)
2860 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2862 raw_joy_axis[i] = 0;
2863 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2873 for (i = 0; i < joy_num_axes; i++)
2878 //--------- Read Joystick -----------
2879 if ((Config_control_type>0) && (Config_control_type<5) ) {
2880 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
2881 for (i=0; i<4; i++ ) {
2882 if (channel_masks&(1<<i)) {
2883 int joy_null_value = 10;
2885 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2887 if (kc_joystick[23].value==i) // If this is the throttle
2888 joy_null_value = 20; // Then use a larger dead-zone
2890 if (raw_joy_axis[i] > joy_null_value)
2891 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2892 else if (raw_joy_axis[i] < -joy_null_value)
2893 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2895 raw_joy_axis[i] = 0;
2896 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2903 for (i=0; i<4; i++ )
2907 #endif // ifndef MACINTOSH
2909 if (Config_control_type==5 && !CybermouseActive) {
2910 //--------- Read Mouse -----------
2912 mouse_get_delta_z( &dx, &dy, &dz );
2914 mouse_get_delta( &dx, &dy );
2916 mouse_axis[0] = (dx*FrameTime)/35;
2917 mouse_axis[1] = (dy*FrameTime)/25;
2919 mouse_axis[2] = (dz*FrameTime);
2921 mouse_buttons = mouse_get_btns();
2922 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2924 } else if (Config_control_type==6 && !CybermouseActive) {
2925 //--------- Read Cyberman -----------
2926 mouse_get_cyberman_pos(&idx,&idy );
2927 mouse_axis[0] = (idx*FrameTime)/128;
2928 mouse_axis[1] = (idy*FrameTime)/128;
2929 mouse_buttons = mouse_get_btns();
2931 } else if (CybermouseActive) {
2932 // ReadOWL (kc_external_control);
2933 // CybermouseAdjust();
2942 //added on 2/4/99 by Victor Rachels for d1x keys
2943 //--------- Read primary weapon select -------------
2944 //the following "if" added by WraithX to stop deadies from switchin weapons, 4/14/00
2945 if (!Player_is_dead)
2948 int d2x_joystick_state[10];
2951 d2x_joystick_state[i] = joy_get_button_state(kc_d2x[i*2+1].value);
2954 //----------------Weapon 1----------------
2955 if(key_down_count(kc_d2x[0].value) ||
2956 (joy_get_button_state(kc_d2x[1].value) &&
2957 (d2x_joystick_state[0]!=d2x_joystick_ostate[0]) ) )
2960 do_weapon_select(0,0);
2962 for(i=MAX_PRIMARY_WEAPONS;i<MAX_PRIMARY_WEAPONS+NEWPRIMS;i++)
2963 if(primary_order[i]>primary_order[valu]&&player_has_weapon(i,0))
2965 LaserPowSelected = valu;
2968 //----------------Weapon 2----------------
2969 if(key_down_count(kc_d2x[2].value) ||
2970 (joy_get_button_state(kc_d2x[3].value) &&
2971 (d2x_joystick_state[1]!=d2x_joystick_ostate[1]) ) )
2972 do_weapon_select(1,0);
2973 //----------------Weapon 3----------------
2974 if(key_down_count(kc_d2x[4].value) ||
2975 (joy_get_button_state(kc_d2x[5].value) &&
2976 (d2x_joystick_state[2]!=d2x_joystick_ostate[2]) ) )
2977 do_weapon_select(2,0);
2978 //----------------Weapon 4----------------
2979 if(key_down_count(kc_d2x[6].value) ||
2980 (joy_get_button_state(kc_d2x[7].value) &&
2981 (d2x_joystick_state[3]!=d2x_joystick_ostate[3]) ) )
2982 do_weapon_select(3,0);
2983 //----------------Weapon 5----------------
2984 if(key_down_count(kc_d2x[8].value) ||
2985 (joy_get_button_state(kc_d2x[9].value) &&
2986 (d2x_joystick_state[4]!=d2x_joystick_ostate[4]) ) )
2987 do_weapon_select(4,0);
2989 //--------- Read secondary weapon select ----------
2990 //----------------Weapon 6----------------
2991 if(key_down_count(kc_d2x[10].value) ||
2992 (joy_get_button_state(kc_d2x[11].value) &&
2993 (d2x_joystick_state[5]!=d2x_joystick_ostate[5]) ) )
2994 do_weapon_select(0,1);
2995 //----------------Weapon 7----------------
2996 if(key_down_count(kc_d2x[12].value) ||
2997 (joy_get_button_state(kc_d2x[13].value) &&
2998 (d2x_joystick_state[6]!=d2x_joystick_ostate[6]) ) )
2999 do_weapon_select(1,1);
3000 //----------------Weapon 8----------------
3001 if(key_down_count(kc_d2x[14].value) ||
3002 (joy_get_button_state(kc_d2x[15].value) &&
3003 (d2x_joystick_state[7]!=d2x_joystick_ostate[7]) ) )
3004 do_weapon_select(2,1);
3005 //----------------Weapon 9----------------
3006 if(key_down_count(kc_d2x[16].value) ||
3007 (joy_get_button_state(kc_d2x[17].value) &&
3008 (d2x_joystick_state[8]!=d2x_joystick_ostate[8]) ) )
3009 do_weapon_select(3,1);
3010 //----------------Weapon 0----------------
3011 if(key_down_count(kc_d2x[18].value) ||
3012 (joy_get_button_state(kc_d2x[19].value) &&
3013 (d2x_joystick_state[9]!=d2x_joystick_ostate[9]) ) )
3014 do_weapon_select(4,1);
3015 memcpy(d2x_joystick_ostate,d2x_joystick_state,10*sizeof(int));
3017 //end this section addition - VR
3020 }//end "if (!Player_is_dead)" - WraithX
3024 //------------- Read slide_on -------------
3027 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
3028 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
3030 if ((use_joystick)&&(kc_joystick[5].value<255)) slide_on |= joy_get_button_state( kc_joystick[5].value );
3032 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
3034 //------------- Read bank_on ---------------
3037 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
3038 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
3040 if ( (use_joystick)&&(kc_joystick[10].value < 255 )) bank_on |= joy_get_button_state( kc_joystick[10].value );
3042 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
3044 //------------ Read pitch_time -----------
3046 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
3048 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
3049 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
3050 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
3051 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
3054 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
3055 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
3056 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
3057 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
3060 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3061 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
3062 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
3066 Controls.pitch_time = 0;
3068 if (Controls.pitch_time < 0)
3069 Controls.pitch_time = 0;
3071 if (Controls.pitch_time > 0)
3072 Controls.pitch_time = 0;
3073 Controls.pitch_time += kp;
3076 if ( (use_joystick)&&(kc_joystick[13].value < 255 )) {
3077 if ( !kc_joystick[14].value ) // If not inverted...
3078 Controls.pitch_time -= (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
3080 Controls.pitch_time += (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
3084 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
3085 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
3086 if ( !kc_mouse[14].value ) // If not inverted...
3087 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
3089 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
3092 Controls.pitch_time = 0;
3096 // the following "if" added by WraithX, 4/14/00
3097 // done so that dead players can't move
3098 if (!Player_is_dead)
3100 //----------- Read vertical_thrust_time -----------------
3103 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
3104 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
3105 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
3106 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
3109 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
3110 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
3111 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
3112 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
3115 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3116 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
3117 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
3121 if ((use_joystick)&&( kc_joystick[13].value < 255 )) {
3122 if ( !kc_joystick[14].value ) // If not inverted...
3123 Controls.vertical_thrust_time += joy_axis[kc_joystick[13].value];
3125 Controls.vertical_thrust_time -= joy_axis[kc_joystick[13].value];
3129 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
3130 if ( !kc_mouse[14].value ) // If not inverted...
3131 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
3133 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
3138 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
3139 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
3140 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
3141 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
3144 if ((use_joystick)&&( kc_joystick[19].value < 255 )) {
3145 if ( !kc_joystick[20].value ) // If not inverted...
3146 Controls.vertical_thrust_time += joy_axis[kc_joystick[19].value];
3148 Controls.vertical_thrust_time -= joy_axis[kc_joystick[19].value];
3151 // From joystick buttons
3152 if ( (use_joystick)&&(kc_joystick[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_joystick[8].value );
3153 if ( (use_joystick)&&(kc_joystick[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_joystick[9].value );
3155 // From mouse buttons
3156 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
3157 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
3160 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
3161 if ( !kc_mouse[20].value ) // If not inverted...
3162 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
3164 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
3168 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3169 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
3170 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
3172 }// end "if" added by WraithX
3174 //---------- Read heading_time -----------
3176 if (!slide_on && !bank_on) {
3177 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
3179 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
3180 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
3181 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
3182 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
3185 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
3186 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
3187 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
3188 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
3191 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3192 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
3193 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
3197 Controls.heading_time = 0;
3199 if (Controls.heading_time < 0)
3200 Controls.heading_time = 0;
3202 if (Controls.heading_time > 0)
3203 Controls.heading_time = 0;
3204 Controls.heading_time += kh;
3207 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
3208 if ( !kc_joystick[16].value ) // If not inverted...
3209 Controls.heading_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3211 Controls.heading_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3215 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3216 if ( !kc_mouse[16].value ) // If not inverted...
3217 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3219 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3222 Controls.heading_time = 0;
3225 // the following "if" added by WraithX, 4/14/00
3226 // done so that dead players can't move
3227 if (!Player_is_dead)
3229 //----------- Read sideways_thrust_time -----------------
3232 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3233 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3234 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3235 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3238 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
3239 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
3240 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
3241 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
3244 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
3245 if ( !kc_joystick[16].value ) // If not inverted...
3246 Controls.sideways_thrust_time += joy_axis[kc_joystick[15].value];
3248 Controls.sideways_thrust_time -= joy_axis[kc_joystick[15].value];
3252 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3253 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
3254 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
3258 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3259 if ( !kc_mouse[16].value ) // If not inverted...
3260 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
3262 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
3267 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
3268 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
3269 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
3270 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
3273 if ( (use_joystick)&&(kc_joystick[17].value < 255 )) {
3274 if ( !kc_joystick[18].value ) // If not inverted...
3275 Controls.sideways_thrust_time -= joy_axis[kc_joystick[17].value];
3277 Controls.sideways_thrust_time += joy_axis[kc_joystick[17].value];
3280 // From joystick buttons
3281 if ( (use_joystick)&&(kc_joystick[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_joystick[6].value );
3282 if ( (use_joystick)&&(kc_joystick[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_joystick[7].value );
3284 // From mouse buttons
3285 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
3286 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
3289 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
3290 if ( !kc_mouse[18].value ) // If not inverted...
3291 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
3293 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
3295 }// end "if" added by WraithX
3297 //----------- Read bank_time -----------------
3300 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3301 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3302 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3303 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3306 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
3307 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
3308 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
3309 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
3312 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3313 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
3314 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
3318 if ( (use_joystick)&&(kc_joystick[15].value < 255) ) {
3319 if ( !kc_joystick[16].value ) // If not inverted...
3320 Controls.bank_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3322 Controls.bank_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3326 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3327 if ( !kc_mouse[16].value ) // If not inverted...
3328 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3330 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3335 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
3336 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
3337 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
3338 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
3341 if ( (use_joystick)&&(kc_joystick[21].value < 255) ) {
3342 if ( !kc_joystick[22].value ) // If not inverted...
3343 Controls.bank_time -= joy_axis[kc_joystick[21].value];
3345 Controls.bank_time += joy_axis[kc_joystick[21].value];
3348 // From joystick buttons
3349 if ( (use_joystick)&&(kc_joystick[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_joystick[11].value );
3350 if ( (use_joystick)&&(kc_joystick[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_joystick[12].value );
3352 // From mouse buttons
3353 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
3354 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
3357 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
3358 if ( !kc_mouse[22].value ) // If not inverted...
3359 Controls.bank_time += mouse_axis[kc_mouse[21].value];
3361 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
3365 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3366 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
3367 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
3370 // the following "if" added by WraithX, 4/14/00
3371 // done so that dead players can't move
3372 if (!Player_is_dead)
3374 //----------- Read forward_thrust_time -------------
3377 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
3378 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
3379 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
3380 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
3383 if ( (use_joystick)&&(kc_joystick[23].value < 255 )) {
3384 if ( !kc_joystick[24].value ) // If not inverted...
3385 Controls.forward_thrust_time -= joy_axis[kc_joystick[23].value];
3387 Controls.forward_thrust_time += joy_axis[kc_joystick[23].value];
3390 // From joystick buttons
3391 if ( (use_joystick)&&(kc_joystick[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_joystick[2].value );
3392 if ( (use_joystick)&&(kc_joystick[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_joystick[3].value );
3395 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
3396 if ( !kc_mouse[24].value ) // If not inverted...
3397 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
3399 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
3402 // From mouse buttons
3403 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
3404 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
3406 //----------- Read afterburner_state -------------
3409 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
3410 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
3412 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
3414 if ( (use_joystick)&&(kc_joystick[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_joystick[27].value);
3416 //-------Read headlight key--------------------------
3418 if (kc_keyboard[52].value < 255 )
3419 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
3420 if (kc_keyboard[53].value < 255 )
3421 Controls.headlight_count+=key_down_count(kc_keyboard[53].value);
3422 if ((use_joystick)&&(kc_joystick[30].value < 255 ))
3423 Controls.headlight_count+=joy_get_button_down_cnt(kc_joystick[30].value);
3425 //--------Read Cycle Primary Key------------------
3427 if (kc_keyboard[48].value<255)
3428 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
3429 if (kc_keyboard[49].value<255)
3430 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
3431 if ((use_joystick)&&(kc_joystick[28].value < 255 ))
3432 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_joystick[28].value);
3435 //--------Read Cycle Secondary Key------------------
3437 if (kc_keyboard[50].value<255)
3438 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
3439 if (kc_keyboard[51].value<255)
3440 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
3441 if ((use_joystick)&&(kc_joystick[29].value < 255 ))
3442 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_joystick[29].value);
3444 //--------Read Toggle Bomb key----------------------
3446 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
3448 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
3450 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
3451 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
3453 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3454 HUD_init_message ("No bombs available!");
3458 if (Players[Player_num].secondary_ammo[bomb]==0)
3460 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3461 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
3465 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
3466 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
3471 //---------Read Energy->Shield key----------
3473 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
3474 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
3475 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
3476 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
3478 //----------- Read fire_primary_down_count
3479 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
3480 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
3481 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_joystick[0].value);
3482 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
3484 //----------- Read fire_primary_state
3485 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
3486 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
3487 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_joystick[0].value);
3488 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
3490 //----------- Read fire_secondary_down_count
3491 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
3492 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
3493 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_joystick[1].value);
3494 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
3496 //----------- Read fire_secondary_state
3497 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
3498 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
3499 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_joystick[1].value);
3500 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
3502 //----------- Read fire_flare_down_count
3503 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
3504 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
3505 if ((use_joystick)&&(kc_joystick[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_joystick[4].value);
3506 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
3508 //----------- Read drop_bomb_down_count
3509 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
3510 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
3511 if ((use_joystick)&&(kc_joystick[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_joystick[26].value);
3512 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
3514 //----------- Read rear_view_down_count
3515 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
3516 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
3517 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_joystick[25].value);
3518 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
3520 //----------- Read rear_view_down_state
3521 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
3522 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
3523 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_joystick[25].value);
3524 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
3526 }//end "if" added by WraithX
3528 //----------- Read automap_down_count
3529 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
3530 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
3532 //----------- Read automap_state
3533 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
3534 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
3536 //----------- Read stupid-cruise-control-type of throttle.
3538 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
3539 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
3540 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
3541 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
3542 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
3544 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
3547 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
3548 if (Cruise_speed < 0 ) Cruise_speed = 0;
3550 if (Controls.forward_thrust_time==0)
3551 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
3554 #if !defined(MACINTOSH)
3555 //read_head_tracker();
3557 // Read external controls
3558 // if (kc_use_external_control || CybermouseActive)
3559 // kconfig_read_external_controls();
3562 //----------- Clamp values between -FrameTime and FrameTime
3563 if (FrameTime > F1_0 )
3564 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
3566 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
3567 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
3568 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
3569 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
3570 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
3571 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
3572 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
3574 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
3575 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
3576 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
3577 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
3578 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
3579 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
3580 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
3583 //--------- Don't do anything if in debug mode
3585 if ( keyd_pressed[KEY_DELETE] ) {
3586 memset( &Controls, 0, sizeof(control_info) );
3593 void controls_read_console()
3595 // Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3596 // Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3597 // Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3598 // Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3599 // Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3600 // Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3601 // Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3602 // Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3603 // Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3604 Controls.fire_primary_state |= Console_button_states[CMD_ATTACK];
3605 Controls.fire_secondary_state |= Console_button_states[CMD_ATTACK2];
3606 // Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3607 // Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3608 // Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3609 // Controls.automap_down_count += kc_external_control->automap_down_count;
3610 // Controls.automap_state |= kc_external_control->automap_state;
3614 void reset_cruise(void)
3620 void kc_set_controls()
3624 for (i=0; i<NUM_KEY_CONTROLS; i++ )
3625 kc_keyboard[i].value = kconfig_settings[0][i];
3627 if ( (Config_control_type>0) && (Config_control_type<5)) {
3628 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3629 kc_joystick[i].value = kconfig_settings[Config_control_type][i];
3630 if (kc_joystick[i].type == BT_INVERT ) {
3631 if (kc_joystick[i].value!=1)
3632 kc_joystick[i].value = 0;
3633 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
3636 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
3637 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3638 kc_mouse[i].value = kconfig_settings[Config_control_type][i];
3639 if (kc_mouse[i].type == BT_INVERT ) {
3640 if (kc_mouse[i].value!=1)
3641 kc_mouse[i].value = 0;
3642 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
3645 } else if (Config_control_type == CONTROL_WINJOYSTICK) {
3646 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3647 kc_superjoy[i].value = kconfig_settings[Config_control_type][i];
3648 if (kc_superjoy[i].type == BT_INVERT ) {
3649 if (kc_superjoy[i].value!=1)
3650 kc_superjoy[i].value = 0;
3651 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
3657 for (i=0; i<NUM_D2X_CONTROLS; i++ )
3658 kc_d2x[i].value = kconfig_d2x_settings[i];
3662 #if 0 //ndef MACINTOSH // no mac support for vr headset
3664 void kconfig_center_headset()
3668 vfx_center_headset();
3670 // } else if (iglasses_headset_installed) {
3671 // } else if (Victor_headset_installed) {
3677 #endif // end of #ifndef MACINTOSH for kconfig_center_headset
3679 void CybermouseAdjust ()
3681 /* if ( Player_num > -1 ) {
3682 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3683 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3684 Auto_leveling_on = 0;
3686 if ( kc_external_version > 0 ) {
3687 vms_matrix tempm, ViewMatrix;
3688 vms_angvec * Kconfig_abs_movement;
3691 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
3693 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3694 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3695 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3696 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3698 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3699 if (oem_message[0] != '\0' )
3700 HUD_init_message( oem_message );
3704 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3705 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3706 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3707 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3708 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3709 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3710 // Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3711 // Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3712 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3713 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3714 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3715 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3716 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3717 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3718 // Controls.automap_down_count += kc_external_control->automap_down_count;
3719 // Controls.automap_state |= kc_external_control->automap_state;
3722 char GetKeyValue (char key)
3724 mprintf ((0,"Returning %c!\n",kc_keyboard[(int)key].value));
3725 return (kc_keyboard[(int)key].value);
3728 #if !defined(MACINTOSH)
3731 extern object *obj_find_first_of_type (int);
3732 void kconfig_read_external_controls()
3737 if ( !kc_enable_external_control ) return;
3739 if ( kc_external_version == 0 )
3740 memset( kc_external_control, 0, sizeof(ext_control_info));
3741 else if ( kc_external_version > 0 ) {
3743 if (kc_external_version>=4)
3744 memset( kc_external_control, 0, sizeof(advanced_ext_control_info));
3745 else if (kc_external_version>0)
3746 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 );
3747 else if (kc_external_version>2)
3748 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof(vms_matrix) +4 );
3750 if ( kc_external_version > 1 ) {
3751 // Write ship pos and angles to external controls...
3752 ubyte *temp_ptr = (ubyte *)kc_external_control;
3753 vms_vector *ship_pos;
3754 vms_matrix *ship_orient;
3755 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
3756 temp_ptr += sizeof(ext_control_info) + sizeof(vms_angvec) + 64;
3757 ship_pos = (vms_vector *)temp_ptr;
3758 temp_ptr += sizeof(vms_vector);
3759 ship_orient = (vms_matrix *)temp_ptr;
3760 // Fill in ship postion...
3761 *ship_pos = Objects[Players[Player_num].objnum].pos;
3762 // Fill in ship orientation...
3763 *ship_orient = Objects[Players[Player_num].objnum].orient;
3765 if (kc_external_version>=4)
3767 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3769 temp_ptr->headlight_state=(Players[Player_num].flags & PLAYER_FLAGS_HEADLIGHT_ON);
3770 temp_ptr->primary_weapon_flags=Players[Player_num].primary_weapon_flags;
3771 temp_ptr->secondary_weapon_flags=Players[Player_num].secondary_weapon_flags;
3772 temp_ptr->current_primary_weapon=Primary_weapon;
3773 temp_ptr->current_secondary_weapon=Secondary_weapon;
3775 temp_ptr->current_guidebot_command=Escort_goal_object;
3777 temp_ptr->force_vector=ExtForceVec;
3778 temp_ptr->force_matrix=ExtApplyForceMatrix;
3780 temp_ptr->joltinfo[i]=ExtJoltInfo[i];
3782 temp_ptr->x_vibrate_info[i]=ExtXVibrateInfo[i];
3783 temp_ptr->x_vibrate_clear=ExtXVibrateClear;
3784 temp_ptr->game_status=ExtGameStatus;
3786 memset ((void *)&ExtForceVec,0,sizeof(vms_vector));
3787 memset ((void *)&ExtApplyForceMatrix,0,sizeof(vms_matrix));
3792 ExtXVibrateInfo[i]=0;
3797 if ( Automap_active ) // (If in automap...)
3798 kc_external_control->automap_state = 1;
3799 //memset(&r,0,sizeof(r));
3803 int386 ( kc_external_intno, &r, &r); // Read external info...
3807 if ( Player_num > -1 ) {
3808 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3809 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3810 Auto_leveling_on = 0;
3812 if ( kc_external_version > 0 ) {
3813 vms_matrix tempm, ViewMatrix;
3814 vms_angvec * Kconfig_abs_movement;
3817 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(ext_control_info));
3819 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3820 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3821 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3822 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3824 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3825 if (oem_message[0] != '\0' )
3826 HUD_init_message( oem_message );
3830 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3831 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3832 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3833 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3834 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3835 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3836 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3837 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3838 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3839 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3840 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3841 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3842 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3843 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3844 Controls.automap_down_count += kc_external_control->automap_down_count;
3845 Controls.automap_state |= kc_external_control->automap_state;
3847 if (kc_external_version>=3)
3849 ubyte *temp_ptr = (ubyte *)kc_external_control;
3850 temp_ptr += (sizeof(ext_control_info) + sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof (vms_matrix));
3853 Controls.cycle_primary_count=(*(temp_ptr));
3855 Controls.cycle_secondary_count=(*(temp_ptr+1));
3858 Controls.afterburner_state=(*(temp_ptr+2));
3860 Controls.headlight_count=(*(temp_ptr+3));
3862 if (kc_external_version>=4)
3865 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3868 if (temp_ptr->keyboard[i])
3871 if (temp_ptr->Reactor_blown)
3873 if (Game_mode & GM_MULTI)
3874 net_destroy_controlcen (obj_find_first_of_type (OBJ_CNTRLCEN));
3876 do_controlcen_destroyed_stuff(obj_find_first_of_type (OBJ_CNTRLCEN));