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.
20 static char rcsid[] = "$Id: kconfig.c,v 1.14 2002-09-19 03:45:14 btb Exp $";
33 #include "pa_enabl.h" //$$POLY_ACC
79 ubyte ExtGameStatus=1;
81 vms_vector ExtForceVec;
82 vms_matrix ExtApplyForceMatrix;
84 int ExtJoltInfo[3]={0,0,0};
85 int ExtXVibrateInfo[2]={0,0};
86 int ExtYVibrateInfo[2]={0,0};
87 ubyte ExtXVibrateClear=0;
88 ubyte ExtYVibrateClear=0;
90 #define TABLE_CREATION 1
92 // Array used to 'blink' the cursor while waiting for a keypress.
93 byte 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 };
95 //char * invert_text[2] = { "N", "Y" };
96 //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" };
97 //char * joyaxis_text[4] = { "X1", "Y1", "X2", "Y2" };
98 //char * mouseaxis_text[2] = { "L/R", "F/B" };
99 //char * mousebutton_text[3] = { "Left", "Right", "Mid" };
101 int invert_text[2] = { TNUM_N, TNUM_Y };
104 int joybutton_text[28] =
105 { TNUM_BTN_1, TNUM_BTN_2, TNUM_BTN_3, TNUM_BTN_4,
109 TNUM_HAT_L, TNUM_HAT_R, TNUM_HAT_U, TNUM_HAT_D,
113 int joyaxis_text[7] = { TNUM_X1, TNUM_Y1, TNUM_Z1, TNUM_UN, TNUM_P1,TNUM_R1,TNUM_YA1 };
115 int joybutton_text[28] =
116 { TNUM_BTN_1, TNUM_BTN_2, TNUM_BTN_3, TNUM_BTN_4,
117 -1, TNUM_TRIG, TNUM_LEFT, TNUM_HAT_L,
118 TNUM_RIGHT, -1, TNUM_HAT2_D, TNUM_HAT_R,
119 TNUM_MID, -1, TNUM_HAT2_R, TNUM_HAT_U,
120 TNUM_HAT2_L, -1, TNUM_HAT2_U, TNUM_HAT_D,
121 TNUM_TRIG, TNUM_LEFT, TNUM_RIGHT, -1,
122 TNUM_UP, TNUM_DOWN, TNUM_LEFT, TNUM_RIGHT };
124 int joyaxis_text[7] = { TNUM_X1, TNUM_Y1, TNUM_Z1, TNUM_UN, TNUM_P1,TNUM_R1,TNUM_YA1 };
125 // int joyaxis_text[4] = { TNUM_X1, TNUM_Y1, TNUM_X2, TNUM_Y2 };
128 int mouseaxis_text[3] = { TNUM_L_R, TNUM_F_B, TNUM_Z1 };
130 int mousebutton_text[3] = { TNUM_LEFT, TNUM_RIGHT, TNUM_MID };
131 char * mousebutton_textra[13] = { "M4", "M5", "M6", "M7", "M8", "M9", "M10","M11","M12","M13","M14","M15","M16" };//text for buttons above 3. -MPM
133 char *mousebutton_text[3] = { "Btn", "", "" }; // only one silly mouse button on the mac
137 char * key_text[256] = {
138 "","S","D","F","H","G","Z","X","C","V","","B","Q", "W", "E", "R",
139 "Y","T","1","2","3","4","6","5","=","9","7","-", "8", "0", "]", "O",
140 "U","[","I","P","RET","L","J","'","K", ";", "\\", ",", "/", "N", "M", ".",
141 "TAB","SPC","`","DEL","","ESC","","APL","SHIFT","CAPSL","OPTN","CTRL","","","","A",
142 "","PAD.","","PAD*","","PAD+","","NMLCK","","","","PAD/","ENTER","","PAD-","",
143 "","PAD=","PAD0","PAD1","PAD2","PAD3","PAD4","PAD5","PAD6","PAD7","","PAD8","PAD9","","","",
144 "F5","F6","F7","","F8","F9","","F11","","F13","","F14","","F10","","F12",
145 "","PAUSE","HELP","HOME","PGUP","DEL","","END","F2","","F1","LARW","RARW","DARW","UARW","",
146 "","","","","","","","","","","","","","","","",
147 "","","","","","","","","","","","","","","","",
148 "","","","","","","","","","","","","","","","",
149 "","","","","","","","","","","","","","","","",
150 "","","","","","","","","","","","","","","","",
151 "","","","","","","","","","","","","","","","",
152 "","","","","","","","","","","","","","","","",
153 "","","","","","","","","","","","","","","",""};
155 #if !defined OGL && !defined SDL_INPUT
156 char * key_text[256] = { \
157 "","ESC","1","2","3","4","5","6","7","8","9","0","-", \
158 "=","BSPC","TAB","Q","W","E","R","T","Y","U","I","O", \
159 "P","[","]","
\83","LCTRL","A","S","D","F", \
160 "G","H","J","K","L",";","'","`", \
161 "LSHFT","\\","Z","X","C","V","B","N","M",",", \
162 ".","/","RSHFT","PAD*","LALT","SPC", \
163 "CPSLK","F1","F2","F3","F4","F5","F6","F7","F8","F9", \
164 "F10","NMLCK","SCLK","PAD7","PAD8","PAD9","PAD-", \
165 "PAD4","PAD5","PAD6","PAD+","PAD1","PAD2","PAD3","PAD0", \
166 "PAD.","","","","F11","F12","","","","","","","","","", \
167 "","","","","","","","","","","","","","","","","","","","", \
168 "","","","","","","","","","","","","","","","","","","","", \
169 "","","","","","","","","","","","","","","","","","", \
170 "PAD
\83","RCTRL","","","","","","","","","","","","","", \
171 "","","","","","","","","","","PAD/","","","RALT","", \
172 "","","","","","","","","","","","","","HOME","
\82","PGUP", \
173 "","
\81","","
\7f","","END","
\80","PGDN","INS", \
174 "DEL","","","","","","","","","","","","","","","","","", \
175 "","","","","","","","","","","","","","","","","","","","", \
176 "","","","","","","" };
180 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 };
182 //extern void GameLoop(int, int );
184 extern void transfer_energy_to_shield(fix);
185 extern void CyclePrimary(),CycleSecondary(),InitMarkerInput();
186 extern ubyte DefiningMarkerMessage;
187 extern char CybermouseActive;
190 extern int joydefsw_do_button();
191 extern int joydefsw_do_winjoybutton(int *axis);
192 extern joydefsw_win_joyselect(char *title);
195 control_info Controls;
199 // macros for drawing lo/hi res kconfig screens (see scores.c as well)
201 #define LHX(x) ((x)*(MenuHires?2:1))
202 #define LHY(y) ((y)*(MenuHires?2.4:1))
206 #define BT_MOUSE_BUTTON 1
207 #define BT_MOUSE_AXIS 2
208 #define BT_JOY_BUTTON 3
209 #define BT_JOY_AXIS 4
212 char *btype_text[] = { "BT_KEY", "BT_MOUSE_BUTTON", "BT_MOUSE_AXIS", "BT_JOY_BUTTON", "BT_JOY_AXIS", "BT_INVERT" };
216 typedef struct kc_item {
217 short id; // The id of this item
225 ubyte value; // what key,button,etc
231 ubyte kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS];
233 //----------- WARNING!!!!!!! -------------------------------------------
234 // THESE NEXT FOUR BLOCKS OF DATA ARE GENERATED BY PRESSING DEL+F12 WHEN
235 // IN THE KEYBOARD CONFIG SCREEN. BASICALLY, THAT PROCEDURE MODIFIES THE
236 // U,D,L,R FIELDS OF THE ARRAYS AND DUMPS THE NEW ARRAYS INTO KCONFIG.COD
237 //-------------------------------------------------------------------------
238 /*ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
239 {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},
240 {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},
241 {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},
242 {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},
243 {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},
244 {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},
245 {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},
249 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
250 {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},
251 {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},
252 {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},
253 {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},
254 {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},
255 {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},
256 {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},
258 {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},
264 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
265 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
266 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
267 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
268 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
269 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
270 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
271 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
272 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
273 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
274 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
275 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
276 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
277 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
278 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
279 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
280 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
281 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
282 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
283 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
284 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
285 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
286 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
287 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
288 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
289 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
290 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
291 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
292 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
293 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
294 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
295 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
296 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
297 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
298 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
299 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
300 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
301 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
302 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
303 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
304 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
305 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
306 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
307 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
308 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
309 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
310 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
311 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
312 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
313 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
314 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
315 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
316 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
317 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
318 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
319 { 54,158,171, 83, 26, 52, 56, 51, 55,"Energy->Shield", BT_KEY, 255 },
320 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
321 { 56,158,179,83, 26, 54, 0, 0, 0, "Toggle Bomb", BT_KEY,255},
323 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
324 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
325 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
326 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
327 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
328 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
329 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
330 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
331 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
332 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
333 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
334 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
335 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
336 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
337 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
338 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
339 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
340 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
341 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
342 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
343 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
344 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
345 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
346 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
347 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
348 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
349 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
350 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
351 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
352 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
353 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
354 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
356 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
357 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
358 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
359 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
360 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
361 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
362 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
363 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
364 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
365 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
366 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
367 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
368 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
369 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
370 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
371 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
372 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
373 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
374 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
375 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
376 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
377 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
378 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
379 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
380 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
381 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
382 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
383 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
384 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
385 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
386 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
387 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
390 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
391 { 0, 25, 46, 85, 26, 12, 1, 24, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
392 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
393 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
394 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
395 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
396 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
397 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
398 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
399 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
400 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
401 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
402 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
403 { 12,180,106, 59, 26, 11, 0, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
404 { 13,103,138, 58, 26, 27, 15, 25, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
405 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
406 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
407 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
408 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
409 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
410 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
411 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
412 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
413 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
414 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
415 { 24,103,182,106, 8, 22, 5, 23, 0,"throttle", BT_INVERT, 255 },
416 { 25, 25,109, 85, 26, 3, 27, 12, 13,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
417 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
418 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
421 #else // ifndef MACINTOSH (following are macintosh controls)
423 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
424 {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},
425 {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},
426 {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},
427 {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},
428 {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},
429 {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},
430 {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},
433 ubyte default_firebird_settings[MAX_CONTROLS] =
434 {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};
436 ubyte default_mousestick_settings[MAX_CONTROLS] =
437 {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};
439 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
440 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
441 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
442 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
443 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
444 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
445 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
446 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
447 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
448 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
449 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
450 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
451 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
452 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
453 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
454 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
455 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
456 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
457 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
458 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
459 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
460 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
461 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
462 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
463 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
464 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
465 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
466 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
467 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
468 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
469 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
470 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
471 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
472 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
473 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
474 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
475 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
476 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
477 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
478 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
479 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
480 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
481 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
482 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
483 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
484 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
485 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
486 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
487 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
488 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
489 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
490 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
491 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
492 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
493 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
494 { 54,158,171, 83, 26, 52, 25, 51, 55,"Energy->Shield", BT_KEY, 255 },
495 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
497 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
498 { 0, 25, 46, 85, 28, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
499 { 1, 25, 54, 85, 28, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
500 { 2, 25, 85, 85, 28, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
501 { 3, 25, 93, 85, 28, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
502 { 4, 25, 62, 85, 28, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
503 { 5,180, 46, 79, 28, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
504 { 6,180, 54, 79, 28, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
505 { 7,180, 62, 79, 28, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
506 { 8,180, 70, 79, 28, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
507 { 9,180, 78, 79, 28, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
508 { 10,180, 90, 79, 28, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
509 { 11,180, 98, 79, 28, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
510 { 12,180,106, 79, 28, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
511 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
512 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
513 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
514 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
515 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
516 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
517 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
518 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
519 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
520 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
521 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
522 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
523 { 25, 25,109, 85, 28, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
524 { 26, 25, 70, 85, 28, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
525 { 27, 25,117, 85, 28, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
526 { 28,180,114, 79, 28, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
527 { 29,180,122, 79, 28, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
528 { 30, 25,125, 85, 28, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
530 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
531 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
532 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
533 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
534 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
535 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
536 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
537 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
538 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
539 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
540 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
541 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
542 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
543 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
544 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
545 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
546 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
547 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
548 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
549 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
550 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
551 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
552 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
553 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
554 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
555 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
556 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
557 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
558 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
559 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
560 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
561 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
564 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
565 { 0, 25, 46, 85, 26, 28, 1, 28, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
566 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
567 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
568 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
569 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
570 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
571 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
572 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
573 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
574 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
575 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
576 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
577 { 12,180,106, 59, 26, 11, 28, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
578 { 13,103,138, 58, 26, 27, 15, 27, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
579 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
580 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
581 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
582 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
583 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
584 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
585 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
586 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
587 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
588 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
589 { 24,103,182,106, 8, 22, 5, 23, 28,"throttle", BT_INVERT, 255 },
590 { 25, 25,109, 85, 26, 3, 27, 12, 27,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
591 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
592 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
597 void kc_drawitem( kc_item *item, int is_current );
598 void kc_change_key( kc_item * item );
599 void kc_change_joybutton( kc_item * item );
600 void kc_change_mousebutton( kc_item * item );
601 void kc_change_joyaxis( kc_item * item );
602 void kc_change_mouseaxis( kc_item * item );
603 void kc_change_invert( kc_item * item );
604 void kconfig_read_fcs( int raw_axis );
605 void kconfig_set_fcs_button( int btn, int button );
606 void kconfig_read_external_controls( void );
608 int kconfig_is_axes_used(int axis)
611 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
612 if (( kc_joystick[i].type == BT_JOY_AXIS ) && (kc_joystick[i].value == axis ))
618 #ifdef TABLE_CREATION
619 int find_item_at( kc_item * items, int nitems, int x, int y )
623 for (i=0; i<nitems; i++ ) {
624 if ( ((items[i].x+items[i].w1)==x) && (items[i].y==y))
630 int find_next_item_up( kc_item * items, int nitems, int citem )
635 x = items[citem].x+items[citem].w1;
640 y = grd_curcanv->cv_bitmap.bm_h-1;
643 x = grd_curcanv->cv_bitmap.bm_w-1;
646 i = find_item_at( items, nitems, x, y );
652 int find_next_item_down( kc_item * items, int nitems, int citem )
657 x = items[citem].x+items[citem].w1;
661 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
664 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
668 i = find_item_at( items, nitems, x, y );
674 int find_next_item_right( kc_item * items, int nitems, int citem )
679 x = items[citem].x+items[citem].w1;
683 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
686 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
690 i = find_item_at( items, nitems, x, y );
696 int find_next_item_left( kc_item * items, int nitems, int citem )
701 x = items[citem].x+items[citem].w1;
706 x = grd_curcanv->cv_bitmap.bm_w-1;
709 y = grd_curcanv->cv_bitmap.bm_h-1;
712 i = find_item_at( items, nitems, x, y );
719 #if defined(MACINTOSH) || defined(WINDOWS)
720 int get_item_height(kc_item *item)
725 if (item->value==255) {
726 sprintf( btext, "" );
728 switch( item->type ) {
730 strncpy( btext, key_text[item->value], 10 ); break;
731 case BT_MOUSE_BUTTON:
733 strncpy( btext, Text_string[mousebutton_text[item->value]], 10); break;
735 strncpy( btext, mousebutton_text[item->value], 10 ); break;
738 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
740 if ( joybutton_text[item->value] !=-1 )
741 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
743 sprintf( btext, "BTN%d", item->value );
746 strncpy( btext, Text_string[joyaxis_text[item->value]], 10 ); break;
748 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
751 gr_get_string_size(btext, &w, &h, &aw );
757 void kconfig_sub(kc_item * items,int nitems, char * title)
760 dd_grs_canvas * save_canvas,
761 grs_canvas * save_canvas
763 grs_font * save_font;
765 #if defined(MACINTOSH) || defined(WINDOWS)
766 int mouse_state, omouse_state, mx, my, x1, x2, y1, y2;
767 int close_x, close_y, close_size;
770 int i,k,ocitem,citem;
771 int time_stopped = 0;
772 WIN(char *old_bg_pcx);
774 WIN(old_bg_pcx = _SCRContext.bkg_filename);
775 WIN(DEFINE_SCREEN(NULL));
780 if (!((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence)) )
786 // if (Config_control_type == CONTROL_WINJOYSTICK) {
788 // joydefsw_win_joyselect(title2); title = title2,
790 // ); // Get Samir...
794 save_canvas = dd_grd_curcanv,
795 save_canvas = grd_curcanv
800 dd_gr_set_current_canvas(NULL),
801 gr_set_current_canvas(NULL)
803 save_font = grd_curcanv->cv_font;
809 old_keyd_repeat = keyd_repeat;
812 //gr_clear_canvas( BM_XRGB(0,0,0) );
814 nm_draw_background(0,0,grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
815 gr_palette_load (gr_palette);
817 grd_curcanv->cv_font = MEDIUM3_FONT;
819 WIN(DDGRLOCK(dd_grd_curcanv));
822 p = strchr( title, '\n' );
824 gr_string( 0x8000, LHY(8), title );
829 // if ( items == kc_keyboard ) {
830 // gr_string( 0x8000, 8, "Keyboard" );
831 // } else if ( items == kc_joystick ) {
832 // gr_string( 0x8000, 8, "Joysticks" );
833 // } else if ( items == kc_mouse ) {
834 // gr_string( 0x8000, 8, "Mouse" );
837 #if defined(MACINTOSH) || defined(WINDOWS)
838 close_x = close_y = 15;
840 gr_setcolor( BM_XRGB(0, 0, 0) );
841 gr_rect(close_x, close_y, close_x + close_size, close_y + close_size);
842 gr_setcolor( BM_XRGB(21, 21, 21) );
843 gr_rect( close_x + 2, close_y + 2, close_x + close_size - 2, close_y + close_size -2 );
846 grd_curcanv->cv_font = GAME_FONT;
847 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
850 gr_string( 0x8000, LHY(20), TXT_KCONFIG_STRING_1 );
852 gr_string( 0x8000, LHY(20), "Enter changes, ctrl-d deletes, ctrl-r resets defaults, ESC exits");
854 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
855 if ( items == kc_keyboard ) {
856 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
857 gr_setcolor( BM_XRGB(31,27,6) );
859 gr_scanline( LHX(98), LHX(106), LHY(42) );
860 gr_scanline( LHX(120), LHX(128), LHY(42) );
861 gr_pixel( LHX(98), LHY(43) );
862 gr_pixel( LHX(98), LHY(44) );
863 gr_pixel( LHX(128), LHY(43) );
864 gr_pixel( LHX(128), LHY(44) );
866 gr_string( LHX(109), LHY(40), "OR" );
868 gr_scanline( LHX(253), LHX(261), LHY(42) );
869 gr_scanline( LHX(274), LHX(283), LHY(42) );
870 gr_pixel( LHX(253), LHY(43) );
871 gr_pixel( LHX(253), LHY(44) );
872 gr_pixel( LHX(283), LHY(43) );
873 gr_pixel( LHX(283), LHY(44) );
875 gr_string( LHX(264), LHY(40), "OR" );
877 } if ( items == kc_joystick ) {
878 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
879 gr_setcolor( BM_XRGB(31,27,6) );
880 gr_scanline( LHX(18), LHX(135), LHY(37) );
881 gr_scanline( LHX(181), LHX(294), LHY(37) );
882 gr_scanline( LHX(18), LHX(144), LHY(119+18) );
883 gr_scanline( LHX(174), LHX(294), LHY(119+18) );
884 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
885 gr_string( 0x8000,LHY(117+18), TXT_AXES );
886 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
887 gr_string( LHX(81), LHY(137+8), TXT_AXIS );
888 gr_string( LHX(111), LHY(137+8), TXT_INVERT );
889 gr_string( LHX(222), LHY(137+8), TXT_AXIS );
890 gr_string( LHX(252), LHY(137+8), TXT_INVERT );
891 } else if ( items == kc_mouse ) {
892 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
893 gr_setcolor( BM_XRGB(31,27,6) );
894 gr_scanline( LHX(18), LHX(135), LHY(37) );
895 gr_scanline( LHX(181), LHX(294), LHY(37) );
896 gr_scanline( LHX(18), LHX(144), LHY(119+5) );
897 gr_scanline( LHX(174), LHX(294), LHY(119+5) );
898 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
899 gr_string( 0x8000,LHY(117+5), TXT_AXES );
900 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
901 gr_string( LHX(169), LHY(129), TXT_AXIS );
902 gr_string( LHX(199), LHY(129), TXT_INVERT );
904 WIN(DDGRUNLOCK(dd_grd_curcanv));
906 for (i=0; i<nitems; i++ ) {
907 kc_drawitem( &items[i], 0 );
911 kc_drawitem( &items[citem], 1 );
916 #if defined(MACINTOSH) || defined(WINDOWS)
917 mouse_state = omouse_state = 0;
921 // Windows addendum to allow for kconfig input.
926 DoMessageStuff(&msg);
929 _RedrawScreen = FALSE;
931 dd_gr_set_current_canvas(NULL);
941 //see if redbook song needs to be restarted
942 songs_check_redbook_repeat();
946 #if defined(MACINTOSH) || defined(WINDOWS)
947 omouse_state = mouse_state;
948 mouse_state = mouse_button_state(0);
951 if ( !time_stopped ) {
953 if (multi_menu_poll() == -1)
962 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_3:)
963 case KEY_PRINT_SCREEN:
966 case KEY_CTRLED+KEY_D:
967 items[citem].value = 255;
968 kc_drawitem( &items[citem], 1 );
970 case KEY_CTRLED+KEY_R:
971 if ( items==kc_keyboard ) {
972 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
973 items[i].value=default_kconfig_settings[0][i];
974 kc_drawitem( &items[i], 0 );
978 // hack for firebire and mousestick default controls since I made
979 // them the same control type -- dumb dumb dumb
980 if (joy_have_firebird())
981 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
982 items[i].value = default_firebird_settings[i];
983 kc_drawitem( &items[i], 0 );
985 else if (joy_have_mousestick())
986 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
987 items[i].value = default_mousestick_settings[i];
988 kc_drawitem( &items[i], 0 );
991 #endif // note link to above else
992 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
993 items[i].value = default_kconfig_settings[Config_control_type][i];
994 kc_drawitem( &items[i], 0 );
997 kc_drawitem( &items[citem], 1 );
1000 items[citem].value=255;
1001 kc_drawitem( &items[citem], 1 );
1005 #ifdef TABLE_CREATION
1006 if (items[citem].u==-1) items[citem].u=find_next_item_up( items,nitems, citem);
1008 citem = items[citem].u;
1013 #ifdef TABLE_CREATION
1014 if (items[citem].d==-1) items[citem].d=find_next_item_down( items,nitems, citem);
1016 citem = items[citem].d;
1020 #ifdef TABLE_CREATION
1021 if (items[citem].l==-1) items[citem].l=find_next_item_left( items,nitems, citem);
1023 citem = items[citem].l;
1027 #ifdef TABLE_CREATION
1028 if (items[citem].r==-1) items[citem].r=find_next_item_right( items,nitems, citem);
1030 citem = items[citem].r;
1034 switch( items[citem].type ) {
1035 case BT_KEY: kc_change_key( &items[citem] ); break;
1036 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1037 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1038 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1039 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1040 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1045 grd_curcanv->cv_font = save_font;
1047 WIN(DEFINE_SCREEN(old_bg_pcx));
1050 dd_gr_set_current_canvas(save_canvas),
1051 gr_set_current_canvas( save_canvas )
1053 keyd_repeat = old_keyd_repeat;
1054 game_flush_inputs();
1055 WIN( HideCursorW());
1056 MAC( hide_cursor(); )
1060 #ifdef TABLE_CREATION
1061 case KEY_DEBUGGED+KEY_F12: {
1063 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1064 kc_keyboard[i].u = find_next_item_up( kc_keyboard,NUM_KEY_CONTROLS, i);
1065 kc_keyboard[i].d = find_next_item_down( kc_keyboard,NUM_KEY_CONTROLS, i);
1066 kc_keyboard[i].l = find_next_item_left( kc_keyboard,NUM_KEY_CONTROLS, i);
1067 kc_keyboard[i].r = find_next_item_right( kc_keyboard,NUM_KEY_CONTROLS, i);
1069 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1070 kc_joystick[i].u = find_next_item_up( kc_joystick,NUM_OTHER_CONTROLS, i);
1071 kc_joystick[i].d = find_next_item_down( kc_joystick,NUM_OTHER_CONTROLS, i);
1072 kc_joystick[i].l = find_next_item_left( kc_joystick,NUM_OTHER_CONTROLS, i);
1073 kc_joystick[i].r = find_next_item_right( kc_joystick,NUM_OTHER_CONTROLS, i);
1075 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1076 kc_mouse[i].u = find_next_item_up( kc_mouse,NUM_OTHER_CONTROLS, i);
1077 kc_mouse[i].d = find_next_item_down( kc_mouse,NUM_OTHER_CONTROLS, i);
1078 kc_mouse[i].l = find_next_item_left( kc_mouse,NUM_OTHER_CONTROLS, i);
1079 kc_mouse[i].r = find_next_item_right( kc_mouse,NUM_OTHER_CONTROLS, i);
1081 fp = fopen( "kconfig.cod", "wt" );
1083 fprintf( fp, "ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {\n" );
1084 for (i=0; i<CONTROL_MAX_TYPES; i++ ) {
1086 fprintf( fp, "{0x%x", kconfig_settings[i][0] );
1087 for (j=1; j<MAX_CONTROLS; j++ )
1088 fprintf( fp, ",0x%x", kconfig_settings[i][j] );
1089 fprintf( fp, "},\n" );
1091 fprintf( fp, "};\n" );
1093 fprintf( fp, "\nkc_item kc_keyboard[NUM_KEY_CONTROLS] = {\n" );
1094 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1095 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1096 kc_keyboard[i].id, kc_keyboard[i].x, kc_keyboard[i].y, kc_keyboard[i].w1, kc_keyboard[i].w2,
1097 kc_keyboard[i].u, kc_keyboard[i].d, kc_keyboard[i].l, kc_keyboard[i].r,
1098 34, kc_keyboard[i].text, 34, btype_text[kc_keyboard[i].type] );
1100 fprintf( fp, "};" );
1102 fprintf( fp, "\nkc_item kc_joystick[NUM_OTHER_CONTROLS] = {\n" );
1103 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1104 if (kc_joystick[i].type == BT_JOY_BUTTON)
1105 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1106 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1107 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1108 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1110 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1111 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1112 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1113 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1115 fprintf( fp, "};" );
1117 fprintf( fp, "\nkc_item kc_mouse[NUM_OTHER_CONTROLS] = {\n" );
1118 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1119 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1120 kc_mouse[i].id, kc_mouse[i].x, kc_mouse[i].y, kc_mouse[i].w1, kc_mouse[i].w2,
1121 kc_mouse[i].u, kc_mouse[i].d, kc_mouse[i].l, kc_mouse[i].r,
1122 34, kc_mouse[i].text, 34, btype_text[kc_mouse[i].type] );
1124 fprintf( fp, "};" );
1133 #if defined (MACINTOSH) || defined(WINDOWS)
1134 if ( (mouse_state && !omouse_state) || (mouse_state && omouse_state) ) {
1137 mouse_get_pos(&mx, &my);
1138 for (i=0; i<nitems; i++ ) {
1139 item_height = get_item_height( &items[i] );
1140 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[i].x) + LHX(items[i].w1);
1141 x2 = x1 + LHX(items[i].w2);
1142 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[i].y);
1143 y2 = y1 + LHX(item_height);
1144 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1150 else if ( !mouse_state && omouse_state ) {
1153 mouse_get_pos(&mx, &my);
1154 item_height = get_item_height( &items[citem] );
1155 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[citem].x) + LHX(items[citem].w1);
1156 x2 = x1 + LHX(items[citem].w2);
1157 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[citem].y);
1158 y2 = y1 + LHY(item_height);
1159 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1162 switch( items[citem].type ) {
1163 case BT_KEY: kc_change_key( &items[citem] ); break;
1164 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1165 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1166 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1167 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1168 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1173 x1 = grd_curcanv->cv_bitmap.bm_x + close_x + 2;
1174 x2 = x1 + close_size - 2;
1175 y1 = grd_curcanv->cv_bitmap.bm_y + close_y + 2;
1176 y2 = y1 + close_size - 2;
1177 if ( ((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2)) ) {
1178 grd_curcanv->cv_font = save_font;
1179 WINDOS(dd_gr_set_current_canvas( save_canvas ),
1180 gr_set_current_canvas( save_canvas ));
1181 keyd_repeat = old_keyd_repeat;
1182 game_flush_inputs();
1192 #endif // MACINTOSH WINDOWS
1194 if (ocitem!=citem) {
1197 kc_drawitem( &items[ocitem], 0 );
1198 kc_drawitem( &items[citem], 1 );
1206 void kc_drawitem( kc_item *item, int is_current )
1210 // PA_DFX (pa_set_frontbuffer_current());
1211 WIN(DDGRLOCK(dd_grd_curcanv));
1214 gr_set_fontcolor( BM_XRGB(20,20,29), -1 );
1216 gr_set_fontcolor( BM_XRGB(15,15,24), -1 );
1217 gr_string( LHX(item->x), LHY(item->y), item->text );
1218 WIN(DDGRUNLOCK(dd_grd_curcanv));
1220 if (item->value==255) {
1221 strcpy( btext, "" );
1223 switch( item->type ) {
1225 strncpy( btext, key_text[item->value], 10 ); break;
1226 case BT_MOUSE_BUTTON:
1228 strncpy( btext, Text_string[mousebutton_text[item->value]], 10 ); break;
1229 strncpy( btext, (item->value <= 3)?Text_string[mousebutton_text[item->value]]:mousebutton_textra[item->value-3], 10 ); break;
1231 strncpy( btext, mousebutton_text[item->value], 10 ); break;
1234 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
1238 if (joybutton_text[item->value] != -1)
1239 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1241 sprintf( btext, "BTN%2d", item->value+1 );
1243 if ( joybutton_text[item->value] !=-1 )
1244 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1246 sprintf( btext, "BTN%d", item->value );
1249 strncpy( btext, joy_btn_name( item->value ), 10);
1251 sprintf( btext, "BTN%d", item->value );
1255 strncpy( btext, Text_string[joyaxis_text[item->value]], 10 ); break;
1257 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
1261 WIN(DDGRLOCK(dd_grd_curcanv));
1262 gr_get_string_size(btext, &w, &h, &aw );
1265 gr_setcolor( BM_XRGB(21,0,24) );
1267 gr_setcolor( BM_XRGB(16,0,19) );
1268 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1270 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1272 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1274 gr_string( x, LHY(item->y), btext );
1275 // PA_DFX (pa_set_backbuffer_current());
1277 WIN(DDGRUNLOCK(dd_grd_curcanv));
1282 static int looper=0;
1284 void kc_drawquestion( kc_item *item )
1288 WIN(DDGRLOCK(dd_grd_curcanv));
1289 // PA_DFX (pa_set_frontbuffer_current());
1291 gr_get_string_size("?", &w, &h, &aw );
1293 c = BM_XRGB(21,0,24);
1295 //@@gr_setcolor( gr_fade_table[fades[looper]*256+c] );
1296 gr_setcolor(BM_XRGB(21*fades[looper]/31,0,24*fades[looper]/31));
1298 if (looper>63) looper=0;
1300 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1302 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1304 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1306 gr_string( x, LHY(item->y), "?" );
1307 // PA_DFX (pa_set_backbuffer_current());
1308 WIN(DDGRUNLOCK(dd_grd_curcanv));
1312 void kc_change_key( kc_item * item )
1317 WIN(DDGRLOCK(dd_grd_curcanv));
1318 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1320 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_KEY );
1321 WIN(DDGRUNLOCK(dd_grd_curcanv));
1323 game_flush_inputs();
1327 while( (k!=KEY_ESC) && (keycode==255) )
1333 DoMessageStuff(&msg);
1340 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1343 // if ( Game_mode & GM_MULTI )
1344 // GameLoop( 0, 0 ); // Continue
1347 kc_drawquestion( item );
1349 for (i=0; i<256; i++ ) {
1350 if (keyd_pressed[i] && (strlen(key_text[i])>0)) {
1352 for (n=0; n<sizeof(system_keys); n++ )
1353 if ( system_keys[n] == i )
1362 for (i=0; i<Num_items; i++ ) {
1363 n = item - All_items;
1364 if ( (i!=n) && (All_items[i].type==BT_KEY) && (All_items[i].value==keycode) ) {
1365 All_items[i].value = 255;
1366 kc_drawitem( &All_items[i], 0 );
1369 item->value = keycode;
1371 kc_drawitem( item, 1 );
1373 WIN(DDGRLOCK(dd_grd_curcanv));
1374 gr_set_fontcolor( BM_XRGB(28,28,28), BM_XRGB(0,0,0) );
1375 WIN(DDGRUNLOCK(dd_grd_curcanv));
1377 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1379 game_flush_inputs();
1383 void kc_change_joybutton( kc_item * item )
1388 WIN(DDGRLOCK(dd_grd_curcanv));
1389 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1391 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_JBUTTON );
1392 WIN(DDGRUNLOCK(dd_grd_curcanv));
1394 game_flush_inputs();
1398 while( (k!=KEY_ESC) && (code==255))
1403 DoMessageStuff(&msg);
1409 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1412 // if ( Game_mode & GM_MULTI )
1413 // GameLoop( 0, 0 ); // Continue
1417 if (k == KEY_PRINT_SCREEN)
1418 save_screen_shot(0);
1420 kc_drawquestion( item );
1422 WIN(code = joydefsw_do_button());
1425 code = joy_do_buttons();
1428 #if !defined(WINDOWS) && !defined(MACINTOSH)
1429 if (Config_control_type==CONTROL_THRUSTMASTER_FCS) {
1431 joystick_read_raw_axis( JOY_ALL_AXIS, axis );
1432 kconfig_read_fcs( axis[3] );
1433 if ( joy_get_button_state(7) ) code = 7;
1434 if ( joy_get_button_state(11) ) code = 11;
1435 if ( joy_get_button_state(15) ) code = 15;
1436 if ( joy_get_button_state(19) ) code = 19;
1437 for (i=0; i<4; i++ ) {
1438 if ( joy_get_button_state(i) )
1441 } else if (Config_control_type==CONTROL_FLIGHTSTICK_PRO) {
1442 for (i=4; i<20; i++ ) {
1443 if ( joy_get_button_state(i) ) {
1445 mprintf(( 0, "JB: %d\n", code ));
1449 for (i=0; i<MAX_BUTTONS; i++ ) {
1450 if ( joy_get_button_state(i) )
1457 for (i=0; i<Num_items; i++ ) {
1458 n = item - All_items;
1459 if ( (i!=n) && (All_items[i].type==BT_JOY_BUTTON) && (All_items[i].value==code) ) {
1460 All_items[i].value = 255;
1461 kc_drawitem( &All_items[i], 0 );
1466 kc_drawitem( item, 1 );
1467 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1468 game_flush_inputs();
1471 void kc_change_mousebutton( kc_item * item )
1476 WIN(DDGRLOCK(dd_grd_curcanv));
1477 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1479 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_MBUTTON );
1480 WIN(DDGRUNLOCK(dd_grd_curcanv));
1483 game_flush_inputs();
1487 while( (k!=KEY_ESC) && (code==255))
1492 DoMessageStuff(&msg);
1498 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1501 // if ( Game_mode & GM_MULTI )
1502 // GameLoop( 0, 0 ); // Continue
1506 if (k == KEY_PRINT_SCREEN)
1507 save_screen_shot(0);
1509 kc_drawquestion( item );
1511 b = mouse_get_btns();
1512 for (i = 0; i < 16; i++ ) {
1518 for (i=0; i<Num_items; i++ ) {
1519 n = item - All_items;
1520 if ( (i!=n) && (All_items[i].type==BT_MOUSE_BUTTON) && (All_items[i].value==code) ) {
1521 All_items[i].value = 255;
1522 kc_drawitem( &All_items[i], 0 );
1527 kc_drawitem( item, 1 );
1528 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1529 game_flush_inputs();
1533 void kc_change_joyaxis( kc_item * item )
1537 int old_axis[MAX_AXES];
1539 int axis[JOY_NUM_AXES];
1540 int old_axis[JOY_NUM_AXES];
1549 WIN(DDGRLOCK(dd_grd_curcanv));
1550 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1552 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_JOY_AXIS );
1553 WIN(DDGRUNLOCK(dd_grd_curcanv));
1555 game_flush_inputs();
1560 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, old_axis ),
1561 joystick_read_raw_axis( JOY_ALL_AXIS, old_axis )
1564 while( (k!=KEY_ESC) && (code==255))
1569 DoMessageStuff(&msg);
1575 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1578 // if ( Game_mode & GM_MULTI )
1579 // GameLoop( 0, 0 ); // Continue
1583 if (k == KEY_PRINT_SCREEN)
1584 save_screen_shot(0);
1586 kc_drawquestion( item );
1589 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, axis ),
1590 joystick_read_raw_axis( JOY_ALL_AXIS, axis )
1593 for (i=0; i<numaxis; i++ ) {
1594 #if defined (MACINTOSH)
1595 if ( abs(axis[i]-old_axis[i])>100 ) {
1596 #elif defined(WINDOWS)
1597 if ( abs(axis[i]-old_axis[i])>1024 ) {
1599 if ( abs(axis[i]-old_axis[i])>200 ) {
1602 con_printf(CON_DEBUG, "Axis Movement detected: Axis %i\n", i);
1604 //old_axis[i] = axis[i];
1606 for (i=0; i<Num_items; i++ )
1608 n = item - All_items;
1609 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) )
1615 for (i=0; i<Num_items; i++ ) {
1616 n = item - All_items;
1617 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) ) {
1618 All_items[i].value = 255;
1619 kc_drawitem( &All_items[i], 0 );
1625 kc_drawitem( item, 1 );
1626 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1627 game_flush_inputs();
1631 void kc_change_mouseaxis( kc_item * item )
1640 WIN(DDGRLOCK(dd_grd_curcanv));
1641 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1643 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_MSE_AXIS );
1644 WIN(DDGRUNLOCK(dd_grd_curcanv));
1646 game_flush_inputs();
1650 mouse_get_delta( &dx, &dy );
1652 while( (k!=KEY_ESC) && (code==255))
1657 DoMessageStuff(&msg);
1663 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1666 // if ( Game_mode & GM_MULTI )
1667 // GameLoop( 0, 0 ); // Continue
1671 if (k == KEY_PRINT_SCREEN)
1672 save_screen_shot(0);
1674 kc_drawquestion( item );
1677 mouse_get_delta_z( &dx, &dy, &dz );
1679 mouse_get_delta( &dx, &dy );
1681 if ( abs(dx)>20 ) code = 0;
1682 if ( abs(dy)>20 ) code = 1;
1684 if ( abs(dz)>20 ) code = 2;
1688 for (i=0; i<Num_items; i++ ) {
1689 n = item - All_items;
1690 if ( (i!=n) && (All_items[i].type==BT_MOUSE_AXIS) && (All_items[i].value==code) ) {
1691 All_items[i].value = 255;
1692 kc_drawitem( &All_items[i], 0 );
1697 kc_drawitem( item, 1 );
1698 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1699 game_flush_inputs();
1704 void kc_change_invert( kc_item * item )
1706 game_flush_inputs();
1713 kc_drawitem( item, 1 );
1717 #include "screens.h"
1719 extern void gr_bm_bitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
1721 void kconfig(int n, char * title)
1724 grs_bitmap *save_bm;
1726 set_screen_mode( SCREEN_MENU );
1731 WIN(mouse_set_mode(0));
1732 WIN(dd_gr_set_current_canvas(NULL));
1734 #if defined(POLY_ACC)
1735 save_bm = gr_create_bitmap2( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h, grd_curcanv->cv_bitmap.bm_type, NULL );
1737 save_bm = gr_create_bitmap( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
1739 Assert( save_bm != NULL );
1741 WIN(DDGRLOCK(dd_grd_curcanv));
1742 gr_bm_bitblt(grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_w,
1743 0, 0, 0, 0, &grd_curcanv->cv_bitmap, save_bm );
1744 WIN(DDGRUNLOCK(dd_grd_curcanv));
1747 case 0:kconfig_sub( kc_keyboard, NUM_KEY_CONTROLS, title );break;
1748 case 1:kconfig_sub( kc_joystick, NUM_OTHER_CONTROLS, title );break;
1749 case 2:kconfig_sub( kc_mouse, NUM_OTHER_CONTROLS, title ); break;
1750 case 3:kconfig_sub( kc_superjoy, NUM_OTHER_CONTROLS, title); break;
1757 WIN(mouse_set_mode(1));
1758 WIN(dd_gr_set_current_canvas(NULL));
1759 WIN(DDGRLOCK(dd_grd_curcanv));
1760 gr_bitmap(0, 0, save_bm);
1761 WIN(DDGRUNLOCK(dd_grd_curcanv));
1762 gr_free_bitmap(save_bm);
1764 reset_cockpit(); //force cockpit redraw next time
1766 // Update save values...
1768 for (i=0; i<NUM_KEY_CONTROLS; i++ )
1769 kconfig_settings[0][i] = kc_keyboard[i].value;
1771 if ( (Config_control_type>0) && (Config_control_type<5)) {
1772 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1773 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
1774 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
1775 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1776 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
1778 else if (Config_control_type == CONTROL_WINJOYSTICK) {
1779 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1780 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
1785 void kconfig_read_fcs( int raw_axis )
1787 int raw_button, button, axis_min[4], axis_center[4], axis_max[4];
1789 if (Config_control_type!=CONTROL_THRUSTMASTER_FCS) return;
1791 joy_get_cal_vals(axis_min, axis_center, axis_max);
1793 if ( axis_max[3] > 1 )
1794 raw_button = (raw_axis*100)/axis_max[3];
1798 if ( raw_button > 88 )
1800 else if ( raw_button > 63 )
1802 else if ( raw_button > 39 )
1804 else if ( raw_button > 15 )
1809 kconfig_set_fcs_button( 19, button );
1810 kconfig_set_fcs_button( 15, button );
1811 kconfig_set_fcs_button( 11, button );
1812 kconfig_set_fcs_button( 7, button );
1816 void kconfig_set_fcs_button( int btn, int button )
1818 int state,time_down,upcount,downcount;
1819 state = time_down = upcount = downcount = 0;
1821 if ( joy_get_button_state(btn) ) {
1822 if ( btn==button ) {
1824 time_down = FrameTime;
1829 if ( btn==button ) {
1831 time_down = FrameTime;
1838 joy_set_btn_values( btn, state, time_down, downcount, upcount );
1844 fix Last_angles_p = 0;
1845 fix Last_angles_b = 0;
1846 fix Last_angles_h = 0;
1847 ubyte Last_angles_read = 0;
1849 extern int VR_sensitivity;
1851 int VR_sense_range[3] = { 25, 50, 75 };
1853 #if 0 //ndef MACINTOSH
1858 fix yaw, pitch, roll;
1861 //------ read vfx1 helmet --------
1862 if (vfx1_installed) {
1863 vfx_get_data(&yaw,&pitch,&roll,&buttons);
1864 } else if (iglasses_headset_installed) {
1865 iglasses_read_headset( &yaw, &pitch, &roll );
1866 } else if (Victor_headset_installed) {
1867 victor_read_headset_filtered( &yaw, &pitch, &roll );
1872 Use_player_head_angles = 0;
1873 if ( Last_angles_read ) {
1877 if ( (Last_angles_h < (F1_0/4) ) && (yaw > ((F1_0*3)/4) ) )
1879 else if ( (yaw < (F1_0/4) ) && (Last_angles_h > ((F1_0*3)/4) ) )
1882 Controls.pitch_time += fixmul((pitch- Last_angles_p)*VR_sense_range[VR_sensitivity],FrameTime);
1883 Controls.heading_time+= fixmul((yaw1 - Last_angles_h)*VR_sense_range[VR_sensitivity],FrameTime);
1884 Controls.bank_time += fixmul((roll - Last_angles_b)*VR_sense_range[VR_sensitivity],FrameTime);
1886 Last_angles_read = 1;
1887 Last_angles_p = pitch;
1888 Last_angles_h = yaw;
1889 Last_angles_b = roll;
1897 #define JOYSTICK_READ_TIME (F1_0/40) // Read joystick at 40 Hz.
1899 #define JOYSTICK_READ_TIME (F1_0/10) // Read joystick at 10 Hz.
1902 fix LastReadTime = 0;
1906 ubyte kc_use_external_control = 0;
1907 ubyte kc_enable_external_control = 0;
1908 ubyte kc_external_intno = 0;
1909 ext_control_info *kc_external_control = NULL;
1910 ubyte *kc_external_name = NULL;
1911 ubyte kc_external_version = 0;
1912 extern int Automap_active;
1914 void kconfig_init_external_controls(int intno, int address)
1917 kc_external_intno = intno;
1918 kc_external_control = (ext_control_info *)address;
1919 kc_use_external_control = 1;
1920 kc_enable_external_control = 1;
1922 i = FindArg ( "-xname" );
1924 kc_external_name = Args[i+1];
1926 kc_external_name = "External Controller";
1928 for (i=0;i<strlen (kc_external_name);i++)
1929 if (kc_external_name[i]=='_')
1930 kc_external_name[i]=' ';
1932 i = FindArg ( "-xver" );
1934 kc_external_version = atoi(Args[i+1]);
1936 printf( "%s int: 0x%x, data: 0x%p, ver:%d\n", kc_external_name, kc_external_intno, kc_external_control, kc_external_version );
1940 #if !defined(MACINTOSH)
1941 /*void kconfig_read_external_controls()
1945 if ( !kc_enable_external_control && !CybermouseActive)
1948 if ( kc_external_version == 0 )
1949 memset( kc_external_control, 0, sizeof(control_info) );
1950 else if ( kc_external_version > 0 ) {
1951 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 );
1952 if ( kc_external_version > 1 ) {
1953 // Write ship pos and angles to external controls...
1954 ubyte *temp_ptr = (ubyte *)kc_external_control;
1955 vms_vector *ship_pos;
1956 vms_matrix *ship_orient;
1957 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
1958 temp_ptr += sizeof(control_info)+sizeof(vms_angvec) + 64;
1959 ship_pos = (vms_vector *)temp_ptr;
1960 temp_ptr += sizeof(vms_vector);
1961 ship_orient = (vms_matrix *)temp_ptr;
1962 // Fill in ship postion...
1963 *ship_pos = Objects[Players[Player_num].objnum].pos;
1964 // Fill in ship orientation...
1965 *ship_orient = Objects[Players[Player_num].objnum].orient;
1969 if ( Automap_active ) // (If in automap...)
1970 kc_external_control->automap_state = 1;
1971 memset(&r,0,sizeof(r));
1975 if (!CybermouseActive)
1976 int386 ( kc_external_intno, &r, &r); // Read external info...
1978 // ReadOWL (kc_external_control);
1982 if ( Player_num > -1 ) {
1983 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
1984 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
1985 Auto_leveling_on = 0;
1987 if ( kc_external_version > 0 ) {
1988 vms_matrix tempm, ViewMatrix;
1989 vms_angvec * Kconfig_abs_movement;
1992 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
1994 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
1995 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
1996 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
1997 Objects[Players[Player_num].objnum].orient = ViewMatrix;
1999 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
2000 if (oem_message[0] != '\0' )
2001 HUD_init_message( oem_message );
2005 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
2006 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
2007 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
2008 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
2009 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
2010 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
2011 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
2012 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
2013 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
2014 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
2015 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
2016 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
2017 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
2018 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
2019 Controls.automap_down_count += kc_external_control->automap_down_count;
2020 Controls.automap_state |= kc_external_control->automap_state;
2025 void controls_read_all_win()
2028 int slide_on, bank_on;
2032 int raw_joy_axis[7];
2034 fix k0, k1, k2, k3, kp;
2035 fix k4, k5, k6, k7, kh;
2036 ubyte channel_masks;
2037 int use_mouse, use_joystick;
2040 if (Game_turbo_mode)
2044 fix temp = Controls.heading_time;
2045 fix temp1 = Controls.pitch_time;
2046 memset( &Controls, 0, sizeof(control_info) );
2047 Controls.heading_time = temp;
2048 Controls.pitch_time = temp1;
2053 ctime = timer_get_fixed_seconds();
2055 // DO JOYSTICK (X,Y,Z R,U,V)
2056 // ----------------------------------------------------------------------------
2057 if ( (LastReadTime + JOYSTICK_READ_TIME) > ctime ) {
2058 if ((ctime < 0) && (LastReadTime > 0))
2059 LastReadTime = ctime;
2061 } else if ((Config_control_type==CONTROL_WINJOYSTICK)) {
2062 LastReadTime = ctime;
2063 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, raw_joy_axis );
2065 for (i=0; i<7; i++ ) {
2066 if (channel_masks&(1<<i)) {
2067 int joy_null_value = 28;
2069 // DO POV if joystick has a hat.
2070 // --------------------------------------------------------------------
2072 joydefsw_do_winjoybutton(raw_joy_axis);
2076 // --------------------------------------------------------------------
2077 // mprintf((0, "(%d)=%d,", i, raw_joy_axis[i]));
2078 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2079 // mprintf((0, "%d ",raw_joy_axis[i]));
2080 // if (i%2) mprintf((0,"\n"));
2083 if (kc_superjoy[23].value==i) // If this is the throttle
2084 joy_null_value = 32; // Then use a larger dead-zone
2086 if (raw_joy_axis[i] > (joy_null_value-2))
2087 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2088 else if (raw_joy_axis[i] < -(joy_null_value+2))
2089 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2091 raw_joy_axis[i] = 0;
2092 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2101 for (i=0; i<6; i++ )
2107 // ----------------------------------------------------------------------------
2108 if (Config_control_type==5) {
2109 mouse_get_delta( &dx, &dy );
2110 mouse_axis[0] = (dx*FrameTime)/35;
2111 mouse_axis[1] = (dy*FrameTime)/25;
2112 mouse_buttons = mouse_get_btns();
2113 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2122 //------------- Read slide_on -------------
2125 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
2126 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
2128 if ((use_joystick)&&(kc_superjoy[5].value<255)) slide_on |= joy_get_button_state( kc_superjoy[5].value );
2130 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
2132 //------------- Read bank_on ---------------
2135 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
2136 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
2138 if ( (use_joystick)&&(kc_superjoy[10].value < 255 )) bank_on |= joy_get_button_state( kc_superjoy[10].value );
2140 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
2142 //------------ Read pitch_time -----------
2144 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2146 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
2147 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
2148 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
2149 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
2152 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
2153 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
2154 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
2155 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
2158 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2159 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
2160 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
2164 Controls.pitch_time = 0;
2166 if (Controls.pitch_time < 0)
2167 Controls.pitch_time = 0;
2169 if (Controls.pitch_time > 0)
2170 Controls.pitch_time = 0;
2171 Controls.pitch_time += kp;
2174 if ( (use_joystick)&&(kc_superjoy[13].value < 255 )) {
2175 if ( !kc_superjoy[14].value ) // If not inverted...
2176 Controls.pitch_time -= (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2178 Controls.pitch_time += (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2182 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
2183 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
2184 if ( !kc_mouse[14].value ) // If not inverted...
2185 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2187 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2190 Controls.pitch_time = 0;
2194 //----------- Read vertical_thrust_time -----------------
2197 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
2198 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
2199 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
2200 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
2203 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
2204 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
2205 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
2206 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
2209 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2210 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
2211 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
2215 if ((use_joystick)&&( kc_superjoy[13].value < 255 )) {
2216 if ( !kc_superjoy[14].value ) // If not inverted...
2217 Controls.vertical_thrust_time += joy_axis[kc_superjoy[13].value];
2219 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[13].value];
2223 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
2224 if ( !kc_mouse[14].value ) // If not inverted...
2225 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
2227 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
2232 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
2233 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
2234 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
2235 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
2238 if ((use_joystick)&&( kc_superjoy[19].value < 255 )) {
2239 if ( !kc_superjoy[20].value ) // If not inverted...
2240 Controls.vertical_thrust_time += joy_axis[kc_superjoy[19].value];
2242 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[19].value];
2245 // From joystick buttons
2246 if ( (use_joystick)&&(kc_superjoy[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_superjoy[8].value );
2247 if ( (use_joystick)&&(kc_superjoy[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_superjoy[9].value );
2249 // From mouse buttons
2250 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
2251 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
2254 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
2255 if ( !kc_mouse[20].value ) // If not inverted...
2256 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
2258 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
2262 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2263 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
2264 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
2267 //---------- Read heading_time -----------
2269 if (!slide_on && !bank_on) {
2270 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2272 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
2273 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
2274 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
2275 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
2278 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
2279 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
2280 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
2281 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
2284 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2285 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
2286 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
2290 Controls.heading_time = 0;
2292 if (Controls.heading_time < 0)
2293 Controls.heading_time = 0;
2295 if (Controls.heading_time > 0)
2296 Controls.heading_time = 0;
2297 Controls.heading_time += kh;
2300 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2301 if ( !kc_superjoy[16].value ) // If not inverted...
2302 Controls.heading_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2304 Controls.heading_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2308 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2309 if ( !kc_mouse[16].value ) // If not inverted...
2310 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2312 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2315 Controls.heading_time = 0;
2318 //----------- Read sideways_thrust_time -----------------
2321 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2322 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2323 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2324 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2327 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
2328 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
2329 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
2330 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
2333 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2334 if ( !kc_superjoy[16].value ) // If not inverted...
2335 Controls.sideways_thrust_time += joy_axis[kc_superjoy[15].value];
2337 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[15].value];
2341 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2342 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
2343 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
2347 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2348 if ( !kc_mouse[16].value ) // If not inverted...
2349 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
2351 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
2356 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
2357 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
2358 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
2359 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
2362 if ( (use_joystick)&&(kc_superjoy[17].value < 255 )) {
2363 if ( !kc_superjoy[18].value ) // If not inverted...
2364 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[17].value];
2366 Controls.sideways_thrust_time += joy_axis[kc_superjoy[17].value];
2369 // From joystick buttons
2370 if ( (use_joystick)&&(kc_superjoy[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_superjoy[6].value );
2371 if ( (use_joystick)&&(kc_superjoy[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_superjoy[7].value );
2373 // From mouse buttons
2374 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
2375 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
2378 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
2379 if ( !kc_mouse[18].value ) // If not inverted...
2380 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
2382 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
2385 //----------- Read bank_time -----------------
2388 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2389 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2390 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2391 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2394 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
2395 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
2396 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
2397 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
2400 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2401 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
2402 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
2406 if ( (use_joystick)&&(kc_superjoy[15].value < 255) ) {
2407 if ( !kc_superjoy[16].value ) // If not inverted...
2408 Controls.bank_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2410 Controls.bank_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2414 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2415 if ( !kc_mouse[16].value ) // If not inverted...
2416 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2418 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2423 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
2424 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
2425 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
2426 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
2429 if ( (use_joystick)&&(kc_superjoy[21].value < 255) ) {
2430 if ( !kc_superjoy[22].value ) // If not inverted...
2431 Controls.bank_time -= joy_axis[kc_superjoy[21].value];
2433 Controls.bank_time += joy_axis[kc_superjoy[21].value];
2436 // From joystick buttons
2437 if ( (use_joystick)&&(kc_superjoy[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_superjoy[11].value );
2438 if ( (use_joystick)&&(kc_superjoy[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_superjoy[12].value );
2440 // From mouse buttons
2441 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
2442 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
2445 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
2446 if ( !kc_mouse[22].value ) // If not inverted...
2447 Controls.bank_time += mouse_axis[kc_mouse[21].value];
2449 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
2453 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2454 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
2455 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
2458 //----------- Read forward_thrust_time -------------
2461 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
2462 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
2463 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
2464 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
2467 if ( (use_joystick)&&(kc_superjoy[23].value < 255 )) {
2468 if ( !kc_superjoy[24].value ) // If not inverted...
2469 Controls.forward_thrust_time -= joy_axis[kc_superjoy[23].value];
2471 Controls.forward_thrust_time += joy_axis[kc_superjoy[23].value];
2474 // From joystick buttons
2475 if ( (use_joystick)&&(kc_superjoy[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_superjoy[2].value );
2476 if ( (use_joystick)&&(kc_superjoy[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_superjoy[3].value );
2479 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
2480 if ( !kc_mouse[24].value ) // If not inverted...
2481 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
2483 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
2486 // From mouse buttons
2487 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
2488 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
2490 //----------- Read afterburner_state -------------
2493 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
2494 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
2496 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
2498 if ( (use_joystick)&&(kc_superjoy[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_superjoy[27].value);
2500 //-------Read headlight key--------------------------
2501 if (kc_keyboard[52].value < 255 )
2502 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
2503 if (kc_keyboard[53].value < 255 )
2504 Controls.headlight_count=key_down_count(kc_keyboard[53].value);
2505 if ((use_joystick)&&(kc_superjoy[30].value < 255 ))
2506 Controls.headlight_count=joy_get_button_down_cnt(kc_superjoy[30].value);
2508 //--------Read Cycle Primary Key------------------
2510 if (kc_keyboard[48].value<255)
2511 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
2512 if (kc_keyboard[49].value<255)
2513 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
2514 if ((use_joystick)&&(kc_superjoy[28].value < 255 ))
2515 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_superjoy[28].value);
2517 //--------Read Cycle Secondary Key------------------
2519 if (kc_keyboard[50].value<255)
2520 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
2521 if (kc_keyboard[51].value<255)
2522 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
2523 if ((use_joystick)&&(kc_superjoy[29].value < 255 ))
2524 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_superjoy[29].value);
2526 //--------Read Toggle Bomb key----------------------
2528 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
2530 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
2532 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
2533 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
2535 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2536 HUD_init_message ("No bombs available!");
2540 if (Players[Player_num].secondary_ammo[bomb]==0)
2542 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2543 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
2547 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
2548 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
2553 //---------Read Energy->Shield key----------
2555 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
2556 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
2557 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
2558 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
2560 //----------- Read fire_primary_down_count
2561 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
2562 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
2563 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_superjoy[0].value);
2564 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
2566 //----------- Read fire_primary_state
2567 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
2568 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
2569 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_superjoy[0].value);
2570 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
2572 //----------- Read fire_secondary_down_count
2573 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
2574 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
2575 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_superjoy[1].value);
2576 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
2578 //----------- Read fire_secondary_state
2579 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
2580 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
2581 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_superjoy[1].value);
2582 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
2584 //----------- Read fire_flare_down_count
2585 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
2586 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
2587 if ((use_joystick)&&(kc_superjoy[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_superjoy[4].value);
2588 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
2590 //----------- Read drop_bomb_down_count
2591 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
2592 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
2593 if ((use_joystick)&&(kc_superjoy[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_superjoy[26].value);
2594 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
2596 //----------- Read rear_view_down_count
2597 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
2598 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
2599 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_superjoy[25].value);
2600 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
2602 //----------- Read rear_view_down_state
2603 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
2604 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
2605 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_superjoy[25].value);
2606 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
2608 //----------- Read automap_down_count
2609 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
2610 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
2612 //----------- Read automap_state
2613 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
2614 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
2616 //----------- Read stupid-cruise-control-type of throttle.
2618 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
2619 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
2620 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
2621 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
2622 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
2624 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
2627 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
2628 if (Cruise_speed < 0 ) Cruise_speed = 0;
2630 if (Controls.forward_thrust_time==0)
2631 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
2634 //read_head_tracker();
2636 // Read external controls
2637 if (kc_use_external_control || CybermouseActive)
2638 kconfig_read_external_controls();
2640 //----------- Clamp values between -FrameTime and FrameTime
2641 if (FrameTime > F1_0 )
2642 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
2644 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
2645 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
2646 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
2647 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
2648 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
2649 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
2650 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
2652 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
2653 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
2654 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
2655 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
2656 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
2657 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
2658 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
2661 //--------- Don't do anything if in debug mode
2663 if ( keyd_pressed[KEY_DELETE] ) {
2664 memset( &Controls, 0, sizeof(control_info) );
2671 fix Next_toggle_time[3]={0,0,0};
2673 int allowed_to_toggle(int i)
2675 //used for keeping tabs of when its ok to toggle headlight,primary,and secondary
2677 if (Next_toggle_time[i] > GameTime)
2678 if (Next_toggle_time[i] < GameTime + (F1_0/8)) // In case time is bogus, never wait > 1 second.
2681 Next_toggle_time[i] = GameTime + (F1_0/8);
2688 void controls_read_all()
2691 int slide_on, bank_on;
2698 fix mouse_axis[3] = {0,0,0};
2700 int raw_joy_axis[MAX_AXES];
2702 int raw_joy_axis[JOY_NUM_AXES];
2705 fix k0, k1, k2, k3, kp;
2706 fix k4, k5, k6, k7, kh;
2707 ubyte channel_masks;
2708 int use_mouse, use_joystick;
2714 if (Game_turbo_mode)
2718 fix temp = Controls.heading_time;
2719 fix temp1 = Controls.pitch_time;
2720 memset( &Controls, 0, sizeof(control_info) );
2721 Controls.heading_time = temp;
2722 Controls.pitch_time = temp1;
2727 ctime = timer_get_fixed_seconds();
2729 //--------- Read Joystick -----------
2731 if ( (LastReadTime + JOYSTICK_READ_TIME > ctime) && (Config_control_type!=CONTROL_THRUSTMASTER_FCS) ) {
2732 if ((ctime < 0) && (LastReadTime > 0))
2733 LastReadTime = ctime;
2735 } else if ((Config_control_type>0) && (Config_control_type<5) ) {
2736 LastReadTime = ctime;
2737 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
2739 for (i=0; i<6; i++ ) {
2741 if (channel_masks&(1<<i)) {
2743 int joy_null_value = 10;
2745 if ( (i==3) && (Config_control_type==CONTROL_THRUSTMASTER_FCS) ) {
2746 kconfig_read_fcs( raw_joy_axis[i] );
2748 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2750 if (kc_joystick[23].value==i) // If this is the throttle
2751 joy_null_value = 20; // Then use a larger dead-zone
2753 if (raw_joy_axis[i] > joy_null_value)
2754 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2755 else if (raw_joy_axis[i] < -joy_null_value)
2756 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2758 raw_joy_axis[i] = 0;
2759 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2769 for (i=0; i<4; i++ )
2774 //--------- Read Joystick -----------
2775 if ((Config_control_type>0) && (Config_control_type<5) ) {
2776 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
2777 for (i=0; i<4; i++ ) {
2778 if (channel_masks&(1<<i)) {
2779 int joy_null_value = 10;
2781 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2783 if (kc_joystick[23].value==i) // If this is the throttle
2784 joy_null_value = 20; // Then use a larger dead-zone
2786 if (raw_joy_axis[i] > joy_null_value)
2787 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2788 else if (raw_joy_axis[i] < -joy_null_value)
2789 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2791 raw_joy_axis[i] = 0;
2792 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2799 for (i=0; i<4; i++ )
2803 #endif // ifndef MACINTOSH
2805 if (Config_control_type==5 && !CybermouseActive) {
2806 //--------- Read Mouse -----------
2808 mouse_get_delta_z( &dx, &dy, &dz );
2810 mouse_get_delta( &dx, &dy );
2812 mouse_axis[0] = (dx*FrameTime)/35;
2813 mouse_axis[1] = (dy*FrameTime)/25;
2815 mouse_axis[2] = (dz*FrameTime);
2817 mouse_buttons = mouse_get_btns();
2818 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2820 } else if (Config_control_type==6 && !CybermouseActive) {
2821 //--------- Read Cyberman -----------
2822 mouse_get_cyberman_pos(&idx,&idy );
2823 mouse_axis[0] = (idx*FrameTime)/128;
2824 mouse_axis[1] = (idy*FrameTime)/128;
2825 mouse_buttons = mouse_get_btns();
2827 } else if (CybermouseActive) {
2828 // ReadOWL (kc_external_control);
2829 // CybermouseAdjust();
2837 //------------- Read slide_on -------------
2840 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
2841 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
2843 if ((use_joystick)&&(kc_joystick[5].value<255)) slide_on |= joy_get_button_state( kc_joystick[5].value );
2845 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
2847 //------------- Read bank_on ---------------
2850 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
2851 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
2853 if ( (use_joystick)&&(kc_joystick[10].value < 255 )) bank_on |= joy_get_button_state( kc_joystick[10].value );
2855 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
2857 //------------ Read pitch_time -----------
2859 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2861 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
2862 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
2863 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
2864 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
2867 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
2868 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
2869 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
2870 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
2873 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2874 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
2875 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
2879 Controls.pitch_time = 0;
2881 if (Controls.pitch_time < 0)
2882 Controls.pitch_time = 0;
2884 if (Controls.pitch_time > 0)
2885 Controls.pitch_time = 0;
2886 Controls.pitch_time += kp;
2889 if ( (use_joystick)&&(kc_joystick[13].value < 255 )) {
2890 if ( !kc_joystick[14].value ) // If not inverted...
2891 Controls.pitch_time -= (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
2893 Controls.pitch_time += (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
2897 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
2898 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
2899 if ( !kc_mouse[14].value ) // If not inverted...
2900 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2902 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2905 Controls.pitch_time = 0;
2909 //----------- Read vertical_thrust_time -----------------
2912 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
2913 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
2914 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
2915 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
2918 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
2919 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
2920 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
2921 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
2924 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2925 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
2926 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
2930 if ((use_joystick)&&( kc_joystick[13].value < 255 )) {
2931 if ( !kc_joystick[14].value ) // If not inverted...
2932 Controls.vertical_thrust_time += joy_axis[kc_joystick[13].value];
2934 Controls.vertical_thrust_time -= joy_axis[kc_joystick[13].value];
2938 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
2939 if ( !kc_mouse[14].value ) // If not inverted...
2940 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
2942 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
2947 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
2948 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
2949 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
2950 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
2953 if ((use_joystick)&&( kc_joystick[19].value < 255 )) {
2954 if ( !kc_joystick[20].value ) // If not inverted...
2955 Controls.vertical_thrust_time += joy_axis[kc_joystick[19].value];
2957 Controls.vertical_thrust_time -= joy_axis[kc_joystick[19].value];
2960 // From joystick buttons
2961 if ( (use_joystick)&&(kc_joystick[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_joystick[8].value );
2962 if ( (use_joystick)&&(kc_joystick[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_joystick[9].value );
2964 // From mouse buttons
2965 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
2966 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
2969 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
2970 if ( !kc_mouse[20].value ) // If not inverted...
2971 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
2973 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
2977 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2978 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
2979 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
2982 //---------- Read heading_time -----------
2984 if (!slide_on && !bank_on) {
2985 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2987 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
2988 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
2989 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
2990 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
2993 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
2994 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
2995 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
2996 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
2999 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3000 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
3001 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
3005 Controls.heading_time = 0;
3007 if (Controls.heading_time < 0)
3008 Controls.heading_time = 0;
3010 if (Controls.heading_time > 0)
3011 Controls.heading_time = 0;
3012 Controls.heading_time += kh;
3015 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
3016 if ( !kc_joystick[16].value ) // If not inverted...
3017 Controls.heading_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3019 Controls.heading_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3023 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3024 if ( !kc_mouse[16].value ) // If not inverted...
3025 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3027 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3030 Controls.heading_time = 0;
3033 //----------- Read sideways_thrust_time -----------------
3036 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3037 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3038 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3039 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3042 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
3043 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
3044 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
3045 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
3048 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
3049 if ( !kc_joystick[16].value ) // If not inverted...
3050 Controls.sideways_thrust_time += joy_axis[kc_joystick[15].value];
3052 Controls.sideways_thrust_time -= joy_axis[kc_joystick[15].value];
3056 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3057 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
3058 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
3062 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3063 if ( !kc_mouse[16].value ) // If not inverted...
3064 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
3066 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
3071 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
3072 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
3073 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
3074 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
3077 if ( (use_joystick)&&(kc_joystick[17].value < 255 )) {
3078 if ( !kc_joystick[18].value ) // If not inverted...
3079 Controls.sideways_thrust_time -= joy_axis[kc_joystick[17].value];
3081 Controls.sideways_thrust_time += joy_axis[kc_joystick[17].value];
3084 // From joystick buttons
3085 if ( (use_joystick)&&(kc_joystick[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_joystick[6].value );
3086 if ( (use_joystick)&&(kc_joystick[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_joystick[7].value );
3088 // From mouse buttons
3089 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
3090 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
3093 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
3094 if ( !kc_mouse[18].value ) // If not inverted...
3095 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
3097 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
3100 //----------- Read bank_time -----------------
3103 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3104 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3105 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3106 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3109 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
3110 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
3111 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
3112 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
3115 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3116 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
3117 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
3121 if ( (use_joystick)&&(kc_joystick[15].value < 255) ) {
3122 if ( !kc_joystick[16].value ) // If not inverted...
3123 Controls.bank_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3125 Controls.bank_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3129 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3130 if ( !kc_mouse[16].value ) // If not inverted...
3131 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3133 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3138 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
3139 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
3140 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
3141 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
3144 if ( (use_joystick)&&(kc_joystick[21].value < 255) ) {
3145 if ( !kc_joystick[22].value ) // If not inverted...
3146 Controls.bank_time -= joy_axis[kc_joystick[21].value];
3148 Controls.bank_time += joy_axis[kc_joystick[21].value];
3151 // From joystick buttons
3152 if ( (use_joystick)&&(kc_joystick[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_joystick[11].value );
3153 if ( (use_joystick)&&(kc_joystick[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_joystick[12].value );
3155 // From mouse buttons
3156 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
3157 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
3160 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
3161 if ( !kc_mouse[22].value ) // If not inverted...
3162 Controls.bank_time += mouse_axis[kc_mouse[21].value];
3164 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
3168 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3169 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
3170 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
3173 //----------- Read forward_thrust_time -------------
3176 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
3177 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
3178 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
3179 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
3182 if ( (use_joystick)&&(kc_joystick[23].value < 255 )) {
3183 if ( !kc_joystick[24].value ) // If not inverted...
3184 Controls.forward_thrust_time -= joy_axis[kc_joystick[23].value];
3186 Controls.forward_thrust_time += joy_axis[kc_joystick[23].value];
3189 // From joystick buttons
3190 if ( (use_joystick)&&(kc_joystick[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_joystick[2].value );
3191 if ( (use_joystick)&&(kc_joystick[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_joystick[3].value );
3194 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
3195 if ( !kc_mouse[24].value ) // If not inverted...
3196 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
3198 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
3201 // From mouse buttons
3202 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
3203 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
3205 //----------- Read afterburner_state -------------
3208 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
3209 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
3211 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
3213 if ( (use_joystick)&&(kc_joystick[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_joystick[27].value);
3215 //-------Read headlight key--------------------------
3217 if (kc_keyboard[52].value < 255 )
3218 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
3219 if (kc_keyboard[53].value < 255 )
3220 Controls.headlight_count+=key_down_count(kc_keyboard[53].value);
3221 if ((use_joystick)&&(kc_joystick[30].value < 255 ))
3222 Controls.headlight_count+=joy_get_button_down_cnt(kc_joystick[30].value);
3224 //--------Read Cycle Primary Key------------------
3226 if (kc_keyboard[48].value<255)
3227 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
3228 if (kc_keyboard[49].value<255)
3229 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
3230 if ((use_joystick)&&(kc_joystick[28].value < 255 ))
3231 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_joystick[28].value);
3234 //--------Read Cycle Secondary Key------------------
3236 if (kc_keyboard[50].value<255)
3237 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
3238 if (kc_keyboard[51].value<255)
3239 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
3240 if ((use_joystick)&&(kc_joystick[29].value < 255 ))
3241 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_joystick[29].value);
3243 //--------Read Toggle Bomb key----------------------
3245 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
3247 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
3249 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
3250 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
3252 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3253 HUD_init_message ("No bombs available!");
3257 if (Players[Player_num].secondary_ammo[bomb]==0)
3259 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3260 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
3264 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
3265 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
3270 //---------Read Energy->Shield key----------
3272 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
3273 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
3274 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
3275 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
3277 //----------- Read fire_primary_down_count
3278 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
3279 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
3280 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_joystick[0].value);
3281 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
3283 //----------- Read fire_primary_state
3284 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
3285 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
3286 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_joystick[0].value);
3287 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
3289 //----------- Read fire_secondary_down_count
3290 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
3291 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
3292 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_joystick[1].value);
3293 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
3295 //----------- Read fire_secondary_state
3296 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
3297 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
3298 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_joystick[1].value);
3299 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
3301 //----------- Read fire_flare_down_count
3302 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
3303 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
3304 if ((use_joystick)&&(kc_joystick[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_joystick[4].value);
3305 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
3307 //----------- Read drop_bomb_down_count
3308 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
3309 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
3310 if ((use_joystick)&&(kc_joystick[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_joystick[26].value);
3311 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
3313 //----------- Read rear_view_down_count
3314 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
3315 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
3316 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_joystick[25].value);
3317 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
3319 //----------- Read rear_view_down_state
3320 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
3321 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
3322 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_joystick[25].value);
3323 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
3325 //----------- Read automap_down_count
3326 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
3327 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
3329 //----------- Read automap_state
3330 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
3331 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
3333 //----------- Read stupid-cruise-control-type of throttle.
3335 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
3336 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
3337 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
3338 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
3339 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
3341 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
3344 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
3345 if (Cruise_speed < 0 ) Cruise_speed = 0;
3347 if (Controls.forward_thrust_time==0)
3348 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
3351 #if !defined(MACINTOSH)
3352 //read_head_tracker();
3354 // Read external controls
3355 // if (kc_use_external_control || CybermouseActive)
3356 // kconfig_read_external_controls();
3359 //----------- Clamp values between -FrameTime and FrameTime
3360 if (FrameTime > F1_0 )
3361 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
3363 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
3364 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
3365 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
3366 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
3367 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
3368 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
3369 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
3371 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
3372 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
3373 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
3374 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
3375 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
3376 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
3377 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
3380 //--------- Don't do anything if in debug mode
3382 if ( keyd_pressed[KEY_DELETE] ) {
3383 memset( &Controls, 0, sizeof(control_info) );
3389 void reset_cruise(void)
3395 void kc_set_controls()
3399 for (i=0; i<NUM_KEY_CONTROLS; i++ )
3400 kc_keyboard[i].value = kconfig_settings[0][i];
3402 if ( (Config_control_type>0) && (Config_control_type<5)) {
3403 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3404 kc_joystick[i].value = kconfig_settings[Config_control_type][i];
3405 if (kc_joystick[i].type == BT_INVERT ) {
3406 if (kc_joystick[i].value!=1)
3407 kc_joystick[i].value = 0;
3408 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
3411 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
3412 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3413 kc_mouse[i].value = kconfig_settings[Config_control_type][i];
3414 if (kc_mouse[i].type == BT_INVERT ) {
3415 if (kc_mouse[i].value!=1)
3416 kc_mouse[i].value = 0;
3417 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
3420 } else if (Config_control_type == CONTROL_WINJOYSTICK) {
3421 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3422 kc_superjoy[i].value = kconfig_settings[Config_control_type][i];
3423 if (kc_superjoy[i].type == BT_INVERT ) {
3424 if (kc_superjoy[i].value!=1)
3425 kc_superjoy[i].value = 0;
3426 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
3432 #if 0 //ndef MACINTOSH // no mac support for vr headset
3434 void kconfig_center_headset()
3438 vfx_center_headset();
3440 // } else if (iglasses_headset_installed) {
3441 // } else if (Victor_headset_installed) {
3447 #endif // end of #ifndef MACINTOSH for kconfig_center_headset
3449 void CybermouseAdjust ()
3451 /* if ( Player_num > -1 ) {
3452 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3453 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3454 Auto_leveling_on = 0;
3456 if ( kc_external_version > 0 ) {
3457 vms_matrix tempm, ViewMatrix;
3458 vms_angvec * Kconfig_abs_movement;
3461 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
3463 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3464 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3465 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3466 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3468 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3469 if (oem_message[0] != '\0' )
3470 HUD_init_message( oem_message );
3474 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3475 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3476 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3477 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3478 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3479 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3480 // Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3481 // Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3482 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3483 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3484 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3485 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3486 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3487 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3488 // Controls.automap_down_count += kc_external_control->automap_down_count;
3489 // Controls.automap_state |= kc_external_control->automap_state;
3492 char GetKeyValue (char key)
3494 mprintf ((0,"Returning %c!\n",kc_keyboard[(int)key].value));
3495 return (kc_keyboard[(int)key].value);
3498 #if !defined(MACINTOSH)
3501 extern object *obj_find_first_of_type (int);
3502 void kconfig_read_external_controls()
3507 if ( !kc_enable_external_control ) return;
3509 if ( kc_external_version == 0 )
3510 memset( kc_external_control, 0, sizeof(ext_control_info));
3511 else if ( kc_external_version > 0 ) {
3513 if (kc_external_version>=4)
3514 memset( kc_external_control, 0, sizeof(advanced_ext_control_info));
3515 else if (kc_external_version>0)
3516 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 );
3517 else if (kc_external_version>2)
3518 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof(vms_matrix) +4 );
3520 if ( kc_external_version > 1 ) {
3521 // Write ship pos and angles to external controls...
3522 ubyte *temp_ptr = (ubyte *)kc_external_control;
3523 vms_vector *ship_pos;
3524 vms_matrix *ship_orient;
3525 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
3526 temp_ptr += sizeof(ext_control_info) + sizeof(vms_angvec) + 64;
3527 ship_pos = (vms_vector *)temp_ptr;
3528 temp_ptr += sizeof(vms_vector);
3529 ship_orient = (vms_matrix *)temp_ptr;
3530 // Fill in ship postion...
3531 *ship_pos = Objects[Players[Player_num].objnum].pos;
3532 // Fill in ship orientation...
3533 *ship_orient = Objects[Players[Player_num].objnum].orient;
3535 if (kc_external_version>=4)
3537 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3539 temp_ptr->headlight_state=(Players[Player_num].flags & PLAYER_FLAGS_HEADLIGHT_ON);
3540 temp_ptr->primary_weapon_flags=Players[Player_num].primary_weapon_flags;
3541 temp_ptr->secondary_weapon_flags=Players[Player_num].secondary_weapon_flags;
3542 temp_ptr->current_primary_weapon=Primary_weapon;
3543 temp_ptr->current_secondary_weapon=Secondary_weapon;
3545 temp_ptr->current_guidebot_command=Escort_goal_object;
3547 temp_ptr->force_vector=ExtForceVec;
3548 temp_ptr->force_matrix=ExtApplyForceMatrix;
3550 temp_ptr->joltinfo[i]=ExtJoltInfo[i];
3552 temp_ptr->x_vibrate_info[i]=ExtXVibrateInfo[i];
3553 temp_ptr->x_vibrate_clear=ExtXVibrateClear;
3554 temp_ptr->game_status=ExtGameStatus;
3556 memset ((void *)&ExtForceVec,0,sizeof(vms_vector));
3557 memset ((void *)&ExtApplyForceMatrix,0,sizeof(vms_matrix));
3562 ExtXVibrateInfo[i]=0;
3567 if ( Automap_active ) // (If in automap...)
3568 kc_external_control->automap_state = 1;
3569 //memset(&r,0,sizeof(r));
3573 int386 ( kc_external_intno, &r, &r); // Read external info...
3577 if ( Player_num > -1 ) {
3578 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3579 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3580 Auto_leveling_on = 0;
3582 if ( kc_external_version > 0 ) {
3583 vms_matrix tempm, ViewMatrix;
3584 vms_angvec * Kconfig_abs_movement;
3587 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(ext_control_info));
3589 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3590 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3591 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3592 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3594 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3595 if (oem_message[0] != '\0' )
3596 HUD_init_message( oem_message );
3600 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3601 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3602 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3603 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3604 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3605 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3606 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3607 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3608 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3609 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3610 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3611 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3612 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3613 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3614 Controls.automap_down_count += kc_external_control->automap_down_count;
3615 Controls.automap_state |= kc_external_control->automap_state;
3617 if (kc_external_version>=3)
3619 ubyte *temp_ptr = (ubyte *)kc_external_control;
3620 temp_ptr += (sizeof(ext_control_info) + sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof (vms_matrix));
3623 Controls.cycle_primary_count=(*(temp_ptr));
3625 Controls.cycle_secondary_count=(*(temp_ptr+1));
3628 Controls.afterburner_state=(*(temp_ptr+2));
3630 Controls.headlight_count=(*(temp_ptr+3));
3632 if (kc_external_version>=4)
3635 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3638 if (temp_ptr->keyboard[i])
3641 if (temp_ptr->Reactor_blown)
3643 if (Game_mode & GM_MULTI)
3644 net_destroy_controlcen (obj_find_first_of_type (OBJ_CNTRLCEN));
3646 do_controlcen_destroyed_stuff(obj_find_first_of_type (OBJ_CNTRLCEN));