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.13 2002-07-22 22:59:24 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 };
132 char *mousebutton_text[3] = { "Btn", "", "" }; // only one silly mouse button on the mac
136 char * key_text[256] = {
137 "","S","D","F","H","G","Z","X","C","V","","B","Q", "W", "E", "R",
138 "Y","T","1","2","3","4","6","5","=","9","7","-", "8", "0", "]", "O",
139 "U","[","I","P","RET","L","J","'","K", ";", "\\", ",", "/", "N", "M", ".",
140 "TAB","SPC","`","DEL","","ESC","","APL","SHIFT","CAPSL","OPTN","CTRL","","","","A",
141 "","PAD.","","PAD*","","PAD+","","NMLCK","","","","PAD/","ENTER","","PAD-","",
142 "","PAD=","PAD0","PAD1","PAD2","PAD3","PAD4","PAD5","PAD6","PAD7","","PAD8","PAD9","","","",
143 "F5","F6","F7","","F8","F9","","F11","","F13","","F14","","F10","","F12",
144 "","PAUSE","HELP","HOME","PGUP","DEL","","END","F2","","F1","LARW","RARW","DARW","UARW","",
145 "","","","","","","","","","","","","","","","",
146 "","","","","","","","","","","","","","","","",
147 "","","","","","","","","","","","","","","","",
148 "","","","","","","","","","","","","","","","",
149 "","","","","","","","","","","","","","","","",
150 "","","","","","","","","","","","","","","","",
151 "","","","","","","","","","","","","","","","",
152 "","","","","","","","","","","","","","","",""};
154 #if !defined OGL && !defined SDL_INPUT
155 char * key_text[256] = { \
156 "","ESC","1","2","3","4","5","6","7","8","9","0","-", \
157 "=","BSPC","TAB","Q","W","E","R","T","Y","U","I","O", \
158 "P","[","]","
\83","LCTRL","A","S","D","F", \
159 "G","H","J","K","L",";","'","`", \
160 "LSHFT","\\","Z","X","C","V","B","N","M",",", \
161 ".","/","RSHFT","PAD*","LALT","SPC", \
162 "CPSLK","F1","F2","F3","F4","F5","F6","F7","F8","F9", \
163 "F10","NMLCK","SCLK","PAD7","PAD8","PAD9","PAD-", \
164 "PAD4","PAD5","PAD6","PAD+","PAD1","PAD2","PAD3","PAD0", \
165 "PAD.","","","","F11","F12","","","","","","","","","", \
166 "","","","","","","","","","","","","","","","","","","","", \
167 "","","","","","","","","","","","","","","","","","","","", \
168 "","","","","","","","","","","","","","","","","","", \
169 "PAD
\83","RCTRL","","","","","","","","","","","","","", \
170 "","","","","","","","","","","PAD/","","","RALT","", \
171 "","","","","","","","","","","","","","HOME","
\82","PGUP", \
172 "","
\81","","
\7f","","END","
\80","PGDN","INS", \
173 "DEL","","","","","","","","","","","","","","","","","", \
174 "","","","","","","","","","","","","","","","","","","","", \
175 "","","","","","","" };
179 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 };
181 //extern void GameLoop(int, int );
183 extern void transfer_energy_to_shield(fix);
184 extern void CyclePrimary(),CycleSecondary(),InitMarkerInput();
185 extern ubyte DefiningMarkerMessage;
186 extern char CybermouseActive;
189 extern int joydefsw_do_button();
190 extern int joydefsw_do_winjoybutton(int *axis);
191 extern joydefsw_win_joyselect(char *title);
194 control_info Controls;
198 // macros for drawing lo/hi res kconfig screens (see scores.c as well)
200 #define LHX(x) ((x)*(MenuHires?2:1))
201 #define LHY(y) ((y)*(MenuHires?2.4:1))
205 #define BT_MOUSE_BUTTON 1
206 #define BT_MOUSE_AXIS 2
207 #define BT_JOY_BUTTON 3
208 #define BT_JOY_AXIS 4
211 char *btype_text[] = { "BT_KEY", "BT_MOUSE_BUTTON", "BT_MOUSE_AXIS", "BT_JOY_BUTTON", "BT_JOY_AXIS", "BT_INVERT" };
215 typedef struct kc_item {
216 short id; // The id of this item
224 ubyte value; // what key,button,etc
230 ubyte kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS];
232 //----------- WARNING!!!!!!! -------------------------------------------
233 // THESE NEXT FOUR BLOCKS OF DATA ARE GENERATED BY PRESSING DEL+F12 WHEN
234 // IN THE KEYBOARD CONFIG SCREEN. BASICALLY, THAT PROCEDURE MODIFIES THE
235 // U,D,L,R FIELDS OF THE ARRAYS AND DUMPS THE NEW ARRAYS INTO KCONFIG.COD
236 //-------------------------------------------------------------------------
237 /*ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
238 {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},
239 {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},
240 {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},
241 {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},
242 {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},
243 {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},
244 {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},
248 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
249 {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},
250 {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},
251 {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},
252 {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},
253 {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},
254 {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},
255 {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},
257 {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},
263 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
264 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
265 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
266 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
267 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
268 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
269 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
270 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
271 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
272 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
273 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
274 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
275 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
276 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
277 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
278 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
279 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
280 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
281 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
282 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
283 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
284 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
285 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
286 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
287 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
288 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
289 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
290 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
291 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
292 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
293 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
294 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
295 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
296 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
297 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
298 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
299 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
300 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
301 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
302 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
303 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
304 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
305 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
306 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
307 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
308 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
309 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
310 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
311 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
312 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
313 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
314 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
315 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
316 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
317 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
318 { 54,158,171, 83, 26, 52, 56, 51, 55,"Energy->Shield", BT_KEY, 255 },
319 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
320 { 56,158,179,83, 26, 54, 0, 0, 0, "Toggle Bomb", BT_KEY,255},
322 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
323 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
324 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
325 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
326 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
327 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
328 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
329 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
330 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
331 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
332 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
333 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
334 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
335 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
336 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
337 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
338 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
339 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
340 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
341 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
342 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
343 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
344 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
345 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
346 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
347 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
348 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
349 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
350 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
351 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
352 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
353 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
355 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
356 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
357 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
358 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
359 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
360 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
361 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
362 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
363 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
364 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
365 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
366 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
367 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
368 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
369 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
370 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
371 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
372 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
373 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
374 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
375 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
376 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
377 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
378 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
379 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
380 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
381 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
382 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
383 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
384 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
385 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
386 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
389 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
390 { 0, 25, 46, 85, 26, 12, 1, 24, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
391 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
392 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
393 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
394 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
395 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
396 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
397 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
398 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
399 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
400 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
401 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
402 { 12,180,106, 59, 26, 11, 0, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
403 { 13,103,138, 58, 26, 27, 15, 25, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
404 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
405 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
406 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
407 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
408 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
409 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
410 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
411 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
412 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
413 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
414 { 24,103,182,106, 8, 22, 5, 23, 0,"throttle", BT_INVERT, 255 },
415 { 25, 25,109, 85, 26, 3, 27, 12, 13,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
416 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
417 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
420 #else // ifndef MACINTOSH (following are macintosh controls)
422 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
423 {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},
424 {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},
425 {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},
426 {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},
427 {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},
428 {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},
429 {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},
432 ubyte default_firebird_settings[MAX_CONTROLS] =
433 {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};
435 ubyte default_mousestick_settings[MAX_CONTROLS] =
436 {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};
438 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
439 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
440 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
441 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
442 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
443 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
444 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
445 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
446 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
447 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
448 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
449 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
450 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
451 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
452 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
453 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
454 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
455 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
456 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
457 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
458 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
459 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
460 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
461 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
462 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
463 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
464 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
465 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
466 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
467 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
468 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
469 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
470 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
471 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
472 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
473 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
474 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
475 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
476 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
477 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
478 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
479 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
480 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
481 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
482 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
483 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
484 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
485 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
486 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
487 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
488 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
489 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
490 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
491 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
492 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
493 { 54,158,171, 83, 26, 52, 25, 51, 55,"Energy->Shield", BT_KEY, 255 },
494 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
496 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
497 { 0, 25, 46, 85, 28, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
498 { 1, 25, 54, 85, 28, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
499 { 2, 25, 85, 85, 28, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
500 { 3, 25, 93, 85, 28, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
501 { 4, 25, 62, 85, 28, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
502 { 5,180, 46, 79, 28, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
503 { 6,180, 54, 79, 28, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
504 { 7,180, 62, 79, 28, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
505 { 8,180, 70, 79, 28, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
506 { 9,180, 78, 79, 28, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
507 { 10,180, 90, 79, 28, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
508 { 11,180, 98, 79, 28, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
509 { 12,180,106, 79, 28, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
510 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
511 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
512 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
513 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
514 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
515 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
516 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
517 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
518 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
519 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
520 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
521 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
522 { 25, 25,109, 85, 28, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
523 { 26, 25, 70, 85, 28, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
524 { 27, 25,117, 85, 28, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
525 { 28,180,114, 79, 28, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
526 { 29,180,122, 79, 28, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
527 { 30, 25,125, 85, 28, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
529 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
530 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
531 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
532 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
533 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
534 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
535 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
536 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
537 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
538 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
539 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
540 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
541 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
542 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
543 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
544 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
545 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
546 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
547 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
548 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
549 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
550 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
551 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
552 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
553 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
554 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
555 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
556 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
557 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
558 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
559 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
560 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
563 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
564 { 0, 25, 46, 85, 26, 28, 1, 28, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
565 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
566 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
567 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
568 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
569 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
570 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
571 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
572 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
573 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
574 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
575 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
576 { 12,180,106, 59, 26, 11, 28, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
577 { 13,103,138, 58, 26, 27, 15, 27, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
578 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
579 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
580 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
581 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
582 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
583 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
584 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
585 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
586 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
587 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
588 { 24,103,182,106, 8, 22, 5, 23, 28,"throttle", BT_INVERT, 255 },
589 { 25, 25,109, 85, 26, 3, 27, 12, 27,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
590 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
591 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
596 void kc_drawitem( kc_item *item, int is_current );
597 void kc_change_key( kc_item * item );
598 void kc_change_joybutton( kc_item * item );
599 void kc_change_mousebutton( kc_item * item );
600 void kc_change_joyaxis( kc_item * item );
601 void kc_change_mouseaxis( kc_item * item );
602 void kc_change_invert( kc_item * item );
603 void kconfig_read_fcs( int raw_axis );
604 void kconfig_set_fcs_button( int btn, int button );
605 void kconfig_read_external_controls( void );
607 int kconfig_is_axes_used(int axis)
610 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
611 if (( kc_joystick[i].type == BT_JOY_AXIS ) && (kc_joystick[i].value == axis ))
617 #ifdef TABLE_CREATION
618 int find_item_at( kc_item * items, int nitems, int x, int y )
622 for (i=0; i<nitems; i++ ) {
623 if ( ((items[i].x+items[i].w1)==x) && (items[i].y==y))
629 int find_next_item_up( kc_item * items, int nitems, int citem )
634 x = items[citem].x+items[citem].w1;
639 y = grd_curcanv->cv_bitmap.bm_h-1;
642 x = grd_curcanv->cv_bitmap.bm_w-1;
645 i = find_item_at( items, nitems, x, y );
651 int find_next_item_down( kc_item * items, int nitems, int citem )
656 x = items[citem].x+items[citem].w1;
660 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
663 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
667 i = find_item_at( items, nitems, x, y );
673 int find_next_item_right( kc_item * items, int nitems, int citem )
678 x = items[citem].x+items[citem].w1;
682 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
685 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
689 i = find_item_at( items, nitems, x, y );
695 int find_next_item_left( kc_item * items, int nitems, int citem )
700 x = items[citem].x+items[citem].w1;
705 x = grd_curcanv->cv_bitmap.bm_w-1;
708 y = grd_curcanv->cv_bitmap.bm_h-1;
711 i = find_item_at( items, nitems, x, y );
718 #if defined(MACINTOSH) || defined(WINDOWS)
719 int get_item_height(kc_item *item)
724 if (item->value==255) {
725 sprintf( btext, "" );
727 switch( item->type ) {
729 strncpy( btext, key_text[item->value], 10 ); break;
730 case BT_MOUSE_BUTTON:
732 strncpy( btext, Text_string[mousebutton_text[item->value]], 10); break;
734 strncpy( btext, mousebutton_text[item->value], 10 ); break;
737 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
739 if ( joybutton_text[item->value] !=-1 )
740 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
742 sprintf( btext, "BTN%d", item->value );
745 strncpy( btext, Text_string[joyaxis_text[item->value]], 10 ); break;
747 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
750 gr_get_string_size(btext, &w, &h, &aw );
756 void kconfig_sub(kc_item * items,int nitems, char * title)
759 dd_grs_canvas * save_canvas,
760 grs_canvas * save_canvas
762 grs_font * save_font;
764 #if defined(MACINTOSH) || defined(WINDOWS)
765 int mouse_state, omouse_state, mx, my, x1, x2, y1, y2;
766 int close_x, close_y, close_size;
769 int i,k,ocitem,citem;
770 int time_stopped = 0;
771 WIN(char *old_bg_pcx);
773 WIN(old_bg_pcx = _SCRContext.bkg_filename);
774 WIN(DEFINE_SCREEN(NULL));
779 if (!((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence)) )
785 // if (Config_control_type == CONTROL_WINJOYSTICK) {
787 // joydefsw_win_joyselect(title2); title = title2,
789 // ); // Get Samir...
793 save_canvas = dd_grd_curcanv,
794 save_canvas = grd_curcanv
799 dd_gr_set_current_canvas(NULL),
800 gr_set_current_canvas(NULL)
802 save_font = grd_curcanv->cv_font;
808 old_keyd_repeat = keyd_repeat;
811 //gr_clear_canvas( BM_XRGB(0,0,0) );
813 nm_draw_background(0,0,grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
814 gr_palette_load (gr_palette);
816 grd_curcanv->cv_font = MEDIUM3_FONT;
818 WIN(DDGRLOCK(dd_grd_curcanv));
821 p = strchr( title, '\n' );
823 gr_string( 0x8000, LHY(8), title );
828 // if ( items == kc_keyboard ) {
829 // gr_string( 0x8000, 8, "Keyboard" );
830 // } else if ( items == kc_joystick ) {
831 // gr_string( 0x8000, 8, "Joysticks" );
832 // } else if ( items == kc_mouse ) {
833 // gr_string( 0x8000, 8, "Mouse" );
836 #if defined(MACINTOSH) || defined(WINDOWS)
837 close_x = close_y = 15;
839 gr_setcolor( BM_XRGB(0, 0, 0) );
840 gr_rect(close_x, close_y, close_x + close_size, close_y + close_size);
841 gr_setcolor( BM_XRGB(21, 21, 21) );
842 gr_rect( close_x + 2, close_y + 2, close_x + close_size - 2, close_y + close_size -2 );
845 grd_curcanv->cv_font = GAME_FONT;
846 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
849 gr_string( 0x8000, LHY(20), TXT_KCONFIG_STRING_1 );
851 gr_string( 0x8000, LHY(20), "Enter changes, ctrl-d deletes, ctrl-r resets defaults, ESC exits");
853 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
854 if ( items == kc_keyboard ) {
855 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
856 gr_setcolor( BM_XRGB(31,27,6) );
858 gr_scanline( LHX(98), LHX(106), LHY(42) );
859 gr_scanline( LHX(120), LHX(128), LHY(42) );
860 gr_pixel( LHX(98), LHY(43) );
861 gr_pixel( LHX(98), LHY(44) );
862 gr_pixel( LHX(128), LHY(43) );
863 gr_pixel( LHX(128), LHY(44) );
865 gr_string( LHX(109), LHY(40), "OR" );
867 gr_scanline( LHX(253), LHX(261), LHY(42) );
868 gr_scanline( LHX(274), LHX(283), LHY(42) );
869 gr_pixel( LHX(253), LHY(43) );
870 gr_pixel( LHX(253), LHY(44) );
871 gr_pixel( LHX(283), LHY(43) );
872 gr_pixel( LHX(283), LHY(44) );
874 gr_string( LHX(264), LHY(40), "OR" );
876 } if ( items == kc_joystick ) {
877 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
878 gr_setcolor( BM_XRGB(31,27,6) );
879 gr_scanline( LHX(18), LHX(135), LHY(37) );
880 gr_scanline( LHX(181), LHX(294), LHY(37) );
881 gr_scanline( LHX(18), LHX(144), LHY(119+18) );
882 gr_scanline( LHX(174), LHX(294), LHY(119+18) );
883 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
884 gr_string( 0x8000,LHY(117+18), TXT_AXES );
885 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
886 gr_string( LHX(81), LHY(137+8), TXT_AXIS );
887 gr_string( LHX(111), LHY(137+8), TXT_INVERT );
888 gr_string( LHX(222), LHY(137+8), TXT_AXIS );
889 gr_string( LHX(252), LHY(137+8), TXT_INVERT );
890 } else if ( items == kc_mouse ) {
891 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
892 gr_setcolor( BM_XRGB(31,27,6) );
893 gr_scanline( LHX(18), LHX(135), LHY(37) );
894 gr_scanline( LHX(181), LHX(294), LHY(37) );
895 gr_scanline( LHX(18), LHX(144), LHY(119+5) );
896 gr_scanline( LHX(174), LHX(294), LHY(119+5) );
897 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
898 gr_string( 0x8000,LHY(117+5), TXT_AXES );
899 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
900 gr_string( LHX(169), LHY(129), TXT_AXIS );
901 gr_string( LHX(199), LHY(129), TXT_INVERT );
903 WIN(DDGRUNLOCK(dd_grd_curcanv));
905 for (i=0; i<nitems; i++ ) {
906 kc_drawitem( &items[i], 0 );
910 kc_drawitem( &items[citem], 1 );
915 #if defined(MACINTOSH) || defined(WINDOWS)
916 mouse_state = omouse_state = 0;
920 // Windows addendum to allow for kconfig input.
925 DoMessageStuff(&msg);
928 _RedrawScreen = FALSE;
930 dd_gr_set_current_canvas(NULL);
940 //see if redbook song needs to be restarted
941 songs_check_redbook_repeat();
945 #if defined(MACINTOSH) || defined(WINDOWS)
946 omouse_state = mouse_state;
947 mouse_state = mouse_button_state(0);
950 if ( !time_stopped ) {
952 if (multi_menu_poll() == -1)
961 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_3:)
962 case KEY_PRINT_SCREEN:
965 case KEY_CTRLED+KEY_D:
966 items[citem].value = 255;
967 kc_drawitem( &items[citem], 1 );
969 case KEY_CTRLED+KEY_R:
970 if ( items==kc_keyboard ) {
971 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
972 items[i].value=default_kconfig_settings[0][i];
973 kc_drawitem( &items[i], 0 );
977 // hack for firebire and mousestick default controls since I made
978 // them the same control type -- dumb dumb dumb
979 if (joy_have_firebird())
980 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
981 items[i].value = default_firebird_settings[i];
982 kc_drawitem( &items[i], 0 );
984 else if (joy_have_mousestick())
985 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
986 items[i].value = default_mousestick_settings[i];
987 kc_drawitem( &items[i], 0 );
990 #endif // note link to above else
991 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
992 items[i].value = default_kconfig_settings[Config_control_type][i];
993 kc_drawitem( &items[i], 0 );
996 kc_drawitem( &items[citem], 1 );
999 items[citem].value=255;
1000 kc_drawitem( &items[citem], 1 );
1004 #ifdef TABLE_CREATION
1005 if (items[citem].u==-1) items[citem].u=find_next_item_up( items,nitems, citem);
1007 citem = items[citem].u;
1012 #ifdef TABLE_CREATION
1013 if (items[citem].d==-1) items[citem].d=find_next_item_down( items,nitems, citem);
1015 citem = items[citem].d;
1019 #ifdef TABLE_CREATION
1020 if (items[citem].l==-1) items[citem].l=find_next_item_left( items,nitems, citem);
1022 citem = items[citem].l;
1026 #ifdef TABLE_CREATION
1027 if (items[citem].r==-1) items[citem].r=find_next_item_right( items,nitems, citem);
1029 citem = items[citem].r;
1033 switch( items[citem].type ) {
1034 case BT_KEY: kc_change_key( &items[citem] ); break;
1035 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1036 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1037 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1038 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1039 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1044 grd_curcanv->cv_font = save_font;
1046 WIN(DEFINE_SCREEN(old_bg_pcx));
1049 dd_gr_set_current_canvas(save_canvas),
1050 gr_set_current_canvas( save_canvas )
1052 keyd_repeat = old_keyd_repeat;
1053 game_flush_inputs();
1054 WIN( HideCursorW());
1055 MAC( hide_cursor(); )
1059 #ifdef TABLE_CREATION
1060 case KEY_DEBUGGED+KEY_F12: {
1062 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1063 kc_keyboard[i].u = find_next_item_up( kc_keyboard,NUM_KEY_CONTROLS, i);
1064 kc_keyboard[i].d = find_next_item_down( kc_keyboard,NUM_KEY_CONTROLS, i);
1065 kc_keyboard[i].l = find_next_item_left( kc_keyboard,NUM_KEY_CONTROLS, i);
1066 kc_keyboard[i].r = find_next_item_right( kc_keyboard,NUM_KEY_CONTROLS, i);
1068 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1069 kc_joystick[i].u = find_next_item_up( kc_joystick,NUM_OTHER_CONTROLS, i);
1070 kc_joystick[i].d = find_next_item_down( kc_joystick,NUM_OTHER_CONTROLS, i);
1071 kc_joystick[i].l = find_next_item_left( kc_joystick,NUM_OTHER_CONTROLS, i);
1072 kc_joystick[i].r = find_next_item_right( kc_joystick,NUM_OTHER_CONTROLS, i);
1074 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1075 kc_mouse[i].u = find_next_item_up( kc_mouse,NUM_OTHER_CONTROLS, i);
1076 kc_mouse[i].d = find_next_item_down( kc_mouse,NUM_OTHER_CONTROLS, i);
1077 kc_mouse[i].l = find_next_item_left( kc_mouse,NUM_OTHER_CONTROLS, i);
1078 kc_mouse[i].r = find_next_item_right( kc_mouse,NUM_OTHER_CONTROLS, i);
1080 fp = fopen( "kconfig.cod", "wt" );
1082 fprintf( fp, "ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {\n" );
1083 for (i=0; i<CONTROL_MAX_TYPES; i++ ) {
1085 fprintf( fp, "{0x%x", kconfig_settings[i][0] );
1086 for (j=1; j<MAX_CONTROLS; j++ )
1087 fprintf( fp, ",0x%x", kconfig_settings[i][j] );
1088 fprintf( fp, "},\n" );
1090 fprintf( fp, "};\n" );
1092 fprintf( fp, "\nkc_item kc_keyboard[NUM_KEY_CONTROLS] = {\n" );
1093 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1094 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1095 kc_keyboard[i].id, kc_keyboard[i].x, kc_keyboard[i].y, kc_keyboard[i].w1, kc_keyboard[i].w2,
1096 kc_keyboard[i].u, kc_keyboard[i].d, kc_keyboard[i].l, kc_keyboard[i].r,
1097 34, kc_keyboard[i].text, 34, btype_text[kc_keyboard[i].type] );
1099 fprintf( fp, "};" );
1101 fprintf( fp, "\nkc_item kc_joystick[NUM_OTHER_CONTROLS] = {\n" );
1102 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1103 if (kc_joystick[i].type == BT_JOY_BUTTON)
1104 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1105 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1106 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1107 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1109 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1110 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1111 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1112 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1114 fprintf( fp, "};" );
1116 fprintf( fp, "\nkc_item kc_mouse[NUM_OTHER_CONTROLS] = {\n" );
1117 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1118 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1119 kc_mouse[i].id, kc_mouse[i].x, kc_mouse[i].y, kc_mouse[i].w1, kc_mouse[i].w2,
1120 kc_mouse[i].u, kc_mouse[i].d, kc_mouse[i].l, kc_mouse[i].r,
1121 34, kc_mouse[i].text, 34, btype_text[kc_mouse[i].type] );
1123 fprintf( fp, "};" );
1132 #if defined (MACINTOSH) || defined(WINDOWS)
1133 if ( (mouse_state && !omouse_state) || (mouse_state && omouse_state) ) {
1136 mouse_get_pos(&mx, &my);
1137 for (i=0; i<nitems; i++ ) {
1138 item_height = get_item_height( &items[i] );
1139 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[i].x) + LHX(items[i].w1);
1140 x2 = x1 + LHX(items[i].w2);
1141 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[i].y);
1142 y2 = y1 + LHX(item_height);
1143 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1149 else if ( !mouse_state && omouse_state ) {
1152 mouse_get_pos(&mx, &my);
1153 item_height = get_item_height( &items[citem] );
1154 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[citem].x) + LHX(items[citem].w1);
1155 x2 = x1 + LHX(items[citem].w2);
1156 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[citem].y);
1157 y2 = y1 + LHY(item_height);
1158 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1161 switch( items[citem].type ) {
1162 case BT_KEY: kc_change_key( &items[citem] ); break;
1163 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1164 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1165 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1166 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1167 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1172 x1 = grd_curcanv->cv_bitmap.bm_x + close_x + 2;
1173 x2 = x1 + close_size - 2;
1174 y1 = grd_curcanv->cv_bitmap.bm_y + close_y + 2;
1175 y2 = y1 + close_size - 2;
1176 if ( ((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2)) ) {
1177 grd_curcanv->cv_font = save_font;
1178 WINDOS(dd_gr_set_current_canvas( save_canvas ),
1179 gr_set_current_canvas( save_canvas ));
1180 keyd_repeat = old_keyd_repeat;
1181 game_flush_inputs();
1191 #endif // MACINTOSH WINDOWS
1193 if (ocitem!=citem) {
1196 kc_drawitem( &items[ocitem], 0 );
1197 kc_drawitem( &items[citem], 1 );
1205 void kc_drawitem( kc_item *item, int is_current )
1209 // PA_DFX (pa_set_frontbuffer_current());
1210 WIN(DDGRLOCK(dd_grd_curcanv));
1213 gr_set_fontcolor( BM_XRGB(20,20,29), -1 );
1215 gr_set_fontcolor( BM_XRGB(15,15,24), -1 );
1216 gr_string( LHX(item->x), LHY(item->y), item->text );
1217 WIN(DDGRUNLOCK(dd_grd_curcanv));
1219 if (item->value==255) {
1220 strcpy( btext, "" );
1222 switch( item->type ) {
1224 strncpy( btext, key_text[item->value], 10 ); break;
1225 case BT_MOUSE_BUTTON:
1227 strncpy( btext, Text_string[mousebutton_text[item->value]], 10 ); break;
1229 strncpy( btext, mousebutton_text[item->value], 10 ); break;
1232 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
1236 if (joybutton_text[item->value] != -1)
1237 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1239 sprintf( btext, "BTN%2d", item->value+1 );
1241 if ( joybutton_text[item->value] !=-1 )
1242 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1244 sprintf( btext, "BTN%d", item->value );
1247 strncpy( btext, joy_btn_name( item->value ), 10);
1249 sprintf( btext, "BTN%d", item->value );
1253 strncpy( btext, Text_string[joyaxis_text[item->value]], 10 ); break;
1255 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
1259 WIN(DDGRLOCK(dd_grd_curcanv));
1260 gr_get_string_size(btext, &w, &h, &aw );
1263 gr_setcolor( BM_XRGB(21,0,24) );
1265 gr_setcolor( BM_XRGB(16,0,19) );
1266 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1268 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1270 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1272 gr_string( x, LHY(item->y), btext );
1273 // PA_DFX (pa_set_backbuffer_current());
1275 WIN(DDGRUNLOCK(dd_grd_curcanv));
1280 static int looper=0;
1282 void kc_drawquestion( kc_item *item )
1286 WIN(DDGRLOCK(dd_grd_curcanv));
1287 // PA_DFX (pa_set_frontbuffer_current());
1289 gr_get_string_size("?", &w, &h, &aw );
1291 c = BM_XRGB(21,0,24);
1293 //@@gr_setcolor( gr_fade_table[fades[looper]*256+c] );
1294 gr_setcolor(BM_XRGB(21*fades[looper]/31,0,24*fades[looper]/31));
1296 if (looper>63) looper=0;
1298 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1300 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1302 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1304 gr_string( x, LHY(item->y), "?" );
1305 // PA_DFX (pa_set_backbuffer_current());
1306 WIN(DDGRUNLOCK(dd_grd_curcanv));
1310 void kc_change_key( kc_item * item )
1315 WIN(DDGRLOCK(dd_grd_curcanv));
1316 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1318 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_KEY );
1319 WIN(DDGRUNLOCK(dd_grd_curcanv));
1321 game_flush_inputs();
1325 while( (k!=KEY_ESC) && (keycode==255) )
1331 DoMessageStuff(&msg);
1338 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1341 // if ( Game_mode & GM_MULTI )
1342 // GameLoop( 0, 0 ); // Continue
1345 kc_drawquestion( item );
1347 for (i=0; i<256; i++ ) {
1348 if (keyd_pressed[i] && (strlen(key_text[i])>0)) {
1350 for (n=0; n<sizeof(system_keys); n++ )
1351 if ( system_keys[n] == i )
1360 for (i=0; i<Num_items; i++ ) {
1361 n = item - All_items;
1362 if ( (i!=n) && (All_items[i].type==BT_KEY) && (All_items[i].value==keycode) ) {
1363 All_items[i].value = 255;
1364 kc_drawitem( &All_items[i], 0 );
1367 item->value = keycode;
1369 kc_drawitem( item, 1 );
1371 WIN(DDGRLOCK(dd_grd_curcanv));
1372 gr_set_fontcolor( BM_XRGB(28,28,28), BM_XRGB(0,0,0) );
1373 WIN(DDGRUNLOCK(dd_grd_curcanv));
1375 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1377 game_flush_inputs();
1381 void kc_change_joybutton( kc_item * item )
1386 WIN(DDGRLOCK(dd_grd_curcanv));
1387 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1389 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_JBUTTON );
1390 WIN(DDGRUNLOCK(dd_grd_curcanv));
1392 game_flush_inputs();
1396 while( (k!=KEY_ESC) && (code==255))
1401 DoMessageStuff(&msg);
1407 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1410 // if ( Game_mode & GM_MULTI )
1411 // GameLoop( 0, 0 ); // Continue
1415 if (k == KEY_PRINT_SCREEN)
1416 save_screen_shot(0);
1418 kc_drawquestion( item );
1420 WIN(code = joydefsw_do_button());
1423 code = joy_do_buttons();
1426 #if !defined(WINDOWS) && !defined(MACINTOSH)
1427 if (Config_control_type==CONTROL_THRUSTMASTER_FCS) {
1429 joystick_read_raw_axis( JOY_ALL_AXIS, axis );
1430 kconfig_read_fcs( axis[3] );
1431 if ( joy_get_button_state(7) ) code = 7;
1432 if ( joy_get_button_state(11) ) code = 11;
1433 if ( joy_get_button_state(15) ) code = 15;
1434 if ( joy_get_button_state(19) ) code = 19;
1435 for (i=0; i<4; i++ ) {
1436 if ( joy_get_button_state(i) )
1439 } else if (Config_control_type==CONTROL_FLIGHTSTICK_PRO) {
1440 for (i=4; i<20; i++ ) {
1441 if ( joy_get_button_state(i) ) {
1443 mprintf(( 0, "JB: %d\n", code ));
1447 for (i=0; i<MAX_BUTTONS; i++ ) {
1448 if ( joy_get_button_state(i) )
1455 for (i=0; i<Num_items; i++ ) {
1456 n = item - All_items;
1457 if ( (i!=n) && (All_items[i].type==BT_JOY_BUTTON) && (All_items[i].value==code) ) {
1458 All_items[i].value = 255;
1459 kc_drawitem( &All_items[i], 0 );
1464 kc_drawitem( item, 1 );
1465 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1466 game_flush_inputs();
1469 void kc_change_mousebutton( kc_item * item )
1474 WIN(DDGRLOCK(dd_grd_curcanv));
1475 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1477 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_MBUTTON );
1478 WIN(DDGRUNLOCK(dd_grd_curcanv));
1481 game_flush_inputs();
1485 while( (k!=KEY_ESC) && (code==255))
1490 DoMessageStuff(&msg);
1496 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1499 // if ( Game_mode & GM_MULTI )
1500 // GameLoop( 0, 0 ); // Continue
1504 if (k == KEY_PRINT_SCREEN)
1505 save_screen_shot(0);
1507 kc_drawquestion( item );
1509 b = mouse_get_btns();
1510 for (i=0; i<3; i++ ) {
1516 for (i=0; i<Num_items; i++ ) {
1517 n = item - All_items;
1518 if ( (i!=n) && (All_items[i].type==BT_MOUSE_BUTTON) && (All_items[i].value==code) ) {
1519 All_items[i].value = 255;
1520 kc_drawitem( &All_items[i], 0 );
1525 kc_drawitem( item, 1 );
1526 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1527 game_flush_inputs();
1531 void kc_change_joyaxis( kc_item * item )
1535 int old_axis[MAX_AXES];
1537 int axis[JOY_NUM_AXES];
1538 int old_axis[JOY_NUM_AXES];
1547 WIN(DDGRLOCK(dd_grd_curcanv));
1548 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1550 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_JOY_AXIS );
1551 WIN(DDGRUNLOCK(dd_grd_curcanv));
1553 game_flush_inputs();
1558 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, old_axis ),
1559 joystick_read_raw_axis( JOY_ALL_AXIS, old_axis )
1562 while( (k!=KEY_ESC) && (code==255))
1567 DoMessageStuff(&msg);
1573 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1576 // if ( Game_mode & GM_MULTI )
1577 // GameLoop( 0, 0 ); // Continue
1581 if (k == KEY_PRINT_SCREEN)
1582 save_screen_shot(0);
1584 kc_drawquestion( item );
1587 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, axis ),
1588 joystick_read_raw_axis( JOY_ALL_AXIS, axis )
1591 for (i=0; i<numaxis; i++ ) {
1592 #if defined (MACINTOSH)
1593 if ( abs(axis[i]-old_axis[i])>100 ) {
1594 #elif defined(WINDOWS)
1595 if ( abs(axis[i]-old_axis[i])>1024 ) {
1597 if ( abs(axis[i]-old_axis[i])>200 ) {
1600 con_printf(CON_DEBUG, "Axis Movement detected: Axis %i\n", i);
1602 //old_axis[i] = axis[i];
1604 for (i=0; i<Num_items; i++ )
1606 n = item - All_items;
1607 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) )
1613 for (i=0; i<Num_items; i++ ) {
1614 n = item - All_items;
1615 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) ) {
1616 All_items[i].value = 255;
1617 kc_drawitem( &All_items[i], 0 );
1623 kc_drawitem( item, 1 );
1624 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1625 game_flush_inputs();
1629 void kc_change_mouseaxis( kc_item * item )
1638 WIN(DDGRLOCK(dd_grd_curcanv));
1639 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1641 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_MSE_AXIS );
1642 WIN(DDGRUNLOCK(dd_grd_curcanv));
1644 game_flush_inputs();
1648 mouse_get_delta( &dx, &dy );
1650 while( (k!=KEY_ESC) && (code==255))
1655 DoMessageStuff(&msg);
1661 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1664 // if ( Game_mode & GM_MULTI )
1665 // GameLoop( 0, 0 ); // Continue
1669 if (k == KEY_PRINT_SCREEN)
1670 save_screen_shot(0);
1672 kc_drawquestion( item );
1675 mouse_get_delta_z( &dx, &dy, &dz );
1677 mouse_get_delta( &dx, &dy );
1679 if ( abs(dx)>20 ) code = 0;
1680 if ( abs(dy)>20 ) code = 1;
1682 if ( abs(dz)>20 ) code = 2;
1686 for (i=0; i<Num_items; i++ ) {
1687 n = item - All_items;
1688 if ( (i!=n) && (All_items[i].type==BT_MOUSE_AXIS) && (All_items[i].value==code) ) {
1689 All_items[i].value = 255;
1690 kc_drawitem( &All_items[i], 0 );
1695 kc_drawitem( item, 1 );
1696 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1697 game_flush_inputs();
1702 void kc_change_invert( kc_item * item )
1704 game_flush_inputs();
1711 kc_drawitem( item, 1 );
1715 #include "screens.h"
1717 extern void gr_bm_bitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
1719 void kconfig(int n, char * title)
1722 grs_bitmap *save_bm;
1724 set_screen_mode( SCREEN_MENU );
1729 WIN(mouse_set_mode(0));
1730 WIN(dd_gr_set_current_canvas(NULL));
1732 #if defined(POLY_ACC)
1733 save_bm = gr_create_bitmap2( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h, grd_curcanv->cv_bitmap.bm_type, NULL );
1735 save_bm = gr_create_bitmap( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
1737 Assert( save_bm != NULL );
1739 WIN(DDGRLOCK(dd_grd_curcanv));
1740 gr_bm_bitblt(grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_w,
1741 0, 0, 0, 0, &grd_curcanv->cv_bitmap, save_bm );
1742 WIN(DDGRUNLOCK(dd_grd_curcanv));
1745 case 0:kconfig_sub( kc_keyboard, NUM_KEY_CONTROLS, title );break;
1746 case 1:kconfig_sub( kc_joystick, NUM_OTHER_CONTROLS, title );break;
1747 case 2:kconfig_sub( kc_mouse, NUM_OTHER_CONTROLS, title ); break;
1748 case 3:kconfig_sub( kc_superjoy, NUM_OTHER_CONTROLS, title); break;
1755 WIN(mouse_set_mode(1));
1756 WIN(dd_gr_set_current_canvas(NULL));
1757 WIN(DDGRLOCK(dd_grd_curcanv));
1758 gr_bitmap(0, 0, save_bm);
1759 WIN(DDGRUNLOCK(dd_grd_curcanv));
1760 gr_free_bitmap(save_bm);
1762 reset_cockpit(); //force cockpit redraw next time
1764 // Update save values...
1766 for (i=0; i<NUM_KEY_CONTROLS; i++ )
1767 kconfig_settings[0][i] = kc_keyboard[i].value;
1769 if ( (Config_control_type>0) && (Config_control_type<5)) {
1770 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1771 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
1772 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
1773 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1774 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
1776 else if (Config_control_type == CONTROL_WINJOYSTICK) {
1777 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1778 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
1783 void kconfig_read_fcs( int raw_axis )
1785 int raw_button, button, axis_min[4], axis_center[4], axis_max[4];
1787 if (Config_control_type!=CONTROL_THRUSTMASTER_FCS) return;
1789 joy_get_cal_vals(axis_min, axis_center, axis_max);
1791 if ( axis_max[3] > 1 )
1792 raw_button = (raw_axis*100)/axis_max[3];
1796 if ( raw_button > 88 )
1798 else if ( raw_button > 63 )
1800 else if ( raw_button > 39 )
1802 else if ( raw_button > 15 )
1807 kconfig_set_fcs_button( 19, button );
1808 kconfig_set_fcs_button( 15, button );
1809 kconfig_set_fcs_button( 11, button );
1810 kconfig_set_fcs_button( 7, button );
1814 void kconfig_set_fcs_button( int btn, int button )
1816 int state,time_down,upcount,downcount;
1817 state = time_down = upcount = downcount = 0;
1819 if ( joy_get_button_state(btn) ) {
1820 if ( btn==button ) {
1822 time_down = FrameTime;
1827 if ( btn==button ) {
1829 time_down = FrameTime;
1836 joy_set_btn_values( btn, state, time_down, downcount, upcount );
1842 fix Last_angles_p = 0;
1843 fix Last_angles_b = 0;
1844 fix Last_angles_h = 0;
1845 ubyte Last_angles_read = 0;
1847 extern int VR_sensitivity;
1849 int VR_sense_range[3] = { 25, 50, 75 };
1851 #if 0 //ndef MACINTOSH
1856 fix yaw, pitch, roll;
1859 //------ read vfx1 helmet --------
1860 if (vfx1_installed) {
1861 vfx_get_data(&yaw,&pitch,&roll,&buttons);
1862 } else if (iglasses_headset_installed) {
1863 iglasses_read_headset( &yaw, &pitch, &roll );
1864 } else if (Victor_headset_installed) {
1865 victor_read_headset_filtered( &yaw, &pitch, &roll );
1870 Use_player_head_angles = 0;
1871 if ( Last_angles_read ) {
1875 if ( (Last_angles_h < (F1_0/4) ) && (yaw > ((F1_0*3)/4) ) )
1877 else if ( (yaw < (F1_0/4) ) && (Last_angles_h > ((F1_0*3)/4) ) )
1880 Controls.pitch_time += fixmul((pitch- Last_angles_p)*VR_sense_range[VR_sensitivity],FrameTime);
1881 Controls.heading_time+= fixmul((yaw1 - Last_angles_h)*VR_sense_range[VR_sensitivity],FrameTime);
1882 Controls.bank_time += fixmul((roll - Last_angles_b)*VR_sense_range[VR_sensitivity],FrameTime);
1884 Last_angles_read = 1;
1885 Last_angles_p = pitch;
1886 Last_angles_h = yaw;
1887 Last_angles_b = roll;
1895 #define JOYSTICK_READ_TIME (F1_0/40) // Read joystick at 40 Hz.
1897 #define JOYSTICK_READ_TIME (F1_0/10) // Read joystick at 10 Hz.
1900 fix LastReadTime = 0;
1904 ubyte kc_use_external_control = 0;
1905 ubyte kc_enable_external_control = 0;
1906 ubyte kc_external_intno = 0;
1907 ext_control_info *kc_external_control = NULL;
1908 ubyte *kc_external_name = NULL;
1909 ubyte kc_external_version = 0;
1910 extern int Automap_active;
1912 void kconfig_init_external_controls(int intno, int address)
1915 kc_external_intno = intno;
1916 kc_external_control = (ext_control_info *)address;
1917 kc_use_external_control = 1;
1918 kc_enable_external_control = 1;
1920 i = FindArg ( "-xname" );
1922 kc_external_name = Args[i+1];
1924 kc_external_name = "External Controller";
1926 for (i=0;i<strlen (kc_external_name);i++)
1927 if (kc_external_name[i]=='_')
1928 kc_external_name[i]=' ';
1930 i = FindArg ( "-xver" );
1932 kc_external_version = atoi(Args[i+1]);
1934 printf( "%s int: 0x%x, data: 0x%p, ver:%d\n", kc_external_name, kc_external_intno, kc_external_control, kc_external_version );
1938 #if !defined(MACINTOSH)
1939 /*void kconfig_read_external_controls()
1943 if ( !kc_enable_external_control && !CybermouseActive)
1946 if ( kc_external_version == 0 )
1947 memset( kc_external_control, 0, sizeof(control_info) );
1948 else if ( kc_external_version > 0 ) {
1949 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 );
1950 if ( kc_external_version > 1 ) {
1951 // Write ship pos and angles to external controls...
1952 ubyte *temp_ptr = (ubyte *)kc_external_control;
1953 vms_vector *ship_pos;
1954 vms_matrix *ship_orient;
1955 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
1956 temp_ptr += sizeof(control_info)+sizeof(vms_angvec) + 64;
1957 ship_pos = (vms_vector *)temp_ptr;
1958 temp_ptr += sizeof(vms_vector);
1959 ship_orient = (vms_matrix *)temp_ptr;
1960 // Fill in ship postion...
1961 *ship_pos = Objects[Players[Player_num].objnum].pos;
1962 // Fill in ship orientation...
1963 *ship_orient = Objects[Players[Player_num].objnum].orient;
1967 if ( Automap_active ) // (If in automap...)
1968 kc_external_control->automap_state = 1;
1969 memset(&r,0,sizeof(r));
1973 if (!CybermouseActive)
1974 int386 ( kc_external_intno, &r, &r); // Read external info...
1976 // ReadOWL (kc_external_control);
1980 if ( Player_num > -1 ) {
1981 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
1982 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
1983 Auto_leveling_on = 0;
1985 if ( kc_external_version > 0 ) {
1986 vms_matrix tempm, ViewMatrix;
1987 vms_angvec * Kconfig_abs_movement;
1990 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
1992 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
1993 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
1994 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
1995 Objects[Players[Player_num].objnum].orient = ViewMatrix;
1997 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
1998 if (oem_message[0] != '\0' )
1999 HUD_init_message( oem_message );
2003 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
2004 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
2005 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
2006 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
2007 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
2008 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
2009 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
2010 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
2011 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
2012 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
2013 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
2014 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
2015 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
2016 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
2017 Controls.automap_down_count += kc_external_control->automap_down_count;
2018 Controls.automap_state |= kc_external_control->automap_state;
2023 void controls_read_all_win()
2026 int slide_on, bank_on;
2030 int raw_joy_axis[7];
2032 fix k0, k1, k2, k3, kp;
2033 fix k4, k5, k6, k7, kh;
2034 ubyte channel_masks;
2035 int use_mouse, use_joystick;
2038 if (Game_turbo_mode)
2042 fix temp = Controls.heading_time;
2043 fix temp1 = Controls.pitch_time;
2044 memset( &Controls, 0, sizeof(control_info) );
2045 Controls.heading_time = temp;
2046 Controls.pitch_time = temp1;
2051 ctime = timer_get_fixed_seconds();
2053 // DO JOYSTICK (X,Y,Z R,U,V)
2054 // ----------------------------------------------------------------------------
2055 if ( (LastReadTime + JOYSTICK_READ_TIME) > ctime ) {
2056 if ((ctime < 0) && (LastReadTime > 0))
2057 LastReadTime = ctime;
2059 } else if ((Config_control_type==CONTROL_WINJOYSTICK)) {
2060 LastReadTime = ctime;
2061 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, raw_joy_axis );
2063 for (i=0; i<7; i++ ) {
2064 if (channel_masks&(1<<i)) {
2065 int joy_null_value = 28;
2067 // DO POV if joystick has a hat.
2068 // --------------------------------------------------------------------
2070 joydefsw_do_winjoybutton(raw_joy_axis);
2074 // --------------------------------------------------------------------
2075 // mprintf((0, "(%d)=%d,", i, raw_joy_axis[i]));
2076 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2077 // mprintf((0, "%d ",raw_joy_axis[i]));
2078 // if (i%2) mprintf((0,"\n"));
2081 if (kc_superjoy[23].value==i) // If this is the throttle
2082 joy_null_value = 32; // Then use a larger dead-zone
2084 if (raw_joy_axis[i] > (joy_null_value-2))
2085 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2086 else 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);
2089 raw_joy_axis[i] = 0;
2090 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2099 for (i=0; i<6; i++ )
2105 // ----------------------------------------------------------------------------
2106 if (Config_control_type==5) {
2107 mouse_get_delta( &dx, &dy );
2108 mouse_axis[0] = (dx*FrameTime)/35;
2109 mouse_axis[1] = (dy*FrameTime)/25;
2110 mouse_buttons = mouse_get_btns();
2111 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2120 //------------- Read slide_on -------------
2123 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
2124 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
2126 if ((use_joystick)&&(kc_superjoy[5].value<255)) slide_on |= joy_get_button_state( kc_superjoy[5].value );
2128 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
2130 //------------- Read bank_on ---------------
2133 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
2134 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
2136 if ( (use_joystick)&&(kc_superjoy[10].value < 255 )) bank_on |= joy_get_button_state( kc_superjoy[10].value );
2138 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
2140 //------------ Read pitch_time -----------
2142 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2144 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
2145 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
2146 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
2147 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
2150 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
2151 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
2152 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
2153 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
2156 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2157 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
2158 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
2162 Controls.pitch_time = 0;
2164 if (Controls.pitch_time < 0)
2165 Controls.pitch_time = 0;
2167 if (Controls.pitch_time > 0)
2168 Controls.pitch_time = 0;
2169 Controls.pitch_time += kp;
2172 if ( (use_joystick)&&(kc_superjoy[13].value < 255 )) {
2173 if ( !kc_superjoy[14].value ) // If not inverted...
2174 Controls.pitch_time -= (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2176 Controls.pitch_time += (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2180 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
2181 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
2182 if ( !kc_mouse[14].value ) // If not inverted...
2183 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2185 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2188 Controls.pitch_time = 0;
2192 //----------- Read vertical_thrust_time -----------------
2195 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
2196 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
2197 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
2198 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
2201 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
2202 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
2203 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
2204 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
2207 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2208 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
2209 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
2213 if ((use_joystick)&&( kc_superjoy[13].value < 255 )) {
2214 if ( !kc_superjoy[14].value ) // If not inverted...
2215 Controls.vertical_thrust_time += joy_axis[kc_superjoy[13].value];
2217 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[13].value];
2221 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
2222 if ( !kc_mouse[14].value ) // If not inverted...
2223 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
2225 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
2230 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
2231 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
2232 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
2233 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
2236 if ((use_joystick)&&( kc_superjoy[19].value < 255 )) {
2237 if ( !kc_superjoy[20].value ) // If not inverted...
2238 Controls.vertical_thrust_time += joy_axis[kc_superjoy[19].value];
2240 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[19].value];
2243 // From joystick buttons
2244 if ( (use_joystick)&&(kc_superjoy[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_superjoy[8].value );
2245 if ( (use_joystick)&&(kc_superjoy[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_superjoy[9].value );
2247 // From mouse buttons
2248 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
2249 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
2252 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
2253 if ( !kc_mouse[20].value ) // If not inverted...
2254 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
2256 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
2260 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2261 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
2262 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
2265 //---------- Read heading_time -----------
2267 if (!slide_on && !bank_on) {
2268 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2270 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
2271 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
2272 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
2273 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
2276 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
2277 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
2278 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
2279 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
2282 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2283 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
2284 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
2288 Controls.heading_time = 0;
2290 if (Controls.heading_time < 0)
2291 Controls.heading_time = 0;
2293 if (Controls.heading_time > 0)
2294 Controls.heading_time = 0;
2295 Controls.heading_time += kh;
2298 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2299 if ( !kc_superjoy[16].value ) // If not inverted...
2300 Controls.heading_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2302 Controls.heading_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2306 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2307 if ( !kc_mouse[16].value ) // If not inverted...
2308 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2310 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2313 Controls.heading_time = 0;
2316 //----------- Read sideways_thrust_time -----------------
2319 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2320 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2321 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2322 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2325 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
2326 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
2327 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
2328 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
2331 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2332 if ( !kc_superjoy[16].value ) // If not inverted...
2333 Controls.sideways_thrust_time += joy_axis[kc_superjoy[15].value];
2335 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[15].value];
2339 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2340 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
2341 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
2345 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2346 if ( !kc_mouse[16].value ) // If not inverted...
2347 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
2349 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
2354 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
2355 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
2356 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
2357 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
2360 if ( (use_joystick)&&(kc_superjoy[17].value < 255 )) {
2361 if ( !kc_superjoy[18].value ) // If not inverted...
2362 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[17].value];
2364 Controls.sideways_thrust_time += joy_axis[kc_superjoy[17].value];
2367 // From joystick buttons
2368 if ( (use_joystick)&&(kc_superjoy[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_superjoy[6].value );
2369 if ( (use_joystick)&&(kc_superjoy[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_superjoy[7].value );
2371 // From mouse buttons
2372 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
2373 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
2376 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
2377 if ( !kc_mouse[18].value ) // If not inverted...
2378 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
2380 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
2383 //----------- Read bank_time -----------------
2386 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2387 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2388 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2389 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2392 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
2393 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
2394 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
2395 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
2398 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2399 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
2400 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
2404 if ( (use_joystick)&&(kc_superjoy[15].value < 255) ) {
2405 if ( !kc_superjoy[16].value ) // If not inverted...
2406 Controls.bank_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2408 Controls.bank_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2412 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2413 if ( !kc_mouse[16].value ) // If not inverted...
2414 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2416 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2421 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
2422 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
2423 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
2424 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
2427 if ( (use_joystick)&&(kc_superjoy[21].value < 255) ) {
2428 if ( !kc_superjoy[22].value ) // If not inverted...
2429 Controls.bank_time -= joy_axis[kc_superjoy[21].value];
2431 Controls.bank_time += joy_axis[kc_superjoy[21].value];
2434 // From joystick buttons
2435 if ( (use_joystick)&&(kc_superjoy[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_superjoy[11].value );
2436 if ( (use_joystick)&&(kc_superjoy[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_superjoy[12].value );
2438 // From mouse buttons
2439 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
2440 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
2443 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
2444 if ( !kc_mouse[22].value ) // If not inverted...
2445 Controls.bank_time += mouse_axis[kc_mouse[21].value];
2447 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
2451 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2452 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
2453 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
2456 //----------- Read forward_thrust_time -------------
2459 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
2460 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
2461 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
2462 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
2465 if ( (use_joystick)&&(kc_superjoy[23].value < 255 )) {
2466 if ( !kc_superjoy[24].value ) // If not inverted...
2467 Controls.forward_thrust_time -= joy_axis[kc_superjoy[23].value];
2469 Controls.forward_thrust_time += joy_axis[kc_superjoy[23].value];
2472 // From joystick buttons
2473 if ( (use_joystick)&&(kc_superjoy[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_superjoy[2].value );
2474 if ( (use_joystick)&&(kc_superjoy[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_superjoy[3].value );
2477 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
2478 if ( !kc_mouse[24].value ) // If not inverted...
2479 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
2481 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
2484 // From mouse buttons
2485 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
2486 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
2488 //----------- Read afterburner_state -------------
2491 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
2492 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
2494 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
2496 if ( (use_joystick)&&(kc_superjoy[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_superjoy[27].value);
2498 //-------Read headlight key--------------------------
2499 if (kc_keyboard[52].value < 255 )
2500 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
2501 if (kc_keyboard[53].value < 255 )
2502 Controls.headlight_count=key_down_count(kc_keyboard[53].value);
2503 if ((use_joystick)&&(kc_superjoy[30].value < 255 ))
2504 Controls.headlight_count=joy_get_button_down_cnt(kc_superjoy[30].value);
2506 //--------Read Cycle Primary Key------------------
2508 if (kc_keyboard[48].value<255)
2509 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
2510 if (kc_keyboard[49].value<255)
2511 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
2512 if ((use_joystick)&&(kc_superjoy[28].value < 255 ))
2513 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_superjoy[28].value);
2515 //--------Read Cycle Secondary Key------------------
2517 if (kc_keyboard[50].value<255)
2518 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
2519 if (kc_keyboard[51].value<255)
2520 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
2521 if ((use_joystick)&&(kc_superjoy[29].value < 255 ))
2522 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_superjoy[29].value);
2524 //--------Read Toggle Bomb key----------------------
2526 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
2528 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
2530 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
2531 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
2533 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2534 HUD_init_message ("No bombs available!");
2538 if (Players[Player_num].secondary_ammo[bomb]==0)
2540 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2541 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
2545 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
2546 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
2551 //---------Read Energy->Shield key----------
2553 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
2554 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
2555 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
2556 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
2558 //----------- Read fire_primary_down_count
2559 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
2560 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
2561 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_superjoy[0].value);
2562 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
2564 //----------- Read fire_primary_state
2565 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
2566 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
2567 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_superjoy[0].value);
2568 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
2570 //----------- Read fire_secondary_down_count
2571 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
2572 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
2573 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_superjoy[1].value);
2574 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
2576 //----------- Read fire_secondary_state
2577 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
2578 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
2579 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_superjoy[1].value);
2580 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
2582 //----------- Read fire_flare_down_count
2583 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
2584 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
2585 if ((use_joystick)&&(kc_superjoy[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_superjoy[4].value);
2586 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
2588 //----------- Read drop_bomb_down_count
2589 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
2590 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
2591 if ((use_joystick)&&(kc_superjoy[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_superjoy[26].value);
2592 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
2594 //----------- Read rear_view_down_count
2595 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
2596 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
2597 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_superjoy[25].value);
2598 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
2600 //----------- Read rear_view_down_state
2601 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
2602 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
2603 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_superjoy[25].value);
2604 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
2606 //----------- Read automap_down_count
2607 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
2608 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
2610 //----------- Read automap_state
2611 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
2612 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
2614 //----------- Read stupid-cruise-control-type of throttle.
2616 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
2617 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
2618 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
2619 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
2620 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
2622 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
2625 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
2626 if (Cruise_speed < 0 ) Cruise_speed = 0;
2628 if (Controls.forward_thrust_time==0)
2629 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
2632 //read_head_tracker();
2634 // Read external controls
2635 if (kc_use_external_control || CybermouseActive)
2636 kconfig_read_external_controls();
2638 //----------- Clamp values between -FrameTime and FrameTime
2639 if (FrameTime > F1_0 )
2640 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
2642 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
2643 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
2644 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
2645 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
2646 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
2647 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
2648 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
2650 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
2651 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
2652 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
2653 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
2654 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
2655 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
2656 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
2659 //--------- Don't do anything if in debug mode
2661 if ( keyd_pressed[KEY_DELETE] ) {
2662 memset( &Controls, 0, sizeof(control_info) );
2669 fix Next_toggle_time[3]={0,0,0};
2671 int allowed_to_toggle(int i)
2673 //used for keeping tabs of when its ok to toggle headlight,primary,and secondary
2675 if (Next_toggle_time[i] > GameTime)
2676 if (Next_toggle_time[i] < GameTime + (F1_0/8)) // In case time is bogus, never wait > 1 second.
2679 Next_toggle_time[i] = GameTime + (F1_0/8);
2686 void controls_read_all()
2689 int slide_on, bank_on;
2696 fix mouse_axis[3] = {0,0,0};
2698 int raw_joy_axis[MAX_AXES];
2700 int raw_joy_axis[JOY_NUM_AXES];
2703 fix k0, k1, k2, k3, kp;
2704 fix k4, k5, k6, k7, kh;
2705 ubyte channel_masks;
2706 int use_mouse, use_joystick;
2712 if (Game_turbo_mode)
2716 fix temp = Controls.heading_time;
2717 fix temp1 = Controls.pitch_time;
2718 memset( &Controls, 0, sizeof(control_info) );
2719 Controls.heading_time = temp;
2720 Controls.pitch_time = temp1;
2725 ctime = timer_get_fixed_seconds();
2727 //--------- Read Joystick -----------
2729 if ( (LastReadTime + JOYSTICK_READ_TIME > ctime) && (Config_control_type!=CONTROL_THRUSTMASTER_FCS) ) {
2730 if ((ctime < 0) && (LastReadTime > 0))
2731 LastReadTime = ctime;
2733 } else if ((Config_control_type>0) && (Config_control_type<5) ) {
2734 LastReadTime = ctime;
2735 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
2737 for (i=0; i<6; i++ ) {
2739 if (channel_masks&(1<<i)) {
2741 int joy_null_value = 10;
2743 if ( (i==3) && (Config_control_type==CONTROL_THRUSTMASTER_FCS) ) {
2744 kconfig_read_fcs( raw_joy_axis[i] );
2746 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2748 if (kc_joystick[23].value==i) // If this is the throttle
2749 joy_null_value = 20; // Then use a larger dead-zone
2751 if (raw_joy_axis[i] > joy_null_value)
2752 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2753 else 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);
2756 raw_joy_axis[i] = 0;
2757 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2767 for (i=0; i<4; i++ )
2772 //--------- Read Joystick -----------
2773 if ((Config_control_type>0) && (Config_control_type<5) ) {
2774 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
2775 for (i=0; i<4; i++ ) {
2776 if (channel_masks&(1<<i)) {
2777 int joy_null_value = 10;
2779 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2781 if (kc_joystick[23].value==i) // If this is the throttle
2782 joy_null_value = 20; // Then use a larger dead-zone
2784 if (raw_joy_axis[i] > joy_null_value)
2785 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2786 else 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);
2789 raw_joy_axis[i] = 0;
2790 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2797 for (i=0; i<4; i++ )
2801 #endif // ifndef MACINTOSH
2803 if (Config_control_type==5 && !CybermouseActive) {
2804 //--------- Read Mouse -----------
2806 mouse_get_delta_z( &dx, &dy, &dz );
2808 mouse_get_delta( &dx, &dy );
2810 mouse_axis[0] = (dx*FrameTime)/35;
2811 mouse_axis[1] = (dy*FrameTime)/25;
2813 mouse_axis[2] = (dz*FrameTime);
2815 mouse_buttons = mouse_get_btns();
2816 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2818 } else if (Config_control_type==6 && !CybermouseActive) {
2819 //--------- Read Cyberman -----------
2820 mouse_get_cyberman_pos(&idx,&idy );
2821 mouse_axis[0] = (idx*FrameTime)/128;
2822 mouse_axis[1] = (idy*FrameTime)/128;
2823 mouse_buttons = mouse_get_btns();
2825 } else if (CybermouseActive) {
2826 // ReadOWL (kc_external_control);
2827 // CybermouseAdjust();
2835 //------------- Read slide_on -------------
2838 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
2839 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
2841 if ((use_joystick)&&(kc_joystick[5].value<255)) slide_on |= joy_get_button_state( kc_joystick[5].value );
2843 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
2845 //------------- Read bank_on ---------------
2848 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
2849 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
2851 if ( (use_joystick)&&(kc_joystick[10].value < 255 )) bank_on |= joy_get_button_state( kc_joystick[10].value );
2853 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
2855 //------------ Read pitch_time -----------
2857 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2859 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
2860 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
2861 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
2862 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
2865 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
2866 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
2867 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
2868 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
2871 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2872 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
2873 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
2877 Controls.pitch_time = 0;
2879 if (Controls.pitch_time < 0)
2880 Controls.pitch_time = 0;
2882 if (Controls.pitch_time > 0)
2883 Controls.pitch_time = 0;
2884 Controls.pitch_time += kp;
2887 if ( (use_joystick)&&(kc_joystick[13].value < 255 )) {
2888 if ( !kc_joystick[14].value ) // If not inverted...
2889 Controls.pitch_time -= (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
2891 Controls.pitch_time += (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
2895 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
2896 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
2897 if ( !kc_mouse[14].value ) // If not inverted...
2898 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2900 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2903 Controls.pitch_time = 0;
2907 //----------- Read vertical_thrust_time -----------------
2910 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
2911 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
2912 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
2913 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
2916 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
2917 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
2918 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
2919 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
2922 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2923 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
2924 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
2928 if ((use_joystick)&&( kc_joystick[13].value < 255 )) {
2929 if ( !kc_joystick[14].value ) // If not inverted...
2930 Controls.vertical_thrust_time += joy_axis[kc_joystick[13].value];
2932 Controls.vertical_thrust_time -= joy_axis[kc_joystick[13].value];
2936 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
2937 if ( !kc_mouse[14].value ) // If not inverted...
2938 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
2940 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
2945 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
2946 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
2947 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
2948 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
2951 if ((use_joystick)&&( kc_joystick[19].value < 255 )) {
2952 if ( !kc_joystick[20].value ) // If not inverted...
2953 Controls.vertical_thrust_time += joy_axis[kc_joystick[19].value];
2955 Controls.vertical_thrust_time -= joy_axis[kc_joystick[19].value];
2958 // From joystick buttons
2959 if ( (use_joystick)&&(kc_joystick[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_joystick[8].value );
2960 if ( (use_joystick)&&(kc_joystick[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_joystick[9].value );
2962 // From mouse buttons
2963 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
2964 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
2967 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
2968 if ( !kc_mouse[20].value ) // If not inverted...
2969 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
2971 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
2975 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2976 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
2977 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
2980 //---------- Read heading_time -----------
2982 if (!slide_on && !bank_on) {
2983 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2985 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
2986 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
2987 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
2988 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
2991 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
2992 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
2993 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
2994 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
2997 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2998 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
2999 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
3003 Controls.heading_time = 0;
3005 if (Controls.heading_time < 0)
3006 Controls.heading_time = 0;
3008 if (Controls.heading_time > 0)
3009 Controls.heading_time = 0;
3010 Controls.heading_time += kh;
3013 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
3014 if ( !kc_joystick[16].value ) // If not inverted...
3015 Controls.heading_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3017 Controls.heading_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3021 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3022 if ( !kc_mouse[16].value ) // If not inverted...
3023 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3025 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3028 Controls.heading_time = 0;
3031 //----------- Read sideways_thrust_time -----------------
3034 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3035 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3036 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3037 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3040 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
3041 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
3042 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
3043 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
3046 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
3047 if ( !kc_joystick[16].value ) // If not inverted...
3048 Controls.sideways_thrust_time += joy_axis[kc_joystick[15].value];
3050 Controls.sideways_thrust_time -= joy_axis[kc_joystick[15].value];
3054 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3055 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
3056 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
3060 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3061 if ( !kc_mouse[16].value ) // If not inverted...
3062 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
3064 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
3069 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
3070 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
3071 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
3072 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
3075 if ( (use_joystick)&&(kc_joystick[17].value < 255 )) {
3076 if ( !kc_joystick[18].value ) // If not inverted...
3077 Controls.sideways_thrust_time -= joy_axis[kc_joystick[17].value];
3079 Controls.sideways_thrust_time += joy_axis[kc_joystick[17].value];
3082 // From joystick buttons
3083 if ( (use_joystick)&&(kc_joystick[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_joystick[6].value );
3084 if ( (use_joystick)&&(kc_joystick[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_joystick[7].value );
3086 // From mouse buttons
3087 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
3088 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
3091 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
3092 if ( !kc_mouse[18].value ) // If not inverted...
3093 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
3095 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
3098 //----------- Read bank_time -----------------
3101 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3102 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3103 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3104 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3107 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
3108 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
3109 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
3110 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
3113 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3114 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
3115 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
3119 if ( (use_joystick)&&(kc_joystick[15].value < 255) ) {
3120 if ( !kc_joystick[16].value ) // If not inverted...
3121 Controls.bank_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3123 Controls.bank_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3127 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3128 if ( !kc_mouse[16].value ) // If not inverted...
3129 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3131 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3136 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
3137 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
3138 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
3139 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
3142 if ( (use_joystick)&&(kc_joystick[21].value < 255) ) {
3143 if ( !kc_joystick[22].value ) // If not inverted...
3144 Controls.bank_time -= joy_axis[kc_joystick[21].value];
3146 Controls.bank_time += joy_axis[kc_joystick[21].value];
3149 // From joystick buttons
3150 if ( (use_joystick)&&(kc_joystick[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_joystick[11].value );
3151 if ( (use_joystick)&&(kc_joystick[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_joystick[12].value );
3153 // From mouse buttons
3154 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
3155 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
3158 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
3159 if ( !kc_mouse[22].value ) // If not inverted...
3160 Controls.bank_time += mouse_axis[kc_mouse[21].value];
3162 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
3166 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3167 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
3168 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
3171 //----------- Read forward_thrust_time -------------
3174 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
3175 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
3176 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
3177 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
3180 if ( (use_joystick)&&(kc_joystick[23].value < 255 )) {
3181 if ( !kc_joystick[24].value ) // If not inverted...
3182 Controls.forward_thrust_time -= joy_axis[kc_joystick[23].value];
3184 Controls.forward_thrust_time += joy_axis[kc_joystick[23].value];
3187 // From joystick buttons
3188 if ( (use_joystick)&&(kc_joystick[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_joystick[2].value );
3189 if ( (use_joystick)&&(kc_joystick[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_joystick[3].value );
3192 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
3193 if ( !kc_mouse[24].value ) // If not inverted...
3194 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
3196 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
3199 // From mouse buttons
3200 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
3201 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
3203 //----------- Read afterburner_state -------------
3206 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
3207 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
3209 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
3211 if ( (use_joystick)&&(kc_joystick[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_joystick[27].value);
3213 //-------Read headlight key--------------------------
3215 if (kc_keyboard[52].value < 255 )
3216 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
3217 if (kc_keyboard[53].value < 255 )
3218 Controls.headlight_count+=key_down_count(kc_keyboard[53].value);
3219 if ((use_joystick)&&(kc_joystick[30].value < 255 ))
3220 Controls.headlight_count+=joy_get_button_down_cnt(kc_joystick[30].value);
3222 //--------Read Cycle Primary Key------------------
3224 if (kc_keyboard[48].value<255)
3225 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
3226 if (kc_keyboard[49].value<255)
3227 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
3228 if ((use_joystick)&&(kc_joystick[28].value < 255 ))
3229 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_joystick[28].value);
3232 //--------Read Cycle Secondary Key------------------
3234 if (kc_keyboard[50].value<255)
3235 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
3236 if (kc_keyboard[51].value<255)
3237 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
3238 if ((use_joystick)&&(kc_joystick[29].value < 255 ))
3239 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_joystick[29].value);
3241 //--------Read Toggle Bomb key----------------------
3243 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
3245 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
3247 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
3248 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
3250 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3251 HUD_init_message ("No bombs available!");
3255 if (Players[Player_num].secondary_ammo[bomb]==0)
3257 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3258 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
3262 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
3263 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
3268 //---------Read Energy->Shield key----------
3270 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
3271 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
3272 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
3273 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
3275 //----------- Read fire_primary_down_count
3276 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
3277 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
3278 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_joystick[0].value);
3279 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
3281 //----------- Read fire_primary_state
3282 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
3283 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
3284 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_joystick[0].value);
3285 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
3287 //----------- Read fire_secondary_down_count
3288 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
3289 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
3290 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_joystick[1].value);
3291 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
3293 //----------- Read fire_secondary_state
3294 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
3295 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
3296 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_joystick[1].value);
3297 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
3299 //----------- Read fire_flare_down_count
3300 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
3301 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
3302 if ((use_joystick)&&(kc_joystick[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_joystick[4].value);
3303 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
3305 //----------- Read drop_bomb_down_count
3306 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
3307 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
3308 if ((use_joystick)&&(kc_joystick[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_joystick[26].value);
3309 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
3311 //----------- Read rear_view_down_count
3312 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
3313 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
3314 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_joystick[25].value);
3315 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
3317 //----------- Read rear_view_down_state
3318 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
3319 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
3320 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_joystick[25].value);
3321 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
3323 //----------- Read automap_down_count
3324 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
3325 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
3327 //----------- Read automap_state
3328 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
3329 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
3331 //----------- Read stupid-cruise-control-type of throttle.
3333 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
3334 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
3335 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
3336 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
3337 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
3339 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
3342 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
3343 if (Cruise_speed < 0 ) Cruise_speed = 0;
3345 if (Controls.forward_thrust_time==0)
3346 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
3349 #if !defined(MACINTOSH)
3350 //read_head_tracker();
3352 // Read external controls
3353 // if (kc_use_external_control || CybermouseActive)
3354 // kconfig_read_external_controls();
3357 //----------- Clamp values between -FrameTime and FrameTime
3358 if (FrameTime > F1_0 )
3359 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
3361 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
3362 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
3363 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
3364 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
3365 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
3366 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
3367 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
3369 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
3370 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
3371 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
3372 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
3373 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
3374 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
3375 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
3378 //--------- Don't do anything if in debug mode
3380 if ( keyd_pressed[KEY_DELETE] ) {
3381 memset( &Controls, 0, sizeof(control_info) );
3387 void reset_cruise(void)
3393 void kc_set_controls()
3397 for (i=0; i<NUM_KEY_CONTROLS; i++ )
3398 kc_keyboard[i].value = kconfig_settings[0][i];
3400 if ( (Config_control_type>0) && (Config_control_type<5)) {
3401 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3402 kc_joystick[i].value = kconfig_settings[Config_control_type][i];
3403 if (kc_joystick[i].type == BT_INVERT ) {
3404 if (kc_joystick[i].value!=1)
3405 kc_joystick[i].value = 0;
3406 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
3409 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
3410 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3411 kc_mouse[i].value = kconfig_settings[Config_control_type][i];
3412 if (kc_mouse[i].type == BT_INVERT ) {
3413 if (kc_mouse[i].value!=1)
3414 kc_mouse[i].value = 0;
3415 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
3418 } else if (Config_control_type == CONTROL_WINJOYSTICK) {
3419 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3420 kc_superjoy[i].value = kconfig_settings[Config_control_type][i];
3421 if (kc_superjoy[i].type == BT_INVERT ) {
3422 if (kc_superjoy[i].value!=1)
3423 kc_superjoy[i].value = 0;
3424 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
3430 #if 0 //ndef MACINTOSH // no mac support for vr headset
3432 void kconfig_center_headset()
3436 vfx_center_headset();
3438 // } else if (iglasses_headset_installed) {
3439 // } else if (Victor_headset_installed) {
3445 #endif // end of #ifndef MACINTOSH for kconfig_center_headset
3447 void CybermouseAdjust ()
3449 /* if ( Player_num > -1 ) {
3450 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3451 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3452 Auto_leveling_on = 0;
3454 if ( kc_external_version > 0 ) {
3455 vms_matrix tempm, ViewMatrix;
3456 vms_angvec * Kconfig_abs_movement;
3459 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
3461 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3462 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3463 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3464 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3466 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3467 if (oem_message[0] != '\0' )
3468 HUD_init_message( oem_message );
3472 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3473 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3474 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3475 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3476 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3477 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3478 // Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3479 // Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3480 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3481 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3482 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3483 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3484 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3485 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3486 // Controls.automap_down_count += kc_external_control->automap_down_count;
3487 // Controls.automap_state |= kc_external_control->automap_state;
3490 char GetKeyValue (char key)
3492 mprintf ((0,"Returning %c!\n",kc_keyboard[(int)key].value));
3493 return (kc_keyboard[(int)key].value);
3496 #if !defined(MACINTOSH)
3499 extern object *obj_find_first_of_type (int);
3500 void kconfig_read_external_controls()
3505 if ( !kc_enable_external_control ) return;
3507 if ( kc_external_version == 0 )
3508 memset( kc_external_control, 0, sizeof(ext_control_info));
3509 else if ( kc_external_version > 0 ) {
3511 if (kc_external_version>=4)
3512 memset( kc_external_control, 0, sizeof(advanced_ext_control_info));
3513 else if (kc_external_version>0)
3514 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 );
3515 else if (kc_external_version>2)
3516 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof(vms_matrix) +4 );
3518 if ( kc_external_version > 1 ) {
3519 // Write ship pos and angles to external controls...
3520 ubyte *temp_ptr = (ubyte *)kc_external_control;
3521 vms_vector *ship_pos;
3522 vms_matrix *ship_orient;
3523 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
3524 temp_ptr += sizeof(ext_control_info) + sizeof(vms_angvec) + 64;
3525 ship_pos = (vms_vector *)temp_ptr;
3526 temp_ptr += sizeof(vms_vector);
3527 ship_orient = (vms_matrix *)temp_ptr;
3528 // Fill in ship postion...
3529 *ship_pos = Objects[Players[Player_num].objnum].pos;
3530 // Fill in ship orientation...
3531 *ship_orient = Objects[Players[Player_num].objnum].orient;
3533 if (kc_external_version>=4)
3535 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3537 temp_ptr->headlight_state=(Players[Player_num].flags & PLAYER_FLAGS_HEADLIGHT_ON);
3538 temp_ptr->primary_weapon_flags=Players[Player_num].primary_weapon_flags;
3539 temp_ptr->secondary_weapon_flags=Players[Player_num].secondary_weapon_flags;
3540 temp_ptr->current_primary_weapon=Primary_weapon;
3541 temp_ptr->current_secondary_weapon=Secondary_weapon;
3543 temp_ptr->current_guidebot_command=Escort_goal_object;
3545 temp_ptr->force_vector=ExtForceVec;
3546 temp_ptr->force_matrix=ExtApplyForceMatrix;
3548 temp_ptr->joltinfo[i]=ExtJoltInfo[i];
3550 temp_ptr->x_vibrate_info[i]=ExtXVibrateInfo[i];
3551 temp_ptr->x_vibrate_clear=ExtXVibrateClear;
3552 temp_ptr->game_status=ExtGameStatus;
3554 memset ((void *)&ExtForceVec,0,sizeof(vms_vector));
3555 memset ((void *)&ExtApplyForceMatrix,0,sizeof(vms_matrix));
3560 ExtXVibrateInfo[i]=0;
3565 if ( Automap_active ) // (If in automap...)
3566 kc_external_control->automap_state = 1;
3567 //memset(&r,0,sizeof(r));
3571 int386 ( kc_external_intno, &r, &r); // Read external info...
3575 if ( Player_num > -1 ) {
3576 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3577 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3578 Auto_leveling_on = 0;
3580 if ( kc_external_version > 0 ) {
3581 vms_matrix tempm, ViewMatrix;
3582 vms_angvec * Kconfig_abs_movement;
3585 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(ext_control_info));
3587 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3588 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3589 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3590 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3592 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3593 if (oem_message[0] != '\0' )
3594 HUD_init_message( oem_message );
3598 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3599 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3600 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3601 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3602 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3603 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3604 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3605 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3606 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3607 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3608 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3609 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3610 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3611 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3612 Controls.automap_down_count += kc_external_control->automap_down_count;
3613 Controls.automap_state |= kc_external_control->automap_state;
3615 if (kc_external_version>=3)
3617 ubyte *temp_ptr = (ubyte *)kc_external_control;
3618 temp_ptr += (sizeof(ext_control_info) + sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof (vms_matrix));
3621 Controls.cycle_primary_count=(*(temp_ptr));
3623 Controls.cycle_secondary_count=(*(temp_ptr+1));
3626 Controls.afterburner_state=(*(temp_ptr+2));
3628 Controls.headlight_count=(*(temp_ptr+3));
3630 if (kc_external_version>=4)
3633 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3636 if (temp_ptr->keyboard[i])
3639 if (temp_ptr->Reactor_blown)
3641 if (Game_mode & GM_MULTI)
3642 net_destroy_controlcen (obj_find_first_of_type (OBJ_CNTRLCEN));
3644 do_controlcen_destroyed_stuff(obj_find_first_of_type (OBJ_CNTRLCEN));