1 /* $Id: kconfig.c,v 1.38 2005-04-05 07:35:09 btb Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
17 * Routines to configure keyboard, joystick, etc..
26 static char rcsid[] = "$Id: kconfig.c,v 1.38 2005-04-05 07:35:09 btb Exp $";
39 #include "pa_enabl.h" //$$POLY_ACC
84 ubyte ExtGameStatus=1;
86 vms_vector ExtForceVec;
87 vms_matrix ExtApplyForceMatrix;
89 int ExtJoltInfo[3]={0,0,0};
90 int ExtXVibrateInfo[2]={0,0};
91 int ExtYVibrateInfo[2]={0,0};
92 ubyte ExtXVibrateClear=0;
93 ubyte ExtYVibrateClear=0;
95 #define TABLE_CREATION 1
97 // Array used to 'blink' the cursor while waiting for a keypress.
98 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 };
100 //char * invert_text[2] = { "N", "Y" };
101 //char * joybutton_text[28] = { "BTN 1", "BTN 2", "BTN 3", "BTN 4", "", "TRIG", "LEFT", "HAT
\81", "RIGHT", "", "", "HAT
\80", "MID", "", "", "HAT
\7f", "", "", "", "HAT
\82", "TRIG", "LEFT", "RIGHT", "", "UP","DOWN","LEFT", "RIGHT" };
102 //char * joyaxis_text[4] = { "X1", "Y1", "X2", "Y2" };
103 //char * mouseaxis_text[2] = { "L/R", "F/B" };
104 //char * mousebutton_text[3] = { "Left", "Right", "Mid" };
106 int invert_text[2] = { TNUM_N, TNUM_Y };
108 #ifndef USE_LINUX_JOY
110 int joybutton_text[28] =
111 { TNUM_BTN_1, TNUM_BTN_2, TNUM_BTN_3, TNUM_BTN_4,
115 TNUM_HAT_L, TNUM_HAT_R, TNUM_HAT_U, TNUM_HAT_D,
119 int joyaxis_text[7] = { TNUM_X1, TNUM_Y1, TNUM_Z1, TNUM_UN, TNUM_P1,TNUM_R1,TNUM_YA1 };
120 #elif defined(SDL_INPUT)
121 char *joybutton_text[JOY_MAX_BUTTONS];
122 char *joyaxis_text[JOY_MAX_AXES];
124 int joybutton_text[28] =
125 { TNUM_BTN_1, TNUM_BTN_2, TNUM_BTN_3, TNUM_BTN_4,
126 -1, TNUM_TRIG, TNUM_LEFT, TNUM_HAT_L,
127 TNUM_RIGHT, -1, TNUM_HAT2_D, TNUM_HAT_R,
128 TNUM_MID, -1, TNUM_HAT2_R, TNUM_HAT_U,
129 TNUM_HAT2_L, -1, TNUM_HAT2_U, TNUM_HAT_D,
130 TNUM_TRIG, TNUM_LEFT, TNUM_RIGHT, -1,
131 TNUM_UP, TNUM_DOWN, TNUM_LEFT, TNUM_RIGHT };
133 int joyaxis_text[7] = { TNUM_X1, TNUM_Y1, TNUM_Z1, TNUM_UN, TNUM_P1,TNUM_R1,TNUM_YA1 };
134 // int joyaxis_text[4] = { TNUM_X1, TNUM_Y1, TNUM_X2, TNUM_Y2 };
138 int mouseaxis_text[3] = { TNUM_L_R, TNUM_F_B, TNUM_Z1 };
140 int mousebutton_text[3] = { TNUM_LEFT, TNUM_RIGHT, TNUM_MID };
141 char * mousebutton_textra[13] = { "M4", "M5", "M6", "M7", "M8", "M9", "M10","M11","M12","M13","M14","M15","M16" };//text for buttons above 3. -MPM
143 char *mousebutton_text[3] = { "Btn", "", "" }; // only one silly mouse button on the mac
147 char * key_text[256] = {
148 "","S","D","F","H","G","Z","X","C","V","","B","Q", "W", "E", "R",
149 "Y","T","1","2","3","4","6","5","=","9","7","-", "8", "0", "]", "O",
150 "U","[","I","P","RET","L","J","'","K", ";", "\\", ",", "/", "N", "M", ".",
151 "TAB","SPC","`","DEL","","ESC","","APL","SHIFT","CAPSL","OPTN","CTRL","","","","A",
152 "","PAD.","","PAD*","","PAD+","","NMLCK","","","","PAD/","ENTER","","PAD-","",
153 "","PAD=","PAD0","PAD1","PAD2","PAD3","PAD4","PAD5","PAD6","PAD7","","PAD8","PAD9","","","",
154 "F5","F6","F7","","F8","F9","","F11","","F13","","F14","","F10","","F12",
155 "","PAUSE","HELP","HOME","PGUP","DEL","","END","F2","","F1","LARW","RARW","DARW","UARW","",
156 "","","","","","","","","","","","","","","","",
157 "","","","","","","","","","","","","","","","",
158 "","","","","","","","","","","","","","","","",
159 "","","","","","","","","","","","","","","","",
160 "","","","","","","","","","","","","","","","",
161 "","","","","","","","","","","","","","","","",
162 "","","","","","","","","","","","","","","","",
163 "","","","","","","","","","","","","","","",""};
165 #if !defined OGL && !defined SDL_INPUT
166 char * key_text[256] = { \
167 "","ESC","1","2","3","4","5","6","7","8","9","0","-", \
168 "=","BSPC","TAB","Q","W","E","R","T","Y","U","I","O", \
169 "P","[","]","
\83","LCTRL","A","S","D","F", \
170 "G","H","J","K","L",";","'","`", \
171 "LSHFT","\\","Z","X","C","V","B","N","M",",", \
172 ".","/","RSHFT","PAD*","LALT","SPC", \
173 "CPSLK","F1","F2","F3","F4","F5","F6","F7","F8","F9", \
174 "F10","NMLCK","SCLK","PAD7","PAD8","PAD9","PAD-", \
175 "PAD4","PAD5","PAD6","PAD+","PAD1","PAD2","PAD3","PAD0", \
176 "PAD.","","","","F11","F12","","","","","","","","","", \
177 "","","","","","","","","","","","","","","","","","","","", \
178 "","","","","","","","","","","","","","","","","","","","", \
179 "","","","","","","","","","","","","","","","","","", \
180 "PAD
\83","RCTRL","","","","","","","","","","","","","", \
181 "","","","","","","","","","","PAD/","","","RALT","", \
182 "","","","","","","","","","","","","","HOME","
\82","PGUP", \
183 "","
\81","","
\7f","","END","
\80","PGDN","INS", \
184 "DEL","","","","","","","","","","","","","","","","","", \
185 "","","","","","","","","","","","","","","","","","","","", \
186 "","","","","","","" };
191 //added/removed by Victor Rachels for adding rebindable keys for these
192 // KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0
193 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 };
195 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 };
198 //extern void GameLoop(int, int );
200 extern void transfer_energy_to_shield(fix);
201 extern void CyclePrimary(),CycleSecondary(),InitMarkerInput();
202 extern ubyte DefiningMarkerMessage;
203 extern char CybermouseActive;
206 extern int joydefsw_do_button();
207 extern int joydefsw_do_winjoybutton(int *axis);
208 extern joydefsw_win_joyselect(char *title);
211 control_info Controls;
215 // macros for drawing lo/hi res kconfig screens (see scores.c as well)
217 #define LHX(x) ((x)*(MenuHires?2:1))
218 #define LHY(y) ((y)*(MenuHires?2.4:1))
222 #define BT_MOUSE_BUTTON 1
223 #define BT_MOUSE_AXIS 2
224 #define BT_JOY_BUTTON 3
225 #define BT_JOY_AXIS 4
228 char *btype_text[] = { "BT_KEY", "BT_MOUSE_BUTTON", "BT_MOUSE_AXIS", "BT_JOY_BUTTON", "BT_JOY_AXIS", "BT_INVERT" };
232 typedef struct kc_item {
233 short id; // The id of this item
241 ubyte value; // what key,button,etc
247 ubyte kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS];
249 //added on 2/4/99 by Victor Rachels to add d1x new keys
250 ubyte kconfig_d2x_settings[MAX_D2X_CONTROLS];
251 //end this section addition - VR
253 //----------- WARNING!!!!!!! -------------------------------------------
254 // THESE NEXT FOUR BLOCKS OF DATA ARE GENERATED BY PRESSING DEL+F12 WHEN
255 // IN THE KEYBOARD CONFIG SCREEN. BASICALLY, THAT PROCEDURE MODIFIES THE
256 // U,D,L,R FIELDS OF THE ARRAYS AND DUMPS THE NEW ARRAYS INTO KCONFIG.COD
257 //-------------------------------------------------------------------------
258 /*ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
259 {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},
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,0xff},
261 {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},
262 {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},
263 {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},
264 {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},
265 {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},
269 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
270 {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},
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,0xff,0x0,0x0,0x0,0x0},
272 {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},
273 {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},
274 {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},
275 {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},
276 {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},
278 {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},
284 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
285 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
286 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
287 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
288 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
289 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
290 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
291 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
292 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
293 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
294 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
295 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
296 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
297 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
298 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
299 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
300 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
301 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
302 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
303 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
304 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
305 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
306 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
307 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
308 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
309 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
310 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
311 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
312 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
313 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
314 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
315 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
316 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
317 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
318 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
319 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
320 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
321 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
322 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
323 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
324 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
325 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
326 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
327 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
328 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
329 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
330 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
331 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
332 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
333 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
334 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
335 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
336 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
337 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
338 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
339 { 54,158,171, 83, 26, 52, 56, 51, 55,"Energy->Shield", BT_KEY, 255 },
340 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
341 { 56,158,179,83, 26, 54, 0, 0, 0, "Toggle Bomb", BT_KEY,255},
343 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
344 { 0, 25, 46, 85, 40, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
345 { 1, 25, 54, 85, 40, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
346 { 2, 25, 85, 85, 40, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
347 { 3, 25, 93, 85, 40, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
348 { 4, 25, 62, 85, 40, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
349 { 5,180, 46, 79, 40, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
350 { 6,180, 54, 79, 40, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
351 { 7,180, 62, 79, 40, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
352 { 8,180, 70, 79, 40, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
353 { 9,180, 78, 79, 40, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
354 { 10,180, 90, 79, 40, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
355 { 11,180, 98, 79, 40, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
356 { 12,180,106, 79, 40, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
357 { 13, 22,154, 51, 40, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
358 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
359 { 15, 22,162, 51, 40, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
360 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
361 { 17,164,154, 58, 40, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
362 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
363 { 19,164,162, 58, 40, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
364 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
365 { 21,164,172, 58, 40, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
366 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
367 { 23,164,180, 58, 40, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
368 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
369 { 25, 25,109, 85, 40, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
370 { 26, 25, 70, 85, 40, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
371 { 27, 25,117, 85, 40, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
372 { 28,180,114, 79, 40, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
373 { 29,180,122, 79, 40, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
374 { 30, 25,125, 85, 40, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
376 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
377 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
378 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
379 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
380 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
381 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
382 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
383 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
384 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
385 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
386 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
387 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
388 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
389 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
390 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
391 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
392 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
393 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
394 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
395 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
396 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
397 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
398 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
399 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
400 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
401 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
402 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
403 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
404 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
405 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
406 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
407 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
410 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
411 { 0, 25, 46, 85, 26, 12, 1, 24, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
412 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
413 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
414 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
415 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
416 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
417 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
418 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
419 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
420 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
421 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
422 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
423 { 12,180,106, 59, 26, 11, 0, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
424 { 13,103,138, 58, 26, 27, 15, 25, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
425 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
426 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
427 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
428 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
429 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
430 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
431 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
432 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
433 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
434 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
435 { 24,103,182,106, 8, 22, 5, 23, 0,"throttle", BT_INVERT, 255 },
436 { 25, 25,109, 85, 26, 3, 27, 12, 13,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
437 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
438 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
442 //added on 2/4/99 by Victor Rachels to add d1x new keys
443 kc_item kc_d2x[NUM_D2X_CONTROLS] = {
444 // id,x,y,w1,w2,u,d,l,r,text_num1,type,value
445 { 0, 15, 49, 71, 26, 27, 2, 27, 1, "WEAPON 1", BT_KEY, 255},
446 { 1, 15, 49,100, 26, 26, 3, 0, 2, "WEAPON 1", BT_JOY_BUTTON, 255},
447 { 2, 15, 57, 71, 26, 0, 4, 1, 3, "WEAPON 2", BT_KEY, 255},
448 { 3, 15, 57,100, 26, 1, 5, 2, 4, "WEAPON 2", BT_JOY_BUTTON, 255},
449 { 4, 15, 65, 71, 26, 2, 6, 3, 5, "WEAPON 3", BT_KEY, 255},
450 { 5, 15, 65,100, 26, 3, 7, 4, 6, "WEAPON 3", BT_JOY_BUTTON, 255},
451 { 6, 15, 73, 71, 26, 4, 8, 5, 7, "WEAPON 4", BT_KEY, 255},
452 { 7, 15, 73,100, 26, 5, 9, 6, 8, "WEAPON 4", BT_JOY_BUTTON, 255},
453 { 8, 15, 81, 71, 26, 6, 10, 7, 9, "WEAPON 5", BT_KEY, 255},
454 { 9, 15, 81,100, 26, 7, 11, 8, 10, "WEAPON 5", BT_JOY_BUTTON, 255},
456 { 10, 15, 89, 71, 26, 8, 12, 9, 11, "WEAPON 6", BT_KEY, 255},
457 { 11, 15, 89,100, 26, 9, 13, 10, 12, "WEAPON 6", BT_JOY_BUTTON, 255},
458 { 12, 15, 97, 71, 26, 10, 14, 11, 13, "WEAPON 7", BT_KEY, 255},
459 { 13, 15, 97,100, 26, 11, 15, 12, 14, "WEAPON 7", BT_JOY_BUTTON, 255},
460 { 14, 15,105, 71, 26, 12, 16, 13, 15, "WEAPON 8", BT_KEY, 255},
461 { 15, 15,105,100, 26, 13, 17, 14, 16, "WEAPON 8", BT_JOY_BUTTON, 255},
462 { 16, 15,113, 71, 26, 14, 18, 15, 17, "WEAPON 9", BT_KEY, 255},
463 { 17, 15,113,100, 26, 15, 19, 16, 18, "WEAPON 9", BT_JOY_BUTTON, 255},
464 { 18, 15,121, 71, 26, 16, 20, 17, 19, "WEAPON 0", BT_KEY, 255},
465 { 19, 15,121,100, 26, 17, 21, 18, 20, "WEAPON 0", BT_JOY_BUTTON, 255},
467 //{ 20, 15,131, 71, 26, 18, 22, 19, 21, "CYC PRIMARY", BT_KEY, 255},
468 //{ 21, 15,131,100, 26, 19, 23, 20, 22, "CYC PRIMARY", BT_JOY_BUTTON, 255},
469 //{ 22, 15,139, 71, 26, 20, 24, 21, 23, "CYC SECONDARY", BT_KEY, 255},
470 //{ 23, 15,139,100, 26, 21, 25, 22, 24, "CYC SECONDARY", BT_JOY_BUTTON, 255},
471 //{ 24, 8,147, 78, 26, 22, 26, 23, 25, "TOGGLE_PRIM AUTO", BT_KEY, 255},
472 //{ 25, 8,147,107, 26, 23, 27, 24, 26, "TOGGLE_PRIM_AUTO", BT_JOY_BUTTON, 255},
473 //{ 26, 8,155, 78, 26, 24, 1, 25, 27, "TOGGLE SEC AUTO", BT_KEY, 255},
474 //{ 27, 8,155,107, 26, 25, 0, 26, 0, "TOGGLE SEC AUTO", BT_JOY_BUTTON, 255},
476 //end this section addition - VR
479 #else // ifndef MACINTOSH (following are macintosh controls)
481 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
482 {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},
483 {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},
484 {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},
485 {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},
486 {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},
487 {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},
488 {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},
491 ubyte default_firebird_settings[MAX_CONTROLS] =
492 {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};
494 ubyte default_mousestick_settings[MAX_CONTROLS] =
495 {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};
497 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
498 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
499 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
500 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
501 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
502 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
503 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
504 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
505 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
506 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
507 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
508 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
509 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
510 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
511 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
512 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
513 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
514 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
515 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
516 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
517 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
518 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
519 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
520 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
521 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
522 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
523 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
524 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
525 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
526 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
527 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
528 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
529 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
530 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
531 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
532 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
533 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
534 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
535 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
536 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
537 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
538 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
539 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
540 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
541 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
542 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
543 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
544 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
545 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
546 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
547 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
548 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
549 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
550 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
551 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
552 { 54,158,171, 83, 26, 52, 25, 51, 55,"Energy->Shield", BT_KEY, 255 },
553 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
555 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
556 { 0, 25, 46, 85, 28, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
557 { 1, 25, 54, 85, 28, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
558 { 2, 25, 85, 85, 28, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
559 { 3, 25, 93, 85, 28, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
560 { 4, 25, 62, 85, 28, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
561 { 5,180, 46, 79, 28, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
562 { 6,180, 54, 79, 28, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
563 { 7,180, 62, 79, 28, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
564 { 8,180, 70, 79, 28, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
565 { 9,180, 78, 79, 28, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
566 { 10,180, 90, 79, 28, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
567 { 11,180, 98, 79, 28, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
568 { 12,180,106, 79, 28, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
569 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
570 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
571 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
572 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
573 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
574 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
575 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
576 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
577 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
578 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
579 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
580 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
581 { 25, 25,109, 85, 28, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
582 { 26, 25, 70, 85, 28, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
583 { 27, 25,117, 85, 28, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
584 { 28,180,114, 79, 28, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
585 { 29,180,122, 79, 28, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
586 { 30, 25,125, 85, 28, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
588 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
589 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
590 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
591 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
592 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
593 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
594 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
595 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
596 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
597 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
598 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
599 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
600 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
601 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
602 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
603 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
604 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
605 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
606 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
607 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
608 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
609 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
610 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
611 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
612 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
613 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
614 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
615 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
616 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
617 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
618 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
619 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
622 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
623 { 0, 25, 46, 85, 26, 28, 1, 28, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
624 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
625 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
626 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
627 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
628 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
629 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
630 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
631 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
632 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
633 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
634 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
635 { 12,180,106, 59, 26, 11, 28, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
636 { 13,103,138, 58, 26, 27, 15, 27, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
637 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
638 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
639 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
640 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
641 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
642 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
643 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
644 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
645 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
646 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
647 { 24,103,182,106, 8, 22, 5, 23, 28,"throttle", BT_INVERT, 255 },
648 { 25, 25,109, 85, 26, 3, 27, 12, 27,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
649 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
650 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
655 //added on 2/4/99 by Victor Rachels to add new keys system
656 ubyte default_kconfig_d2x_settings[MAX_D2X_CONTROLS] = {
657 0x2 ,0xff,0x3 ,0xff,0x4 ,0xff,0x5 ,0xff,0x6 ,0xff,0x7 ,0xff,0x8 ,0xff,0x9 ,
658 0xff,0xa ,0xff,0xb ,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
659 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff };
660 //end this section addition - VR
662 void kc_drawitem( kc_item *item, int is_current );
663 void kc_change_key( kc_item * item );
664 void kc_change_joybutton( kc_item * item );
665 void kc_change_mousebutton( kc_item * item );
666 void kc_next_joyaxis(kc_item *item); //added by WraithX on 11/22/00
667 void kc_change_joyaxis( kc_item * item );
668 void kc_change_mouseaxis( kc_item * item );
669 void kc_change_invert( kc_item * item );
670 void kconfig_read_fcs( int raw_axis );
671 void kconfig_set_fcs_button( int btn, int button );
672 void kconfig_read_external_controls( void );
674 // the following methods added by WraithX, 4/17/00
675 int isJoyRotationKey(int test_key)
677 if (test_key == kc_joystick[11].value ||
678 test_key == kc_joystick[12].value)
685 }// method isJoyRotationKey
687 int isMouseRotationKey(int test_key)
689 if (test_key == kc_mouse[11].value ||
690 test_key == kc_mouse[12].value)
697 }// method isMouseRotationKey
699 int isKeyboardRotationKey(int test_key)
701 if (test_key == kc_keyboard[0].value ||
702 test_key == kc_keyboard[1].value ||
703 test_key == kc_keyboard[2].value ||
704 test_key == kc_keyboard[3].value ||
705 test_key == kc_keyboard[4].value ||
706 test_key == kc_keyboard[5].value ||
707 test_key == kc_keyboard[6].value ||
708 test_key == kc_keyboard[7].value ||
709 test_key == kc_keyboard[20].value ||
710 test_key == kc_keyboard[21].value ||
711 test_key == kc_keyboard[22].value ||
712 test_key == kc_keyboard[23].value)
719 }// method isKeyboardRotationKey
720 // end addition - WraithX
722 int kconfig_is_axes_used(int axis)
725 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
726 if (( kc_joystick[i].type == BT_JOY_AXIS ) && (kc_joystick[i].value == axis ))
732 #ifdef TABLE_CREATION
733 int find_item_at( kc_item * items, int nitems, int x, int y )
737 for (i=0; i<nitems; i++ ) {
738 if ( ((items[i].x+items[i].w1)==x) && (items[i].y==y))
744 int find_next_item_up( kc_item * items, int nitems, int citem )
749 x = items[citem].x+items[citem].w1;
754 y = grd_curcanv->cv_bitmap.bm_h-1;
757 x = grd_curcanv->cv_bitmap.bm_w-1;
760 i = find_item_at( items, nitems, x, y );
766 int find_next_item_down( kc_item * items, int nitems, int citem )
771 x = items[citem].x+items[citem].w1;
775 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
778 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
782 i = find_item_at( items, nitems, x, y );
788 int find_next_item_right( kc_item * items, int nitems, int citem )
793 x = items[citem].x+items[citem].w1;
797 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
800 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
804 i = find_item_at( items, nitems, x, y );
810 int find_next_item_left( kc_item * items, int nitems, int citem )
815 x = items[citem].x+items[citem].w1;
820 x = grd_curcanv->cv_bitmap.bm_w-1;
823 y = grd_curcanv->cv_bitmap.bm_h-1;
826 i = find_item_at( items, nitems, x, y );
834 int get_item_height(kc_item *item)
839 if (item->value==255) {
842 switch( item->type ) {
844 strncpy( btext, key_text[item->value], 10 ); break;
845 case BT_MOUSE_BUTTON:
847 strncpy( btext, Text_string[mousebutton_text[item->value]], 10); break;
849 strncpy( btext, mousebutton_text[item->value], 10 ); break;
852 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
855 sprintf(btext, "J%d B%d", j_button[item->value].joydev, j_Get_joydev_button_number(item->value));
856 #elif defined(SDL_INPUT)
857 if (joybutton_text[item->value])
858 strncpy(btext, joybutton_text[item->value], 10);
860 sprintf(btext, "BTN%2d", item->value + 1);
862 if ( joybutton_text[item->value] !=-1 )
863 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
865 sprintf( btext, "BTN%d", item->value );
870 sprintf( btext, "J%d A%d", j_axis[item->value].joydev, j_Get_joydev_axis_number (item->value) );
871 #elif defined(SDL_INPUT)
872 if (joyaxis_text[item->value])
873 strncpy(btext, joyaxis_text[item->value], 10);
875 sprintf(btext, "AXIS%2d", item->value + 1);
877 strncpy(btext, Text_string[joyaxis_text[item->value]], 10);
881 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
884 gr_get_string_size(btext, &w, &h, &aw );
890 void kconfig_sub(kc_item * items,int nitems, char * title)
893 dd_grs_canvas * save_canvas,
894 grs_canvas * save_canvas
896 grs_font * save_font;
899 int mouse_state, omouse_state, mx, my, x1, x2, y1, y2;
900 int close_x, close_y, close_size;
903 int i,k,ocitem,citem;
904 int time_stopped = 0;
905 WIN(char *old_bg_pcx);
907 WIN(old_bg_pcx = _SCRContext.bkg_filename);
908 WIN(DEFINE_SCREEN(NULL));
913 if (!((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence)) )
919 // if (Config_control_type == CONTROL_WINJOYSTICK) {
921 // joydefsw_win_joyselect(title2); title = title2,
923 // ); // Get Samir...
927 save_canvas = dd_grd_curcanv,
928 save_canvas = grd_curcanv
933 dd_gr_set_current_canvas(NULL),
934 gr_set_current_canvas(NULL)
936 save_font = grd_curcanv->cv_font;
942 old_keyd_repeat = keyd_repeat;
945 //gr_clear_canvas( BM_XRGB(0,0,0) );
947 nm_draw_background(0, 0, grd_curcanv->cv_bitmap.bm_w - 1, grd_curcanv->cv_bitmap.bm_h - 1);
948 gr_palette_load (gr_palette);
950 grd_curcanv->cv_font = MEDIUM3_FONT;
952 WIN(DDGRLOCK(dd_grd_curcanv));
955 p = strchr( title, '\n' );
957 gr_string( 0x8000, LHY(8), title );
962 // if ( items == kc_keyboard ) {
963 // gr_string( 0x8000, 8, "Keyboard" );
964 // } else if ( items == kc_joystick ) {
965 // gr_string( 0x8000, 8, "Joysticks" );
966 // } else if ( items == kc_mouse ) {
967 // gr_string( 0x8000, 8, "Mouse" );
971 close_x = close_y = MenuHires?15:7;
972 close_size = MenuHires?10:5;
973 gr_setcolor( BM_XRGB(0, 0, 0) );
974 gr_rect(close_x, close_y, close_x + close_size, close_y + close_size);
975 gr_setcolor( BM_XRGB(21, 21, 21) );
976 gr_rect(close_x + LHX(1), close_y + LHX(1), close_x + close_size - LHX(1), close_y + close_size - LHX(1));
979 grd_curcanv->cv_font = GAME_FONT;
980 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
983 gr_string( 0x8000, LHY(20), TXT_KCONFIG_STRING_1 );
985 gr_string( 0x8000, LHY(20), "Enter changes, ctrl-d deletes, ctrl-r resets defaults, ESC exits");
987 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
988 if ( items == kc_keyboard ) {
989 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
990 gr_setcolor( BM_XRGB(31,27,6) );
992 gr_scanline( LHX(98), LHX(106), LHY(42) );
993 gr_scanline( LHX(120), LHX(128), LHY(42) );
994 gr_pixel( LHX(98), LHY(43) );
995 gr_pixel( LHX(98), LHY(44) );
996 gr_pixel( LHX(128), LHY(43) );
997 gr_pixel( LHX(128), LHY(44) );
999 gr_string( LHX(109), LHY(40), "OR" );
1001 gr_scanline( LHX(253), LHX(261), LHY(42) );
1002 gr_scanline( LHX(274), LHX(283), LHY(42) );
1003 gr_pixel( LHX(253), LHY(43) );
1004 gr_pixel( LHX(253), LHY(44) );
1005 gr_pixel( LHX(283), LHY(43) );
1006 gr_pixel( LHX(283), LHY(44) );
1008 gr_string( LHX(264), LHY(40), "OR" );
1010 } if ( items == kc_joystick ) {
1011 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
1012 gr_setcolor( BM_XRGB(31,27,6) );
1013 gr_scanline( LHX(18), LHX(135), LHY(37) );
1014 gr_scanline( LHX(181), LHX(294), LHY(37) );
1015 gr_scanline( LHX(18), LHX(144), LHY(119+18) );
1016 gr_scanline( LHX(174), LHX(294), LHY(119+18) );
1017 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
1018 gr_string( 0x8000,LHY(117+18), TXT_AXES );
1019 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1020 gr_string( LHX(81), LHY(137+8), TXT_AXIS );
1021 gr_string( LHX(111), LHY(137+8), TXT_INVERT );
1022 gr_string( LHX(230), LHY(137+8), TXT_AXIS );
1023 gr_string( LHX(260), LHY(137+8), TXT_INVERT );
1024 } else if ( items == kc_mouse ) {
1025 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
1026 gr_setcolor( BM_XRGB(31,27,6) );
1027 gr_scanline( LHX(18), LHX(135), LHY(37) );
1028 gr_scanline( LHX(181), LHX(294), LHY(37) );
1029 gr_scanline( LHX(18), LHX(144), LHY(119+5) );
1030 gr_scanline( LHX(174), LHX(294), LHY(119+5) );
1031 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
1032 gr_string( 0x8000,LHY(117+5), TXT_AXES );
1033 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1034 gr_string( LHX(169), LHY(129), TXT_AXIS );
1035 gr_string( LHX(199), LHY(129), TXT_INVERT );
1038 else if ( items == kc_d2x )
1040 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
1041 gr_setcolor( BM_XRGB(31,27,6) );
1043 gr_string(LHX( 94), LHY(40), "KB");
1044 gr_string(LHX(121), LHY(40), "JOY");
1048 WIN(DDGRUNLOCK(dd_grd_curcanv));
1050 for (i=0; i<nitems; i++ ) {
1051 kc_drawitem( &items[i], 0 );
1055 kc_drawitem( &items[citem], 1 );
1057 newmenu_show_cursor();
1059 #ifdef NEWMENU_MOUSE
1060 mouse_state = omouse_state = 0;
1064 // Windows addendum to allow for kconfig input.
1069 DoMessageStuff(&msg);
1071 if (_RedrawScreen) {
1072 _RedrawScreen = FALSE;
1074 dd_gr_set_current_canvas(NULL);
1084 //see if redbook song needs to be restarted
1085 songs_check_redbook_repeat();
1089 #ifdef NEWMENU_MOUSE
1090 omouse_state = mouse_state;
1091 mouse_state = mouse_button_state(0);
1094 if ( !time_stopped ) {
1096 if (multi_menu_poll() == -1)
1105 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_3:)
1106 case KEY_PRINT_SCREEN:
1107 save_screen_shot(0);
1109 case KEY_CTRLED+KEY_D:
1110 items[citem].value = 255;
1111 kc_drawitem( &items[citem], 1 );
1113 case KEY_CTRLED+KEY_R:
1114 if ( items==kc_keyboard ) {
1115 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1116 items[i].value=default_kconfig_settings[0][i];
1117 kc_drawitem( &items[i], 0 );
1120 } else if ( items==kc_d2x ) {
1121 for(i=0;i<NUM_D2X_CONTROLS;i++)
1123 items[i].value=default_kconfig_d2x_settings[i];
1124 kc_drawitem( &items[i], 0 );
1129 // hack for firebire and mousestick default controls since I made
1130 // them the same control type -- dumb dumb dumb
1131 if (joy_have_firebird())
1132 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1133 items[i].value = default_firebird_settings[i];
1134 kc_drawitem( &items[i], 0 );
1136 else if (joy_have_mousestick())
1137 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1138 items[i].value = default_mousestick_settings[i];
1139 kc_drawitem( &items[i], 0 );
1142 #endif // note link to above else
1143 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1144 items[i].value = default_kconfig_settings[Config_control_type][i];
1145 kc_drawitem( &items[i], 0 );
1148 kc_drawitem( &items[citem], 1 );
1151 items[citem].value=255;
1152 kc_drawitem( &items[citem], 1 );
1156 #ifdef TABLE_CREATION
1157 if (items[citem].u==-1) items[citem].u=find_next_item_up( items,nitems, citem);
1159 citem = items[citem].u;
1164 #ifdef TABLE_CREATION
1165 if (items[citem].d==-1) items[citem].d=find_next_item_down( items,nitems, citem);
1167 citem = items[citem].d;
1171 #ifdef TABLE_CREATION
1172 if (items[citem].l==-1) items[citem].l=find_next_item_left( items,nitems, citem);
1174 citem = items[citem].l;
1178 #ifdef TABLE_CREATION
1179 if (items[citem].r==-1) items[citem].r=find_next_item_right( items,nitems, citem);
1181 citem = items[citem].r;
1185 switch( items[citem].type ) {
1186 case BT_KEY: kc_change_key( &items[citem] ); break;
1187 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1188 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1189 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1190 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1191 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1194 //the following case added by WraithX on 11/22/00 to work around the weird joystick bug...
1196 switch(items[citem].type)
1199 kc_next_joyaxis(&items[citem]);
1203 //end addition by WraithX
1206 grd_curcanv->cv_font = save_font;
1208 WIN(DEFINE_SCREEN(old_bg_pcx));
1211 dd_gr_set_current_canvas(save_canvas),
1212 gr_set_current_canvas( save_canvas )
1214 keyd_repeat = old_keyd_repeat;
1215 game_flush_inputs();
1216 newmenu_hide_cursor();
1220 #ifdef TABLE_CREATION
1221 case KEY_DEBUGGED+KEY_F12: {
1223 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1224 kc_keyboard[i].u = find_next_item_up( kc_keyboard,NUM_KEY_CONTROLS, i);
1225 kc_keyboard[i].d = find_next_item_down( kc_keyboard,NUM_KEY_CONTROLS, i);
1226 kc_keyboard[i].l = find_next_item_left( kc_keyboard,NUM_KEY_CONTROLS, i);
1227 kc_keyboard[i].r = find_next_item_right( kc_keyboard,NUM_KEY_CONTROLS, i);
1229 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1230 kc_joystick[i].u = find_next_item_up( kc_joystick,NUM_OTHER_CONTROLS, i);
1231 kc_joystick[i].d = find_next_item_down( kc_joystick,NUM_OTHER_CONTROLS, i);
1232 kc_joystick[i].l = find_next_item_left( kc_joystick,NUM_OTHER_CONTROLS, i);
1233 kc_joystick[i].r = find_next_item_right( kc_joystick,NUM_OTHER_CONTROLS, i);
1235 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1236 kc_mouse[i].u = find_next_item_up( kc_mouse,NUM_OTHER_CONTROLS, i);
1237 kc_mouse[i].d = find_next_item_down( kc_mouse,NUM_OTHER_CONTROLS, i);
1238 kc_mouse[i].l = find_next_item_left( kc_mouse,NUM_OTHER_CONTROLS, i);
1239 kc_mouse[i].r = find_next_item_right( kc_mouse,NUM_OTHER_CONTROLS, i);
1241 fp = fopen( "kconfig.cod", "wt" );
1243 fprintf( fp, "ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {\n" );
1244 for (i=0; i<CONTROL_MAX_TYPES; i++ ) {
1246 fprintf( fp, "{0x%x", kconfig_settings[i][0] );
1247 for (j=1; j<MAX_CONTROLS; j++ )
1248 fprintf( fp, ",0x%x", kconfig_settings[i][j] );
1249 fprintf( fp, "},\n" );
1251 fprintf( fp, "};\n" );
1253 fprintf( fp, "\nkc_item kc_keyboard[NUM_KEY_CONTROLS] = {\n" );
1254 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1255 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1256 kc_keyboard[i].id, kc_keyboard[i].x, kc_keyboard[i].y, kc_keyboard[i].w1, kc_keyboard[i].w2,
1257 kc_keyboard[i].u, kc_keyboard[i].d, kc_keyboard[i].l, kc_keyboard[i].r,
1258 34, kc_keyboard[i].text, 34, btype_text[kc_keyboard[i].type] );
1260 fprintf( fp, "};" );
1262 fprintf( fp, "\nkc_item kc_joystick[NUM_OTHER_CONTROLS] = {\n" );
1263 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1264 if (kc_joystick[i].type == BT_JOY_BUTTON)
1265 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1266 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1267 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1268 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1270 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1271 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1272 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1273 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1275 fprintf( fp, "};" );
1277 fprintf( fp, "\nkc_item kc_mouse[NUM_OTHER_CONTROLS] = {\n" );
1278 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1279 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1280 kc_mouse[i].id, kc_mouse[i].x, kc_mouse[i].y, kc_mouse[i].w1, kc_mouse[i].w2,
1281 kc_mouse[i].u, kc_mouse[i].d, kc_mouse[i].l, kc_mouse[i].r,
1282 34, kc_mouse[i].text, 34, btype_text[kc_mouse[i].type] );
1284 fprintf( fp, "};" );
1293 #ifdef NEWMENU_MOUSE
1294 if ( (mouse_state && !omouse_state) || (mouse_state && omouse_state) ) {
1297 mouse_get_pos(&mx, &my);
1298 for (i=0; i<nitems; i++ ) {
1299 item_height = get_item_height( &items[i] );
1300 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[i].x) + LHX(items[i].w1);
1301 x2 = x1 + LHX(items[i].w2);
1302 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[i].y);
1303 y2 = y1 + LHX(item_height);
1304 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1310 else if ( !mouse_state && omouse_state ) {
1313 mouse_get_pos(&mx, &my);
1314 item_height = get_item_height( &items[citem] );
1315 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[citem].x) + LHX(items[citem].w1);
1316 x2 = x1 + LHX(items[citem].w2);
1317 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[citem].y);
1318 y2 = y1 + LHY(item_height);
1319 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1320 newmenu_hide_cursor();
1321 switch( items[citem].type ) {
1322 case BT_KEY: kc_change_key( &items[citem] ); break;
1323 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1324 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1325 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1326 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1327 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1329 newmenu_show_cursor();
1331 x1 = grd_curcanv->cv_bitmap.bm_x + close_x + LHX(1);
1332 x2 = x1 + close_size - LHX(1);
1333 y1 = grd_curcanv->cv_bitmap.bm_y + close_y + LHX(1);
1334 y2 = y1 + close_size - LHX(1);
1335 if ( ((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2)) ) {
1336 grd_curcanv->cv_font = save_font;
1337 WINDOS(dd_gr_set_current_canvas( save_canvas ),
1338 gr_set_current_canvas( save_canvas ));
1339 keyd_repeat = old_keyd_repeat;
1340 game_flush_inputs();
1341 newmenu_hide_cursor();
1349 #endif // NEWMENU_MOUSE
1351 if (ocitem!=citem) {
1352 newmenu_hide_cursor();
1353 kc_drawitem( &items[ocitem], 0 );
1354 kc_drawitem( &items[citem], 1 );
1355 newmenu_show_cursor();
1361 void kc_drawitem( kc_item *item, int is_current )
1365 // PA_DFX (pa_set_frontbuffer_current());
1366 WIN(DDGRLOCK(dd_grd_curcanv));
1369 gr_set_fontcolor( BM_XRGB(20,20,29), -1 );
1371 gr_set_fontcolor( BM_XRGB(15,15,24), -1 );
1372 gr_string( LHX(item->x), LHY(item->y), item->text );
1373 WIN(DDGRUNLOCK(dd_grd_curcanv));
1375 if (item->value==255) {
1376 strcpy( btext, "" );
1378 switch( item->type ) {
1380 strncpy( btext, key_text[item->value], 10 ); break;
1381 case BT_MOUSE_BUTTON:
1383 //strncpy( btext, Text_string[mousebutton_text[item->value]], 10 ); break;
1384 strncpy( btext, (item->value <= 3)?Text_string[mousebutton_text[item->value]]:mousebutton_textra[item->value-3], 10 ); break;
1386 strncpy( btext, mousebutton_text[item->value], 10 ); break;
1389 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
1391 #ifdef USE_LINUX_JOY
1392 sprintf(btext, "J%d B%d", j_button[item->value].joydev, j_Get_joydev_button_number(item->value));
1393 #elif defined(SDL_INPUT)
1394 if (joybutton_text[item->value])
1395 strncpy(btext, joybutton_text[item->value], 10);
1397 sprintf(btext, "BTN%2d", item->value + 1);
1401 if (joybutton_text[item->value] != -1)
1402 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1404 sprintf( btext, "BTN%2d", item->value+1 );
1406 if ( joybutton_text[item->value] !=-1 )
1407 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1409 sprintf( btext, "BTN%d", item->value );
1412 strncpy( btext, joy_btn_name( item->value ), 10);
1414 sprintf( btext, "BTN%d", item->value );
1419 #ifdef USE_LINUX_JOY
1420 sprintf(btext, "J%d A%d", j_axis[item->value].joydev, j_Get_joydev_axis_number(item->value));
1421 #elif defined(SDL_INPUT)
1422 if (joyaxis_text[item->value])
1423 strncpy(btext, joyaxis_text[item->value], 10);
1425 sprintf(btext, "AXIS%2d", item->value + 1);
1427 strncpy(btext, Text_string[joyaxis_text[item->value]], 10);
1431 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
1435 WIN(DDGRLOCK(dd_grd_curcanv));
1436 gr_get_string_size(btext, &w, &h, &aw );
1439 gr_setcolor( BM_XRGB(21,0,24) );
1441 gr_setcolor( BM_XRGB(16,0,19) );
1442 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1444 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1446 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1448 gr_string( x, LHY(item->y), btext );
1449 // PA_DFX (pa_set_backbuffer_current());
1451 WIN(DDGRUNLOCK(dd_grd_curcanv));
1456 static int looper=0;
1458 void kc_drawquestion( kc_item *item )
1462 WIN(DDGRLOCK(dd_grd_curcanv));
1463 // PA_DFX (pa_set_frontbuffer_current());
1465 gr_get_string_size("?", &w, &h, &aw );
1467 c = BM_XRGB(21,0,24);
1469 //@@gr_setcolor( gr_fade_table[fades[looper]*256+c] );
1470 gr_setcolor(BM_XRGB(21*fades[looper]/31,0,24*fades[looper]/31));
1472 if (looper>63) looper=0;
1474 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1476 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1478 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1480 gr_string( x, LHY(item->y), "?" );
1481 // PA_DFX (pa_set_backbuffer_current());
1482 WIN(DDGRUNLOCK(dd_grd_curcanv));
1486 void kc_change_key( kc_item * item )
1491 WIN(DDGRLOCK(dd_grd_curcanv));
1492 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1494 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_KEY );
1495 WIN(DDGRUNLOCK(dd_grd_curcanv));
1497 game_flush_inputs();
1501 while( (k!=KEY_ESC) && (keycode==255) )
1507 DoMessageStuff(&msg);
1514 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1517 // if ( Game_mode & GM_MULTI )
1518 // GameLoop( 0, 0 ); // Continue
1520 timer_delay(f0_1/10);
1521 kc_drawquestion( item );
1523 for (i=0; i<256; i++ ) {
1524 if (keyd_pressed[i] && (strlen(key_text[i])>0)) {
1526 for (n=0; n<sizeof(system_keys); n++ )
1527 if ( system_keys[n] == i )
1536 for (i=0; i<Num_items; i++ ) {
1537 n = item - All_items;
1538 if ( (i!=n) && (All_items[i].type==BT_KEY) && (All_items[i].value==keycode) ) {
1539 All_items[i].value = 255;
1540 kc_drawitem( &All_items[i], 0 );
1543 item->value = keycode;
1545 kc_drawitem( item, 1 );
1547 WIN(DDGRLOCK(dd_grd_curcanv));
1548 gr_set_fontcolor( BM_XRGB(28,28,28), BM_XRGB(0,0,0) );
1549 WIN(DDGRUNLOCK(dd_grd_curcanv));
1551 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1553 game_flush_inputs();
1557 void kc_change_joybutton( kc_item * item )
1562 WIN(DDGRLOCK(dd_grd_curcanv));
1563 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1565 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_JBUTTON );
1566 WIN(DDGRUNLOCK(dd_grd_curcanv));
1568 game_flush_inputs();
1572 while( (k!=KEY_ESC) && (code==255))
1577 DoMessageStuff(&msg);
1583 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1586 // if ( Game_mode & GM_MULTI )
1587 // GameLoop( 0, 0 ); // Continue
1589 timer_delay(f0_1/10);
1591 if (k == KEY_PRINT_SCREEN)
1592 save_screen_shot(0);
1594 kc_drawquestion( item );
1596 WIN(code = joydefsw_do_button());
1599 code = joy_do_buttons();
1602 #if !defined(WINDOWS) && !defined(MACINTOSH)
1603 if (Config_control_type==CONTROL_THRUSTMASTER_FCS) {
1605 joystick_read_raw_axis( JOY_ALL_AXIS, axis );
1606 kconfig_read_fcs( axis[3] );
1607 if ( joy_get_button_state(7) ) code = 7;
1608 if ( joy_get_button_state(11) ) code = 11;
1609 if ( joy_get_button_state(15) ) code = 15;
1610 if ( joy_get_button_state(19) ) code = 19;
1611 for (i=0; i<4; i++ ) {
1612 if ( joy_get_button_state(i) )
1615 } else if (Config_control_type==CONTROL_FLIGHTSTICK_PRO) {
1616 for (i=4; i<20; i++ ) {
1617 if ( joy_get_button_state(i) ) {
1619 mprintf(( 0, "JB: %d\n", code ));
1623 for (i = 0; i < JOY_MAX_BUTTONS; i++)
1625 if ( joy_get_button_state(i) )
1632 for (i=0; i<Num_items; i++ ) {
1633 n = item - All_items;
1634 if ( (i!=n) && (All_items[i].type==BT_JOY_BUTTON) && (All_items[i].value==code) ) {
1635 All_items[i].value = 255;
1636 kc_drawitem( &All_items[i], 0 );
1641 kc_drawitem( item, 1 );
1642 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1643 game_flush_inputs();
1646 void kc_change_mousebutton( kc_item * item )
1651 WIN(DDGRLOCK(dd_grd_curcanv));
1652 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1654 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_MBUTTON );
1655 WIN(DDGRUNLOCK(dd_grd_curcanv));
1658 game_flush_inputs();
1662 while( (k!=KEY_ESC) && (code==255))
1667 DoMessageStuff(&msg);
1673 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1676 // if ( Game_mode & GM_MULTI )
1677 // GameLoop( 0, 0 ); // Continue
1679 timer_delay(f0_1/10);
1681 if (k == KEY_PRINT_SCREEN)
1682 save_screen_shot(0);
1684 kc_drawquestion( item );
1686 b = mouse_get_btns();
1687 for (i = 0; i < 16; i++ ) {
1693 for (i=0; i<Num_items; i++ ) {
1694 n = item - All_items;
1695 if ( (i!=n) && (All_items[i].type==BT_MOUSE_BUTTON) && (All_items[i].value==code) ) {
1696 All_items[i].value = 255;
1697 kc_drawitem( &All_items[i], 0 );
1702 kc_drawitem( item, 1 );
1703 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1704 game_flush_inputs();
1709 // 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
1710 void kc_next_joyaxis(kc_item *item)
1712 int n, i, k, max, tries;
1719 // I modelled this ifdef after the code in the kc_change_joyaxis method.
1720 // So, if somethin's not workin here, it might not be workin there either.
1723 code = (item->value + 1) % max;
1727 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))
1733 return; // all axes allocated already
1734 i = -1; // -1 so the i++ will push back to 0
1735 code = (item->value + ++tries) % max; // try next axis
1742 kc_drawitem(item, 1);
1743 nm_restore_background(0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h);
1744 game_flush_inputs();
1746 }//method kc_next_joyaxis
1747 //end addition by WraithX
1750 void kc_change_joyaxis( kc_item * item )
1752 int axis[JOY_MAX_AXES];
1753 int old_axis[JOY_MAX_AXES];
1754 int numaxis = joy_num_axes;
1758 WIN(DDGRLOCK(dd_grd_curcanv));
1759 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1761 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_JOY_AXIS );
1762 WIN(DDGRUNLOCK(dd_grd_curcanv));
1764 game_flush_inputs();
1769 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, old_axis ),
1770 joystick_read_raw_axis( JOY_ALL_AXIS, old_axis )
1773 while( (k!=KEY_ESC) && (code==255))
1778 DoMessageStuff(&msg);
1784 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1787 // if ( Game_mode & GM_MULTI )
1788 // GameLoop( 0, 0 ); // Continue
1790 timer_delay(f0_1/10);
1792 if (k == KEY_PRINT_SCREEN)
1793 save_screen_shot(0);
1795 kc_drawquestion( item );
1798 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, axis ),
1799 joystick_read_raw_axis( JOY_ALL_AXIS, axis )
1802 for (i=0; i<numaxis; i++ ) {
1803 #if defined (MACINTOSH)
1804 if ( abs(axis[i]-old_axis[i])>100 ) {
1805 #elif defined(WINDOWS)
1806 if ( abs(axis[i]-old_axis[i])>1024 ) {
1808 if ( abs(axis[i]-old_axis[i])>200 ) {
1811 con_printf(CON_DEBUG, "Axis Movement detected: Axis %i\n", i);
1813 //old_axis[i] = axis[i];
1815 for (i=0; i<Num_items; i++ )
1817 n = item - All_items;
1818 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) )
1824 for (i=0; i<Num_items; i++ ) {
1825 n = item - All_items;
1826 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) ) {
1827 All_items[i].value = 255;
1828 kc_drawitem( &All_items[i], 0 );
1834 kc_drawitem( item, 1 );
1835 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1836 game_flush_inputs();
1840 void kc_change_mouseaxis( kc_item * item )
1849 WIN(DDGRLOCK(dd_grd_curcanv));
1850 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1852 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_MSE_AXIS );
1853 WIN(DDGRUNLOCK(dd_grd_curcanv));
1855 game_flush_inputs();
1859 mouse_get_delta( &dx, &dy );
1861 while( (k!=KEY_ESC) && (code==255))
1866 DoMessageStuff(&msg);
1872 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1875 // if ( Game_mode & GM_MULTI )
1876 // GameLoop( 0, 0 ); // Continue
1878 timer_delay(f0_1/10);
1880 if (k == KEY_PRINT_SCREEN)
1881 save_screen_shot(0);
1883 kc_drawquestion( item );
1886 mouse_get_delta_z( &dx, &dy, &dz );
1888 mouse_get_delta( &dx, &dy );
1890 if ( abs(dx)>20 ) code = 0;
1891 if ( abs(dy)>20 ) code = 1;
1893 if ( abs(dz)>20 ) code = 2;
1897 for (i=0; i<Num_items; i++ ) {
1898 n = item - All_items;
1899 if ( (i!=n) && (All_items[i].type==BT_MOUSE_AXIS) && (All_items[i].value==code) ) {
1900 All_items[i].value = 255;
1901 kc_drawitem( &All_items[i], 0 );
1906 kc_drawitem( item, 1 );
1907 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1908 game_flush_inputs();
1913 void kc_change_invert( kc_item * item )
1915 game_flush_inputs();
1922 kc_drawitem( item, 1 );
1926 #include "screens.h"
1928 void kconfig(int n, char * title)
1931 grs_bitmap *save_bm;
1933 set_screen_mode( SCREEN_MENU );
1938 WIN(mouse_set_mode(0));
1939 WIN(dd_gr_set_current_canvas(NULL));
1941 #if defined(POLY_ACC)
1942 save_bm = gr_create_bitmap2( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h, grd_curcanv->cv_bitmap.bm_type, NULL );
1944 save_bm = gr_create_bitmap( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
1946 Assert( save_bm != NULL );
1948 WIN(DDGRLOCK(dd_grd_curcanv));
1949 gr_bm_bitblt(grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_w,
1950 0, 0, 0, 0, &grd_curcanv->cv_bitmap, save_bm );
1951 WIN(DDGRUNLOCK(dd_grd_curcanv));
1954 case 0:kconfig_sub( kc_keyboard, NUM_KEY_CONTROLS, title );break;
1955 case 1:kconfig_sub( kc_joystick, NUM_OTHER_CONTROLS, title );break;
1956 case 2:kconfig_sub( kc_mouse, NUM_OTHER_CONTROLS, title ); break;
1957 case 3:kconfig_sub( kc_superjoy, NUM_OTHER_CONTROLS, title); break;
1959 //added on 2/4/99 by Victor Rachels for new keys menu
1960 case 4:kconfig_sub( kc_d2x, NUM_D2X_CONTROLS, title ); break;
1961 //end this section addition - VR
1969 WIN(mouse_set_mode(1));
1970 WIN(dd_gr_set_current_canvas(NULL));
1971 WIN(DDGRLOCK(dd_grd_curcanv));
1972 gr_bitmap(0, 0, save_bm);
1973 WIN(DDGRUNLOCK(dd_grd_curcanv));
1974 gr_free_bitmap(save_bm);
1976 #if 0 // set_screen_mode always calls this later... right?
1977 reset_cockpit(); //force cockpit redraw next time
1980 // Update save values...
1982 for (i=0; i<NUM_KEY_CONTROLS; i++ )
1983 kconfig_settings[0][i] = kc_keyboard[i].value;
1985 if ( (Config_control_type>0) && (Config_control_type<5)) {
1986 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1987 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
1988 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
1989 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1990 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
1992 else if (Config_control_type == CONTROL_WINJOYSTICK) {
1993 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1994 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
1998 for (i=0; i<NUM_D2X_CONTROLS; i++)
1999 kconfig_d2x_settings[i] = kc_d2x[i].value;
2004 void kconfig_read_fcs( int raw_axis )
2006 int raw_button, button, axis_min[4], axis_center[4], axis_max[4];
2008 if (Config_control_type!=CONTROL_THRUSTMASTER_FCS) return;
2010 joy_get_cal_vals(axis_min, axis_center, axis_max);
2012 if ( axis_max[3] > 1 )
2013 raw_button = (raw_axis*100)/axis_max[3];
2017 if ( raw_button > 88 )
2019 else if ( raw_button > 63 )
2021 else if ( raw_button > 39 )
2023 else if ( raw_button > 15 )
2028 kconfig_set_fcs_button( 19, button );
2029 kconfig_set_fcs_button( 15, button );
2030 kconfig_set_fcs_button( 11, button );
2031 kconfig_set_fcs_button( 7, button );
2035 void kconfig_set_fcs_button( int btn, int button )
2037 int state,time_down,upcount,downcount;
2038 state = time_down = upcount = downcount = 0;
2040 if ( joy_get_button_state(btn) ) {
2041 if ( btn==button ) {
2043 time_down = FrameTime;
2048 if ( btn==button ) {
2050 time_down = FrameTime;
2057 joy_set_btn_values( btn, state, time_down, downcount, upcount );
2063 fix Last_angles_p = 0;
2064 fix Last_angles_b = 0;
2065 fix Last_angles_h = 0;
2066 ubyte Last_angles_read = 0;
2068 extern int VR_sensitivity;
2070 int VR_sense_range[3] = { 25, 50, 75 };
2072 #if 0 //ndef MACINTOSH
2077 fix yaw, pitch, roll;
2080 //------ read vfx1 helmet --------
2081 if (vfx1_installed) {
2082 vfx_get_data(&yaw,&pitch,&roll,&buttons);
2083 } else if (iglasses_headset_installed) {
2084 iglasses_read_headset( &yaw, &pitch, &roll );
2085 } else if (Victor_headset_installed) {
2086 victor_read_headset_filtered( &yaw, &pitch, &roll );
2091 Use_player_head_angles = 0;
2092 if ( Last_angles_read ) {
2096 if ( (Last_angles_h < (F1_0/4) ) && (yaw > ((F1_0*3)/4) ) )
2098 else if ( (yaw < (F1_0/4) ) && (Last_angles_h > ((F1_0*3)/4) ) )
2101 Controls.pitch_time += fixmul((pitch- Last_angles_p)*VR_sense_range[VR_sensitivity],FrameTime);
2102 Controls.heading_time+= fixmul((yaw1 - Last_angles_h)*VR_sense_range[VR_sensitivity],FrameTime);
2103 Controls.bank_time += fixmul((roll - Last_angles_b)*VR_sense_range[VR_sensitivity],FrameTime);
2105 Last_angles_read = 1;
2106 Last_angles_p = pitch;
2107 Last_angles_h = yaw;
2108 Last_angles_b = roll;
2115 #ifndef __MSDOS__ // WINDOWS
2116 #define JOYSTICK_READ_TIME (F1_0/40) // Read joystick at 40 Hz.
2118 #define JOYSTICK_READ_TIME (F1_0/10) // Read joystick at 10 Hz.
2121 fix LastReadTime = 0;
2123 fix joy_axis[JOY_MAX_AXES];
2125 ubyte kc_use_external_control = 0;
2126 ubyte kc_enable_external_control = 0;
2127 ubyte kc_external_intno = 0;
2128 ext_control_info *kc_external_control = NULL;
2129 char *kc_external_name = NULL;
2130 ubyte kc_external_version = 0;
2131 extern int Automap_active;
2133 void kconfig_init_external_controls(int intno, int address)
2136 kc_external_intno = intno;
2137 kc_external_control = (ext_control_info *)address;
2138 kc_use_external_control = 1;
2139 kc_enable_external_control = 1;
2141 i = FindArg ( "-xname" );
2143 kc_external_name = Args[i+1];
2145 kc_external_name = "External Controller";
2147 for (i=0;i<strlen (kc_external_name);i++)
2148 if (kc_external_name[i]=='_')
2149 kc_external_name[i]=' ';
2151 i = FindArg ( "-xver" );
2153 kc_external_version = atoi(Args[i+1]);
2155 printf( "%s int: 0x%x, data: 0x%p, ver:%d\n", kc_external_name, kc_external_intno, kc_external_control, kc_external_version );
2159 #if !defined(MACINTOSH)
2160 /*void kconfig_read_external_controls()
2164 if ( !kc_enable_external_control && !CybermouseActive)
2167 if ( kc_external_version == 0 )
2168 memset( kc_external_control, 0, sizeof(control_info) );
2169 else if ( kc_external_version > 0 ) {
2170 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 );
2171 if ( kc_external_version > 1 ) {
2172 // Write ship pos and angles to external controls...
2173 ubyte *temp_ptr = (ubyte *)kc_external_control;
2174 vms_vector *ship_pos;
2175 vms_matrix *ship_orient;
2176 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
2177 temp_ptr += sizeof(control_info)+sizeof(vms_angvec) + 64;
2178 ship_pos = (vms_vector *)temp_ptr;
2179 temp_ptr += sizeof(vms_vector);
2180 ship_orient = (vms_matrix *)temp_ptr;
2181 // Fill in ship postion...
2182 *ship_pos = Objects[Players[Player_num].objnum].pos;
2183 // Fill in ship orientation...
2184 *ship_orient = Objects[Players[Player_num].objnum].orient;
2188 if ( Automap_active ) // (If in automap...)
2189 kc_external_control->automap_state = 1;
2190 memset(&r,0,sizeof(r));
2194 if (!CybermouseActive)
2195 int386 ( kc_external_intno, &r, &r); // Read external info...
2197 // ReadOWL (kc_external_control);
2201 if ( Player_num > -1 ) {
2202 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
2203 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
2204 Auto_leveling_on = 0;
2206 if ( kc_external_version > 0 ) {
2207 vms_matrix tempm, ViewMatrix;
2208 vms_angvec * Kconfig_abs_movement;
2211 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
2213 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
2214 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
2215 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
2216 Objects[Players[Player_num].objnum].orient = ViewMatrix;
2218 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
2219 if (oem_message[0] != '\0' )
2220 HUD_init_message( oem_message );
2224 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
2225 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
2226 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
2227 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
2228 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
2229 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
2230 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
2231 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
2232 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
2233 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
2234 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
2235 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
2236 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
2237 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
2238 Controls.automap_down_count += kc_external_control->automap_down_count;
2239 Controls.automap_state |= kc_external_control->automap_state;
2244 void controls_read_all_win()
2247 int slide_on, bank_on;
2251 int raw_joy_axis[7];
2253 fix k0, k1, k2, k3, kp;
2254 fix k4, k5, k6, k7, kh;
2255 ubyte channel_masks;
2256 int use_mouse, use_joystick;
2259 if (Game_turbo_mode)
2263 fix temp = Controls.heading_time;
2264 fix temp1 = Controls.pitch_time;
2265 memset( &Controls, 0, sizeof(control_info) );
2266 Controls.heading_time = temp;
2267 Controls.pitch_time = temp1;
2272 ctime = timer_get_fixed_seconds();
2274 // DO JOYSTICK (X,Y,Z R,U,V)
2275 // ----------------------------------------------------------------------------
2276 if ( (LastReadTime + JOYSTICK_READ_TIME) > ctime ) {
2277 if ((ctime < 0) && (LastReadTime > 0))
2278 LastReadTime = ctime;
2280 } else if ((Config_control_type==CONTROL_WINJOYSTICK)) {
2281 LastReadTime = ctime;
2282 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, raw_joy_axis );
2284 for (i=0; i<7; i++ ) {
2285 if (channel_masks&(1<<i)) {
2286 int joy_null_value = 28;
2288 // DO POV if joystick has a hat.
2289 // --------------------------------------------------------------------
2291 joydefsw_do_winjoybutton(raw_joy_axis);
2295 // --------------------------------------------------------------------
2296 // mprintf((0, "(%d)=%d,", i, raw_joy_axis[i]));
2297 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2298 // mprintf((0, "%d ",raw_joy_axis[i]));
2299 // if (i%2) mprintf((0,"\n"));
2302 if (kc_superjoy[23].value==i) // If this is the throttle
2303 joy_null_value = 32; // Then use a larger dead-zone
2305 if (raw_joy_axis[i] > (joy_null_value-2))
2306 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2307 else if (raw_joy_axis[i] < -(joy_null_value+2))
2308 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2310 raw_joy_axis[i] = 0;
2311 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2320 for (i=0; i<6; i++ )
2326 // ----------------------------------------------------------------------------
2327 if (Config_control_type==5) {
2328 mouse_get_delta( &dx, &dy );
2329 mouse_axis[0] = (dx*FrameTime)/35;
2330 mouse_axis[1] = (dy*FrameTime)/25;
2331 mouse_buttons = mouse_get_btns();
2332 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2341 //------------- Read slide_on -------------
2344 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
2345 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
2347 if ((use_joystick)&&(kc_superjoy[5].value<255)) slide_on |= joy_get_button_state( kc_superjoy[5].value );
2349 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
2351 //------------- Read bank_on ---------------
2354 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
2355 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
2357 if ( (use_joystick)&&(kc_superjoy[10].value < 255 )) bank_on |= joy_get_button_state( kc_superjoy[10].value );
2359 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
2361 //------------ Read pitch_time -----------
2363 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2365 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
2366 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
2367 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
2368 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
2371 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
2372 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
2373 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
2374 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
2377 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2378 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
2379 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
2383 Controls.pitch_time = 0;
2385 if (Controls.pitch_time < 0)
2386 Controls.pitch_time = 0;
2388 if (Controls.pitch_time > 0)
2389 Controls.pitch_time = 0;
2390 Controls.pitch_time += kp;
2393 if ( (use_joystick)&&(kc_superjoy[13].value < 255 )) {
2394 if ( !kc_superjoy[14].value ) // If not inverted...
2395 Controls.pitch_time -= (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2397 Controls.pitch_time += (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2401 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
2402 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
2403 if ( !kc_mouse[14].value ) // If not inverted...
2404 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2406 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2409 Controls.pitch_time = 0;
2413 //----------- Read vertical_thrust_time -----------------
2416 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
2417 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
2418 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
2419 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
2422 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
2423 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
2424 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
2425 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
2428 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2429 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
2430 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
2434 if ((use_joystick)&&( kc_superjoy[13].value < 255 )) {
2435 if ( !kc_superjoy[14].value ) // If not inverted...
2436 Controls.vertical_thrust_time += joy_axis[kc_superjoy[13].value];
2438 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[13].value];
2442 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
2443 if ( !kc_mouse[14].value ) // If not inverted...
2444 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
2446 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
2451 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
2452 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
2453 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
2454 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
2457 if ((use_joystick)&&( kc_superjoy[19].value < 255 )) {
2458 if ( !kc_superjoy[20].value ) // If not inverted...
2459 Controls.vertical_thrust_time += joy_axis[kc_superjoy[19].value];
2461 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[19].value];
2464 // From joystick buttons
2465 if ( (use_joystick)&&(kc_superjoy[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_superjoy[8].value );
2466 if ( (use_joystick)&&(kc_superjoy[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_superjoy[9].value );
2468 // From mouse buttons
2469 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
2470 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
2473 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
2474 if ( !kc_mouse[20].value ) // If not inverted...
2475 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
2477 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
2481 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2482 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
2483 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
2486 //---------- Read heading_time -----------
2488 if (!slide_on && !bank_on) {
2489 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2491 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
2492 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
2493 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
2494 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
2497 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
2498 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
2499 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
2500 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
2503 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2504 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
2505 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
2509 Controls.heading_time = 0;
2511 if (Controls.heading_time < 0)
2512 Controls.heading_time = 0;
2514 if (Controls.heading_time > 0)
2515 Controls.heading_time = 0;
2516 Controls.heading_time += kh;
2519 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2520 if ( !kc_superjoy[16].value ) // If not inverted...
2521 Controls.heading_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2523 Controls.heading_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2527 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2528 if ( !kc_mouse[16].value ) // If not inverted...
2529 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2531 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2534 Controls.heading_time = 0;
2537 //----------- Read sideways_thrust_time -----------------
2540 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2541 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2542 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2543 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2546 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
2547 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
2548 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
2549 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
2552 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2553 if ( !kc_superjoy[16].value ) // If not inverted...
2554 Controls.sideways_thrust_time += joy_axis[kc_superjoy[15].value];
2556 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[15].value];
2560 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2561 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
2562 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
2566 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2567 if ( !kc_mouse[16].value ) // If not inverted...
2568 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
2570 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
2575 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
2576 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
2577 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
2578 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
2581 if ( (use_joystick)&&(kc_superjoy[17].value < 255 )) {
2582 if ( !kc_superjoy[18].value ) // If not inverted...
2583 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[17].value];
2585 Controls.sideways_thrust_time += joy_axis[kc_superjoy[17].value];
2588 // From joystick buttons
2589 if ( (use_joystick)&&(kc_superjoy[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_superjoy[6].value );
2590 if ( (use_joystick)&&(kc_superjoy[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_superjoy[7].value );
2592 // From mouse buttons
2593 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
2594 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
2597 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
2598 if ( !kc_mouse[18].value ) // If not inverted...
2599 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
2601 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
2604 //----------- Read bank_time -----------------
2607 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2608 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2609 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2610 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2613 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
2614 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
2615 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
2616 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
2619 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2620 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
2621 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
2625 if ( (use_joystick)&&(kc_superjoy[15].value < 255) ) {
2626 if ( !kc_superjoy[16].value ) // If not inverted...
2627 Controls.bank_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2629 Controls.bank_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2633 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2634 if ( !kc_mouse[16].value ) // If not inverted...
2635 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2637 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2642 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
2643 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
2644 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
2645 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
2648 if ( (use_joystick)&&(kc_superjoy[21].value < 255) ) {
2649 if ( !kc_superjoy[22].value ) // If not inverted...
2650 Controls.bank_time -= joy_axis[kc_superjoy[21].value];
2652 Controls.bank_time += joy_axis[kc_superjoy[21].value];
2655 // From joystick buttons
2656 if ( (use_joystick)&&(kc_superjoy[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_superjoy[11].value );
2657 if ( (use_joystick)&&(kc_superjoy[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_superjoy[12].value );
2659 // From mouse buttons
2660 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
2661 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
2664 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
2665 if ( !kc_mouse[22].value ) // If not inverted...
2666 Controls.bank_time += mouse_axis[kc_mouse[21].value];
2668 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
2672 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2673 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
2674 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
2677 //----------- Read forward_thrust_time -------------
2680 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
2681 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
2682 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
2683 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
2686 if ( (use_joystick)&&(kc_superjoy[23].value < 255 )) {
2687 if ( !kc_superjoy[24].value ) // If not inverted...
2688 Controls.forward_thrust_time -= joy_axis[kc_superjoy[23].value];
2690 Controls.forward_thrust_time += joy_axis[kc_superjoy[23].value];
2693 // From joystick buttons
2694 if ( (use_joystick)&&(kc_superjoy[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_superjoy[2].value );
2695 if ( (use_joystick)&&(kc_superjoy[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_superjoy[3].value );
2698 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
2699 if ( !kc_mouse[24].value ) // If not inverted...
2700 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
2702 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
2705 // From mouse buttons
2706 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
2707 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
2709 //----------- Read afterburner_state -------------
2712 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
2713 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
2715 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
2717 if ( (use_joystick)&&(kc_superjoy[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_superjoy[27].value);
2719 //-------Read headlight key--------------------------
2720 if (kc_keyboard[52].value < 255 )
2721 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
2722 if (kc_keyboard[53].value < 255 )
2723 Controls.headlight_count=key_down_count(kc_keyboard[53].value);
2724 if ((use_joystick)&&(kc_superjoy[30].value < 255 ))
2725 Controls.headlight_count=joy_get_button_down_cnt(kc_superjoy[30].value);
2727 //--------Read Cycle Primary Key------------------
2729 if (kc_keyboard[48].value<255)
2730 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
2731 if (kc_keyboard[49].value<255)
2732 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
2733 if ((use_joystick)&&(kc_superjoy[28].value < 255 ))
2734 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_superjoy[28].value);
2736 //--------Read Cycle Secondary Key------------------
2738 if (kc_keyboard[50].value<255)
2739 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
2740 if (kc_keyboard[51].value<255)
2741 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
2742 if ((use_joystick)&&(kc_superjoy[29].value < 255 ))
2743 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_superjoy[29].value);
2745 //--------Read Toggle Bomb key----------------------
2747 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
2749 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
2751 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
2752 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
2754 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2755 HUD_init_message ("No bombs available!");
2759 if (Players[Player_num].secondary_ammo[bomb]==0)
2761 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2762 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
2766 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
2767 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
2772 //---------Read Energy->Shield key----------
2774 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
2775 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
2776 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
2777 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
2779 //----------- Read fire_primary_down_count
2780 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
2781 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
2782 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_superjoy[0].value);
2783 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
2785 //----------- Read fire_primary_state
2786 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
2787 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
2788 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_superjoy[0].value);
2789 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
2791 //----------- Read fire_secondary_down_count
2792 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
2793 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
2794 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_superjoy[1].value);
2795 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
2797 //----------- Read fire_secondary_state
2798 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
2799 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
2800 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_superjoy[1].value);
2801 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
2803 //----------- Read fire_flare_down_count
2804 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
2805 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
2806 if ((use_joystick)&&(kc_superjoy[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_superjoy[4].value);
2807 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
2809 //----------- Read drop_bomb_down_count
2810 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
2811 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
2812 if ((use_joystick)&&(kc_superjoy[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_superjoy[26].value);
2813 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
2815 //----------- Read rear_view_down_count
2816 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
2817 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
2818 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_superjoy[25].value);
2819 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
2821 //----------- Read rear_view_down_state
2822 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
2823 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
2824 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_superjoy[25].value);
2825 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
2827 //----------- Read automap_down_count
2828 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
2829 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
2831 //----------- Read automap_state
2832 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
2833 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
2835 //----------- Read stupid-cruise-control-type of throttle.
2837 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
2838 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
2839 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
2840 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
2841 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
2843 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
2846 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
2847 if (Cruise_speed < 0 ) Cruise_speed = 0;
2849 if (Controls.forward_thrust_time==0)
2850 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
2853 //read_head_tracker();
2855 // Read external controls
2856 if (kc_use_external_control || CybermouseActive)
2857 kconfig_read_external_controls();
2859 //----------- Clamp values between -FrameTime and FrameTime
2860 if (FrameTime > F1_0 )
2861 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
2863 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
2864 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
2865 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
2866 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
2867 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
2868 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
2869 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
2871 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
2872 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
2873 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
2874 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
2875 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
2876 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
2877 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
2880 //--------- Don't do anything if in debug mode
2882 if ( keyd_pressed[KEY_DELETE] ) {
2883 memset( &Controls, 0, sizeof(control_info) );
2890 fix Next_toggle_time[3]={0,0,0};
2892 int allowed_to_toggle(int i)
2894 //used for keeping tabs of when its ok to toggle headlight,primary,and secondary
2896 if (Next_toggle_time[i] > GameTime)
2897 if (Next_toggle_time[i] < GameTime + (F1_0/8)) // In case time is bogus, never wait > 1 second.
2900 Next_toggle_time[i] = GameTime + (F1_0/8);
2907 //added on 2/7/99 by Victor Rachels for jostick state setting
2908 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};
2909 //end this section adition - VR
2913 void controls_read_all()
2916 int slide_on, bank_on;
2923 fix mouse_axis[3] = {0,0,0};
2924 int raw_joy_axis[JOY_MAX_AXES];
2926 fix k0, k1, k2, k3, kp;
2927 fix k4, k5, k6, k7, kh;
2928 ubyte channel_masks;
2929 int use_mouse, use_joystick;
2935 if (Game_turbo_mode)
2939 fix temp = Controls.heading_time;
2940 fix temp1 = Controls.pitch_time;
2941 memset( &Controls, 0, sizeof(control_info) );
2942 Controls.heading_time = temp;
2943 Controls.pitch_time = temp1;
2948 ctime = timer_get_fixed_seconds();
2950 //--------- Read Joystick -----------
2952 if ( (LastReadTime + JOYSTICK_READ_TIME > ctime) && (Config_control_type!=CONTROL_THRUSTMASTER_FCS) ) {
2954 if ((ctime < 0) && (LastReadTime >= 0))
2956 if ((ctime < 0) && (LastReadTime > 0))
2958 LastReadTime = ctime;
2960 } else if ((Config_control_type>0) && (Config_control_type<5) ) {
2961 LastReadTime = ctime;
2962 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
2964 for (i = 0; i < joy_num_axes; i++)
2967 if (channel_masks&(1<<i)) {
2969 int joy_null_value = 10;
2971 if ( (i==3) && (Config_control_type==CONTROL_THRUSTMASTER_FCS) ) {
2972 kconfig_read_fcs( raw_joy_axis[i] );
2974 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2976 if (kc_joystick[23].value==i) // If this is the throttle
2977 joy_null_value = 20; // Then use a larger dead-zone
2979 if (raw_joy_axis[i] > joy_null_value)
2980 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2981 else if (raw_joy_axis[i] < -joy_null_value)
2982 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2984 raw_joy_axis[i] = 0;
2985 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2995 for (i = 0; i < joy_num_axes; i++)
3000 //--------- Read Joystick -----------
3001 if ((Config_control_type>0) && (Config_control_type<5) ) {
3002 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
3003 for (i=0; i<4; i++ ) {
3004 if (channel_masks&(1<<i)) {
3005 int joy_null_value = 10;
3007 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
3009 if (kc_joystick[23].value==i) // If this is the throttle
3010 joy_null_value = 20; // Then use a larger dead-zone
3012 if (raw_joy_axis[i] > joy_null_value)
3013 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
3014 else if (raw_joy_axis[i] < -joy_null_value)
3015 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
3017 raw_joy_axis[i] = 0;
3018 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
3025 for (i=0; i<4; i++ )
3029 #endif // ifndef MACINTOSH
3031 if (Config_control_type==5 && !CybermouseActive) {
3032 //--------- Read Mouse -----------
3034 mouse_get_delta_z( &dx, &dy, &dz );
3036 mouse_get_delta( &dx, &dy );
3038 mouse_axis[0] = (dx*FrameTime)/35;
3039 mouse_axis[1] = (dy*FrameTime)/25;
3041 mouse_axis[2] = (dz*FrameTime);
3043 mouse_buttons = mouse_get_btns();
3044 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
3046 } else if (Config_control_type==6 && !CybermouseActive) {
3047 //--------- Read Cyberman -----------
3048 mouse_get_cyberman_pos(&idx,&idy );
3049 mouse_axis[0] = (idx*FrameTime)/128;
3050 mouse_axis[1] = (idy*FrameTime)/128;
3051 mouse_buttons = mouse_get_btns();
3053 } else if (CybermouseActive) {
3054 // ReadOWL (kc_external_control);
3055 // CybermouseAdjust();
3064 //added on 2/4/99 by Victor Rachels for d1x keys
3065 //--------- Read primary weapon select -------------
3066 //the following "if" added by WraithX to stop deadies from switchin weapons, 4/14/00
3067 if (!Player_is_dead)
3070 int d2x_joystick_state[10];
3073 d2x_joystick_state[i] = joy_get_button_state(kc_d2x[i*2+1].value);
3076 //----------------Weapon 1----------------
3077 if(key_down_count(kc_d2x[0].value) ||
3078 (joy_get_button_state(kc_d2x[1].value) &&
3079 (d2x_joystick_state[0]!=d2x_joystick_ostate[0]) ) )
3082 do_weapon_select(0,0);
3084 for(i=MAX_PRIMARY_WEAPONS;i<MAX_PRIMARY_WEAPONS+NEWPRIMS;i++)
3085 if(primary_order[i]>primary_order[valu]&&player_has_weapon(i,0))
3087 LaserPowSelected = valu;
3090 //----------------Weapon 2----------------
3091 if(key_down_count(kc_d2x[2].value) ||
3092 (joy_get_button_state(kc_d2x[3].value) &&
3093 (d2x_joystick_state[1]!=d2x_joystick_ostate[1]) ) )
3094 do_weapon_select(1,0);
3095 //----------------Weapon 3----------------
3096 if(key_down_count(kc_d2x[4].value) ||
3097 (joy_get_button_state(kc_d2x[5].value) &&
3098 (d2x_joystick_state[2]!=d2x_joystick_ostate[2]) ) )
3099 do_weapon_select(2,0);
3100 //----------------Weapon 4----------------
3101 if(key_down_count(kc_d2x[6].value) ||
3102 (joy_get_button_state(kc_d2x[7].value) &&
3103 (d2x_joystick_state[3]!=d2x_joystick_ostate[3]) ) )
3104 do_weapon_select(3,0);
3105 //----------------Weapon 5----------------
3106 if(key_down_count(kc_d2x[8].value) ||
3107 (joy_get_button_state(kc_d2x[9].value) &&
3108 (d2x_joystick_state[4]!=d2x_joystick_ostate[4]) ) )
3109 do_weapon_select(4,0);
3111 //--------- Read secondary weapon select ----------
3112 //----------------Weapon 6----------------
3113 if(key_down_count(kc_d2x[10].value) ||
3114 (joy_get_button_state(kc_d2x[11].value) &&
3115 (d2x_joystick_state[5]!=d2x_joystick_ostate[5]) ) )
3116 do_weapon_select(0,1);
3117 //----------------Weapon 7----------------
3118 if(key_down_count(kc_d2x[12].value) ||
3119 (joy_get_button_state(kc_d2x[13].value) &&
3120 (d2x_joystick_state[6]!=d2x_joystick_ostate[6]) ) )
3121 do_weapon_select(1,1);
3122 //----------------Weapon 8----------------
3123 if(key_down_count(kc_d2x[14].value) ||
3124 (joy_get_button_state(kc_d2x[15].value) &&
3125 (d2x_joystick_state[7]!=d2x_joystick_ostate[7]) ) )
3126 do_weapon_select(2,1);
3127 //----------------Weapon 9----------------
3128 if(key_down_count(kc_d2x[16].value) ||
3129 (joy_get_button_state(kc_d2x[17].value) &&
3130 (d2x_joystick_state[8]!=d2x_joystick_ostate[8]) ) )
3131 do_weapon_select(3,1);
3132 //----------------Weapon 0----------------
3133 if(key_down_count(kc_d2x[18].value) ||
3134 (joy_get_button_state(kc_d2x[19].value) &&
3135 (d2x_joystick_state[9]!=d2x_joystick_ostate[9]) ) )
3136 do_weapon_select(4,1);
3137 memcpy(d2x_joystick_ostate,d2x_joystick_state,10*sizeof(int));
3139 //end this section addition - VR
3142 }//end "if (!Player_is_dead)" - WraithX
3146 //------------- Read slide_on -------------
3149 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
3150 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
3152 if ((use_joystick)&&(kc_joystick[5].value<255)) slide_on |= joy_get_button_state( kc_joystick[5].value );
3154 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
3156 //------------- Read bank_on ---------------
3159 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
3160 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
3162 if ( (use_joystick)&&(kc_joystick[10].value < 255 )) bank_on |= joy_get_button_state( kc_joystick[10].value );
3164 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
3166 //------------ Read pitch_time -----------
3168 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
3170 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
3171 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
3172 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
3173 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
3176 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
3177 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
3178 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
3179 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
3182 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3183 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
3184 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
3188 Controls.pitch_time = 0;
3190 if (Controls.pitch_time < 0)
3191 Controls.pitch_time = 0;
3193 if (Controls.pitch_time > 0)
3194 Controls.pitch_time = 0;
3195 Controls.pitch_time += kp;
3198 if ( (use_joystick)&&(kc_joystick[13].value < 255 )) {
3199 if ( !kc_joystick[14].value ) // If not inverted...
3200 Controls.pitch_time -= (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
3202 Controls.pitch_time += (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
3206 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
3207 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
3208 if ( !kc_mouse[14].value ) // If not inverted...
3209 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
3211 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
3214 Controls.pitch_time = 0;
3218 // the following "if" added by WraithX, 4/14/00
3219 // done so that dead players can't move
3220 if (!Player_is_dead)
3222 //----------- Read vertical_thrust_time -----------------
3225 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
3226 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
3227 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
3228 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
3231 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
3232 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
3233 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
3234 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
3237 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3238 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
3239 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
3243 if ((use_joystick)&&( kc_joystick[13].value < 255 )) {
3244 if ( !kc_joystick[14].value ) // If not inverted...
3245 Controls.vertical_thrust_time += joy_axis[kc_joystick[13].value];
3247 Controls.vertical_thrust_time -= joy_axis[kc_joystick[13].value];
3251 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
3252 if ( !kc_mouse[14].value ) // If not inverted...
3253 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
3255 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
3260 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
3261 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
3262 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
3263 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
3266 if ((use_joystick)&&( kc_joystick[19].value < 255 )) {
3267 if ( !kc_joystick[20].value ) // If not inverted...
3268 Controls.vertical_thrust_time += joy_axis[kc_joystick[19].value];
3270 Controls.vertical_thrust_time -= joy_axis[kc_joystick[19].value];
3273 // From joystick buttons
3274 if ( (use_joystick)&&(kc_joystick[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_joystick[8].value );
3275 if ( (use_joystick)&&(kc_joystick[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_joystick[9].value );
3277 // From mouse buttons
3278 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
3279 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
3282 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
3283 if ( !kc_mouse[20].value ) // If not inverted...
3284 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
3286 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
3290 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3291 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
3292 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
3294 }// end "if" added by WraithX
3296 //---------- Read heading_time -----------
3298 if (!slide_on && !bank_on) {
3299 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
3301 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
3302 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
3303 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
3304 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
3307 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
3308 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
3309 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
3310 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
3313 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3314 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
3315 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
3319 Controls.heading_time = 0;
3321 if (Controls.heading_time < 0)
3322 Controls.heading_time = 0;
3324 if (Controls.heading_time > 0)
3325 Controls.heading_time = 0;
3326 Controls.heading_time += kh;
3329 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
3330 if ( !kc_joystick[16].value ) // If not inverted...
3331 Controls.heading_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3333 Controls.heading_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3337 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3338 if ( !kc_mouse[16].value ) // If not inverted...
3339 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3341 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3344 Controls.heading_time = 0;
3347 // the following "if" added by WraithX, 4/14/00
3348 // done so that dead players can't move
3349 if (!Player_is_dead)
3351 //----------- Read sideways_thrust_time -----------------
3354 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3355 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3356 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3357 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3360 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
3361 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
3362 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
3363 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
3366 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
3367 if ( !kc_joystick[16].value ) // If not inverted...
3368 Controls.sideways_thrust_time += joy_axis[kc_joystick[15].value];
3370 Controls.sideways_thrust_time -= joy_axis[kc_joystick[15].value];
3374 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3375 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
3376 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
3380 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3381 if ( !kc_mouse[16].value ) // If not inverted...
3382 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
3384 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
3389 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
3390 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
3391 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
3392 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
3395 if ( (use_joystick)&&(kc_joystick[17].value < 255 )) {
3396 if ( !kc_joystick[18].value ) // If not inverted...
3397 Controls.sideways_thrust_time -= joy_axis[kc_joystick[17].value];
3399 Controls.sideways_thrust_time += joy_axis[kc_joystick[17].value];
3402 // From joystick buttons
3403 if ( (use_joystick)&&(kc_joystick[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_joystick[6].value );
3404 if ( (use_joystick)&&(kc_joystick[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_joystick[7].value );
3406 // From mouse buttons
3407 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
3408 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
3411 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
3412 if ( !kc_mouse[18].value ) // If not inverted...
3413 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
3415 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
3417 }// end "if" added by WraithX
3419 //----------- Read bank_time -----------------
3422 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3423 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3424 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3425 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3428 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
3429 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
3430 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
3431 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
3434 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3435 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
3436 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
3440 if ( (use_joystick)&&(kc_joystick[15].value < 255) ) {
3441 if ( !kc_joystick[16].value ) // If not inverted...
3442 Controls.bank_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3444 Controls.bank_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3448 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3449 if ( !kc_mouse[16].value ) // If not inverted...
3450 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3452 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3457 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
3458 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
3459 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
3460 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
3463 if ( (use_joystick)&&(kc_joystick[21].value < 255) ) {
3464 if ( !kc_joystick[22].value ) // If not inverted...
3465 Controls.bank_time -= joy_axis[kc_joystick[21].value];
3467 Controls.bank_time += joy_axis[kc_joystick[21].value];
3470 // From joystick buttons
3471 if ( (use_joystick)&&(kc_joystick[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_joystick[11].value );
3472 if ( (use_joystick)&&(kc_joystick[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_joystick[12].value );
3474 // From mouse buttons
3475 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
3476 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
3479 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
3480 if ( !kc_mouse[22].value ) // If not inverted...
3481 Controls.bank_time += mouse_axis[kc_mouse[21].value];
3483 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
3487 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3488 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
3489 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
3492 // the following "if" added by WraithX, 4/14/00
3493 // done so that dead players can't move
3494 if (!Player_is_dead)
3496 //----------- Read forward_thrust_time -------------
3499 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
3500 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
3501 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
3502 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
3505 if ( (use_joystick)&&(kc_joystick[23].value < 255 )) {
3506 if ( !kc_joystick[24].value ) // If not inverted...
3507 Controls.forward_thrust_time -= joy_axis[kc_joystick[23].value];
3509 Controls.forward_thrust_time += joy_axis[kc_joystick[23].value];
3512 // From joystick buttons
3513 if ( (use_joystick)&&(kc_joystick[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_joystick[2].value );
3514 if ( (use_joystick)&&(kc_joystick[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_joystick[3].value );
3517 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
3518 if ( !kc_mouse[24].value ) // If not inverted...
3519 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
3521 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
3524 // From mouse buttons
3525 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
3526 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
3528 //----------- Read afterburner_state -------------
3531 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
3532 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
3534 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
3536 if ( (use_joystick)&&(kc_joystick[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_joystick[27].value);
3538 //-------Read headlight key--------------------------
3540 if (kc_keyboard[52].value < 255 )
3541 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
3542 if (kc_keyboard[53].value < 255 )
3543 Controls.headlight_count+=key_down_count(kc_keyboard[53].value);
3544 if ((use_joystick)&&(kc_joystick[30].value < 255 ))
3545 Controls.headlight_count+=joy_get_button_down_cnt(kc_joystick[30].value);
3547 //--------Read Cycle Primary Key------------------
3549 if (kc_keyboard[48].value<255)
3550 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
3551 if (kc_keyboard[49].value<255)
3552 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
3553 if ((use_joystick)&&(kc_joystick[28].value < 255 ))
3554 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_joystick[28].value);
3557 //--------Read Cycle Secondary Key------------------
3559 if (kc_keyboard[50].value<255)
3560 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
3561 if (kc_keyboard[51].value<255)
3562 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
3563 if ((use_joystick)&&(kc_joystick[29].value < 255 ))
3564 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_joystick[29].value);
3566 //--------Read Toggle Bomb key----------------------
3568 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
3570 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
3572 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
3573 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
3575 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3576 HUD_init_message ("No bombs available!");
3580 if (Players[Player_num].secondary_ammo[bomb]==0)
3582 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3583 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
3587 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
3588 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
3593 //---------Read Energy->Shield key----------
3595 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
3596 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
3597 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
3598 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
3600 //----------- Read fire_primary_down_count
3601 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
3602 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
3603 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_joystick[0].value);
3604 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
3606 //----------- Read fire_primary_state
3607 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
3608 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
3609 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_joystick[0].value);
3610 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
3612 //----------- Read fire_secondary_down_count
3613 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
3614 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
3615 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_joystick[1].value);
3616 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
3618 //----------- Read fire_secondary_state
3619 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
3620 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
3621 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_joystick[1].value);
3622 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
3624 //----------- Read fire_flare_down_count
3625 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
3626 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
3627 if ((use_joystick)&&(kc_joystick[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_joystick[4].value);
3628 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
3630 //----------- Read drop_bomb_down_count
3631 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
3632 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
3633 if ((use_joystick)&&(kc_joystick[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_joystick[26].value);
3634 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
3636 //----------- Read rear_view_down_count
3637 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
3638 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
3639 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_joystick[25].value);
3640 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
3642 //----------- Read rear_view_down_state
3643 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
3644 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
3645 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_joystick[25].value);
3646 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
3648 }//end "if" added by WraithX
3650 //----------- Read automap_down_count
3651 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
3652 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
3654 //----------- Read automap_state
3655 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
3656 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
3658 //----------- Read stupid-cruise-control-type of throttle.
3660 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
3661 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
3662 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
3663 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
3664 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
3666 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
3669 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
3670 if (Cruise_speed < 0 ) Cruise_speed = 0;
3672 if (Controls.forward_thrust_time==0)
3673 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
3676 #if !defined(MACINTOSH)
3677 //read_head_tracker();
3679 // Read external controls
3680 // if (kc_use_external_control || CybermouseActive)
3681 // kconfig_read_external_controls();
3684 //----------- Clamp values between -FrameTime and FrameTime
3685 if (FrameTime > F1_0 )
3686 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
3688 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
3689 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
3690 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
3691 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
3692 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
3693 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
3694 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
3696 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
3697 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
3698 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
3699 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
3700 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
3701 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
3702 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
3705 //--------- Don't do anything if in debug mode
3707 if ( keyd_pressed[KEY_DELETE] ) {
3708 memset( &Controls, 0, sizeof(control_info) );
3714 void reset_cruise(void)
3720 void kc_set_controls()
3724 for (i=0; i<NUM_KEY_CONTROLS; i++ )
3725 kc_keyboard[i].value = kconfig_settings[0][i];
3727 if ( (Config_control_type>0) && (Config_control_type<5)) {
3728 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3729 kc_joystick[i].value = kconfig_settings[Config_control_type][i];
3730 if (kc_joystick[i].type == BT_INVERT ) {
3731 if (kc_joystick[i].value!=1)
3732 kc_joystick[i].value = 0;
3733 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
3736 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
3737 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3738 kc_mouse[i].value = kconfig_settings[Config_control_type][i];
3739 if (kc_mouse[i].type == BT_INVERT ) {
3740 if (kc_mouse[i].value!=1)
3741 kc_mouse[i].value = 0;
3742 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
3745 } else if (Config_control_type == CONTROL_WINJOYSTICK) {
3746 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3747 kc_superjoy[i].value = kconfig_settings[Config_control_type][i];
3748 if (kc_superjoy[i].type == BT_INVERT ) {
3749 if (kc_superjoy[i].value!=1)
3750 kc_superjoy[i].value = 0;
3751 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
3757 for (i=0; i<NUM_D2X_CONTROLS; i++ )
3758 kc_d2x[i].value = kconfig_d2x_settings[i];
3762 #if 0 //ndef MACINTOSH // no mac support for vr headset
3764 void kconfig_center_headset()
3768 vfx_center_headset();
3770 // } else if (iglasses_headset_installed) {
3771 // } else if (Victor_headset_installed) {
3777 #endif // end of #ifndef MACINTOSH for kconfig_center_headset
3779 void CybermouseAdjust ()
3781 /* if ( Player_num > -1 ) {
3782 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3783 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3784 Auto_leveling_on = 0;
3786 if ( kc_external_version > 0 ) {
3787 vms_matrix tempm, ViewMatrix;
3788 vms_angvec * Kconfig_abs_movement;
3791 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
3793 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3794 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3795 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3796 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3798 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3799 if (oem_message[0] != '\0' )
3800 HUD_init_message( oem_message );
3804 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3805 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3806 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3807 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3808 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3809 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3810 // Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3811 // Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3812 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3813 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3814 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3815 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3816 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3817 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3818 // Controls.automap_down_count += kc_external_control->automap_down_count;
3819 // Controls.automap_state |= kc_external_control->automap_state;
3822 char GetKeyValue (char key)
3824 mprintf ((0,"Returning %c!\n",kc_keyboard[(int)key].value));
3825 return (kc_keyboard[(int)key].value);
3828 #if !defined(MACINTOSH)
3831 extern object *obj_find_first_of_type (int);
3832 void kconfig_read_external_controls()
3837 if ( !kc_enable_external_control ) return;
3839 if ( kc_external_version == 0 )
3840 memset( kc_external_control, 0, sizeof(ext_control_info));
3841 else if ( kc_external_version > 0 ) {
3843 if (kc_external_version>=4)
3844 memset( kc_external_control, 0, sizeof(advanced_ext_control_info));
3845 else if (kc_external_version>0)
3846 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 );
3847 else if (kc_external_version>2)
3848 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof(vms_matrix) +4 );
3850 if ( kc_external_version > 1 ) {
3851 // Write ship pos and angles to external controls...
3852 ubyte *temp_ptr = (ubyte *)kc_external_control;
3853 vms_vector *ship_pos;
3854 vms_matrix *ship_orient;
3855 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
3856 temp_ptr += sizeof(ext_control_info) + sizeof(vms_angvec) + 64;
3857 ship_pos = (vms_vector *)temp_ptr;
3858 temp_ptr += sizeof(vms_vector);
3859 ship_orient = (vms_matrix *)temp_ptr;
3860 // Fill in ship postion...
3861 *ship_pos = Objects[Players[Player_num].objnum].pos;
3862 // Fill in ship orientation...
3863 *ship_orient = Objects[Players[Player_num].objnum].orient;
3865 if (kc_external_version>=4)
3867 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3869 temp_ptr->headlight_state=(Players[Player_num].flags & PLAYER_FLAGS_HEADLIGHT_ON);
3870 temp_ptr->primary_weapon_flags=Players[Player_num].primary_weapon_flags;
3871 temp_ptr->secondary_weapon_flags=Players[Player_num].secondary_weapon_flags;
3872 temp_ptr->current_primary_weapon=Primary_weapon;
3873 temp_ptr->current_secondary_weapon=Secondary_weapon;
3875 temp_ptr->current_guidebot_command=Escort_goal_object;
3877 temp_ptr->force_vector=ExtForceVec;
3878 temp_ptr->force_matrix=ExtApplyForceMatrix;
3880 temp_ptr->joltinfo[i]=ExtJoltInfo[i];
3882 temp_ptr->x_vibrate_info[i]=ExtXVibrateInfo[i];
3883 temp_ptr->x_vibrate_clear=ExtXVibrateClear;
3884 temp_ptr->game_status=ExtGameStatus;
3886 memset ((void *)&ExtForceVec,0,sizeof(vms_vector));
3887 memset ((void *)&ExtApplyForceMatrix,0,sizeof(vms_matrix));
3892 ExtXVibrateInfo[i]=0;
3897 if ( Automap_active ) // (If in automap...)
3898 kc_external_control->automap_state = 1;
3899 //memset(&r,0,sizeof(r));
3903 int386 ( kc_external_intno, &r, &r); // Read external info...
3907 if ( Player_num > -1 ) {
3908 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3909 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3910 Auto_leveling_on = 0;
3912 if ( kc_external_version > 0 ) {
3913 vms_matrix tempm, ViewMatrix;
3914 vms_angvec * Kconfig_abs_movement;
3917 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(ext_control_info));
3919 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3920 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3921 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3922 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3924 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3925 if (oem_message[0] != '\0' )
3926 HUD_init_message( oem_message );
3930 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3931 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3932 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3933 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3934 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3935 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3936 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3937 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3938 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3939 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3940 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3941 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3942 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3943 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3944 Controls.automap_down_count += kc_external_control->automap_down_count;
3945 Controls.automap_state |= kc_external_control->automap_state;
3947 if (kc_external_version>=3)
3949 ubyte *temp_ptr = (ubyte *)kc_external_control;
3950 temp_ptr += (sizeof(ext_control_info) + sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof (vms_matrix));
3953 Controls.cycle_primary_count=(*(temp_ptr));
3955 Controls.cycle_secondary_count=(*(temp_ptr+1));
3958 Controls.afterburner_state=(*(temp_ptr+2));
3960 Controls.headlight_count=(*(temp_ptr+3));
3962 if (kc_external_version>=4)
3965 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3968 if (temp_ptr->keyboard[i])
3971 if (temp_ptr->Reactor_blown)
3973 if (Game_mode & GM_MULTI)
3974 net_destroy_controlcen (obj_find_first_of_type (OBJ_CNTRLCEN));
3976 do_controlcen_destroyed_stuff(obj_find_first_of_type (OBJ_CNTRLCEN));