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 // Int3(); // Get Samir...
916 save_canvas = grd_curcanv;
919 gr_set_current_canvas(NULL);
920 save_font = grd_curcanv->cv_font;
926 old_keyd_repeat = keyd_repeat;
929 //gr_clear_canvas( BM_XRGB(0,0,0) );
931 nm_draw_background(0, 0, grd_curcanv->cv_bitmap.bm_w - 1, grd_curcanv->cv_bitmap.bm_h - 1);
932 gr_palette_load (gr_palette);
934 grd_curcanv->cv_font = MEDIUM3_FONT;
938 p = strchr( title, '\n' );
940 gr_string( 0x8000, LHY(8), title );
945 // if ( items == kc_keyboard ) {
946 // gr_string( 0x8000, 8, "Keyboard" );
947 // } else if ( items == kc_joystick ) {
948 // gr_string( 0x8000, 8, "Joysticks" );
949 // } else if ( items == kc_mouse ) {
950 // gr_string( 0x8000, 8, "Mouse" );
954 close_x = close_y = MenuHires?15:7;
955 close_size = MenuHires?10:5;
956 gr_setcolor( BM_XRGB(0, 0, 0) );
957 gr_rect(close_x, close_y, close_x + close_size, close_y + close_size);
958 gr_setcolor( BM_XRGB(21, 21, 21) );
959 gr_rect(close_x + LHX(1), close_y + LHX(1), close_x + close_size - LHX(1), close_y + close_size - LHX(1));
962 grd_curcanv->cv_font = GAME_FONT;
963 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
966 gr_string( 0x8000, LHY(20), TXT_KCONFIG_STRING_1 );
968 gr_string( 0x8000, LHY(20), "Enter changes, ctrl-d deletes, ctrl-r resets defaults, ESC exits");
970 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
971 if ( items == kc_keyboard ) {
972 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
973 gr_setcolor( BM_XRGB(31,27,6) );
975 gr_scanline( LHX(98), LHX(106), LHY(42) );
976 gr_scanline( LHX(120), LHX(128), LHY(42) );
977 gr_pixel( LHX(98), LHY(43) );
978 gr_pixel( LHX(98), LHY(44) );
979 gr_pixel( LHX(128), LHY(43) );
980 gr_pixel( LHX(128), LHY(44) );
982 gr_string( LHX(109), LHY(40), "OR" );
984 gr_scanline( LHX(253), LHX(261), LHY(42) );
985 gr_scanline( LHX(274), LHX(283), LHY(42) );
986 gr_pixel( LHX(253), LHY(43) );
987 gr_pixel( LHX(253), LHY(44) );
988 gr_pixel( LHX(283), LHY(43) );
989 gr_pixel( LHX(283), LHY(44) );
991 gr_string( LHX(264), LHY(40), "OR" );
993 } if ( items == kc_joystick ) {
994 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
995 gr_setcolor( BM_XRGB(31,27,6) );
996 gr_scanline( LHX(18), LHX(135), LHY(37) );
997 gr_scanline( LHX(181), LHX(294), LHY(37) );
998 gr_scanline( LHX(18), LHX(144), LHY(119+18) );
999 gr_scanline( LHX(174), LHX(294), LHY(119+18) );
1000 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
1001 gr_string( 0x8000,LHY(117+18), TXT_AXES );
1002 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1003 gr_string( LHX(81), LHY(137+8), TXT_AXIS );
1004 gr_string( LHX(111), LHY(137+8), TXT_INVERT );
1005 gr_string( LHX(230), LHY(137+8), TXT_AXIS );
1006 gr_string( LHX(260), LHY(137+8), TXT_INVERT );
1007 } else if ( items == kc_mouse ) {
1008 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
1009 gr_setcolor( BM_XRGB(31,27,6) );
1010 gr_scanline( LHX(18), LHX(135), LHY(37) );
1011 gr_scanline( LHX(181), LHX(294), LHY(37) );
1012 gr_scanline( LHX(18), LHX(144), LHY(119+5) );
1013 gr_scanline( LHX(174), LHX(294), LHY(119+5) );
1014 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
1015 gr_string( 0x8000,LHY(117+5), TXT_AXES );
1016 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1017 gr_string( LHX(169), LHY(129), TXT_AXIS );
1018 gr_string( LHX(199), LHY(129), TXT_INVERT );
1021 else if ( items == kc_d2x )
1023 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
1024 gr_setcolor( BM_XRGB(31,27,6) );
1026 gr_string(LHX( 94), LHY(40), "KB");
1027 gr_string(LHX(121), LHY(40), "JOY");
1031 for (i=0; i<nitems; i++ ) {
1032 kc_drawitem( &items[i], 0 );
1036 kc_drawitem( &items[citem], 1 );
1038 newmenu_show_cursor();
1040 #ifdef NEWMENU_MOUSE
1041 mouse_state = omouse_state = 0;
1045 // Windows addendum to allow for kconfig input.
1048 //see if redbook song needs to be restarted
1049 songs_check_redbook_repeat();
1053 #ifdef NEWMENU_MOUSE
1054 omouse_state = mouse_state;
1055 mouse_state = mouse_button_state(0);
1058 if ( !time_stopped ) {
1060 if (multi_menu_poll() == -1)
1069 case KEY_COMMAND+KEY_SHIFTED+KEY_3:
1070 case KEY_PRINT_SCREEN:
1071 save_screen_shot(0);
1073 case KEY_CTRLED+KEY_D:
1074 items[citem].value = 255;
1075 kc_drawitem( &items[citem], 1 );
1077 case KEY_CTRLED+KEY_R:
1078 if ( items==kc_keyboard ) {
1079 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1080 items[i].value=default_kconfig_settings[0][i];
1081 kc_drawitem( &items[i], 0 );
1084 } else if ( items==kc_d2x ) {
1085 for(i=0;i<NUM_D2X_CONTROLS;i++)
1087 items[i].value=default_kconfig_d2x_settings[i];
1088 kc_drawitem( &items[i], 0 );
1093 // hack for firebire and mousestick default controls since I made
1094 // them the same control type -- dumb dumb dumb
1095 if (joy_have_firebird())
1096 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1097 items[i].value = default_firebird_settings[i];
1098 kc_drawitem( &items[i], 0 );
1100 else if (joy_have_mousestick())
1101 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1102 items[i].value = default_mousestick_settings[i];
1103 kc_drawitem( &items[i], 0 );
1106 #endif // note link to above else
1107 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1108 items[i].value = default_kconfig_settings[Config_control_type][i];
1109 kc_drawitem( &items[i], 0 );
1112 kc_drawitem( &items[citem], 1 );
1115 items[citem].value=255;
1116 kc_drawitem( &items[citem], 1 );
1120 #ifdef TABLE_CREATION
1121 if (items[citem].u==-1) items[citem].u=find_next_item_up( items,nitems, citem);
1123 citem = items[citem].u;
1128 #ifdef TABLE_CREATION
1129 if (items[citem].d==-1) items[citem].d=find_next_item_down( items,nitems, citem);
1131 citem = items[citem].d;
1135 #ifdef TABLE_CREATION
1136 if (items[citem].l==-1) items[citem].l=find_next_item_left( items,nitems, citem);
1138 citem = items[citem].l;
1142 #ifdef TABLE_CREATION
1143 if (items[citem].r==-1) items[citem].r=find_next_item_right( items,nitems, citem);
1145 citem = items[citem].r;
1149 switch( items[citem].type ) {
1150 case BT_KEY: kc_change_key( &items[citem] ); break;
1151 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1152 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1153 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1154 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1155 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1158 //the following case added by WraithX on 11/22/00 to work around the weird joystick bug...
1160 switch(items[citem].type)
1163 kc_next_joyaxis(&items[citem]);
1167 //end addition by WraithX
1170 grd_curcanv->cv_font = save_font;
1172 gr_set_current_canvas( save_canvas );
1173 keyd_repeat = old_keyd_repeat;
1174 game_flush_inputs();
1175 newmenu_hide_cursor();
1179 #ifdef TABLE_CREATION
1180 case KEY_DEBUGGED+KEY_F12: {
1182 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1183 kc_keyboard[i].u = find_next_item_up( kc_keyboard,NUM_KEY_CONTROLS, i);
1184 kc_keyboard[i].d = find_next_item_down( kc_keyboard,NUM_KEY_CONTROLS, i);
1185 kc_keyboard[i].l = find_next_item_left( kc_keyboard,NUM_KEY_CONTROLS, i);
1186 kc_keyboard[i].r = find_next_item_right( kc_keyboard,NUM_KEY_CONTROLS, i);
1188 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1189 kc_joystick[i].u = find_next_item_up( kc_joystick,NUM_OTHER_CONTROLS, i);
1190 kc_joystick[i].d = find_next_item_down( kc_joystick,NUM_OTHER_CONTROLS, i);
1191 kc_joystick[i].l = find_next_item_left( kc_joystick,NUM_OTHER_CONTROLS, i);
1192 kc_joystick[i].r = find_next_item_right( kc_joystick,NUM_OTHER_CONTROLS, i);
1194 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1195 kc_mouse[i].u = find_next_item_up( kc_mouse,NUM_OTHER_CONTROLS, i);
1196 kc_mouse[i].d = find_next_item_down( kc_mouse,NUM_OTHER_CONTROLS, i);
1197 kc_mouse[i].l = find_next_item_left( kc_mouse,NUM_OTHER_CONTROLS, i);
1198 kc_mouse[i].r = find_next_item_right( kc_mouse,NUM_OTHER_CONTROLS, i);
1200 fp = fopen( "kconfig.cod", "wt" );
1202 fprintf( fp, "ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {\n" );
1203 for (i=0; i<CONTROL_MAX_TYPES; i++ ) {
1205 fprintf( fp, "{0x%x", kconfig_settings[i][0] );
1206 for (j=1; j<MAX_CONTROLS; j++ )
1207 fprintf( fp, ",0x%x", kconfig_settings[i][j] );
1208 fprintf( fp, "},\n" );
1210 fprintf( fp, "};\n" );
1212 fprintf( fp, "\nkc_item kc_keyboard[NUM_KEY_CONTROLS] = {\n" );
1213 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1214 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1215 kc_keyboard[i].id, kc_keyboard[i].x, kc_keyboard[i].y, kc_keyboard[i].w1, kc_keyboard[i].w2,
1216 kc_keyboard[i].u, kc_keyboard[i].d, kc_keyboard[i].l, kc_keyboard[i].r,
1217 34, kc_keyboard[i].text, 34, btype_text[kc_keyboard[i].type] );
1219 fprintf( fp, "};" );
1221 fprintf( fp, "\nkc_item kc_joystick[NUM_OTHER_CONTROLS] = {\n" );
1222 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1223 if (kc_joystick[i].type == BT_JOY_BUTTON)
1224 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1225 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1226 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1227 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1229 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1230 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1231 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1232 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1234 fprintf( fp, "};" );
1236 fprintf( fp, "\nkc_item kc_mouse[NUM_OTHER_CONTROLS] = {\n" );
1237 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1238 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1239 kc_mouse[i].id, kc_mouse[i].x, kc_mouse[i].y, kc_mouse[i].w1, kc_mouse[i].w2,
1240 kc_mouse[i].u, kc_mouse[i].d, kc_mouse[i].l, kc_mouse[i].r,
1241 34, kc_mouse[i].text, 34, btype_text[kc_mouse[i].type] );
1243 fprintf( fp, "};" );
1252 #ifdef NEWMENU_MOUSE
1253 if ( (mouse_state && !omouse_state) || (mouse_state && omouse_state) ) {
1256 mouse_get_pos(&mx, &my);
1257 for (i=0; i<nitems; i++ ) {
1258 item_height = get_item_height( &items[i] );
1259 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[i].x) + LHX(items[i].w1);
1260 x2 = x1 + LHX(items[i].w2);
1261 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[i].y);
1262 y2 = y1 + LHX(item_height);
1263 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1269 else if ( !mouse_state && omouse_state ) {
1272 mouse_get_pos(&mx, &my);
1273 item_height = get_item_height( &items[citem] );
1274 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[citem].x) + LHX(items[citem].w1);
1275 x2 = x1 + LHX(items[citem].w2);
1276 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[citem].y);
1277 y2 = y1 + LHY(item_height);
1278 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1279 newmenu_hide_cursor();
1280 switch( items[citem].type ) {
1281 case BT_KEY: kc_change_key( &items[citem] ); break;
1282 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1283 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1284 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1285 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1286 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1288 newmenu_show_cursor();
1290 x1 = grd_curcanv->cv_bitmap.bm_x + close_x + LHX(1);
1291 x2 = x1 + close_size - LHX(1);
1292 y1 = grd_curcanv->cv_bitmap.bm_y + close_y + LHX(1);
1293 y2 = y1 + close_size - LHX(1);
1294 if ( ((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2)) ) {
1295 grd_curcanv->cv_font = save_font;
1296 gr_set_current_canvas( save_canvas );
1297 keyd_repeat = old_keyd_repeat;
1298 game_flush_inputs();
1299 newmenu_hide_cursor();
1307 #endif // NEWMENU_MOUSE
1309 if (ocitem!=citem) {
1310 newmenu_hide_cursor();
1311 kc_drawitem( &items[ocitem], 0 );
1312 kc_drawitem( &items[citem], 1 );
1313 newmenu_show_cursor();
1319 void kc_drawitem( kc_item *item, int is_current )
1325 gr_set_fontcolor( BM_XRGB(20,20,29), -1 );
1327 gr_set_fontcolor( BM_XRGB(15,15,24), -1 );
1328 gr_string( LHX(item->x), LHY(item->y), item->text );
1330 if (item->value==255) {
1331 strcpy( btext, "" );
1333 switch( item->type ) {
1335 strncpy( btext, key_text[item->value], 10 ); break;
1336 case BT_MOUSE_BUTTON:
1338 //strncpy( btext, Text_string[mousebutton_text[item->value]], 10 ); break;
1339 strncpy( btext, (item->value <= 3)?Text_string[mousebutton_text[item->value]]:mousebutton_textra[item->value-3], 10 ); break;
1341 strncpy( btext, mousebutton_text[item->value], 10 ); break;
1344 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
1346 #ifdef USE_LINUX_JOY
1347 sprintf(btext, "J%d B%d", j_button[item->value].joydev, j_Get_joydev_button_number(item->value));
1348 #elif defined(SDL_INPUT)
1349 if (joybutton_text[item->value])
1350 strncpy(btext, joybutton_text[item->value], 10);
1352 sprintf(btext, "BTN%2d", item->value + 1);
1356 if (joybutton_text[item->value] != -1)
1357 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1359 sprintf( btext, "BTN%2d", item->value+1 );
1361 if ( joybutton_text[item->value] !=-1 )
1362 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1364 sprintf( btext, "BTN%d", item->value );
1367 strncpy( btext, joy_btn_name( item->value ), 10);
1369 sprintf( btext, "BTN%d", item->value );
1374 #ifdef USE_LINUX_JOY
1375 sprintf(btext, "J%d A%d", j_axis[item->value].joydev, j_Get_joydev_axis_number(item->value));
1376 #elif defined(SDL_INPUT)
1377 if (joyaxis_text[item->value])
1378 strncpy(btext, joyaxis_text[item->value], 10);
1380 sprintf(btext, "AXIS%2d", item->value + 1);
1382 strncpy(btext, Text_string[joyaxis_text[item->value]], 10);
1386 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
1390 gr_get_string_size(btext, &w, &h, &aw );
1393 gr_setcolor( BM_XRGB(21,0,24) );
1395 gr_setcolor( BM_XRGB(16,0,19) );
1396 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1398 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1400 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1402 gr_string( x, LHY(item->y), btext );
1407 static int looper=0;
1409 void kc_drawquestion( kc_item *item )
1413 gr_get_string_size("?", &w, &h, &aw );
1415 c = BM_XRGB(21,0,24);
1417 //@@gr_setcolor( gr_fade_table[fades[looper]*256+c] );
1418 gr_setcolor(BM_XRGB(21*fades[looper]/31,0,24*fades[looper]/31));
1420 if (looper>63) looper=0;
1422 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1424 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1426 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1428 gr_string( x, LHY(item->y), "?" );
1432 void kc_change_key( kc_item * item )
1437 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1439 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_KEY );
1441 game_flush_inputs();
1445 while( (k!=KEY_ESC) && (keycode==255) )
1448 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1451 // if ( Game_mode & GM_MULTI )
1452 // GameLoop( 0, 0 ); // Continue
1454 timer_delay(f0_1/10);
1455 kc_drawquestion( item );
1457 for (i=0; i<256; i++ ) {
1458 if (keyd_pressed[i] && (strlen(key_text[i])>0)) {
1460 for (n=0; n<sizeof(system_keys); n++ )
1461 if ( system_keys[n] == i )
1470 for (i=0; i<Num_items; i++ ) {
1471 n = item - All_items;
1472 if ( (i!=n) && (All_items[i].type==BT_KEY) && (All_items[i].value==keycode) ) {
1473 All_items[i].value = 255;
1474 kc_drawitem( &All_items[i], 0 );
1477 item->value = keycode;
1479 kc_drawitem( item, 1 );
1481 gr_set_fontcolor( BM_XRGB(28,28,28), BM_XRGB(0,0,0) );
1483 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1485 game_flush_inputs();
1489 void kc_change_joybutton( kc_item * item )
1494 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1496 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_JBUTTON );
1498 game_flush_inputs();
1502 while( (k!=KEY_ESC) && (code==255))
1505 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1508 // if ( Game_mode & GM_MULTI )
1509 // GameLoop( 0, 0 ); // Continue
1511 timer_delay(f0_1/10);
1513 if (k == KEY_PRINT_SCREEN)
1514 save_screen_shot(0);
1516 kc_drawquestion( item );
1518 WIN(code = joydefsw_do_button());
1521 code = joy_do_buttons();
1524 #if !defined(WINDOWS) && !defined(MACINTOSH)
1525 if (Config_control_type==CONTROL_THRUSTMASTER_FCS) {
1527 joystick_read_raw_axis( JOY_ALL_AXIS, axis );
1528 kconfig_read_fcs( axis[3] );
1529 if ( joy_get_button_state(7) ) code = 7;
1530 if ( joy_get_button_state(11) ) code = 11;
1531 if ( joy_get_button_state(15) ) code = 15;
1532 if ( joy_get_button_state(19) ) code = 19;
1533 for (i=0; i<4; i++ ) {
1534 if ( joy_get_button_state(i) )
1537 } else if (Config_control_type==CONTROL_FLIGHTSTICK_PRO) {
1538 for (i=4; i<20; i++ ) {
1539 if ( joy_get_button_state(i) ) {
1541 mprintf(( 0, "JB: %d\n", code ));
1545 for (i = 0; i < JOY_MAX_BUTTONS; i++)
1547 if ( joy_get_button_state(i) )
1554 for (i=0; i<Num_items; i++ ) {
1555 n = item - All_items;
1556 if ( (i!=n) && (All_items[i].type==BT_JOY_BUTTON) && (All_items[i].value==code) ) {
1557 All_items[i].value = 255;
1558 kc_drawitem( &All_items[i], 0 );
1563 kc_drawitem( item, 1 );
1564 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1565 game_flush_inputs();
1568 void kc_change_mousebutton( kc_item * item )
1573 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1575 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_MBUTTON );
1577 game_flush_inputs();
1581 while( (k!=KEY_ESC) && (code==255))
1584 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1587 // if ( Game_mode & GM_MULTI )
1588 // GameLoop( 0, 0 ); // Continue
1590 timer_delay(f0_1/10);
1592 if (k == KEY_PRINT_SCREEN)
1593 save_screen_shot(0);
1595 kc_drawquestion( item );
1597 b = mouse_get_btns();
1598 for (i = 0; i < 16; i++ ) {
1604 for (i=0; i<Num_items; i++ ) {
1605 n = item - All_items;
1606 if ( (i!=n) && (All_items[i].type==BT_MOUSE_BUTTON) && (All_items[i].value==code) ) {
1607 All_items[i].value = 255;
1608 kc_drawitem( &All_items[i], 0 );
1613 kc_drawitem( item, 1 );
1614 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1615 game_flush_inputs();
1620 // 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
1621 void kc_next_joyaxis(kc_item *item)
1623 int n, i, k, max, tries;
1630 // I modelled this ifdef after the code in the kc_change_joyaxis method.
1631 // So, if somethin's not workin here, it might not be workin there either.
1634 code = (item->value + 1) % max;
1638 for (i = 0; i < Num_items; i++)
1640 n = item - All_items;
1641 if ((i != n) && (All_items[i].type == BT_JOY_AXIS) && (All_items[i].value == code))
1644 return; // all axes allocated already
1645 i = -1; // -1 so the i++ will push back to 0
1646 code = (item->value + ++tries) % max; // try next axis
1653 kc_drawitem(item, 1);
1654 nm_restore_background(0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h);
1655 game_flush_inputs();
1657 }//method kc_next_joyaxis
1658 //end addition by WraithX
1661 void kc_change_joyaxis( kc_item * item )
1663 int axis[JOY_MAX_AXES];
1664 int old_axis[JOY_MAX_AXES];
1665 int numaxis = joy_num_axes;
1669 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1671 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_JOY_AXIS );
1673 game_flush_inputs();
1678 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, old_axis );
1680 joystick_read_raw_axis( JOY_ALL_AXIS, old_axis );
1683 while( (k!=KEY_ESC) && (code==255))
1686 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1689 // if ( Game_mode & GM_MULTI )
1690 // GameLoop( 0, 0 ); // Continue
1692 timer_delay(f0_1/10);
1694 if (k == KEY_PRINT_SCREEN)
1695 save_screen_shot(0);
1697 kc_drawquestion( item );
1700 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, axis );
1702 joystick_read_raw_axis( JOY_ALL_AXIS, axis );
1705 for (i=0; i<numaxis; i++ ) {
1706 #if defined (MACINTOSH)
1707 if ( abs(axis[i]-old_axis[i])>100 )
1708 #elif defined(WINDOWS)
1709 if ( abs(axis[i]-old_axis[i])>1024 )
1711 if ( abs(axis[i]-old_axis[i])>200 )
1715 con_printf(CON_DEBUG, "Axis Movement detected: Axis %i\n", i);
1717 //old_axis[i] = axis[i];
1719 for (i=0; i<Num_items; i++ )
1721 n = item - All_items;
1722 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) )
1728 for (i=0; i<Num_items; i++ ) {
1729 n = item - All_items;
1730 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) ) {
1731 All_items[i].value = 255;
1732 kc_drawitem( &All_items[i], 0 );
1738 kc_drawitem( item, 1 );
1739 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1740 game_flush_inputs();
1744 void kc_change_mouseaxis( kc_item * item )
1753 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1755 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_MSE_AXIS );
1757 game_flush_inputs();
1761 mouse_get_delta( &dx, &dy );
1763 while( (k!=KEY_ESC) && (code==255))
1766 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1769 // if ( Game_mode & GM_MULTI )
1770 // GameLoop( 0, 0 ); // Continue
1772 timer_delay(f0_1/10);
1774 if (k == KEY_PRINT_SCREEN)
1775 save_screen_shot(0);
1777 kc_drawquestion( item );
1780 mouse_get_delta_z( &dx, &dy, &dz );
1782 mouse_get_delta( &dx, &dy );
1784 if ( abs(dx)>20 ) code = 0;
1785 if ( abs(dy)>20 ) code = 1;
1787 if ( abs(dz)>20 ) code = 2;
1791 for (i=0; i<Num_items; i++ ) {
1792 n = item - All_items;
1793 if ( (i!=n) && (All_items[i].type==BT_MOUSE_AXIS) && (All_items[i].value==code) ) {
1794 All_items[i].value = 255;
1795 kc_drawitem( &All_items[i], 0 );
1800 kc_drawitem( item, 1 );
1801 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1802 game_flush_inputs();
1807 void kc_change_invert( kc_item * item )
1809 game_flush_inputs();
1816 kc_drawitem( item, 1 );
1820 #include "screens.h"
1822 void kconfig(int n, char * title)
1825 grs_bitmap *save_bm;
1827 set_screen_mode( SCREEN_MENU );
1832 save_bm = gr_create_bitmap( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
1833 Assert( save_bm != NULL );
1835 gr_bm_bitblt(grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_w,
1836 0, 0, 0, 0, &grd_curcanv->cv_bitmap, save_bm );
1839 case 0:kconfig_sub( kc_keyboard, NUM_KEY_CONTROLS, title );break;
1840 case 1:kconfig_sub( kc_joystick, NUM_OTHER_CONTROLS, title );break;
1841 case 2:kconfig_sub( kc_mouse, NUM_OTHER_CONTROLS, title ); break;
1842 case 3:kconfig_sub( kc_superjoy, NUM_OTHER_CONTROLS, title); break;
1844 //added on 2/4/99 by Victor Rachels for new keys menu
1845 case 4:kconfig_sub( kc_d2x, NUM_D2X_CONTROLS, title ); break;
1846 //end this section addition - VR
1854 gr_bitmap(0, 0, save_bm);
1855 gr_free_bitmap(save_bm);
1857 #if 0 // set_screen_mode always calls this later... right?
1858 reset_cockpit(); //force cockpit redraw next time
1861 // Update save values...
1863 for (i=0; i<NUM_KEY_CONTROLS; i++ )
1864 kconfig_settings[0][i] = kc_keyboard[i].value;
1866 if ( (Config_control_type>0) && (Config_control_type<5)) {
1867 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1868 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
1869 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
1870 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1871 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
1873 else if (Config_control_type == CONTROL_WINJOYSTICK) {
1874 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1875 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
1879 for (i=0; i<NUM_D2X_CONTROLS; i++)
1880 kconfig_d2x_settings[i] = kc_d2x[i].value;
1885 void kconfig_read_fcs( int raw_axis )
1887 int raw_button, button, axis_min[4], axis_center[4], axis_max[4];
1889 if (Config_control_type!=CONTROL_THRUSTMASTER_FCS) return;
1891 joy_get_cal_vals(axis_min, axis_center, axis_max);
1893 if ( axis_max[3] > 1 )
1894 raw_button = (raw_axis*100)/axis_max[3];
1898 if ( raw_button > 88 )
1900 else if ( raw_button > 63 )
1902 else if ( raw_button > 39 )
1904 else if ( raw_button > 15 )
1909 kconfig_set_fcs_button( 19, button );
1910 kconfig_set_fcs_button( 15, button );
1911 kconfig_set_fcs_button( 11, button );
1912 kconfig_set_fcs_button( 7, button );
1916 void kconfig_set_fcs_button( int btn, int button )
1918 int state,time_down,upcount,downcount;
1919 state = time_down = upcount = downcount = 0;
1921 if ( joy_get_button_state(btn) ) {
1922 if ( btn==button ) {
1924 time_down = FrameTime;
1929 if ( btn==button ) {
1931 time_down = FrameTime;
1938 joy_set_btn_values( btn, state, time_down, downcount, upcount );
1944 fix Last_angles_p = 0;
1945 fix Last_angles_b = 0;
1946 fix Last_angles_h = 0;
1947 ubyte Last_angles_read = 0;
1949 extern int VR_sensitivity;
1951 int VR_sense_range[3] = { 25, 50, 75 };
1953 #if 0 //ndef MACINTOSH
1958 fix yaw, pitch, roll;
1961 //------ read vfx1 helmet --------
1962 if (vfx1_installed) {
1963 vfx_get_data(&yaw,&pitch,&roll,&buttons);
1964 } else if (iglasses_headset_installed) {
1965 iglasses_read_headset( &yaw, &pitch, &roll );
1966 } else if (Victor_headset_installed) {
1967 victor_read_headset_filtered( &yaw, &pitch, &roll );
1972 Use_player_head_angles = 0;
1973 if ( Last_angles_read ) {
1977 if ( (Last_angles_h < (F1_0/4) ) && (yaw > ((F1_0*3)/4) ) )
1979 else if ( (yaw < (F1_0/4) ) && (Last_angles_h > ((F1_0*3)/4) ) )
1982 Controls.pitch_time += fixmul((pitch- Last_angles_p)*VR_sense_range[VR_sensitivity],FrameTime);
1983 Controls.heading_time+= fixmul((yaw1 - Last_angles_h)*VR_sense_range[VR_sensitivity],FrameTime);
1984 Controls.bank_time += fixmul((roll - Last_angles_b)*VR_sense_range[VR_sensitivity],FrameTime);
1986 Last_angles_read = 1;
1987 Last_angles_p = pitch;
1988 Last_angles_h = yaw;
1989 Last_angles_b = roll;
1996 #ifndef __MSDOS__ // WINDOWS
1997 #define JOYSTICK_READ_TIME (F1_0/40) // Read joystick at 40 Hz.
1999 #define JOYSTICK_READ_TIME (F1_0/10) // Read joystick at 10 Hz.
2002 fix LastReadTime = 0;
2004 fix joy_axis[JOY_MAX_AXES];
2006 ubyte kc_use_external_control = 0;
2007 ubyte kc_enable_external_control = 0;
2008 ubyte kc_external_intno = 0;
2009 ext_control_info *kc_external_control = NULL;
2010 char *kc_external_name = NULL;
2011 ubyte kc_external_version = 0;
2012 extern int Automap_active;
2014 void kconfig_init_external_controls(int intno, int address)
2017 kc_external_intno = intno;
2018 kc_external_control = (ext_control_info *)address;
2019 kc_use_external_control = 1;
2020 kc_enable_external_control = 1;
2022 i = FindArg ( "-xname" );
2024 kc_external_name = Args[i+1];
2026 kc_external_name = "External Controller";
2028 for (i=0;i<strlen (kc_external_name);i++)
2029 if (kc_external_name[i]=='_')
2030 kc_external_name[i]=' ';
2032 i = FindArg ( "-xver" );
2034 kc_external_version = atoi(Args[i+1]);
2036 printf( "%s int: 0x%x, data: 0x%p, ver:%d\n", kc_external_name, kc_external_intno, kc_external_control, kc_external_version );
2040 #if !defined(MACINTOSH)
2041 /*void kconfig_read_external_controls()
2045 if ( !kc_enable_external_control && !CybermouseActive)
2048 if ( kc_external_version == 0 )
2049 memset( kc_external_control, 0, sizeof(control_info) );
2050 else if ( kc_external_version > 0 ) {
2051 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 );
2052 if ( kc_external_version > 1 ) {
2053 // Write ship pos and angles to external controls...
2054 ubyte *temp_ptr = (ubyte *)kc_external_control;
2055 vms_vector *ship_pos;
2056 vms_matrix *ship_orient;
2057 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
2058 temp_ptr += sizeof(control_info)+sizeof(vms_angvec) + 64;
2059 ship_pos = (vms_vector *)temp_ptr;
2060 temp_ptr += sizeof(vms_vector);
2061 ship_orient = (vms_matrix *)temp_ptr;
2062 // Fill in ship postion...
2063 *ship_pos = Objects[Players[Player_num].objnum].pos;
2064 // Fill in ship orientation...
2065 *ship_orient = Objects[Players[Player_num].objnum].orient;
2069 if ( Automap_active ) // (If in automap...)
2070 kc_external_control->automap_state = 1;
2071 memset(&r,0,sizeof(r));
2075 if (!CybermouseActive)
2076 int386 ( kc_external_intno, &r, &r); // Read external info...
2078 // ReadOWL (kc_external_control);
2082 if ( Player_num > -1 ) {
2083 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
2084 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
2085 Auto_leveling_on = 0;
2087 if ( kc_external_version > 0 ) {
2088 vms_matrix tempm, ViewMatrix;
2089 vms_angvec * Kconfig_abs_movement;
2092 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
2094 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
2095 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
2096 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
2097 Objects[Players[Player_num].objnum].orient = ViewMatrix;
2099 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
2100 if (oem_message[0] != '\0' )
2101 HUD_init_message( oem_message );
2105 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
2106 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
2107 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
2108 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
2109 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
2110 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
2111 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
2112 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
2113 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
2114 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
2115 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
2116 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
2117 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
2118 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
2119 Controls.automap_down_count += kc_external_control->automap_down_count;
2120 Controls.automap_state |= kc_external_control->automap_state;
2125 void controls_read_all_win()
2128 int slide_on, bank_on;
2132 int raw_joy_axis[7];
2134 fix k0, k1, k2, k3, kp;
2135 fix k4, k5, k6, k7, kh;
2136 ubyte channel_masks;
2137 int use_mouse, use_joystick;
2140 if (Game_turbo_mode)
2144 fix temp = Controls.heading_time;
2145 fix temp1 = Controls.pitch_time;
2146 memset( &Controls, 0, sizeof(control_info) );
2147 Controls.heading_time = temp;
2148 Controls.pitch_time = temp1;
2153 ctime = timer_get_fixed_seconds();
2155 // DO JOYSTICK (X,Y,Z R,U,V)
2156 // ----------------------------------------------------------------------------
2157 if ( (LastReadTime + JOYSTICK_READ_TIME) > ctime ) {
2158 if ((ctime < 0) && (LastReadTime > 0))
2159 LastReadTime = ctime;
2161 } else if ((Config_control_type==CONTROL_WINJOYSTICK)) {
2162 LastReadTime = ctime;
2163 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, raw_joy_axis );
2165 for (i=0; i<7; i++ ) {
2166 if (channel_masks&(1<<i)) {
2167 int joy_null_value = 28;
2169 // DO POV if joystick has a hat.
2170 // --------------------------------------------------------------------
2172 joydefsw_do_winjoybutton(raw_joy_axis);
2176 // --------------------------------------------------------------------
2177 // mprintf((0, "(%d)=%d,", i, raw_joy_axis[i]));
2178 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2179 // mprintf((0, "%d ",raw_joy_axis[i]));
2180 // if (i%2) mprintf((0,"\n"));
2183 if (kc_superjoy[23].value==i) // If this is the throttle
2184 joy_null_value = 32; // Then use a larger dead-zone
2186 if (raw_joy_axis[i] > (joy_null_value-2))
2187 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2188 else if (raw_joy_axis[i] < -(joy_null_value+2))
2189 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2191 raw_joy_axis[i] = 0;
2192 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2201 for (i=0; i<6; i++ )
2207 // ----------------------------------------------------------------------------
2208 if (Config_control_type==5) {
2209 mouse_get_delta( &dx, &dy );
2210 mouse_axis[0] = (dx*FrameTime)/35;
2211 mouse_axis[1] = (dy*FrameTime)/25;
2212 mouse_buttons = mouse_get_btns();
2213 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2222 //------------- Read slide_on -------------
2225 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
2226 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
2228 if ((use_joystick)&&(kc_superjoy[5].value<255)) slide_on |= joy_get_button_state( kc_superjoy[5].value );
2230 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
2232 //------------- Read bank_on ---------------
2235 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
2236 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
2238 if ( (use_joystick)&&(kc_superjoy[10].value < 255 )) bank_on |= joy_get_button_state( kc_superjoy[10].value );
2240 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
2242 //------------ Read pitch_time -----------
2244 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2246 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
2247 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
2248 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
2249 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
2252 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
2253 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
2254 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
2255 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
2258 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2259 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
2260 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
2264 Controls.pitch_time = 0;
2266 if (Controls.pitch_time < 0)
2267 Controls.pitch_time = 0;
2269 if (Controls.pitch_time > 0)
2270 Controls.pitch_time = 0;
2271 Controls.pitch_time += kp;
2274 if ( (use_joystick)&&(kc_superjoy[13].value < 255 )) {
2275 if ( !kc_superjoy[14].value ) // If not inverted...
2276 Controls.pitch_time -= (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2278 Controls.pitch_time += (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2282 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
2283 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
2284 if ( !kc_mouse[14].value ) // If not inverted...
2285 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2287 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2290 Controls.pitch_time = 0;
2294 //----------- Read vertical_thrust_time -----------------
2297 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
2298 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
2299 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
2300 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
2303 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
2304 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
2305 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
2306 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
2309 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2310 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
2311 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
2315 if ((use_joystick)&&( kc_superjoy[13].value < 255 )) {
2316 if ( !kc_superjoy[14].value ) // If not inverted...
2317 Controls.vertical_thrust_time += joy_axis[kc_superjoy[13].value];
2319 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[13].value];
2323 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
2324 if ( !kc_mouse[14].value ) // If not inverted...
2325 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
2327 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
2332 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
2333 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
2334 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
2335 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
2338 if ((use_joystick)&&( kc_superjoy[19].value < 255 )) {
2339 if ( !kc_superjoy[20].value ) // If not inverted...
2340 Controls.vertical_thrust_time += joy_axis[kc_superjoy[19].value];
2342 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[19].value];
2345 // From joystick buttons
2346 if ( (use_joystick)&&(kc_superjoy[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_superjoy[8].value );
2347 if ( (use_joystick)&&(kc_superjoy[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_superjoy[9].value );
2349 // From mouse buttons
2350 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
2351 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
2354 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
2355 if ( !kc_mouse[20].value ) // If not inverted...
2356 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
2358 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
2362 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2363 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
2364 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
2367 //---------- Read heading_time -----------
2369 if (!slide_on && !bank_on) {
2370 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2372 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
2373 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
2374 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
2375 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
2378 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
2379 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
2380 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
2381 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
2384 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2385 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
2386 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
2390 Controls.heading_time = 0;
2392 if (Controls.heading_time < 0)
2393 Controls.heading_time = 0;
2395 if (Controls.heading_time > 0)
2396 Controls.heading_time = 0;
2397 Controls.heading_time += kh;
2400 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2401 if ( !kc_superjoy[16].value ) // If not inverted...
2402 Controls.heading_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2404 Controls.heading_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2408 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2409 if ( !kc_mouse[16].value ) // If not inverted...
2410 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2412 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2415 Controls.heading_time = 0;
2418 //----------- Read sideways_thrust_time -----------------
2421 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2422 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2423 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2424 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2427 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
2428 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
2429 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
2430 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
2433 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2434 if ( !kc_superjoy[16].value ) // If not inverted...
2435 Controls.sideways_thrust_time += joy_axis[kc_superjoy[15].value];
2437 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[15].value];
2441 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2442 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
2443 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
2447 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2448 if ( !kc_mouse[16].value ) // If not inverted...
2449 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
2451 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
2456 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
2457 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
2458 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
2459 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
2462 if ( (use_joystick)&&(kc_superjoy[17].value < 255 )) {
2463 if ( !kc_superjoy[18].value ) // If not inverted...
2464 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[17].value];
2466 Controls.sideways_thrust_time += joy_axis[kc_superjoy[17].value];
2469 // From joystick buttons
2470 if ( (use_joystick)&&(kc_superjoy[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_superjoy[6].value );
2471 if ( (use_joystick)&&(kc_superjoy[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_superjoy[7].value );
2473 // From mouse buttons
2474 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
2475 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
2478 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
2479 if ( !kc_mouse[18].value ) // If not inverted...
2480 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
2482 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
2485 //----------- Read bank_time -----------------
2488 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2489 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2490 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2491 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2494 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
2495 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
2496 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
2497 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
2500 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2501 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
2502 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
2506 if ( (use_joystick)&&(kc_superjoy[15].value < 255) ) {
2507 if ( !kc_superjoy[16].value ) // If not inverted...
2508 Controls.bank_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2510 Controls.bank_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2514 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2515 if ( !kc_mouse[16].value ) // If not inverted...
2516 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2518 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2523 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
2524 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
2525 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
2526 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
2529 if ( (use_joystick)&&(kc_superjoy[21].value < 255) ) {
2530 if ( !kc_superjoy[22].value ) // If not inverted...
2531 Controls.bank_time -= joy_axis[kc_superjoy[21].value];
2533 Controls.bank_time += joy_axis[kc_superjoy[21].value];
2536 // From joystick buttons
2537 if ( (use_joystick)&&(kc_superjoy[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_superjoy[11].value );
2538 if ( (use_joystick)&&(kc_superjoy[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_superjoy[12].value );
2540 // From mouse buttons
2541 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
2542 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
2545 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
2546 if ( !kc_mouse[22].value ) // If not inverted...
2547 Controls.bank_time += mouse_axis[kc_mouse[21].value];
2549 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
2553 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2554 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
2555 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
2558 //----------- Read forward_thrust_time -------------
2561 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
2562 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
2563 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
2564 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
2567 if ( (use_joystick)&&(kc_superjoy[23].value < 255 )) {
2568 if ( !kc_superjoy[24].value ) // If not inverted...
2569 Controls.forward_thrust_time -= joy_axis[kc_superjoy[23].value];
2571 Controls.forward_thrust_time += joy_axis[kc_superjoy[23].value];
2574 // From joystick buttons
2575 if ( (use_joystick)&&(kc_superjoy[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_superjoy[2].value );
2576 if ( (use_joystick)&&(kc_superjoy[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_superjoy[3].value );
2579 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
2580 if ( !kc_mouse[24].value ) // If not inverted...
2581 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
2583 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
2586 // From mouse buttons
2587 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
2588 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
2590 //----------- Read afterburner_state -------------
2593 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
2594 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
2596 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
2598 if ( (use_joystick)&&(kc_superjoy[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_superjoy[27].value);
2600 //-------Read headlight key--------------------------
2601 if (kc_keyboard[52].value < 255 )
2602 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
2603 if (kc_keyboard[53].value < 255 )
2604 Controls.headlight_count=key_down_count(kc_keyboard[53].value);
2605 if ((use_joystick)&&(kc_superjoy[30].value < 255 ))
2606 Controls.headlight_count=joy_get_button_down_cnt(kc_superjoy[30].value);
2608 //--------Read Cycle Primary Key------------------
2610 if (kc_keyboard[48].value<255)
2611 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
2612 if (kc_keyboard[49].value<255)
2613 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
2614 if ((use_joystick)&&(kc_superjoy[28].value < 255 ))
2615 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_superjoy[28].value);
2617 //--------Read Cycle Secondary Key------------------
2619 if (kc_keyboard[50].value<255)
2620 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
2621 if (kc_keyboard[51].value<255)
2622 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
2623 if ((use_joystick)&&(kc_superjoy[29].value < 255 ))
2624 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_superjoy[29].value);
2626 //--------Read Toggle Bomb key----------------------
2628 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
2630 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
2632 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
2633 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
2635 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2636 HUD_init_message ("No bombs available!");
2640 if (Players[Player_num].secondary_ammo[bomb]==0)
2642 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2643 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
2647 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
2648 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
2653 //---------Read Energy->Shield key----------
2655 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
2656 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
2657 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
2658 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
2660 //----------- Read fire_primary_down_count
2661 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
2662 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
2663 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_superjoy[0].value);
2664 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
2666 //----------- Read fire_primary_state
2667 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
2668 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
2669 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_superjoy[0].value);
2670 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
2672 //----------- Read fire_secondary_down_count
2673 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
2674 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
2675 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_superjoy[1].value);
2676 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
2678 //----------- Read fire_secondary_state
2679 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
2680 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
2681 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_superjoy[1].value);
2682 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
2684 //----------- Read fire_flare_down_count
2685 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
2686 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
2687 if ((use_joystick)&&(kc_superjoy[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_superjoy[4].value);
2688 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
2690 //----------- Read drop_bomb_down_count
2691 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
2692 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
2693 if ((use_joystick)&&(kc_superjoy[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_superjoy[26].value);
2694 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
2696 //----------- Read rear_view_down_count
2697 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
2698 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
2699 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_superjoy[25].value);
2700 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
2702 //----------- Read rear_view_down_state
2703 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
2704 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
2705 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_superjoy[25].value);
2706 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
2708 //----------- Read automap_down_count
2709 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
2710 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
2712 //----------- Read automap_state
2713 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
2714 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
2716 //----------- Read stupid-cruise-control-type of throttle.
2718 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
2719 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
2720 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
2721 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
2722 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
2724 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
2727 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
2728 if (Cruise_speed < 0 ) Cruise_speed = 0;
2730 if (Controls.forward_thrust_time==0)
2731 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
2734 //read_head_tracker();
2736 // Read external controls
2737 if (kc_use_external_control || CybermouseActive)
2738 kconfig_read_external_controls();
2740 //----------- Clamp values between -FrameTime and FrameTime
2741 if (FrameTime > F1_0 )
2742 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
2744 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
2745 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
2746 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
2747 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
2748 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
2749 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
2750 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
2752 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
2753 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
2754 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
2755 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
2756 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
2757 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
2758 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
2761 //--------- Don't do anything if in debug mode
2763 if ( keyd_pressed[KEY_DELETE] ) {
2764 memset( &Controls, 0, sizeof(control_info) );
2771 fix Next_toggle_time[3]={0,0,0};
2773 int allowed_to_toggle(int i)
2775 //used for keeping tabs of when its ok to toggle headlight,primary,and secondary
2777 if (Next_toggle_time[i] > GameTime)
2778 if (Next_toggle_time[i] < GameTime + (F1_0/8)) // In case time is bogus, never wait > 1 second.
2781 Next_toggle_time[i] = GameTime + (F1_0/8);
2788 //added on 2/7/99 by Victor Rachels for jostick state setting
2789 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};
2790 //end this section adition - VR
2794 void controls_read_all()
2797 int slide_on, bank_on;
2804 fix mouse_axis[3] = {0,0,0};
2805 int raw_joy_axis[JOY_MAX_AXES];
2807 fix k0, k1, k2, k3, kp;
2808 fix k4, k5, k6, k7, kh;
2809 ubyte channel_masks;
2810 int use_mouse, use_joystick;
2816 if (Game_turbo_mode)
2820 fix temp = Controls.heading_time;
2821 fix temp1 = Controls.pitch_time;
2822 memset( &Controls, 0, sizeof(control_info) );
2823 Controls.heading_time = temp;
2824 Controls.pitch_time = temp1;
2829 ctime = timer_get_fixed_seconds();
2831 //--------- Read Joystick -----------
2833 if ( (LastReadTime + JOYSTICK_READ_TIME > ctime) && (Config_control_type!=CONTROL_THRUSTMASTER_FCS) ) {
2835 if ((ctime < 0) && (LastReadTime >= 0))
2837 if ((ctime < 0) && (LastReadTime > 0))
2839 LastReadTime = ctime;
2841 } else if ((Config_control_type>0) && (Config_control_type<5) ) {
2842 LastReadTime = ctime;
2843 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
2845 for (i = 0; i < joy_num_axes; i++)
2848 if (channel_masks&(1<<i)) {
2850 int joy_null_value = 10;
2852 if ( (i==3) && (Config_control_type==CONTROL_THRUSTMASTER_FCS) ) {
2853 kconfig_read_fcs( raw_joy_axis[i] );
2855 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2857 if (kc_joystick[23].value==i) // If this is the throttle
2858 joy_null_value = 20; // Then use a larger dead-zone
2860 if (raw_joy_axis[i] > joy_null_value)
2861 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2862 else if (raw_joy_axis[i] < -joy_null_value)
2863 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2865 raw_joy_axis[i] = 0;
2866 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2876 for (i = 0; i < joy_num_axes; i++)
2881 //--------- Read Joystick -----------
2882 if ((Config_control_type>0) && (Config_control_type<5) ) {
2883 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
2884 for (i=0; i<4; i++ ) {
2885 if (channel_masks&(1<<i)) {
2886 int joy_null_value = 10;
2888 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2890 if (kc_joystick[23].value==i) // If this is the throttle
2891 joy_null_value = 20; // Then use a larger dead-zone
2893 if (raw_joy_axis[i] > joy_null_value)
2894 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2895 else if (raw_joy_axis[i] < -joy_null_value)
2896 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2898 raw_joy_axis[i] = 0;
2899 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2906 for (i=0; i<4; i++ )
2910 #endif // ifndef MACINTOSH
2912 if (Config_control_type==5 && !CybermouseActive) {
2913 //--------- Read Mouse -----------
2915 mouse_get_delta_z( &dx, &dy, &dz );
2917 mouse_get_delta( &dx, &dy );
2919 mouse_axis[0] = (dx*FrameTime)/35;
2920 mouse_axis[1] = (dy*FrameTime)/25;
2922 mouse_axis[2] = (dz*FrameTime);
2924 mouse_buttons = mouse_get_btns();
2925 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2927 } else if (Config_control_type==6 && !CybermouseActive) {
2928 //--------- Read Cyberman -----------
2929 mouse_get_cyberman_pos(&idx,&idy );
2930 mouse_axis[0] = (idx*FrameTime)/128;
2931 mouse_axis[1] = (idy*FrameTime)/128;
2932 mouse_buttons = mouse_get_btns();
2934 } else if (CybermouseActive) {
2935 // ReadOWL (kc_external_control);
2936 // CybermouseAdjust();
2945 //added on 2/4/99 by Victor Rachels for d1x keys
2946 //--------- Read primary weapon select -------------
2947 //the following "if" added by WraithX to stop deadies from switchin weapons, 4/14/00
2948 if (!Player_is_dead)
2951 int d2x_joystick_state[10];
2954 d2x_joystick_state[i] = joy_get_button_state(kc_d2x[i*2+1].value);
2957 //----------------Weapon 1----------------
2958 if(key_down_count(kc_d2x[0].value) ||
2959 (joy_get_button_state(kc_d2x[1].value) &&
2960 (d2x_joystick_state[0]!=d2x_joystick_ostate[0]) ) )
2963 do_weapon_select(0,0);
2965 for(i=MAX_PRIMARY_WEAPONS;i<MAX_PRIMARY_WEAPONS+NEWPRIMS;i++)
2966 if(primary_order[i]>primary_order[valu]&&player_has_weapon(i,0))
2968 LaserPowSelected = valu;
2971 //----------------Weapon 2----------------
2972 if(key_down_count(kc_d2x[2].value) ||
2973 (joy_get_button_state(kc_d2x[3].value) &&
2974 (d2x_joystick_state[1]!=d2x_joystick_ostate[1]) ) )
2975 do_weapon_select(1,0);
2976 //----------------Weapon 3----------------
2977 if(key_down_count(kc_d2x[4].value) ||
2978 (joy_get_button_state(kc_d2x[5].value) &&
2979 (d2x_joystick_state[2]!=d2x_joystick_ostate[2]) ) )
2980 do_weapon_select(2,0);
2981 //----------------Weapon 4----------------
2982 if(key_down_count(kc_d2x[6].value) ||
2983 (joy_get_button_state(kc_d2x[7].value) &&
2984 (d2x_joystick_state[3]!=d2x_joystick_ostate[3]) ) )
2985 do_weapon_select(3,0);
2986 //----------------Weapon 5----------------
2987 if(key_down_count(kc_d2x[8].value) ||
2988 (joy_get_button_state(kc_d2x[9].value) &&
2989 (d2x_joystick_state[4]!=d2x_joystick_ostate[4]) ) )
2990 do_weapon_select(4,0);
2992 //--------- Read secondary weapon select ----------
2993 //----------------Weapon 6----------------
2994 if(key_down_count(kc_d2x[10].value) ||
2995 (joy_get_button_state(kc_d2x[11].value) &&
2996 (d2x_joystick_state[5]!=d2x_joystick_ostate[5]) ) )
2997 do_weapon_select(0,1);
2998 //----------------Weapon 7----------------
2999 if(key_down_count(kc_d2x[12].value) ||
3000 (joy_get_button_state(kc_d2x[13].value) &&
3001 (d2x_joystick_state[6]!=d2x_joystick_ostate[6]) ) )
3002 do_weapon_select(1,1);
3003 //----------------Weapon 8----------------
3004 if(key_down_count(kc_d2x[14].value) ||
3005 (joy_get_button_state(kc_d2x[15].value) &&
3006 (d2x_joystick_state[7]!=d2x_joystick_ostate[7]) ) )
3007 do_weapon_select(2,1);
3008 //----------------Weapon 9----------------
3009 if(key_down_count(kc_d2x[16].value) ||
3010 (joy_get_button_state(kc_d2x[17].value) &&
3011 (d2x_joystick_state[8]!=d2x_joystick_ostate[8]) ) )
3012 do_weapon_select(3,1);
3013 //----------------Weapon 0----------------
3014 if(key_down_count(kc_d2x[18].value) ||
3015 (joy_get_button_state(kc_d2x[19].value) &&
3016 (d2x_joystick_state[9]!=d2x_joystick_ostate[9]) ) )
3017 do_weapon_select(4,1);
3018 memcpy(d2x_joystick_ostate,d2x_joystick_state,10*sizeof(int));
3020 //end this section addition - VR
3023 }//end "if (!Player_is_dead)" - WraithX
3027 //------------- Read slide_on -------------
3030 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
3031 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
3033 if ((use_joystick)&&(kc_joystick[5].value<255)) slide_on |= joy_get_button_state( kc_joystick[5].value );
3035 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
3037 //------------- Read bank_on ---------------
3040 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
3041 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
3043 if ( (use_joystick)&&(kc_joystick[10].value < 255 )) bank_on |= joy_get_button_state( kc_joystick[10].value );
3045 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
3047 //------------ Read pitch_time -----------
3049 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
3051 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
3052 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
3053 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
3054 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
3057 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
3058 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
3059 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
3060 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
3063 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3064 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
3065 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
3069 Controls.pitch_time = 0;
3071 if (Controls.pitch_time < 0)
3072 Controls.pitch_time = 0;
3074 if (Controls.pitch_time > 0)
3075 Controls.pitch_time = 0;
3076 Controls.pitch_time += kp;
3079 if ( (use_joystick)&&(kc_joystick[13].value < 255 )) {
3080 if ( !kc_joystick[14].value ) // If not inverted...
3081 Controls.pitch_time -= (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
3083 Controls.pitch_time += (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
3087 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
3088 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
3089 if ( !kc_mouse[14].value ) // If not inverted...
3090 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
3092 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
3095 Controls.pitch_time = 0;
3099 // the following "if" added by WraithX, 4/14/00
3100 // done so that dead players can't move
3101 if (!Player_is_dead)
3103 //----------- Read vertical_thrust_time -----------------
3106 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
3107 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
3108 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
3109 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
3112 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
3113 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
3114 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
3115 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
3118 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3119 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
3120 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
3124 if ((use_joystick)&&( kc_joystick[13].value < 255 )) {
3125 if ( !kc_joystick[14].value ) // If not inverted...
3126 Controls.vertical_thrust_time += joy_axis[kc_joystick[13].value];
3128 Controls.vertical_thrust_time -= joy_axis[kc_joystick[13].value];
3132 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
3133 if ( !kc_mouse[14].value ) // If not inverted...
3134 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
3136 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
3141 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
3142 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
3143 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
3144 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
3147 if ((use_joystick)&&( kc_joystick[19].value < 255 )) {
3148 if ( !kc_joystick[20].value ) // If not inverted...
3149 Controls.vertical_thrust_time += joy_axis[kc_joystick[19].value];
3151 Controls.vertical_thrust_time -= joy_axis[kc_joystick[19].value];
3154 // From joystick buttons
3155 if ( (use_joystick)&&(kc_joystick[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_joystick[8].value );
3156 if ( (use_joystick)&&(kc_joystick[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_joystick[9].value );
3158 // From mouse buttons
3159 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
3160 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
3163 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
3164 if ( !kc_mouse[20].value ) // If not inverted...
3165 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
3167 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
3171 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3172 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
3173 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
3175 }// end "if" added by WraithX
3177 //---------- Read heading_time -----------
3179 if (!slide_on && !bank_on) {
3180 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
3182 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
3183 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
3184 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
3185 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
3188 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
3189 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
3190 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
3191 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
3194 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3195 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
3196 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
3200 Controls.heading_time = 0;
3202 if (Controls.heading_time < 0)
3203 Controls.heading_time = 0;
3205 if (Controls.heading_time > 0)
3206 Controls.heading_time = 0;
3207 Controls.heading_time += kh;
3210 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
3211 if ( !kc_joystick[16].value ) // If not inverted...
3212 Controls.heading_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3214 Controls.heading_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3218 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3219 if ( !kc_mouse[16].value ) // If not inverted...
3220 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3222 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3225 Controls.heading_time = 0;
3228 // the following "if" added by WraithX, 4/14/00
3229 // done so that dead players can't move
3230 if (!Player_is_dead)
3232 //----------- Read sideways_thrust_time -----------------
3235 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3236 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3237 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3238 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3241 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
3242 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
3243 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
3244 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
3247 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
3248 if ( !kc_joystick[16].value ) // If not inverted...
3249 Controls.sideways_thrust_time += joy_axis[kc_joystick[15].value];
3251 Controls.sideways_thrust_time -= joy_axis[kc_joystick[15].value];
3255 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3256 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
3257 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
3261 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3262 if ( !kc_mouse[16].value ) // If not inverted...
3263 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
3265 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
3270 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
3271 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
3272 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
3273 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
3276 if ( (use_joystick)&&(kc_joystick[17].value < 255 )) {
3277 if ( !kc_joystick[18].value ) // If not inverted...
3278 Controls.sideways_thrust_time -= joy_axis[kc_joystick[17].value];
3280 Controls.sideways_thrust_time += joy_axis[kc_joystick[17].value];
3283 // From joystick buttons
3284 if ( (use_joystick)&&(kc_joystick[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_joystick[6].value );
3285 if ( (use_joystick)&&(kc_joystick[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_joystick[7].value );
3287 // From mouse buttons
3288 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
3289 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
3292 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
3293 if ( !kc_mouse[18].value ) // If not inverted...
3294 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
3296 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
3298 }// end "if" added by WraithX
3300 //----------- Read bank_time -----------------
3303 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3304 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3305 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3306 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3309 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
3310 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
3311 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
3312 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
3315 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3316 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
3317 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
3321 if ( (use_joystick)&&(kc_joystick[15].value < 255) ) {
3322 if ( !kc_joystick[16].value ) // If not inverted...
3323 Controls.bank_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3325 Controls.bank_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3329 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3330 if ( !kc_mouse[16].value ) // If not inverted...
3331 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3333 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3338 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
3339 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
3340 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
3341 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
3344 if ( (use_joystick)&&(kc_joystick[21].value < 255) ) {
3345 if ( !kc_joystick[22].value ) // If not inverted...
3346 Controls.bank_time -= joy_axis[kc_joystick[21].value];
3348 Controls.bank_time += joy_axis[kc_joystick[21].value];
3351 // From joystick buttons
3352 if ( (use_joystick)&&(kc_joystick[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_joystick[11].value );
3353 if ( (use_joystick)&&(kc_joystick[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_joystick[12].value );
3355 // From mouse buttons
3356 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
3357 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
3360 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
3361 if ( !kc_mouse[22].value ) // If not inverted...
3362 Controls.bank_time += mouse_axis[kc_mouse[21].value];
3364 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
3368 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3369 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
3370 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
3373 // the following "if" added by WraithX, 4/14/00
3374 // done so that dead players can't move
3375 if (!Player_is_dead)
3377 //----------- Read forward_thrust_time -------------
3380 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
3381 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
3382 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
3383 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
3386 if ( (use_joystick)&&(kc_joystick[23].value < 255 )) {
3387 if ( !kc_joystick[24].value ) // If not inverted...
3388 Controls.forward_thrust_time -= joy_axis[kc_joystick[23].value];
3390 Controls.forward_thrust_time += joy_axis[kc_joystick[23].value];
3393 // From joystick buttons
3394 if ( (use_joystick)&&(kc_joystick[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_joystick[2].value );
3395 if ( (use_joystick)&&(kc_joystick[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_joystick[3].value );
3398 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
3399 if ( !kc_mouse[24].value ) // If not inverted...
3400 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
3402 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
3405 // From mouse buttons
3406 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
3407 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
3409 //----------- Read afterburner_state -------------
3412 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
3413 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
3415 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
3417 if ( (use_joystick)&&(kc_joystick[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_joystick[27].value);
3419 //-------Read headlight key--------------------------
3421 if (kc_keyboard[52].value < 255 )
3422 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
3423 if (kc_keyboard[53].value < 255 )
3424 Controls.headlight_count+=key_down_count(kc_keyboard[53].value);
3425 if ((use_joystick)&&(kc_joystick[30].value < 255 ))
3426 Controls.headlight_count+=joy_get_button_down_cnt(kc_joystick[30].value);
3428 //--------Read Cycle Primary Key------------------
3430 if (kc_keyboard[48].value<255)
3431 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
3432 if (kc_keyboard[49].value<255)
3433 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
3434 if ((use_joystick)&&(kc_joystick[28].value < 255 ))
3435 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_joystick[28].value);
3438 //--------Read Cycle Secondary Key------------------
3440 if (kc_keyboard[50].value<255)
3441 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
3442 if (kc_keyboard[51].value<255)
3443 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
3444 if ((use_joystick)&&(kc_joystick[29].value < 255 ))
3445 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_joystick[29].value);
3447 //--------Read Toggle Bomb key----------------------
3449 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
3451 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
3453 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
3454 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
3456 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3457 HUD_init_message ("No bombs available!");
3461 if (Players[Player_num].secondary_ammo[bomb]==0)
3463 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3464 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
3468 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
3469 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
3474 //---------Read Energy->Shield key----------
3476 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
3477 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
3478 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
3479 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
3481 //----------- Read fire_primary_down_count
3482 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
3483 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
3484 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_joystick[0].value);
3485 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
3487 //----------- Read fire_primary_state
3488 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
3489 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
3490 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_joystick[0].value);
3491 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
3493 //----------- Read fire_secondary_down_count
3494 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
3495 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
3496 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_joystick[1].value);
3497 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
3499 //----------- Read fire_secondary_state
3500 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
3501 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
3502 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_joystick[1].value);
3503 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
3505 //----------- Read fire_flare_down_count
3506 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
3507 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
3508 if ((use_joystick)&&(kc_joystick[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_joystick[4].value);
3509 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
3511 //----------- Read drop_bomb_down_count
3512 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
3513 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
3514 if ((use_joystick)&&(kc_joystick[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_joystick[26].value);
3515 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
3517 //----------- Read rear_view_down_count
3518 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
3519 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
3520 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_joystick[25].value);
3521 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
3523 //----------- Read rear_view_down_state
3524 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
3525 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
3526 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_joystick[25].value);
3527 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
3529 }//end "if" added by WraithX
3531 //----------- Read automap_down_count
3532 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
3533 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
3535 //----------- Read automap_state
3536 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
3537 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
3539 //----------- Read stupid-cruise-control-type of throttle.
3541 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
3542 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
3543 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
3544 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
3545 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
3547 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
3550 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
3551 if (Cruise_speed < 0 ) Cruise_speed = 0;
3553 if (Controls.forward_thrust_time==0)
3554 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
3557 #if !defined(MACINTOSH)
3558 //read_head_tracker();
3560 // Read external controls
3561 // if (kc_use_external_control || CybermouseActive)
3562 // kconfig_read_external_controls();
3565 //----------- Clamp values between -FrameTime and FrameTime
3566 if (FrameTime > F1_0 )
3567 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
3569 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
3570 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
3571 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
3572 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
3573 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
3574 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
3575 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
3577 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
3578 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
3579 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
3580 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
3581 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
3582 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
3583 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
3586 //--------- Don't do anything if in debug mode
3588 if ( keyd_pressed[KEY_DELETE] ) {
3589 memset( &Controls, 0, sizeof(control_info) );
3596 void controls_read_console()
3598 // Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3599 // Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3600 // Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3601 // Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3602 // Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3603 // Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3604 // Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3605 // Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3606 // Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3607 Controls.fire_primary_state |= Console_button_states[CMD_ATTACK];
3608 Controls.fire_secondary_state |= Console_button_states[CMD_ATTACK2];
3609 // Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3610 // Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3611 // Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3612 // Controls.automap_down_count += kc_external_control->automap_down_count;
3613 // Controls.automap_state |= kc_external_control->automap_state;
3617 void reset_cruise(void)
3623 void kc_set_controls()
3627 for (i=0; i<NUM_KEY_CONTROLS; i++ )
3628 kc_keyboard[i].value = kconfig_settings[0][i];
3630 if ( (Config_control_type>0) && (Config_control_type<5)) {
3631 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3632 kc_joystick[i].value = kconfig_settings[Config_control_type][i];
3633 if (kc_joystick[i].type == BT_INVERT ) {
3634 if (kc_joystick[i].value!=1)
3635 kc_joystick[i].value = 0;
3636 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
3639 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
3640 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3641 kc_mouse[i].value = kconfig_settings[Config_control_type][i];
3642 if (kc_mouse[i].type == BT_INVERT ) {
3643 if (kc_mouse[i].value!=1)
3644 kc_mouse[i].value = 0;
3645 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
3648 } else if (Config_control_type == CONTROL_WINJOYSTICK) {
3649 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3650 kc_superjoy[i].value = kconfig_settings[Config_control_type][i];
3651 if (kc_superjoy[i].type == BT_INVERT ) {
3652 if (kc_superjoy[i].value!=1)
3653 kc_superjoy[i].value = 0;
3654 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
3660 for (i=0; i<NUM_D2X_CONTROLS; i++ )
3661 kc_d2x[i].value = kconfig_d2x_settings[i];
3665 #if 0 //ndef MACINTOSH // no mac support for vr headset
3667 void kconfig_center_headset()
3671 vfx_center_headset();
3673 // } else if (iglasses_headset_installed) {
3674 // } else if (Victor_headset_installed) {
3680 #endif // end of #ifndef MACINTOSH for kconfig_center_headset
3682 void CybermouseAdjust ()
3684 /* if ( Player_num > -1 ) {
3685 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3686 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3687 Auto_leveling_on = 0;
3689 if ( kc_external_version > 0 ) {
3690 vms_matrix tempm, ViewMatrix;
3691 vms_angvec * Kconfig_abs_movement;
3694 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
3696 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3697 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3698 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3699 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3701 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3702 if (oem_message[0] != '\0' )
3703 HUD_init_message( oem_message );
3707 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3708 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3709 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3710 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3711 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3712 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3713 // Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3714 // Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3715 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3716 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3717 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3718 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3719 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3720 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3721 // Controls.automap_down_count += kc_external_control->automap_down_count;
3722 // Controls.automap_state |= kc_external_control->automap_state;
3725 char GetKeyValue (char key)
3727 mprintf ((0,"Returning %c!\n",kc_keyboard[(int)key].value));
3728 return (kc_keyboard[(int)key].value);
3731 #if !defined(MACINTOSH)
3734 extern object *obj_find_first_of_type (int);
3735 void kconfig_read_external_controls()
3740 if ( !kc_enable_external_control ) return;
3742 if ( kc_external_version == 0 )
3743 memset( kc_external_control, 0, sizeof(ext_control_info));
3744 else if ( kc_external_version > 0 ) {
3746 if (kc_external_version>=4)
3747 memset( kc_external_control, 0, sizeof(advanced_ext_control_info));
3748 else if (kc_external_version>0)
3749 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 );
3750 else if (kc_external_version>2)
3751 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof(vms_matrix) +4 );
3753 if ( kc_external_version > 1 ) {
3754 // Write ship pos and angles to external controls...
3755 ubyte *temp_ptr = (ubyte *)kc_external_control;
3756 vms_vector *ship_pos;
3757 vms_matrix *ship_orient;
3758 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
3759 temp_ptr += sizeof(ext_control_info) + sizeof(vms_angvec) + 64;
3760 ship_pos = (vms_vector *)temp_ptr;
3761 temp_ptr += sizeof(vms_vector);
3762 ship_orient = (vms_matrix *)temp_ptr;
3763 // Fill in ship postion...
3764 *ship_pos = Objects[Players[Player_num].objnum].pos;
3765 // Fill in ship orientation...
3766 *ship_orient = Objects[Players[Player_num].objnum].orient;
3768 if (kc_external_version>=4)
3770 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3772 temp_ptr->headlight_state=(Players[Player_num].flags & PLAYER_FLAGS_HEADLIGHT_ON);
3773 temp_ptr->primary_weapon_flags=Players[Player_num].primary_weapon_flags;
3774 temp_ptr->secondary_weapon_flags=Players[Player_num].secondary_weapon_flags;
3775 temp_ptr->current_primary_weapon=Primary_weapon;
3776 temp_ptr->current_secondary_weapon=Secondary_weapon;
3778 temp_ptr->current_guidebot_command=Escort_goal_object;
3780 temp_ptr->force_vector=ExtForceVec;
3781 temp_ptr->force_matrix=ExtApplyForceMatrix;
3783 temp_ptr->joltinfo[i]=ExtJoltInfo[i];
3785 temp_ptr->x_vibrate_info[i]=ExtXVibrateInfo[i];
3786 temp_ptr->x_vibrate_clear=ExtXVibrateClear;
3787 temp_ptr->game_status=ExtGameStatus;
3789 memset ((void *)&ExtForceVec,0,sizeof(vms_vector));
3790 memset ((void *)&ExtApplyForceMatrix,0,sizeof(vms_matrix));
3795 ExtXVibrateInfo[i]=0;
3800 if ( Automap_active ) // (If in automap...)
3801 kc_external_control->automap_state = 1;
3802 //memset(&r,0,sizeof(r));
3806 int386 ( kc_external_intno, &r, &r); // Read external info...
3810 if ( Player_num > -1 ) {
3811 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3812 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3813 Auto_leveling_on = 0;
3815 if ( kc_external_version > 0 ) {
3816 vms_matrix tempm, ViewMatrix;
3817 vms_angvec * Kconfig_abs_movement;
3820 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(ext_control_info));
3822 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3823 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3824 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3825 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3827 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3828 if (oem_message[0] != '\0' )
3829 HUD_init_message( oem_message );
3833 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3834 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3835 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3836 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3837 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3838 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3839 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3840 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3841 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3842 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3843 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3844 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3845 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3846 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3847 Controls.automap_down_count += kc_external_control->automap_down_count;
3848 Controls.automap_state |= kc_external_control->automap_state;
3850 if (kc_external_version>=3)
3852 ubyte *temp_ptr = (ubyte *)kc_external_control;
3853 temp_ptr += (sizeof(ext_control_info) + sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof (vms_matrix));
3856 Controls.cycle_primary_count=(*(temp_ptr));
3858 Controls.cycle_secondary_count=(*(temp_ptr+1));
3861 Controls.afterburner_state=(*(temp_ptr+2));
3863 Controls.headlight_count=(*(temp_ptr+3));
3865 if (kc_external_version>=4)
3868 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3871 if (temp_ptr->keyboard[i])
3874 if (temp_ptr->Reactor_blown)
3876 if (Game_mode & GM_MULTI)
3877 net_destroy_controlcen (obj_find_first_of_type (OBJ_CNTRLCEN));
3879 do_controlcen_destroyed_stuff(obj_find_first_of_type (OBJ_CNTRLCEN));