1 /* $Id: kconfig.c,v 1.19.4.1 2003/06/06 22:12:55 btb Exp $ */
2 /*
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.
13 */
14
15 #ifdef HAVE_CONFIG_H
16 #include <conf.h>
17 #endif
18
19 /*
20 *
21 * Routines to configure keyboard, joystick, etc..
22 *
23 * Old Log:
24 * Revision 1.18 1995/10/29 20:14:10 allender
25 * don't read mouse 30x/sec. Still causes problems -- left with
26 * exposure at > 60 frame/s
27 *
28 * Revision 1.17 1995/10/27 14:16:35 allender
29 * don't set lastreadtime when doing mouse stuff if we didn't
30 * read mouse this frame
31 *
32 * Revision 1.16 1995/10/24 18:10:22 allender
33 * get mouse stuff working right this time?
34 *
35 * Revision 1.15 1995/10/23 14:50:50 allender
36 * corrected values for control type in kc_set_controls
37 *
38 * Revision 1.14 1995/10/21 16:36:54 allender
39 * fix up mouse read time
40 *
41 * Revision 1.13 1995/10/20 00:46:53 allender
42 * fix up mouse reading problem
43 *
44 * Revision 1.12 1995/10/19 13:36:38 allender
45 * mouse support in kconfig screens
46 *
47 * Revision 1.11 1995/10/18 21:06:06 allender
48 * removed Int3 in cruise stuff -- was in there for debugging and
49 * now not needed
50 *
51 * Revision 1.10 1995/10/17 13:12:47 allender
52 * fixed config menus so buttons don't get configured
53 *
54 * Revision 1.9 1995/10/15 23:07:55 allender
55 * added return key as second button for primary fire
56 *
57 * Revision 1.8 1995/09/05 08:49:47 allender
58 * change 'PADRTN' label to 'ENTER'
59 *
60 * Revision 1.7 1995/09/01 15:38:22 allender
61 * took out cap of reading controls max 25 times/sec
62 *
63 * Revision 1.6 1995/09/01 13:33:59 allender
64 * erase all old text
65 *
66 * Revision 1.5 1995/08/18 10:20:55 allender
67 * keep controls reading to 25 times/s max so fast
68 * frame rates don't mess up control reading
69 *
70 * Revision 1.4 1995/07/28 15:43:13 allender
71 * make mousebutton control primary fire
72 *
73 * Revision 1.3 1995/07/26 17:04:32 allender
74 * new defaults and make joystick main button work correctly
75 *
76 * Revision 1.2 1995/07/17 08:51:03 allender
77 * fixed up configuration menus to look right
78 *
79 * Revision 1.1 1995/05/16 15:26:56 allender
80 * Initial revision
81 *
82 * Revision 2.11 1995/08/23 16:08:04 john
83 * Added version 2 of external controls that passes the ship
84 * position and orientation the drivers.
85 *
86 * Revision 2.10 1995/07/07 16:48:01 john
87 * Fixed bug with new interface.
88 *
89 * Revision 2.9 1995/07/03 15:02:32 john
90 * Added new version of external controls for Cybermouse absolute position.
91 *
92 * Revision 2.8 1995/06/30 12:30:28 john
93 * Added -Xname command line.
94 *
95 * Revision 2.7 1995/03/30 16:36:56 mike
96 * text localization.
97 *
98 * Revision 2.6 1995/03/21 14:39:31 john
99 * Ifdef'd out the NETWORK code.
100 *
101 * Revision 2.5 1995/03/16 10:53:07 john
102 * Move VFX center to Shift+Z instead of Enter because
103 * it conflicted with toggling HUD on/off.
104 *
105 * Revision 2.4 1995/03/10 13:47:24 john
106 * Added head tracking sensitivity.
107 *
108 * Revision 2.3 1995/03/09 18:07:06 john
109 * Fixed bug with iglasses tracking not "centering" right.
110 * Made VFX have bright headlight lighting.
111 *
112 * Revision 2.2 1995/03/08 15:32:39 john
113 * Made VictorMaxx head tracking use Greenleaf code.
114 *
115 * Revision 2.1 1995/03/06 15:23:31 john
116 * New screen techniques.
117 *
118 * Revision 2.0 1995/02/27 11:29:26 john
119 * New version 2.0, which has no anonymous unions, builds with
120 * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
121 *
122 * Revision 1.105 1995/02/22 14:11:58 allender
123 * remove anonymous unions from object structure
124 *
125 * Revision 1.104 1995/02/13 12:01:56 john
126 * Fixed bug with buggin not mmaking player faster.
127 *
128 * Revision 1.103 1995/02/09 22:00:46 john
129 * Added i-glasses tracking.
130 *
131 * Revision 1.102 1995/01/24 21:25:47 john
132 * Fixed bug with slide/bank on not working with
133 * Cyberman heading.,
134 *
135 * Revision 1.101 1995/01/24 16:09:56 john
136 * Fixed bug with Wingman extreme customize text overwriting title.
137 *
138 * Revision 1.100 1995/01/24 12:37:46 john
139 * Made Esc exit key define menu.
140 *
141 * Revision 1.99 1995/01/23 23:54:43 matt
142 * Made keypad enter work
143 *
144 * Revision 1.98 1995/01/23 16:42:00 john
145 * Made the external controls always turn banking off, leveling off
146 * and passed automap state thru to the tsr.
147 *
148 * Revision 1.97 1995/01/12 11:41:33 john
149 * Added external control reading.
150 *
151 * Revision 1.96 1995/01/05 10:43:58 mike
152 * Handle case when timer_get_fixed_seconds() goes negative. Happens at 9.1
153 * hours. Previously, joystick would stop functioning. Now will work.
154 *
155 * Revision 1.95 1994/12/29 11:17:38 john
156 * Took out some warnings and mprintf.
157 *
158 * Revision 1.94 1994/12/29 11:07:41 john
159 * Fixed Thrustmaster and Logitech Wingman extreme
160 * Hat by reading the y2 axis during the center stage
161 * of the calibration, and using 75, 50, 27, and 3 %
162 * as values for the 4 positions.
163 *
164 * Revision 1.93 1994/12/27 12:16:20 john
165 * Fixed bug with slide on not working with joystick or mouse buttons.
166 *
167 * Revision 1.92 1994/12/20 10:34:15 john
168 * Made sensitivity work for mouse & joystick and made
169 * it only affect, pitch, heading, and roll.
170 *
171 * Revision 1.91 1994/12/16 00:11:23 matt
172 * Made delete key act normally when debug out
173 *
174 * Revision 1.90 1994/12/14 17:41:15 john
175 * Added more buttons so that Yoke would work.
176 *
177 * Revision 1.89 1994/12/13 17:25:35 allender
178 * Added Assert for bogus time for joystick reading.
179 *
180 * Revision 1.88 1994/12/13 14:48:01 john
181 * Took out some debugging mprintf's
182 *
183 *
184 * Revision 1.87 1994/12/13 14:43:02 john
185 * Took out the code in kconfig to build direction array.
186 * Called kc_set_controls after selecting a new control type.
187 *
188 * Revision 1.86 1994/12/13 01:11:32 john
189 * Fixed bug with message clearing overwriting
190 * right border.
191 *
192 * Revision 1.85 1994/12/12 00:35:58 john
193 * Added or thing for keys.
194 *
195 * Revision 1.84 1994/12/09 17:08:06 john
196 * Made mouse a bit less sensitive.
197 *
198 * Revision 1.83 1994/12/09 16:04:00 john
199 * Increased mouse sensitivity.
200 *
201 * Revision 1.82 1994/12/09 00:41:26 mike
202 * fix hang in automap print screen
203 *
204 * Revision 1.81 1994/12/08 11:50:37 john
205 * Made strcpy only copy corect number of chars,.
206 *
207 * Revision 1.80 1994/12/07 16:16:06 john
208 * Added command to check to see if a joystick axes has been used.
209 *
210 * Revision 1.79 1994/12/07 14:52:28 yuan
211 * Localization 492
212 *
213 * Revision 1.78 1994/12/07 13:37:40 john
214 * Made the joystick thrust work in reverse.
215 *
216 * Revision 1.77 1994/12/07 11:28:24 matt
217 * Did a little localization support
218 *
219 * Revision 1.76 1994/12/04 12:30:03 john
220 * Made the Thrustmaster stick read every frame, not every 10 frames,
221 * because it uses analog axis as buttons.
222 *
223 * Revision 1.75 1994/12/03 22:35:25 yuan
224 * Localization 412
225 *
226 * Revision 1.74 1994/12/03 15:39:24 john
227 * Made numeric keypad move in conifg.
228 *
229 * Revision 1.73 1994/12/01 16:23:39 john
230 * Fixed include mistake.
231 *
232 * Revision 1.72 1994/12/01 16:07:57 john
233 * Fixed bug that disabled joystick in automap because it used gametime, which is
234 * paused during automap. Fixed be used timer_Get_fixed_seconds instead of GameTime.
235 *
236 * Revision 1.71 1994/12/01 12:30:49 john
237 * Made Ctrl+D delete, not Ctrl+E
238 *
239 * Revision 1.70 1994/12/01 11:52:52 john
240 * Added default values for GamePad.
241 *
242 * Revision 1.69 1994/11/30 00:59:12 mike
243 * optimizations.
244 *
245 * Revision 1.68 1994/11/29 03:45:50 john
246 * Added joystick sensitivity; Added sound channels to detail menu. Removed -maxchannels
247 * command line arg.
248 *
249 * Revision 1.67 1994/11/27 23:13:44 matt
250 * Made changes for new mprintf calling convention
251 *
252 * Revision 1.66 1994/11/27 19:52:12 matt
253 * Made screen shots work in a few more places
254 *
255 * Revision 1.65 1994/11/22 16:54:50 mike
256 * autorepeat on missiles.
257 *
258 * Revision 1.64 1994/11/21 11:16:17 rob
259 * Changed calls to GameLoop to calls to multi_menu_poll and changed
260 * conditions under which they are called.
261 *
262 * Revision 1.63 1994/11/19 15:14:48 mike
263 * remove unused code and data
264 *
265 * Revision 1.62 1994/11/18 23:37:56 john
266 * Changed some shorts to ints.
267 *
268 * Revision 1.61 1994/11/17 13:36:35 rob
269 * Added better network hook in kconfig menu.
270 *
271 * Revision 1.60 1994/11/14 20:09:13 john
272 * Made Tab be default for automap.
273 *
274 * Revision 1.59 1994/11/13 16:34:07 matt
275 * Fixed victormaxx angle conversions
276 *
277 * Revision 1.58 1994/11/12 14:47:05 john
278 * Added support for victor head tracking.
279 *
280 * Revision 1.57 1994/11/08 15:14:55 john
281 * Added more calls so net doesn't die in net game.
282 *
283 * Revision 1.56 1994/11/07 14:01:07 john
284 * Changed the gamma correction sequencing.
285 *
286 * Revision 1.55 1994/11/01 16:40:08 john
287 * Added Gamma correction.
288 *
289 * Revision 1.54 1994/10/25 23:09:26 john
290 * Made the automap key configurable.
291 *
292 * Revision 1.53 1994/10/25 13:11:59 john
293 * Made keys the way Adam speced 'em for final game.
294 *
295 * Revision 1.52 1994/10/24 17:44:22 john
296 * Added stereo channel reversing.
297 *
298 * Revision 1.51 1994/10/22 13:23:18 john
299 * Made default rear view key be R.
300 *
301 * Revision 1.50 1994/10/22 13:20:09 john
302 * Took out toggle primary/secondary weapons. Fixed black
303 * background for 'axes' and 'buttons' text.
304 *
305 * Revision 1.49 1994/10/21 15:20:15 john
306 * Made PrtScr do screen dump, not F2.
307 *
308 * Revision 1.48 1994/10/21 13:41:36 john
309 * Allowed F2 to screen dump.
310 *
311 * Revision 1.47 1994/10/17 13:07:05 john
312 * Moved the descent.cfg info into the player config file.
313 *
314 * Revision 1.46 1994/10/14 15:30:22 john
315 * Added Cyberman default positions.
316 *
317 * Revision 1.45 1994/10/14 15:24:54 john
318 * Made Cyberman work with config.
319 *
320 * Revision 1.44 1994/10/14 12:46:04 john
321 * Added the ability to reset all to default.
322 *
323 * Revision 1.43 1994/10/14 12:18:31 john
324 * Made mouse invert axis always be 0 or 1.
325 *
326 * Revision 1.42 1994/10/14 12:16:03 john
327 * Changed code so that by doing DEL+F12 saves the current kconfig
328 * values as default. Added support for drop_bomb key. Took out
329 * unused slots for keyboard. Made keyboard use control_type of 0
330 * save slots.
331 *
332 * Revision 1.41 1994/10/13 21:27:02 john
333 * Made axis invert value always be 0 or 1.
334 *
335 * Revision 1.40 1994/10/13 20:18:15 john
336 * Added some more system keys, such as F? and CAPSLOCK.
337 *
338 * Revision 1.39 1994/10/13 19:22:29 john
339 * Added separate config saves for different devices.
340 * Made all the devices work together better, such as mice won't
341 * get read when you're playing with the joystick.
342 *
343 * Revision 1.38 1994/10/13 15:41:57 mike
344 * Remove afterburner.
345 *
346 */
347
348 #ifdef RCS
349 static char rcsid[] = "$Id: kconfig.c,v 1.19.4.1 2003/06/06 22:12:55 btb Exp $";
350 #endif
351
352 #ifdef WINDOWS
353 #include "desw.h"
354 #endif
355
356 #include <stdio.h>
357 #include <stdlib.h>
358 #include <string.h>
359 #include <stdarg.h>
360 #include <ctype.h>
361
362 #include "pa_enabl.h" //$$POLY_ACC
363 #include "error.h"
364 #include "pstypes.h"
365 #include "gr.h"
366 #include "mono.h"
367 #include "key.h"
368 #include "palette.h"
369 #include "game.h"
370 #include "gamefont.h"
371 #include "iff.h"
372 #include "u_mem.h"
373 #include "joy.h"
374 #include "mouse.h"
375 #include "kconfig.h"
376 #include "gauges.h"
377 #include "joydefs.h"
378 #include "songs.h"
379 #include "render.h"
380 #include "digi.h"
381 #include "newmenu.h"
382 #include "endlevel.h"
383 #include "multi.h"
384 #include "timer.h"
385 #include "text.h"
386 #include "player.h"
387 #include "menu.h"
388 #include "automap.h"
389 #include "args.h"
390 #include "lighting.h"
391 #include "ai.h"
392 #include "cntrlcen.h"
393 #if defined (TACTILE)
394 #include "tactile.h"
395 #endif
396
397 #if defined(POLY_ACC)
398 #include "poly_acc.h"
399 #endif
400
401 #include "collide.h"
402
403 #ifdef __unix__
404 #include "joystick.h"
405 #endif
406
407 ubyte ExtGameStatus=1;
408
409 vms_vector ExtForceVec;
410 vms_matrix ExtApplyForceMatrix;
411
412 int ExtJoltInfo[3]={0,0,0};
413 int ExtXVibrateInfo[2]={0,0};
414 int ExtYVibrateInfo[2]={0,0};
415 ubyte ExtXVibrateClear=0;
416 ubyte ExtYVibrateClear=0;
417
418 #define TABLE_CREATION 1
419
420 // Array used to 'blink' the cursor while waiting for a keypress.
421 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 };
422
423 //char * invert_text[2] = { "N", "Y" };
424 //char * joybutton_text[28] = { "BTN 1", "BTN 2", "BTN 3", "BTN 4", "", "TRIG", "LEFT", "HAT �", "RIGHT", "", "", "HAT �", "MID", "", "", "HAT ", "", "", "", "HAT �", "TRIG", "LEFT", "RIGHT", "", "UP","DOWN","LEFT", "RIGHT" };
425 //char * joyaxis_text[4] = { "X1", "Y1", "X2", "Y2" };
426 //char * mouseaxis_text[2] = { "L/R", "F/B" };
427 //char * mousebutton_text[3] = { "Left", "Right", "Mid" };
428
429 int invert_text[2] = { TNUM_N, TNUM_Y };
430
431 #ifdef WINDOWS
432 int joybutton_text[28] =
433 { TNUM_BTN_1, TNUM_BTN_2, TNUM_BTN_3, TNUM_BTN_4,
434 -1, -1, -1, -1,
435 -1, -1, -1, -1,
436 -1, -1, -1, -1,
437 TNUM_HAT_L, TNUM_HAT_R, TNUM_HAT_U, TNUM_HAT_D,
438 -1, -1, -1, -1,
439 -1, -1, -1, -1
440 };
441 int joyaxis_text[7] = { TNUM_X1, TNUM_Y1, TNUM_Z1, TNUM_UN, TNUM_P1,TNUM_R1,TNUM_YA1 };
442 #else
443 int joybutton_text[28] =
444 { TNUM_BTN_1, TNUM_BTN_2, TNUM_BTN_3, TNUM_BTN_4,
445 -1, TNUM_TRIG, TNUM_LEFT, TNUM_HAT_L,
446 TNUM_RIGHT, -1, TNUM_HAT2_D, TNUM_HAT_R,
447 TNUM_MID, -1, TNUM_HAT2_R, TNUM_HAT_U,
448 TNUM_HAT2_L, -1, TNUM_HAT2_U, TNUM_HAT_D,
449 TNUM_TRIG, TNUM_LEFT, TNUM_RIGHT, -1,
450 TNUM_UP, TNUM_DOWN, TNUM_LEFT, TNUM_RIGHT };
451
452 int joyaxis_text[7] = { TNUM_X1, TNUM_Y1, TNUM_Z1, TNUM_UN, TNUM_P1,TNUM_R1,TNUM_YA1 };
453 // int joyaxis_text[4] = { TNUM_X1, TNUM_Y1, TNUM_X2, TNUM_Y2 };
454 #endif
455
456 int mouseaxis_text[3] = { TNUM_L_R, TNUM_F_B, TNUM_Z1 };
457 #ifndef MACINTOSH
458 int mousebutton_text[3] = { TNUM_LEFT, TNUM_RIGHT, TNUM_MID };
459 char * mousebutton_textra[13] = { "M4", "M5", "M6", "M7", "M8", "M9", "M10","M11","M12","M13","M14","M15","M16" };//text for buttons above 3. -MPM
460 #else
461 char *mousebutton_text[3] = { "Btn", "", "" }; // only one silly mouse button on the mac
462 #endif
463
464 #ifdef MACINTOSH
465 char * key_text[256] = {
466 "","S","D","F","H","G","Z","X","C","V","","B","Q", "W", "E", "R",
467 "Y","T","1","2","3","4","6","5","=","9","7","-", "8", "0", "]", "O",
468 "U","[","I","P","RET","L","J","'","K", ";", "\\", ",", "/", "N", "M", ".",
469 "TAB","SPC","`","DEL","","ESC","","APL","SHIFT","CAPSL","OPTN","CTRL","","","","A",
470 "","PAD.","","PAD*","","PAD+","","NMLCK","","","","PAD/","ENTER","","PAD-","",
471 "","PAD=","PAD0","PAD1","PAD2","PAD3","PAD4","PAD5","PAD6","PAD7","","PAD8","PAD9","","","",
472 "F5","F6","F7","","F8","F9","","F11","","F13","","F14","","F10","","F12",
473 "","PAUSE","HELP","HOME","PGUP","DEL","","END","F2","","F1","LARW","RARW","DARW","UARW","",
474 "","","","","","","","","","","","","","","","",
475 "","","","","","","","","","","","","","","","",
476 "","","","","","","","","","","","","","","","",
477 "","","","","","","","","","","","","","","","",
478 "","","","","","","","","","","","","","","","",
479 "","","","","","","","","","","","","","","","",
480 "","","","","","","","","","","","","","","","",
481 "","","","","","","","","","","","","","","",""};
482 #else
483 #if !defined OGL && !defined SDL_INPUT
484 char * key_text[256] = { \
485 "","ESC","1","2","3","4","5","6","7","8","9","0","-", \
486 "=","BSPC","TAB","Q","W","E","R","T","Y","U","I","O", \
487 "P","[","]","�","LCTRL","A","S","D","F", \
488 "G","H","J","K","L",";","'","`", \
489 "LSHFT","\\","Z","X","C","V","B","N","M",",", \
490 ".","/","RSHFT","PAD*","LALT","SPC", \
491 "CPSLK","F1","F2","F3","F4","F5","F6","F7","F8","F9", \
492 "F10","NMLCK","SCLK","PAD7","PAD8","PAD9","PAD-", \
493 "PAD4","PAD5","PAD6","PAD+","PAD1","PAD2","PAD3","PAD0", \
494 "PAD.","","","","F11","F12","","","","","","","","","", \
495 "","","","","","","","","","","","","","","","","","","","", \
496 "","","","","","","","","","","","","","","","","","","","", \
497 "","","","","","","","","","","","","","","","","","", \
498 "PAD�","RCTRL","","","","","","","","","","","","","", \
499 "","","","","","","","","","","PAD/","","","RALT","", \
500 "","","","","","","","","","","","","","HOME","�","PGUP", \
501 "","�","","","","END","�","PGDN","INS", \
502 "DEL","","","","","","","","","","","","","","","","","", \
503 "","","","","","","","","","","","","","","","","","","","", \
504 "","","","","","","" };
505 #endif /* OGL */
506 #endif
507
508 //added/removed by Victor Rachels for adding rebindable keys for these
509 // KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0
510 ubyte system_keys[] = { KEY_ESC, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_MINUS, KEY_EQUAL, KEY_PRINT_SCREEN };
511
512 //extern void GameLoop(int, int );
513
514 extern void transfer_energy_to_shield(fix);
515 extern void CyclePrimary(),CycleSecondary(),InitMarkerInput();
516 extern ubyte DefiningMarkerMessage;
517 extern char CybermouseActive;
518
519 #ifdef WINDOWS
520 extern int joydefsw_do_button();
521 extern int joydefsw_do_winjoybutton(int *axis);
522 extern joydefsw_win_joyselect(char *title);
523 #endif
524
525 control_info Controls;
526
527 fix Cruise_speed=0;
528
529 // macros for drawing lo/hi res kconfig screens (see scores.c as well)
530
531 #define LHX(x) ((x)*(MenuHires?2:1))
532 #define LHY(y) ((y)*(MenuHires?2.4:1))
533
534
535 #define BT_KEY 0
536 #define BT_MOUSE_BUTTON 1
537 #define BT_MOUSE_AXIS 2
538 #define BT_JOY_BUTTON 3
539 #define BT_JOY_AXIS 4
540 #define BT_INVERT 5
541
542 char *btype_text[] = { "BT_KEY", "BT_MOUSE_BUTTON", "BT_MOUSE_AXIS", "BT_JOY_BUTTON", "BT_JOY_AXIS", "BT_INVERT" };
543
544 #define INFO_Y 28
545
546 typedef struct kc_item {
547 short id; // The id of this item
548 short x, y;
549 short w1;
550 short w2;
551 short u,d,l,r;
552 //short text_num1;
553 char *text;
554 ubyte type;
555 ubyte value; // what key,button,etc
556 } kc_item;
557
558 int Num_items=28;
559 kc_item *All_items;
560
561 ubyte kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS];
562
563 //added on 2/4/99 by Victor Rachels to add d1x new keys
564 ubyte kconfig_d2x_settings[MAX_D2X_CONTROLS];
565 //end this section addition - VR
566
567 //----------- WARNING!!!!!!! -------------------------------------------
568 // THESE NEXT FOUR BLOCKS OF DATA ARE GENERATED BY PRESSING DEL+F12 WHEN
569 // IN THE KEYBOARD CONFIG SCREEN. BASICALLY, THAT PROCEDURE MODIFIES THE
570 // U,D,L,R FIELDS OF THE ARRAYS AND DUMPS THE NEW ARRAYS INTO KCONFIG.COD
571 //-------------------------------------------------------------------------
572 /*ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
573 {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},
574 {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},
575 {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},
576 {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},
577 {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},
578 {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},
579 {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},
580 };*/
581
582 #ifndef MACINTOSH
583 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
584 {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},
585 {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},
586 {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},
587 {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},
588 {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},
589 {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},
590 {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},
591 #ifdef WINDOWS
592 {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},
593 #endif
594 };
595
596
597
598 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
599 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
600 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
601 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
602 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
603 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
604 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
605 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
606 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
607 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
608 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
609 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
610 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
611 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
612 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
613 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
614 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
615 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
616 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
617 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
618 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
619 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
620 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
621 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
622 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
623 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
624 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
625 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
626 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
627 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
628 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
629 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
630 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
631 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
632 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
633 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
634 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
635 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
636 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
637 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
638 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
639 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
640 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
641 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
642 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
643 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
644 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
645 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
646 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
647 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
648 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
649 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
650 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
651 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
652 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
653 { 54,158,171, 83, 26, 52, 56, 51, 55,"Energy->Shield", BT_KEY, 255 },
654 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
655 { 56,158,179,83, 26, 54, 0, 0, 0, "Toggle Bomb", BT_KEY,255},
656 };
657 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
658 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
659 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
660 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
661 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
662 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
663 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
664 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
665 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
666 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
667 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
668 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
669 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
670 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
671 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
672 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
673 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
674 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
675 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
676 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
677 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
678 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
679 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
680 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
681 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
682 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
683 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
684 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
685 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
686 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
687 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
688 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
689 };
690 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
691 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
692 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
693 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
694 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
695 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
696 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
697 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
698 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
699 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
700 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
701 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
702 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
703 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
704 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
705 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
706 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
707 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
708 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
709 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
710 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
711 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
712 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
713 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
714 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
715 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
716 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
717 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
718 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
719 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
720 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
721 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
722 };
723
724 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
725 { 0, 25, 46, 85, 26, 12, 1, 24, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
726 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
727 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
728 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
729 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
730 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
731 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
732 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
733 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
734 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
735 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
736 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
737 { 12,180,106, 59, 26, 11, 0, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
738 { 13,103,138, 58, 26, 27, 15, 25, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
739 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
740 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
741 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
742 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
743 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
744 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
745 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
746 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
747 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
748 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
749 { 24,103,182,106, 8, 22, 5, 23, 0,"throttle", BT_INVERT, 255 },
750 { 25, 25,109, 85, 26, 3, 27, 12, 13,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
751 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
752 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
753 };
754
755 //added on 2/4/99 by Victor Rachels to add d1x new keys
756 kc_item kc_d2x[NUM_D2X_CONTROLS] = {
757 // id,x,y,w1,w2,u,d,l,r,text_num1,type,value
758 { 0, 15, 49, 71, 26, 27, 2, 27, 1, "WEAPON 1", BT_KEY, 255},
759 { 1, 15, 49,100, 26, 26, 3, 0, 2, "WEAPON 1", BT_JOY_BUTTON, 255},
760 { 2, 15, 57, 71, 26, 0, 4, 1, 3, "WEAPON 2", BT_KEY, 255},
761 { 3, 15, 57,100, 26, 1, 5, 2, 4, "WEAPON 2", BT_JOY_BUTTON, 255},
762 { 4, 15, 65, 71, 26, 2, 6, 3, 5, "WEAPON 3", BT_KEY, 255},
763 { 5, 15, 65,100, 26, 3, 7, 4, 6, "WEAPON 3", BT_JOY_BUTTON, 255},
764 { 6, 15, 73, 71, 26, 4, 8, 5, 7, "WEAPON 4", BT_KEY, 255},
765 { 7, 15, 73,100, 26, 5, 9, 6, 8, "WEAPON 4", BT_JOY_BUTTON, 255},
766 { 8, 15, 81, 71, 26, 6, 10, 7, 9, "WEAPON 5", BT_KEY, 255},
767 { 9, 15, 81,100, 26, 7, 11, 8, 10, "WEAPON 5", BT_JOY_BUTTON, 255},
768
769 { 10, 15, 89, 71, 26, 8, 12, 9, 11, "WEAPON 6", BT_KEY, 255},
770 { 11, 15, 89,100, 26, 9, 13, 10, 12, "WEAPON 6", BT_JOY_BUTTON, 255},
771 { 12, 15, 97, 71, 26, 10, 14, 11, 13, "WEAPON 7", BT_KEY, 255},
772 { 13, 15, 97,100, 26, 11, 15, 12, 14, "WEAPON 7", BT_JOY_BUTTON, 255},
773 { 14, 15,105, 71, 26, 12, 16, 13, 15, "WEAPON 8", BT_KEY, 255},
774 { 15, 15,105,100, 26, 13, 17, 14, 16, "WEAPON 8", BT_JOY_BUTTON, 255},
775 { 16, 15,113, 71, 26, 14, 18, 15, 17, "WEAPON 9", BT_KEY, 255},
776 { 17, 15,113,100, 26, 15, 19, 16, 18, "WEAPON 9", BT_JOY_BUTTON, 255},
777 { 18, 15,121, 71, 26, 16, 20, 17, 19, "WEAPON 0", BT_KEY, 255},
778 { 19, 15,121,100, 26, 17, 21, 18, 20, "WEAPON 0", BT_JOY_BUTTON, 255},
779
780 //{ 20, 15,131, 71, 26, 18, 22, 19, 21, "CYC PRIMARY", BT_KEY, 255},
781 //{ 21, 15,131,100, 26, 19, 23, 20, 22, "CYC PRIMARY", BT_JOY_BUTTON, 255},
782 //{ 22, 15,139, 71, 26, 20, 24, 21, 23, "CYC SECONDARY", BT_KEY, 255},
783 //{ 23, 15,139,100, 26, 21, 25, 22, 24, "CYC SECONDARY", BT_JOY_BUTTON, 255},
784 //{ 24, 8,147, 78, 26, 22, 26, 23, 25, "TOGGLE_PRIM AUTO", BT_KEY, 255},
785 //{ 25, 8,147,107, 26, 23, 27, 24, 26, "TOGGLE_PRIM_AUTO", BT_JOY_BUTTON, 255},
786 //{ 26, 8,155, 78, 26, 24, 1, 25, 27, "TOGGLE SEC AUTO", BT_KEY, 255},
787 //{ 27, 8,155,107, 26, 25, 0, 26, 0, "TOGGLE SEC AUTO", BT_JOY_BUTTON, 255},
788 };
789 //end this section addition - VR
790
791 #else // ifndef MACINTOSH (following are macintosh controls)
792
793 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
794 {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},
795 {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},
796 {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},
797 {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},
798 {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},
799 {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},
800 {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},
801 };
802
803 ubyte default_firebird_settings[MAX_CONTROLS] =
804 {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};
805
806 ubyte default_mousestick_settings[MAX_CONTROLS] =
807 {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};
808
809 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
810 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
811 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
812 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
813 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
814 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
815 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
816 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
817 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
818 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
819 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
820 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
821 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
822 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
823 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
824 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
825 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
826 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
827 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
828 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
829 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
830 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
831 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
832 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
833 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
834 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
835 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
836 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
837 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
838 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
839 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
840 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
841 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
842 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
843 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
844 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
845 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
846 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
847 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
848 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
849 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
850 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
851 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
852 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
853 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
854 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
855 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
856 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
857 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
858 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
859 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
860 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
861 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
862 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
863 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
864 { 54,158,171, 83, 26, 52, 25, 51, 55,"Energy->Shield", BT_KEY, 255 },
865 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
866 };
867 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
868 { 0, 25, 46, 85, 28, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
869 { 1, 25, 54, 85, 28, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
870 { 2, 25, 85, 85, 28, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
871 { 3, 25, 93, 85, 28, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
872 { 4, 25, 62, 85, 28, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
873 { 5,180, 46, 79, 28, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
874 { 6,180, 54, 79, 28, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
875 { 7,180, 62, 79, 28, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
876 { 8,180, 70, 79, 28, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
877 { 9,180, 78, 79, 28, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
878 { 10,180, 90, 79, 28, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
879 { 11,180, 98, 79, 28, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
880 { 12,180,106, 79, 28, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
881 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
882 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
883 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
884 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
885 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
886 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
887 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
888 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
889 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
890 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
891 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
892 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
893 { 25, 25,109, 85, 28, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
894 { 26, 25, 70, 85, 28, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
895 { 27, 25,117, 85, 28, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
896 { 28,180,114, 79, 28, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
897 { 29,180,122, 79, 28, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
898 { 30, 25,125, 85, 28, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
899 };
900 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
901 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
902 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
903 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
904 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
905 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
906 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
907 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
908 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
909 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
910 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
911 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
912 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
913 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
914 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
915 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
916 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
917 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
918 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
919 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
920 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
921 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
922 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
923 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
924 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
925 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
926 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
927 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
928 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
929 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
930 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
931 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
932 };
933
934 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
935 { 0, 25, 46, 85, 26, 28, 1, 28, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
936 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
937 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
938 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
939 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
940 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
941 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
942 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
943 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
944 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
945 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
946 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
947 { 12,180,106, 59, 26, 11, 28, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
948 { 13,103,138, 58, 26, 27, 15, 27, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
949 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
950 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
951 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
952 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
953 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
954 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
955 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
956 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
957 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
958 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
959 { 24,103,182,106, 8, 22, 5, 23, 28,"throttle", BT_INVERT, 255 },
960 { 25, 25,109, 85, 26, 3, 27, 12, 27,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
961 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
962 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
963 };
964
965 #endif
966
967 //added on 2/4/99 by Victor Rachels to add new keys system
968 ubyte default_kconfig_d2x_settings[MAX_D2X_CONTROLS] = {
969 0x2 ,0xff,0x3 ,0xff,0x4 ,0xff,0x5 ,0xff,0x6 ,0xff,0x7 ,0xff,0x8 ,0xff,0x9 ,
970 0xff,0xa ,0xff,0xb ,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
971 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff };
972 //end this section addition - VR
973
974 void kc_drawitem( kc_item *item, int is_current );
975 void kc_change_key( kc_item * item );
976 void kc_change_joybutton( kc_item * item );
977 void kc_change_mousebutton( kc_item * item );
978 void kc_change_joyaxis( kc_item * item );
979 void kc_change_mouseaxis( kc_item * item );
980 void kc_change_invert( kc_item * item );
981 void kconfig_read_fcs( int raw_axis );
982 void kconfig_set_fcs_button( int btn, int button );
983 void kconfig_read_external_controls( void );
984
kconfig_is_axes_used(int axis)985 int kconfig_is_axes_used(int axis)
986 {
987 int i;
988 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
989 if (( kc_joystick[i].type == BT_JOY_AXIS ) && (kc_joystick[i].value == axis ))
990 return 1;
991 }
992 return 0;
993 }
994
995 #ifdef TABLE_CREATION
find_item_at(kc_item * items,int nitems,int x,int y)996 int find_item_at( kc_item * items, int nitems, int x, int y )
997 {
998 int i;
999
1000 for (i=0; i<nitems; i++ ) {
1001 if ( ((items[i].x+items[i].w1)==x) && (items[i].y==y))
1002 return i;
1003 }
1004 return -1;
1005 }
1006
find_next_item_up(kc_item * items,int nitems,int citem)1007 int find_next_item_up( kc_item * items, int nitems, int citem )
1008 {
1009 int x, y, i;
1010
1011 y = items[citem].y;
1012 x = items[citem].x+items[citem].w1;
1013
1014 do {
1015 y--;
1016 if ( y < 0 ) {
1017 y = grd_curcanv->cv_bitmap.bm_h-1;
1018 x--;
1019 if ( x < 0 ) {
1020 x = grd_curcanv->cv_bitmap.bm_w-1;
1021 }
1022 }
1023 i = find_item_at( items, nitems, x, y );
1024 } while ( i < 0 );
1025
1026 return i;
1027 }
1028
find_next_item_down(kc_item * items,int nitems,int citem)1029 int find_next_item_down( kc_item * items, int nitems, int citem )
1030 {
1031 int x, y, i;
1032
1033 y = items[citem].y;
1034 x = items[citem].x+items[citem].w1;
1035
1036 do {
1037 y++;
1038 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
1039 y = 0;
1040 x++;
1041 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
1042 x = 0;
1043 }
1044 }
1045 i = find_item_at( items, nitems, x, y );
1046 } while ( i < 0 );
1047
1048 return i;
1049 }
1050
find_next_item_right(kc_item * items,int nitems,int citem)1051 int find_next_item_right( kc_item * items, int nitems, int citem )
1052 {
1053 int x, y, i;
1054
1055 y = items[citem].y;
1056 x = items[citem].x+items[citem].w1;
1057
1058 do {
1059 x++;
1060 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
1061 x = 0;
1062 y++;
1063 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
1064 y = 0;
1065 }
1066 }
1067 i = find_item_at( items, nitems, x, y );
1068 } while ( i < 0 );
1069
1070 return i;
1071 }
1072
find_next_item_left(kc_item * items,int nitems,int citem)1073 int find_next_item_left( kc_item * items, int nitems, int citem )
1074 {
1075 int x, y, i;
1076
1077 y = items[citem].y;
1078 x = items[citem].x+items[citem].w1;
1079
1080 do {
1081 x--;
1082 if ( x < 0 ) {
1083 x = grd_curcanv->cv_bitmap.bm_w-1;
1084 y--;
1085 if ( y < 0 ) {
1086 y = grd_curcanv->cv_bitmap.bm_h-1;
1087 }
1088 }
1089 i = find_item_at( items, nitems, x, y );
1090 } while ( i < 0 );
1091
1092 return i;
1093 }
1094 #endif
1095
1096 #if defined(MACINTOSH) || defined(WINDOWS)
get_item_height(kc_item * item)1097 int get_item_height(kc_item *item)
1098 {
1099 int w, h, aw;
1100 char btext[10];
1101
1102 if (item->value==255) {
1103 sprintf( btext, "" );
1104 } else {
1105 switch( item->type ) {
1106 case BT_KEY:
1107 strncpy( btext, key_text[item->value], 10 ); break;
1108 case BT_MOUSE_BUTTON:
1109 #ifdef WINDOWS
1110 strncpy( btext, Text_string[mousebutton_text[item->value]], 10); break;
1111 #else
1112 strncpy( btext, mousebutton_text[item->value], 10 ); break;
1113 #endif
1114 case BT_MOUSE_AXIS:
1115 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
1116 case BT_JOY_BUTTON:
1117 if ( joybutton_text[item->value] !=-1 )
1118 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1119 else
1120 sprintf( btext, "BTN%d", item->value );
1121 break;
1122 case BT_JOY_AXIS:
1123 strncpy( btext, Text_string[joyaxis_text[item->value]], 10 ); break;
1124 case BT_INVERT:
1125 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
1126 }
1127 }
1128 gr_get_string_size(btext, &w, &h, &aw );
1129
1130 return h;
1131 }
1132 #endif
1133
kconfig_sub(kc_item * items,int nitems,char * title)1134 void kconfig_sub(kc_item * items,int nitems, char * title)
1135 {
1136 WINDOS(
1137 dd_grs_canvas * save_canvas,
1138 grs_canvas * save_canvas
1139 );
1140 grs_font * save_font;
1141 int old_keyd_repeat;
1142 #if defined(MACINTOSH) || defined(WINDOWS)
1143 int mouse_state, omouse_state, mx, my, x1, x2, y1, y2;
1144 int close_x, close_y, close_size;
1145 #endif
1146
1147 int i,k,ocitem,citem;
1148 int time_stopped = 0;
1149 WIN(char *old_bg_pcx);
1150
1151 WIN(old_bg_pcx = _SCRContext.bkg_filename);
1152 WIN(DEFINE_SCREEN(NULL));
1153
1154 All_items = items;
1155 Num_items = nitems;
1156
1157 if (!((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence)) )
1158 {
1159 time_stopped = 1;
1160 stop_time();
1161 }
1162
1163 // if (Config_control_type == CONTROL_WINJOYSTICK) {
1164 // WINDOS(
1165 // joydefsw_win_joyselect(title2); title = title2,
1166 // Int3()
1167 // ); // Get Samir...
1168 // }
1169
1170 WINDOS(
1171 save_canvas = dd_grd_curcanv,
1172 save_canvas = grd_curcanv
1173 );
1174
1175
1176 WINDOS(
1177 dd_gr_set_current_canvas(NULL),
1178 gr_set_current_canvas(NULL)
1179 );
1180 save_font = grd_curcanv->cv_font;
1181
1182 #ifdef WINDOWS
1183 KConfigPaint:
1184 #endif
1185 game_flush_inputs();
1186 old_keyd_repeat = keyd_repeat;
1187 keyd_repeat = 1;
1188
1189 //gr_clear_canvas( BM_XRGB(0,0,0) );
1190
1191 nm_draw_background(0, 0, grd_curcanv->cv_bitmap.bm_w - 1, grd_curcanv->cv_bitmap.bm_h - 1);
1192 gr_palette_load (gr_palette);
1193
1194 grd_curcanv->cv_font = MEDIUM3_FONT;
1195
1196 WIN(DDGRLOCK(dd_grd_curcanv));
1197 {
1198 char * p;
1199 p = strchr( title, '\n' );
1200 if ( p ) *p = 32;
1201 gr_string( 0x8000, LHY(8), title );
1202 if ( p ) *p = '\n';
1203 }
1204
1205
1206 // if ( items == kc_keyboard ) {
1207 // gr_string( 0x8000, 8, "Keyboard" );
1208 // } else if ( items == kc_joystick ) {
1209 // gr_string( 0x8000, 8, "Joysticks" );
1210 // } else if ( items == kc_mouse ) {
1211 // gr_string( 0x8000, 8, "Mouse" );
1212 // }
1213
1214 #if defined(MACINTOSH) || defined(WINDOWS)
1215 close_x = close_y = 15;
1216 close_size = 10;
1217 gr_setcolor( BM_XRGB(0, 0, 0) );
1218 gr_rect(close_x, close_y, close_x + close_size, close_y + close_size);
1219 gr_setcolor( BM_XRGB(21, 21, 21) );
1220 gr_rect( close_x + 2, close_y + 2, close_x + close_size - 2, close_y + close_size -2 );
1221 #endif
1222
1223 grd_curcanv->cv_font = GAME_FONT;
1224 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1225
1226 #ifndef MACINTOSH
1227 gr_string( 0x8000, LHY(20), TXT_KCONFIG_STRING_1 );
1228 #else
1229 gr_string( 0x8000, LHY(20), "Enter changes, ctrl-d deletes, ctrl-r resets defaults, ESC exits");
1230 #endif
1231 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1232 if ( items == kc_keyboard ) {
1233 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
1234 gr_setcolor( BM_XRGB(31,27,6) );
1235
1236 gr_scanline( LHX(98), LHX(106), LHY(42) );
1237 gr_scanline( LHX(120), LHX(128), LHY(42) );
1238 gr_pixel( LHX(98), LHY(43) );
1239 gr_pixel( LHX(98), LHY(44) );
1240 gr_pixel( LHX(128), LHY(43) );
1241 gr_pixel( LHX(128), LHY(44) );
1242
1243 gr_string( LHX(109), LHY(40), "OR" );
1244
1245 gr_scanline( LHX(253), LHX(261), LHY(42) );
1246 gr_scanline( LHX(274), LHX(283), LHY(42) );
1247 gr_pixel( LHX(253), LHY(43) );
1248 gr_pixel( LHX(253), LHY(44) );
1249 gr_pixel( LHX(283), LHY(43) );
1250 gr_pixel( LHX(283), LHY(44) );
1251
1252 gr_string( LHX(264), LHY(40), "OR" );
1253
1254 } if ( items == kc_joystick ) {
1255 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
1256 gr_setcolor( BM_XRGB(31,27,6) );
1257 gr_scanline( LHX(18), LHX(135), LHY(37) );
1258 gr_scanline( LHX(181), LHX(294), LHY(37) );
1259 gr_scanline( LHX(18), LHX(144), LHY(119+18) );
1260 gr_scanline( LHX(174), LHX(294), LHY(119+18) );
1261 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
1262 gr_string( 0x8000,LHY(117+18), TXT_AXES );
1263 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1264 gr_string( LHX(81), LHY(137+8), TXT_AXIS );
1265 gr_string( LHX(111), LHY(137+8), TXT_INVERT );
1266 gr_string( LHX(222), LHY(137+8), TXT_AXIS );
1267 gr_string( LHX(252), LHY(137+8), TXT_INVERT );
1268 } else if ( items == kc_mouse ) {
1269 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
1270 gr_setcolor( BM_XRGB(31,27,6) );
1271 gr_scanline( LHX(18), LHX(135), LHY(37) );
1272 gr_scanline( LHX(181), LHX(294), LHY(37) );
1273 gr_scanline( LHX(18), LHX(144), LHY(119+5) );
1274 gr_scanline( LHX(174), LHX(294), LHY(119+5) );
1275 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
1276 gr_string( 0x8000,LHY(117+5), TXT_AXES );
1277 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1278 gr_string( LHX(169), LHY(129), TXT_AXIS );
1279 gr_string( LHX(199), LHY(129), TXT_INVERT );
1280 }
1281 else if ( items == kc_d2x )
1282 {
1283 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
1284 gr_setcolor( BM_XRGB(31,27,6) );
1285
1286 gr_string(LHX( 94), LHY(40), "KB");
1287 gr_string(LHX(121), LHY(40), "JOY");
1288 }
1289
1290 WIN(DDGRUNLOCK(dd_grd_curcanv));
1291
1292 for (i=0; i<nitems; i++ ) {
1293 kc_drawitem( &items[i], 0 );
1294 }
1295
1296 citem = 0;
1297 kc_drawitem( &items[citem], 1 );
1298
1299 WIN(ShowCursorW());
1300 MAC(show_cursor();)
1301
1302 #if defined(MACINTOSH) || defined(WINDOWS)
1303 mouse_state = omouse_state = 0;
1304 #endif
1305
1306 while(1) {
1307 // Windows addendum to allow for kconfig input.
1308 #ifdef WINDOWS
1309 {
1310 MSG msg;
1311
1312 DoMessageStuff(&msg);
1313
1314 if (_RedrawScreen) {
1315 _RedrawScreen = FALSE;
1316
1317 dd_gr_set_current_canvas(NULL);
1318
1319 goto KConfigPaint;
1320 }
1321
1322 DDGRRESTORE;
1323 }
1324 #endif
1325 gr_update();
1326
1327 //see if redbook song needs to be restarted
1328 songs_check_redbook_repeat();
1329
1330 k = key_inkey();
1331
1332 #if defined(MACINTOSH) || defined(WINDOWS)
1333 omouse_state = mouse_state;
1334 mouse_state = mouse_button_state(0);
1335 #endif
1336
1337 if ( !time_stopped ) {
1338 #ifdef NETWORK
1339 if (multi_menu_poll() == -1)
1340 k = -2;
1341 #endif
1342 }
1343 ocitem = citem;
1344 switch( k ) {
1345 case KEY_BACKSP:
1346 Int3();
1347 break;
1348 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_3:)
1349 case KEY_PRINT_SCREEN:
1350 save_screen_shot(0);
1351 break;
1352 case KEY_CTRLED+KEY_D:
1353 items[citem].value = 255;
1354 kc_drawitem( &items[citem], 1 );
1355 break;
1356 case KEY_CTRLED+KEY_R:
1357 if ( items==kc_keyboard ) {
1358 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1359 items[i].value=default_kconfig_settings[0][i];
1360 kc_drawitem( &items[i], 0 );
1361 }
1362 } else if ( items==kc_d2x ) {
1363 for(i=0;i<NUM_D2X_CONTROLS;i++)
1364 {
1365 items[i].value=default_kconfig_d2x_settings[i];
1366 kc_drawitem( &items[i], 0 );
1367 }
1368 } else {
1369 #ifdef MACINTOSH
1370 // hack for firebire and mousestick default controls since I made
1371 // them the same control type -- dumb dumb dumb
1372 if (joy_have_firebird())
1373 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1374 items[i].value = default_firebird_settings[i];
1375 kc_drawitem( &items[i], 0 );
1376 }
1377 else if (joy_have_mousestick())
1378 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1379 items[i].value = default_mousestick_settings[i];
1380 kc_drawitem( &items[i], 0 );
1381 }
1382 else
1383 #endif // note link to above else
1384 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1385 items[i].value = default_kconfig_settings[Config_control_type][i];
1386 kc_drawitem( &items[i], 0 );
1387 }
1388 }
1389 kc_drawitem( &items[citem], 1 );
1390 break;
1391 case KEY_DELETE:
1392 items[citem].value=255;
1393 kc_drawitem( &items[citem], 1 );
1394 break;
1395 case KEY_UP:
1396 case KEY_PAD8:
1397 #ifdef TABLE_CREATION
1398 if (items[citem].u==-1) items[citem].u=find_next_item_up( items,nitems, citem);
1399 #endif
1400 citem = items[citem].u;
1401 break;
1402
1403 case KEY_DOWN:
1404 case KEY_PAD2:
1405 #ifdef TABLE_CREATION
1406 if (items[citem].d==-1) items[citem].d=find_next_item_down( items,nitems, citem);
1407 #endif
1408 citem = items[citem].d;
1409 break;
1410 case KEY_LEFT:
1411 case KEY_PAD4:
1412 #ifdef TABLE_CREATION
1413 if (items[citem].l==-1) items[citem].l=find_next_item_left( items,nitems, citem);
1414 #endif
1415 citem = items[citem].l;
1416 break;
1417 case KEY_RIGHT:
1418 case KEY_PAD6:
1419 #ifdef TABLE_CREATION
1420 if (items[citem].r==-1) items[citem].r=find_next_item_right( items,nitems, citem);
1421 #endif
1422 citem = items[citem].r;
1423 break;
1424 case KEY_ENTER:
1425 case KEY_PADENTER:
1426 switch( items[citem].type ) {
1427 case BT_KEY: kc_change_key( &items[citem] ); break;
1428 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1429 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1430 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1431 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1432 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1433 }
1434 break;
1435 case -2:
1436 case KEY_ESC:
1437 grd_curcanv->cv_font = save_font;
1438
1439 WIN(DEFINE_SCREEN(old_bg_pcx));
1440
1441 WINDOS(
1442 dd_gr_set_current_canvas(save_canvas),
1443 gr_set_current_canvas( save_canvas )
1444 );
1445 keyd_repeat = old_keyd_repeat;
1446 game_flush_inputs();
1447 WIN( HideCursorW());
1448 MAC( hide_cursor(); )
1449 if (time_stopped)
1450 start_time();
1451 return;
1452 #ifdef TABLE_CREATION
1453 case KEY_DEBUGGED+KEY_F12: {
1454 FILE * fp;
1455 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1456 kc_keyboard[i].u = find_next_item_up( kc_keyboard,NUM_KEY_CONTROLS, i);
1457 kc_keyboard[i].d = find_next_item_down( kc_keyboard,NUM_KEY_CONTROLS, i);
1458 kc_keyboard[i].l = find_next_item_left( kc_keyboard,NUM_KEY_CONTROLS, i);
1459 kc_keyboard[i].r = find_next_item_right( kc_keyboard,NUM_KEY_CONTROLS, i);
1460 }
1461 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1462 kc_joystick[i].u = find_next_item_up( kc_joystick,NUM_OTHER_CONTROLS, i);
1463 kc_joystick[i].d = find_next_item_down( kc_joystick,NUM_OTHER_CONTROLS, i);
1464 kc_joystick[i].l = find_next_item_left( kc_joystick,NUM_OTHER_CONTROLS, i);
1465 kc_joystick[i].r = find_next_item_right( kc_joystick,NUM_OTHER_CONTROLS, i);
1466 }
1467 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1468 kc_mouse[i].u = find_next_item_up( kc_mouse,NUM_OTHER_CONTROLS, i);
1469 kc_mouse[i].d = find_next_item_down( kc_mouse,NUM_OTHER_CONTROLS, i);
1470 kc_mouse[i].l = find_next_item_left( kc_mouse,NUM_OTHER_CONTROLS, i);
1471 kc_mouse[i].r = find_next_item_right( kc_mouse,NUM_OTHER_CONTROLS, i);
1472 }
1473 fp = fopen( "kconfig.cod", "wt" );
1474
1475 fprintf( fp, "ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {\n" );
1476 for (i=0; i<CONTROL_MAX_TYPES; i++ ) {
1477 int j;
1478 fprintf( fp, "{0x%x", kconfig_settings[i][0] );
1479 for (j=1; j<MAX_CONTROLS; j++ )
1480 fprintf( fp, ",0x%x", kconfig_settings[i][j] );
1481 fprintf( fp, "},\n" );
1482 }
1483 fprintf( fp, "};\n" );
1484
1485 fprintf( fp, "\nkc_item kc_keyboard[NUM_KEY_CONTROLS] = {\n" );
1486 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1487 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1488 kc_keyboard[i].id, kc_keyboard[i].x, kc_keyboard[i].y, kc_keyboard[i].w1, kc_keyboard[i].w2,
1489 kc_keyboard[i].u, kc_keyboard[i].d, kc_keyboard[i].l, kc_keyboard[i].r,
1490 34, kc_keyboard[i].text, 34, btype_text[kc_keyboard[i].type] );
1491 }
1492 fprintf( fp, "};" );
1493
1494 fprintf( fp, "\nkc_item kc_joystick[NUM_OTHER_CONTROLS] = {\n" );
1495 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1496 if (kc_joystick[i].type == BT_JOY_BUTTON)
1497 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1498 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1499 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1500 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1501 else
1502 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1503 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1504 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1505 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1506 }
1507 fprintf( fp, "};" );
1508
1509 fprintf( fp, "\nkc_item kc_mouse[NUM_OTHER_CONTROLS] = {\n" );
1510 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1511 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1512 kc_mouse[i].id, kc_mouse[i].x, kc_mouse[i].y, kc_mouse[i].w1, kc_mouse[i].w2,
1513 kc_mouse[i].u, kc_mouse[i].d, kc_mouse[i].l, kc_mouse[i].r,
1514 34, kc_mouse[i].text, 34, btype_text[kc_mouse[i].type] );
1515 }
1516 fprintf( fp, "};" );
1517
1518 fclose(fp);
1519
1520 }
1521 break;
1522 #endif
1523 }
1524
1525 #if defined (MACINTOSH) || defined(WINDOWS)
1526 if ( (mouse_state && !omouse_state) || (mouse_state && omouse_state) ) {
1527 int item_height;
1528
1529 mouse_get_pos(&mx, &my);
1530 for (i=0; i<nitems; i++ ) {
1531 item_height = get_item_height( &items[i] );
1532 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[i].x) + LHX(items[i].w1);
1533 x2 = x1 + LHX(items[i].w2);
1534 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[i].y);
1535 y2 = y1 + LHX(item_height);
1536 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1537 citem = i;
1538 break;
1539 }
1540 }
1541 }
1542 else if ( !mouse_state && omouse_state ) {
1543 int item_height;
1544
1545 mouse_get_pos(&mx, &my);
1546 item_height = get_item_height( &items[citem] );
1547 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[citem].x) + LHX(items[citem].w1);
1548 x2 = x1 + LHX(items[citem].w2);
1549 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[citem].y);
1550 y2 = y1 + LHY(item_height);
1551 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1552 WIN(HideCursorW());
1553 MAC(hide_cursor();)
1554 switch( items[citem].type ) {
1555 case BT_KEY: kc_change_key( &items[citem] ); break;
1556 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1557 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1558 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1559 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1560 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1561 }
1562 MAC(show_cursor();)
1563 WIN(ShowCursorW());
1564 } else {
1565 x1 = grd_curcanv->cv_bitmap.bm_x + close_x + 2;
1566 x2 = x1 + close_size - 2;
1567 y1 = grd_curcanv->cv_bitmap.bm_y + close_y + 2;
1568 y2 = y1 + close_size - 2;
1569 if ( ((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2)) ) {
1570 grd_curcanv->cv_font = save_font;
1571 WINDOS(dd_gr_set_current_canvas( save_canvas ),
1572 gr_set_current_canvas( save_canvas ));
1573 keyd_repeat = old_keyd_repeat;
1574 game_flush_inputs();
1575 WIN(HideCursorW());
1576 MAC(hide_cursor();)
1577 if (time_stopped)
1578 start_time();
1579 return;
1580 }
1581 }
1582
1583 }
1584 #endif // MACINTOSH WINDOWS
1585
1586 if (ocitem!=citem) {
1587 MAC(hide_cursor();)
1588 WIN(HideCursorW());
1589 kc_drawitem( &items[ocitem], 0 );
1590 kc_drawitem( &items[citem], 1 );
1591 WIN(ShowCursorW());
1592 MAC(show_cursor();)
1593 }
1594 }
1595 }
1596
1597
kc_drawitem(kc_item * item,int is_current)1598 void kc_drawitem( kc_item *item, int is_current )
1599 {
1600 int x, w, h, aw;
1601 char btext[16];
1602 // PA_DFX (pa_set_frontbuffer_current());
1603 WIN(DDGRLOCK(dd_grd_curcanv));
1604
1605 if (is_current)
1606 gr_set_fontcolor( BM_XRGB(20,20,29), -1 );
1607 else
1608 gr_set_fontcolor( BM_XRGB(15,15,24), -1 );
1609 gr_string( LHX(item->x), LHY(item->y), item->text );
1610 WIN(DDGRUNLOCK(dd_grd_curcanv));
1611
1612 if (item->value==255) {
1613 strcpy( btext, "" );
1614 } else {
1615 switch( item->type ) {
1616 case BT_KEY:
1617 strncpy( btext, key_text[item->value], 10 ); break;
1618 case BT_MOUSE_BUTTON:
1619 #ifndef MACINTOSH
1620 //strncpy( btext, Text_string[mousebutton_text[item->value]], 10 ); break;
1621 strncpy( btext, (item->value <= 3)?Text_string[mousebutton_text[item->value]]:mousebutton_textra[item->value-3], 10 ); break;
1622 #else
1623 strncpy( btext, mousebutton_text[item->value], 10 ); break;
1624 #endif
1625 case BT_MOUSE_AXIS:
1626 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
1627 case BT_JOY_BUTTON:
1628 #ifndef MACINTOSH
1629 #ifdef WINDOWS
1630 if (joybutton_text[item->value] != -1)
1631 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1632 else
1633 sprintf( btext, "BTN%2d", item->value+1 );
1634 #else
1635 if ( joybutton_text[item->value] !=-1 )
1636 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1637 else
1638 sprintf( btext, "BTN%d", item->value );
1639 #endif
1640 #else
1641 strncpy( btext, joy_btn_name( item->value ), 10);
1642 if (btext == NULL)
1643 sprintf( btext, "BTN%d", item->value );
1644 #endif
1645 break;
1646 case BT_JOY_AXIS:
1647 strncpy( btext, Text_string[joyaxis_text[item->value]], 10 ); break;
1648 case BT_INVERT:
1649 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
1650 }
1651 }
1652 if (item->w1) {
1653 WIN(DDGRLOCK(dd_grd_curcanv));
1654 gr_get_string_size(btext, &w, &h, &aw );
1655
1656 if (is_current)
1657 gr_setcolor( BM_XRGB(21,0,24) );
1658 else
1659 gr_setcolor( BM_XRGB(16,0,19) );
1660 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1661
1662 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1663
1664 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1665
1666 gr_string( x, LHY(item->y), btext );
1667 // PA_DFX (pa_set_backbuffer_current());
1668
1669 WIN(DDGRUNLOCK(dd_grd_curcanv));
1670 }
1671 }
1672
1673
1674 static int looper=0;
1675
kc_drawquestion(kc_item * item)1676 void kc_drawquestion( kc_item *item )
1677 {
1678 int c, x, w, h, aw;
1679
1680 WIN(DDGRLOCK(dd_grd_curcanv));
1681 // PA_DFX (pa_set_frontbuffer_current());
1682
1683 gr_get_string_size("?", &w, &h, &aw );
1684
1685 c = BM_XRGB(21,0,24);
1686
1687 //@@gr_setcolor( gr_fade_table[fades[looper]*256+c] );
1688 gr_setcolor(BM_XRGB(21*fades[looper]/31,0,24*fades[looper]/31));
1689 looper++;
1690 if (looper>63) looper=0;
1691
1692 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1693
1694 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1695
1696 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1697
1698 gr_string( x, LHY(item->y), "?" );
1699 // PA_DFX (pa_set_backbuffer_current());
1700 WIN(DDGRUNLOCK(dd_grd_curcanv));
1701 gr_update();
1702 }
1703
kc_change_key(kc_item * item)1704 void kc_change_key( kc_item * item )
1705 {
1706 int i,n,f,k;
1707 ubyte keycode;
1708
1709 WIN(DDGRLOCK(dd_grd_curcanv));
1710 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1711
1712 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_KEY );
1713 WIN(DDGRUNLOCK(dd_grd_curcanv));
1714
1715 game_flush_inputs();
1716 keycode=255;
1717 k=255;
1718
1719 while( (k!=KEY_ESC) && (keycode==255) )
1720 {
1721 #ifdef WINDOWS
1722 {
1723 MSG msg;
1724
1725 DoMessageStuff(&msg);
1726 DDGRRESTORE;
1727
1728 }
1729 #endif
1730
1731 #ifdef NETWORK
1732 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1733 multi_menu_poll();
1734 #endif
1735 // if ( Game_mode & GM_MULTI )
1736 // GameLoop( 0, 0 ); // Continue
1737 k = key_inkey();
1738 timer_delay(f0_1/10);
1739 kc_drawquestion( item );
1740
1741 for (i=0; i<256; i++ ) {
1742 if (keyd_pressed[i] && (strlen(key_text[i])>0)) {
1743 f = 0;
1744 for (n=0; n<sizeof(system_keys); n++ )
1745 if ( system_keys[n] == i )
1746 f=1;
1747 if (!f)
1748 keycode=i;
1749 }
1750 }
1751 }
1752
1753 if (k!=KEY_ESC) {
1754 for (i=0; i<Num_items; i++ ) {
1755 n = item - All_items;
1756 if ( (i!=n) && (All_items[i].type==BT_KEY) && (All_items[i].value==keycode) ) {
1757 All_items[i].value = 255;
1758 kc_drawitem( &All_items[i], 0 );
1759 }
1760 }
1761 item->value = keycode;
1762 }
1763 kc_drawitem( item, 1 );
1764
1765 WIN(DDGRLOCK(dd_grd_curcanv));
1766 gr_set_fontcolor( BM_XRGB(28,28,28), BM_XRGB(0,0,0) );
1767 WIN(DDGRUNLOCK(dd_grd_curcanv));
1768
1769 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1770
1771 game_flush_inputs();
1772
1773 }
1774
kc_change_joybutton(kc_item * item)1775 void kc_change_joybutton( kc_item * item )
1776 {
1777 int n,i,k;
1778 ubyte code;
1779
1780 WIN(DDGRLOCK(dd_grd_curcanv));
1781 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1782
1783 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_JBUTTON );
1784 WIN(DDGRUNLOCK(dd_grd_curcanv));
1785
1786 game_flush_inputs();
1787 code=255;
1788 k=255;
1789
1790 while( (k!=KEY_ESC) && (code==255))
1791 {
1792 #ifdef WINDOWS
1793 {
1794 MSG msg;
1795 DoMessageStuff(&msg);
1796 DDGRRESTORE;
1797 }
1798 #endif
1799
1800 #ifdef NETWORK
1801 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1802 multi_menu_poll();
1803 #endif
1804 // if ( Game_mode & GM_MULTI )
1805 // GameLoop( 0, 0 ); // Continue
1806 k = key_inkey();
1807 timer_delay(f0_1/10);
1808
1809 if (k == KEY_PRINT_SCREEN)
1810 save_screen_shot(0);
1811
1812 kc_drawquestion( item );
1813
1814 WIN(code = joydefsw_do_button());
1815
1816 #ifdef MACINTOSH
1817 code = joy_do_buttons();
1818 #endif
1819
1820 #if !defined(WINDOWS) && !defined(MACINTOSH)
1821 if (Config_control_type==CONTROL_THRUSTMASTER_FCS) {
1822 int axis[4];
1823 joystick_read_raw_axis( JOY_ALL_AXIS, axis );
1824 kconfig_read_fcs( axis[3] );
1825 if ( joy_get_button_state(7) ) code = 7;
1826 if ( joy_get_button_state(11) ) code = 11;
1827 if ( joy_get_button_state(15) ) code = 15;
1828 if ( joy_get_button_state(19) ) code = 19;
1829 for (i=0; i<4; i++ ) {
1830 if ( joy_get_button_state(i) )
1831 code = i;
1832 }
1833 } else if (Config_control_type==CONTROL_FLIGHTSTICK_PRO) {
1834 for (i=4; i<20; i++ ) {
1835 if ( joy_get_button_state(i) ) {
1836 code = i;
1837 mprintf(( 0, "JB: %d\n", code ));
1838 }
1839 }
1840 } else {
1841 for (i=0; i<MAX_BUTTONS; i++ ) {
1842 if ( joy_get_button_state(i) )
1843 code = i;
1844 }
1845 }
1846 #endif
1847 }
1848 if (code!=255) {
1849 for (i=0; i<Num_items; i++ ) {
1850 n = item - All_items;
1851 if ( (i!=n) && (All_items[i].type==BT_JOY_BUTTON) && (All_items[i].value==code) ) {
1852 All_items[i].value = 255;
1853 kc_drawitem( &All_items[i], 0 );
1854 }
1855 }
1856 item->value = code;
1857 }
1858 kc_drawitem( item, 1 );
1859 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1860 game_flush_inputs();
1861 }
1862
kc_change_mousebutton(kc_item * item)1863 void kc_change_mousebutton( kc_item * item )
1864 {
1865 int n,i,b,k;
1866 ubyte code;
1867
1868 WIN(DDGRLOCK(dd_grd_curcanv));
1869 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1870
1871 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_MBUTTON );
1872 WIN(DDGRUNLOCK(dd_grd_curcanv));
1873
1874
1875 game_flush_inputs();
1876 code=255;
1877 k=255;
1878
1879 while( (k!=KEY_ESC) && (code==255))
1880 {
1881 #ifdef WINDOWS
1882 {
1883 MSG msg;
1884 DoMessageStuff(&msg);
1885 DDGRRESTORE;
1886 }
1887 #endif
1888
1889 #ifdef NETWORK
1890 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1891 multi_menu_poll();
1892 #endif
1893 // if ( Game_mode & GM_MULTI )
1894 // GameLoop( 0, 0 ); // Continue
1895 k = key_inkey();
1896 timer_delay(f0_1/10);
1897
1898 if (k == KEY_PRINT_SCREEN)
1899 save_screen_shot(0);
1900
1901 kc_drawquestion( item );
1902
1903 b = mouse_get_btns();
1904 for (i = 0; i < 16; i++ ) {
1905 if ( b & (1<<i) )
1906 code = i;
1907 }
1908 }
1909 if (code!=255) {
1910 for (i=0; i<Num_items; i++ ) {
1911 n = item - All_items;
1912 if ( (i!=n) && (All_items[i].type==BT_MOUSE_BUTTON) && (All_items[i].value==code) ) {
1913 All_items[i].value = 255;
1914 kc_drawitem( &All_items[i], 0 );
1915 }
1916 }
1917 item->value = code;
1918 }
1919 kc_drawitem( item, 1 );
1920 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1921 game_flush_inputs();
1922
1923 }
1924
kc_change_joyaxis(kc_item * item)1925 void kc_change_joyaxis( kc_item * item )
1926 {
1927 #ifdef __unix__
1928 int axis[MAX_AXES];
1929 int old_axis[MAX_AXES];
1930 #else
1931 int axis[JOY_NUM_AXES];
1932 int old_axis[JOY_NUM_AXES];
1933 #endif
1934 int n,i,k;
1935 ubyte code;
1936 WINDOS (
1937 int numaxis=7,
1938 int numaxis=6
1939 );
1940
1941 WIN(DDGRLOCK(dd_grd_curcanv));
1942 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1943
1944 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_JOY_AXIS );
1945 WIN(DDGRUNLOCK(dd_grd_curcanv));
1946
1947 game_flush_inputs();
1948 code=255;
1949 k=255;
1950
1951 WINDOS(
1952 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, old_axis ),
1953 joystick_read_raw_axis( JOY_ALL_AXIS, old_axis )
1954 );
1955
1956 while( (k!=KEY_ESC) && (code==255))
1957 {
1958 #ifdef WINDOWS
1959 {
1960 MSG msg;
1961 DoMessageStuff(&msg);
1962 DDGRRESTORE;
1963 }
1964 #endif
1965
1966 #ifdef NETWORK
1967 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1968 multi_menu_poll();
1969 #endif
1970 // if ( Game_mode & GM_MULTI )
1971 // GameLoop( 0, 0 ); // Continue
1972 k = key_inkey();
1973 timer_delay(f0_1/10);
1974
1975 if (k == KEY_PRINT_SCREEN)
1976 save_screen_shot(0);
1977
1978 kc_drawquestion( item );
1979
1980 WINDOS(
1981 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, axis ),
1982 joystick_read_raw_axis( JOY_ALL_AXIS, axis )
1983 );
1984
1985 for (i=0; i<numaxis; i++ ) {
1986 #if defined (MACINTOSH)
1987 if ( abs(axis[i]-old_axis[i])>100 ) {
1988 #elif defined(WINDOWS)
1989 if ( abs(axis[i]-old_axis[i])>1024 ) {
1990 #else
1991 if ( abs(axis[i]-old_axis[i])>200 ) {
1992 #endif
1993 code = i;
1994 con_printf(CON_DEBUG, "Axis Movement detected: Axis %i\n", i);
1995 }
1996 //old_axis[i] = axis[i];
1997 }
1998 for (i=0; i<Num_items; i++ )
1999 {
2000 n = item - All_items;
2001 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) )
2002 code = 255;
2003 }
2004
2005 }
2006 if (code!=255) {
2007 for (i=0; i<Num_items; i++ ) {
2008 n = item - All_items;
2009 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) ) {
2010 All_items[i].value = 255;
2011 kc_drawitem( &All_items[i], 0 );
2012 }
2013 }
2014
2015 item->value = code;
2016 }
2017 kc_drawitem( item, 1 );
2018 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
2019 game_flush_inputs();
2020
2021 }
2022
2023 void kc_change_mouseaxis( kc_item * item )
2024 {
2025 int i,n,k;
2026 ubyte code;
2027 int dx,dy;
2028 #ifdef SDL_INPUT
2029 int dz;
2030 #endif
2031
2032 WIN(DDGRLOCK(dd_grd_curcanv));
2033 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
2034
2035 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_MSE_AXIS );
2036 WIN(DDGRUNLOCK(dd_grd_curcanv));
2037
2038 game_flush_inputs();
2039 code=255;
2040 k=255;
2041
2042 mouse_get_delta( &dx, &dy );
2043
2044 while( (k!=KEY_ESC) && (code==255))
2045 {
2046 #ifdef WINDOWS
2047 {
2048 MSG msg;
2049 DoMessageStuff(&msg);
2050 DDGRRESTORE;
2051 }
2052 #endif
2053
2054 #ifdef NETWORK
2055 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
2056 multi_menu_poll();
2057 #endif
2058 // if ( Game_mode & GM_MULTI )
2059 // GameLoop( 0, 0 ); // Continue
2060 k = key_inkey();
2061 timer_delay(f0_1/10);
2062
2063 if (k == KEY_PRINT_SCREEN)
2064 save_screen_shot(0);
2065
2066 kc_drawquestion( item );
2067
2068 #ifdef SDL_INPUT
2069 mouse_get_delta_z( &dx, &dy, &dz );
2070 #else
2071 mouse_get_delta( &dx, &dy );
2072 #endif
2073 if ( abs(dx)>20 ) code = 0;
2074 if ( abs(dy)>20 ) code = 1;
2075 #ifdef SDL_INPUT
2076 if ( abs(dz)>20 ) code = 2;
2077 #endif
2078 }
2079 if (code!=255) {
2080 for (i=0; i<Num_items; i++ ) {
2081 n = item - All_items;
2082 if ( (i!=n) && (All_items[i].type==BT_MOUSE_AXIS) && (All_items[i].value==code) ) {
2083 All_items[i].value = 255;
2084 kc_drawitem( &All_items[i], 0 );
2085 }
2086 }
2087 item->value = code;
2088 }
2089 kc_drawitem( item, 1 );
2090 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
2091 game_flush_inputs();
2092
2093 }
2094
2095
2096 void kc_change_invert( kc_item * item )
2097 {
2098 game_flush_inputs();
2099
2100 if (item->value)
2101 item->value = 0;
2102 else
2103 item->value = 1;
2104
2105 kc_drawitem( item, 1 );
2106
2107 }
2108
2109 #include "screens.h"
2110
2111 extern void gr_bm_bitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
2112
2113 void kconfig(int n, char * title)
2114 {
2115 int i;
2116 grs_bitmap *save_bm;
2117
2118 set_screen_mode( SCREEN_MENU );
2119
2120 kc_set_controls();
2121
2122 //save screen
2123 WIN(mouse_set_mode(0));
2124 WIN(dd_gr_set_current_canvas(NULL));
2125
2126 #if defined(POLY_ACC)
2127 save_bm = gr_create_bitmap2( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h, grd_curcanv->cv_bitmap.bm_type, NULL );
2128 #else
2129 save_bm = gr_create_bitmap( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
2130 #endif
2131 Assert( save_bm != NULL );
2132
2133 WIN(DDGRLOCK(dd_grd_curcanv));
2134 gr_bm_bitblt(grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_w,
2135 0, 0, 0, 0, &grd_curcanv->cv_bitmap, save_bm );
2136 WIN(DDGRUNLOCK(dd_grd_curcanv));
2137
2138 switch(n) {
2139 case 0:kconfig_sub( kc_keyboard, NUM_KEY_CONTROLS, title );break;
2140 case 1:kconfig_sub( kc_joystick, NUM_OTHER_CONTROLS, title );break;
2141 case 2:kconfig_sub( kc_mouse, NUM_OTHER_CONTROLS, title ); break;
2142 case 3:kconfig_sub( kc_superjoy, NUM_OTHER_CONTROLS, title); break;
2143 //added on 2/4/99 by Victor Rachels for new keys menu
2144 case 4:kconfig_sub( kc_d2x, NUM_D2X_CONTROLS, title ); break;
2145 //end this section addition - VR
2146 default:
2147 Int3();
2148 return;
2149 }
2150
2151 //restore screen
2152 WIN(mouse_set_mode(1));
2153 WIN(dd_gr_set_current_canvas(NULL));
2154 WIN(DDGRLOCK(dd_grd_curcanv));
2155 gr_bitmap(0, 0, save_bm);
2156 WIN(DDGRUNLOCK(dd_grd_curcanv));
2157 gr_free_bitmap(save_bm);
2158
2159 reset_cockpit(); //force cockpit redraw next time
2160
2161 // Update save values...
2162
2163 for (i=0; i<NUM_KEY_CONTROLS; i++ )
2164 kconfig_settings[0][i] = kc_keyboard[i].value;
2165
2166 if ( (Config_control_type>0) && (Config_control_type<5)) {
2167 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
2168 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
2169 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
2170 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
2171 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
2172 }
2173 else if (Config_control_type == CONTROL_WINJOYSTICK) {
2174 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
2175 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
2176 }
2177
2178 for (i=0; i<NUM_D2X_CONTROLS; i++)
2179 kconfig_d2x_settings[i] = kc_d2x[i].value;
2180 }
2181
2182
2183 void kconfig_read_fcs( int raw_axis )
2184 {
2185 int raw_button, button, axis_min[4], axis_center[4], axis_max[4];
2186
2187 if (Config_control_type!=CONTROL_THRUSTMASTER_FCS) return;
2188
2189 joy_get_cal_vals(axis_min, axis_center, axis_max);
2190
2191 if ( axis_max[3] > 1 )
2192 raw_button = (raw_axis*100)/axis_max[3];
2193 else
2194 raw_button = 0;
2195
2196 if ( raw_button > 88 )
2197 button = 0;
2198 else if ( raw_button > 63 )
2199 button = 7;
2200 else if ( raw_button > 39 )
2201 button = 11;
2202 else if ( raw_button > 15 )
2203 button = 15;
2204 else
2205 button = 19;
2206
2207 kconfig_set_fcs_button( 19, button );
2208 kconfig_set_fcs_button( 15, button );
2209 kconfig_set_fcs_button( 11, button );
2210 kconfig_set_fcs_button( 7, button );
2211 }
2212
2213
2214 void kconfig_set_fcs_button( int btn, int button )
2215 {
2216 int state,time_down,upcount,downcount;
2217 state = time_down = upcount = downcount = 0;
2218
2219 if ( joy_get_button_state(btn) ) {
2220 if ( btn==button ) {
2221 state = 1;
2222 time_down = FrameTime;
2223 } else {
2224 upcount=1;
2225 }
2226 } else {
2227 if ( btn==button ) {
2228 state = 1;
2229 time_down = FrameTime;
2230 downcount=1;
2231 } else {
2232 upcount=1;
2233 }
2234 }
2235
2236 joy_set_btn_values( btn, state, time_down, downcount, upcount );
2237
2238 }
2239
2240
2241
2242 fix Last_angles_p = 0;
2243 fix Last_angles_b = 0;
2244 fix Last_angles_h = 0;
2245 ubyte Last_angles_read = 0;
2246
2247 extern int VR_sensitivity;
2248
2249 int VR_sense_range[3] = { 25, 50, 75 };
2250
2251 #if 0 //ndef MACINTOSH
2252 read_head_tracker()
2253 {
2254 #ifndef WINDOWS
2255
2256 fix yaw, pitch, roll;
2257 int buttons;
2258
2259 //------ read vfx1 helmet --------
2260 if (vfx1_installed) {
2261 vfx_get_data(&yaw,&pitch,&roll,&buttons);
2262 } else if (iglasses_headset_installed) {
2263 iglasses_read_headset( &yaw, &pitch, &roll );
2264 } else if (Victor_headset_installed) {
2265 victor_read_headset_filtered( &yaw, &pitch, &roll );
2266 } else {
2267 return;
2268 }
2269
2270 Use_player_head_angles = 0;
2271 if ( Last_angles_read ) {
2272 fix yaw1 = yaw;
2273
2274 yaw1 = yaw;
2275 if ( (Last_angles_h < (F1_0/4) ) && (yaw > ((F1_0*3)/4) ) )
2276 yaw1 -= F1_0;
2277 else if ( (yaw < (F1_0/4) ) && (Last_angles_h > ((F1_0*3)/4) ) )
2278 yaw1 += F1_0;
2279
2280 Controls.pitch_time += fixmul((pitch- Last_angles_p)*VR_sense_range[VR_sensitivity],FrameTime);
2281 Controls.heading_time+= fixmul((yaw1 - Last_angles_h)*VR_sense_range[VR_sensitivity],FrameTime);
2282 Controls.bank_time += fixmul((roll - Last_angles_b)*VR_sense_range[VR_sensitivity],FrameTime);
2283 }
2284 Last_angles_read = 1;
2285 Last_angles_p = pitch;
2286 Last_angles_h = yaw;
2287 Last_angles_b = roll;
2288 #endif
2289 }
2290 #endif
2291
2292 #define PH_SCALE 8
2293
2294 #ifdef WINDOWS
2295 #define JOYSTICK_READ_TIME (F1_0/40) // Read joystick at 40 Hz.
2296 #else
2297 #define JOYSTICK_READ_TIME (F1_0/10) // Read joystick at 10 Hz.
2298 #endif
2299
2300 fix LastReadTime = 0;
2301
2302 fix joy_axis[7];
2303
2304 ubyte kc_use_external_control = 0;
2305 ubyte kc_enable_external_control = 0;
2306 ubyte kc_external_intno = 0;
2307 ext_control_info *kc_external_control = NULL;
2308 ubyte *kc_external_name = NULL;
2309 ubyte kc_external_version = 0;
2310 extern int Automap_active;
2311
2312 void kconfig_init_external_controls(int intno, int address)
2313 {
2314 int i;
2315 kc_external_intno = intno;
2316 kc_external_control = (ext_control_info *)address;
2317 kc_use_external_control = 1;
2318 kc_enable_external_control = 1;
2319
2320 i = FindArg ( "-xname" );
2321 if ( i )
2322 kc_external_name = Args[i+1];
2323 else
2324 kc_external_name = "External Controller";
2325
2326 for (i=0;i<strlen (kc_external_name);i++)
2327 if (kc_external_name[i]=='_')
2328 kc_external_name[i]=' ';
2329
2330 i = FindArg ( "-xver" );
2331 if ( i )
2332 kc_external_version = atoi(Args[i+1]);
2333
2334 printf( "%s int: 0x%x, data: 0x%p, ver:%d\n", kc_external_name, kc_external_intno, kc_external_control, kc_external_version );
2335
2336 }
2337
2338 #if !defined(MACINTOSH)
2339 /*void kconfig_read_external_controls()
2340 {
2341 union REGS r;
2342
2343 if ( !kc_enable_external_control && !CybermouseActive)
2344 return;
2345
2346 if ( kc_external_version == 0 )
2347 memset( kc_external_control, 0, sizeof(control_info) );
2348 else if ( kc_external_version > 0 ) {
2349 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 );
2350 if ( kc_external_version > 1 ) {
2351 // Write ship pos and angles to external controls...
2352 ubyte *temp_ptr = (ubyte *)kc_external_control;
2353 vms_vector *ship_pos;
2354 vms_matrix *ship_orient;
2355 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
2356 temp_ptr += sizeof(control_info)+sizeof(vms_angvec) + 64;
2357 ship_pos = (vms_vector *)temp_ptr;
2358 temp_ptr += sizeof(vms_vector);
2359 ship_orient = (vms_matrix *)temp_ptr;
2360 // Fill in ship postion...
2361 *ship_pos = Objects[Players[Player_num].objnum].pos;
2362 // Fill in ship orientation...
2363 *ship_orient = Objects[Players[Player_num].objnum].orient;
2364 }
2365 }
2366
2367 if ( Automap_active ) // (If in automap...)
2368 kc_external_control->automap_state = 1;
2369 memset(&r,0,sizeof(r));
2370
2371 #ifndef WINDOWS
2372
2373 if (!CybermouseActive)
2374 int386 ( kc_external_intno, &r, &r); // Read external info...
2375 // else
2376 // ReadOWL (kc_external_control);
2377
2378 #endif
2379
2380 if ( Player_num > -1 ) {
2381 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
2382 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
2383 Auto_leveling_on = 0;
2384
2385 if ( kc_external_version > 0 ) {
2386 vms_matrix tempm, ViewMatrix;
2387 vms_angvec * Kconfig_abs_movement;
2388 char * oem_message;
2389
2390 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
2391
2392 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
2393 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
2394 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
2395 Objects[Players[Player_num].objnum].orient = ViewMatrix;
2396 }
2397 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
2398 if (oem_message[0] != '\0' )
2399 HUD_init_message( oem_message );
2400 }
2401 }
2402
2403 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
2404 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
2405 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
2406 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
2407 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
2408 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
2409 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
2410 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
2411 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
2412 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
2413 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
2414 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
2415 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
2416 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
2417 Controls.automap_down_count += kc_external_control->automap_down_count;
2418 Controls.automap_state |= kc_external_control->automap_state;
2419 } */
2420 #endif
2421
2422 #ifdef WINDOWS
2423 void controls_read_all_win()
2424 {
2425 int i;
2426 int slide_on, bank_on;
2427 int dx, dy;
2428 fix ctime;
2429 fix mouse_axis[2];
2430 int raw_joy_axis[7];
2431 int mouse_buttons;
2432 fix k0, k1, k2, k3, kp;
2433 fix k4, k5, k6, k7, kh;
2434 ubyte channel_masks;
2435 int use_mouse, use_joystick;
2436 int speed_factor=1;
2437
2438 if (Game_turbo_mode)
2439 speed_factor = 2;
2440
2441 {
2442 fix temp = Controls.heading_time;
2443 fix temp1 = Controls.pitch_time;
2444 memset( &Controls, 0, sizeof(control_info) );
2445 Controls.heading_time = temp;
2446 Controls.pitch_time = temp1;
2447 }
2448 slide_on = 0;
2449 bank_on = 0;
2450
2451 ctime = timer_get_fixed_seconds();
2452
2453 // DO JOYSTICK (X,Y,Z R,U,V)
2454 // ----------------------------------------------------------------------------
2455 if ( (LastReadTime + JOYSTICK_READ_TIME) > ctime ) {
2456 if ((ctime < 0) && (LastReadTime > 0))
2457 LastReadTime = ctime;
2458 use_joystick=1;
2459 } else if ((Config_control_type==CONTROL_WINJOYSTICK)) {
2460 LastReadTime = ctime;
2461 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, raw_joy_axis );
2462
2463 for (i=0; i<7; i++ ) {
2464 if (channel_masks&(1<<i)) {
2465 int joy_null_value = 28;
2466
2467 // DO POV if joystick has a hat.
2468 // --------------------------------------------------------------------
2469 if (i == 3) {
2470 joydefsw_do_winjoybutton(raw_joy_axis);
2471 }
2472 else {
2473 // DO AXIS
2474 // --------------------------------------------------------------------
2475 // mprintf((0, "(%d)=%d,", i, raw_joy_axis[i]));
2476 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2477 // mprintf((0, "%d ",raw_joy_axis[i]));
2478 // if (i%2) mprintf((0,"\n"));
2479
2480
2481 if (kc_superjoy[23].value==i) // If this is the throttle
2482 joy_null_value = 32; // Then use a larger dead-zone
2483
2484 if (raw_joy_axis[i] > (joy_null_value-2))
2485 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2486 else if (raw_joy_axis[i] < -(joy_null_value+2))
2487 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2488 else
2489 raw_joy_axis[i] = 0;
2490 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2491 }
2492 } else {
2493 joy_axis[i] = 0;
2494 }
2495 }
2496 use_joystick=1;
2497
2498 } else {
2499 for (i=0; i<6; i++ )
2500 joy_axis[i] = 0;
2501 use_joystick=0;
2502 }
2503
2504 // DO MOUSE
2505 // ----------------------------------------------------------------------------
2506 if (Config_control_type==5) {
2507 mouse_get_delta( &dx, &dy );
2508 mouse_axis[0] = (dx*FrameTime)/35;
2509 mouse_axis[1] = (dy*FrameTime)/25;
2510 mouse_buttons = mouse_get_btns();
2511 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2512 use_mouse=1;
2513 } else {
2514 mouse_axis[0] = 0;
2515 mouse_axis[1] = 0;
2516 mouse_buttons = 0;
2517 use_mouse=0;
2518 }
2519
2520 //------------- Read slide_on -------------
2521
2522 // From keyboard...
2523 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
2524 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
2525 // From joystick...
2526 if ((use_joystick)&&(kc_superjoy[5].value<255)) slide_on |= joy_get_button_state( kc_superjoy[5].value );
2527 // From mouse...
2528 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
2529
2530 //------------- Read bank_on ---------------
2531
2532 // From keyboard...
2533 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
2534 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
2535 // From joystick...
2536 if ( (use_joystick)&&(kc_superjoy[10].value < 255 )) bank_on |= joy_get_button_state( kc_superjoy[10].value );
2537 // From mouse...
2538 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
2539
2540 //------------ Read pitch_time -----------
2541 if ( !slide_on ) {
2542 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2543 kp = 0;
2544 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
2545 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
2546 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
2547 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
2548
2549 // From keyboard...
2550 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
2551 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
2552 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
2553 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
2554
2555 // From Cyberman...
2556 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2557 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
2558 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
2559 }
2560
2561 if (kp == 0)
2562 Controls.pitch_time = 0;
2563 else if (kp > 0) {
2564 if (Controls.pitch_time < 0)
2565 Controls.pitch_time = 0;
2566 } else // kp < 0
2567 if (Controls.pitch_time > 0)
2568 Controls.pitch_time = 0;
2569 Controls.pitch_time += kp;
2570
2571 // From joystick...
2572 if ( (use_joystick)&&(kc_superjoy[13].value < 255 )) {
2573 if ( !kc_superjoy[14].value ) // If not inverted...
2574 Controls.pitch_time -= (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2575 else
2576 Controls.pitch_time += (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2577 }
2578
2579 // From mouse...
2580 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
2581 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
2582 if ( !kc_mouse[14].value ) // If not inverted...
2583 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2584 else
2585 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2586 }
2587 } else {
2588 Controls.pitch_time = 0;
2589 }
2590
2591
2592 //----------- Read vertical_thrust_time -----------------
2593
2594 if ( slide_on ) {
2595 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
2596 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
2597 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
2598 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
2599
2600 // From keyboard...
2601 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
2602 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
2603 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
2604 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
2605
2606 // From Cyberman...
2607 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2608 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
2609 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
2610 }
2611
2612 // From joystick...
2613 if ((use_joystick)&&( kc_superjoy[13].value < 255 )) {
2614 if ( !kc_superjoy[14].value ) // If not inverted...
2615 Controls.vertical_thrust_time += joy_axis[kc_superjoy[13].value];
2616 else
2617 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[13].value];
2618 }
2619
2620 // From mouse...
2621 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
2622 if ( !kc_mouse[14].value ) // If not inverted...
2623 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
2624 else
2625 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
2626 }
2627 }
2628
2629 // From keyboard...
2630 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
2631 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
2632 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
2633 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
2634
2635 // From joystick...
2636 if ((use_joystick)&&( kc_superjoy[19].value < 255 )) {
2637 if ( !kc_superjoy[20].value ) // If not inverted...
2638 Controls.vertical_thrust_time += joy_axis[kc_superjoy[19].value];
2639 else
2640 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[19].value];
2641 }
2642
2643 // From joystick buttons
2644 if ( (use_joystick)&&(kc_superjoy[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_superjoy[8].value );
2645 if ( (use_joystick)&&(kc_superjoy[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_superjoy[9].value );
2646
2647 // From mouse buttons
2648 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
2649 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
2650
2651 // From mouse...
2652 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
2653 if ( !kc_mouse[20].value ) // If not inverted...
2654 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
2655 else
2656 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
2657 }
2658
2659 // From Cyberman...
2660 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2661 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
2662 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
2663 }
2664
2665 //---------- Read heading_time -----------
2666
2667 if (!slide_on && !bank_on) {
2668 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2669 kh = 0;
2670 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
2671 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
2672 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
2673 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
2674
2675 // From keyboard...
2676 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
2677 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
2678 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
2679 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
2680
2681 // From Cyberman...
2682 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2683 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
2684 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
2685 }
2686
2687 if (kh == 0)
2688 Controls.heading_time = 0;
2689 else if (kh > 0) {
2690 if (Controls.heading_time < 0)
2691 Controls.heading_time = 0;
2692 } else // kh < 0
2693 if (Controls.heading_time > 0)
2694 Controls.heading_time = 0;
2695 Controls.heading_time += kh;
2696
2697 // From joystick...
2698 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2699 if ( !kc_superjoy[16].value ) // If not inverted...
2700 Controls.heading_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2701 else
2702 Controls.heading_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2703 }
2704
2705 // From mouse...
2706 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2707 if ( !kc_mouse[16].value ) // If not inverted...
2708 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2709 else
2710 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2711 }
2712 } else {
2713 Controls.heading_time = 0;
2714 }
2715
2716 //----------- Read sideways_thrust_time -----------------
2717
2718 if ( slide_on ) {
2719 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2720 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2721 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2722 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2723
2724 // From keyboard...
2725 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
2726 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
2727 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
2728 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
2729
2730 // From joystick...
2731 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2732 if ( !kc_superjoy[16].value ) // If not inverted...
2733 Controls.sideways_thrust_time += joy_axis[kc_superjoy[15].value];
2734 else
2735 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[15].value];
2736 }
2737
2738 // From cyberman
2739 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2740 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
2741 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
2742 }
2743
2744 // From mouse...
2745 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2746 if ( !kc_mouse[16].value ) // If not inverted...
2747 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
2748 else
2749 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
2750 }
2751 }
2752
2753 // From keyboard...
2754 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
2755 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
2756 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
2757 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
2758
2759 // From joystick...
2760 if ( (use_joystick)&&(kc_superjoy[17].value < 255 )) {
2761 if ( !kc_superjoy[18].value ) // If not inverted...
2762 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[17].value];
2763 else
2764 Controls.sideways_thrust_time += joy_axis[kc_superjoy[17].value];
2765 }
2766
2767 // From joystick buttons
2768 if ( (use_joystick)&&(kc_superjoy[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_superjoy[6].value );
2769 if ( (use_joystick)&&(kc_superjoy[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_superjoy[7].value );
2770
2771 // From mouse buttons
2772 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
2773 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
2774
2775 // From mouse...
2776 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
2777 if ( !kc_mouse[18].value ) // If not inverted...
2778 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
2779 else
2780 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
2781 }
2782
2783 //----------- Read bank_time -----------------
2784
2785 if ( bank_on ) {
2786 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2787 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2788 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2789 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2790
2791 // From keyboard...
2792 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
2793 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
2794 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
2795 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
2796
2797 // From Cyberman...
2798 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2799 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
2800 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
2801 }
2802
2803 // From joystick...
2804 if ( (use_joystick)&&(kc_superjoy[15].value < 255) ) {
2805 if ( !kc_superjoy[16].value ) // If not inverted...
2806 Controls.bank_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2807 else
2808 Controls.bank_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2809 }
2810
2811 // From mouse...
2812 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2813 if ( !kc_mouse[16].value ) // If not inverted...
2814 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2815 else
2816 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2817 }
2818 }
2819
2820 // From keyboard...
2821 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
2822 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
2823 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
2824 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
2825
2826 // From joystick...
2827 if ( (use_joystick)&&(kc_superjoy[21].value < 255) ) {
2828 if ( !kc_superjoy[22].value ) // If not inverted...
2829 Controls.bank_time -= joy_axis[kc_superjoy[21].value];
2830 else
2831 Controls.bank_time += joy_axis[kc_superjoy[21].value];
2832 }
2833
2834 // From joystick buttons
2835 if ( (use_joystick)&&(kc_superjoy[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_superjoy[11].value );
2836 if ( (use_joystick)&&(kc_superjoy[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_superjoy[12].value );
2837
2838 // From mouse buttons
2839 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
2840 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
2841
2842 // From mouse...
2843 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
2844 if ( !kc_mouse[22].value ) // If not inverted...
2845 Controls.bank_time += mouse_axis[kc_mouse[21].value];
2846 else
2847 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
2848 }
2849
2850 // From Cyberman
2851 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2852 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
2853 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
2854 }
2855
2856 //----------- Read forward_thrust_time -------------
2857
2858 // From keyboard...
2859 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
2860 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
2861 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
2862 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
2863
2864 // From joystick...
2865 if ( (use_joystick)&&(kc_superjoy[23].value < 255 )) {
2866 if ( !kc_superjoy[24].value ) // If not inverted...
2867 Controls.forward_thrust_time -= joy_axis[kc_superjoy[23].value];
2868 else
2869 Controls.forward_thrust_time += joy_axis[kc_superjoy[23].value];
2870 }
2871
2872 // From joystick buttons
2873 if ( (use_joystick)&&(kc_superjoy[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_superjoy[2].value );
2874 if ( (use_joystick)&&(kc_superjoy[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_superjoy[3].value );
2875
2876 // From mouse...
2877 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
2878 if ( !kc_mouse[24].value ) // If not inverted...
2879 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
2880 else
2881 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
2882 }
2883
2884 // From mouse buttons
2885 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
2886 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
2887
2888 //----------- Read afterburner_state -------------
2889
2890 // From keyboard...
2891 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
2892 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
2893
2894 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
2895
2896 if ( (use_joystick)&&(kc_superjoy[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_superjoy[27].value);
2897
2898 //-------Read headlight key--------------------------
2899 if (kc_keyboard[52].value < 255 )
2900 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
2901 if (kc_keyboard[53].value < 255 )
2902 Controls.headlight_count=key_down_count(kc_keyboard[53].value);
2903 if ((use_joystick)&&(kc_superjoy[30].value < 255 ))
2904 Controls.headlight_count=joy_get_button_down_cnt(kc_superjoy[30].value);
2905
2906 //--------Read Cycle Primary Key------------------
2907
2908 if (kc_keyboard[48].value<255)
2909 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
2910 if (kc_keyboard[49].value<255)
2911 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
2912 if ((use_joystick)&&(kc_superjoy[28].value < 255 ))
2913 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_superjoy[28].value);
2914
2915 //--------Read Cycle Secondary Key------------------
2916
2917 if (kc_keyboard[50].value<255)
2918 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
2919 if (kc_keyboard[51].value<255)
2920 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
2921 if ((use_joystick)&&(kc_superjoy[29].value < 255 ))
2922 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_superjoy[29].value);
2923
2924 //--------Read Toggle Bomb key----------------------
2925
2926 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
2927 {
2928 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
2929
2930 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
2931 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
2932 {
2933 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2934 HUD_init_message ("No bombs available!");
2935 }
2936 else
2937 {
2938 if (Players[Player_num].secondary_ammo[bomb]==0)
2939 {
2940 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2941 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
2942 }
2943 else
2944 {
2945 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
2946 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
2947 }
2948 }
2949 }
2950
2951 //---------Read Energy->Shield key----------
2952
2953 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
2954 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
2955 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
2956 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
2957
2958 //----------- Read fire_primary_down_count
2959 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
2960 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
2961 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_superjoy[0].value);
2962 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
2963
2964 //----------- Read fire_primary_state
2965 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
2966 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
2967 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_superjoy[0].value);
2968 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
2969
2970 //----------- Read fire_secondary_down_count
2971 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
2972 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
2973 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_superjoy[1].value);
2974 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
2975
2976 //----------- Read fire_secondary_state
2977 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
2978 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
2979 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_superjoy[1].value);
2980 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
2981
2982 //----------- Read fire_flare_down_count
2983 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
2984 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
2985 if ((use_joystick)&&(kc_superjoy[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_superjoy[4].value);
2986 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
2987
2988 //----------- Read drop_bomb_down_count
2989 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
2990 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
2991 if ((use_joystick)&&(kc_superjoy[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_superjoy[26].value);
2992 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
2993
2994 //----------- Read rear_view_down_count
2995 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
2996 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
2997 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_superjoy[25].value);
2998 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
2999
3000 //----------- Read rear_view_down_state
3001 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
3002 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
3003 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_superjoy[25].value);
3004 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
3005
3006 //----------- Read automap_down_count
3007 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
3008 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
3009
3010 //----------- Read automap_state
3011 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
3012 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
3013
3014 //----------- Read stupid-cruise-control-type of throttle.
3015 {
3016 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
3017 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
3018 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
3019 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
3020 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
3021 Cruise_speed = 0;
3022 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
3023 Cruise_speed = 0;
3024
3025 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
3026 if (Cruise_speed < 0 ) Cruise_speed = 0;
3027
3028 if (Controls.forward_thrust_time==0)
3029 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
3030 }
3031
3032 //read_head_tracker();
3033
3034 // Read external controls
3035 if (kc_use_external_control || CybermouseActive)
3036 kconfig_read_external_controls();
3037
3038 //----------- Clamp values between -FrameTime and FrameTime
3039 if (FrameTime > F1_0 )
3040 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
3041
3042 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
3043 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
3044 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
3045 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
3046 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
3047 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
3048 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
3049
3050 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
3051 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
3052 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
3053 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
3054 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
3055 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
3056 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
3057
3058
3059 //--------- Don't do anything if in debug mode
3060 #ifndef RELEASE
3061 if ( keyd_pressed[KEY_DELETE] ) {
3062 memset( &Controls, 0, sizeof(control_info) );
3063 }
3064 #endif
3065 }
3066 #else
3067
3068
3069 fix Next_toggle_time[3]={0,0,0};
3070
3071 int allowed_to_toggle(int i)
3072 {
3073 //used for keeping tabs of when its ok to toggle headlight,primary,and secondary
3074
3075 if (Next_toggle_time[i] > GameTime)
3076 if (Next_toggle_time[i] < GameTime + (F1_0/8)) // In case time is bogus, never wait > 1 second.
3077 return 0;
3078
3079 Next_toggle_time[i] = GameTime + (F1_0/8);
3080
3081 return 1;
3082 }
3083
3084
3085 //added on 2/7/99 by Victor Rachels for jostick state setting
3086 int d2x_joystick_ostate[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
3087 //end this section adition - VR
3088
3089
3090 void controls_read_all()
3091 {
3092 int i;
3093 int slide_on, bank_on;
3094 int dx, dy;
3095 #ifdef SDL_INPUT
3096 int dz;
3097 #endif
3098 int idx, idy;
3099 fix ctime;
3100 fix mouse_axis[3] = {0,0,0};
3101 #ifdef __unix__
3102 int raw_joy_axis[MAX_AXES];
3103 #else
3104 int raw_joy_axis[JOY_NUM_AXES];
3105 #endif
3106 int mouse_buttons;
3107 fix k0, k1, k2, k3, kp;
3108 fix k4, k5, k6, k7, kh;
3109 ubyte channel_masks;
3110 int use_mouse, use_joystick;
3111 int speed_factor=1;
3112
3113 mouse_buttons=0;
3114 use_mouse=0;
3115
3116 if (Game_turbo_mode)
3117 speed_factor = 2;
3118
3119 {
3120 fix temp = Controls.heading_time;
3121 fix temp1 = Controls.pitch_time;
3122 memset( &Controls, 0, sizeof(control_info) );
3123 Controls.heading_time = temp;
3124 Controls.pitch_time = temp1;
3125 }
3126 slide_on = 0;
3127 bank_on = 0;
3128
3129 ctime = timer_get_fixed_seconds();
3130
3131 //--------- Read Joystick -----------
3132 #ifndef MACINTOSH
3133 if ( (LastReadTime + JOYSTICK_READ_TIME > ctime) && (Config_control_type!=CONTROL_THRUSTMASTER_FCS) ) {
3134 if ((ctime < 0) && (LastReadTime > 0))
3135 LastReadTime = ctime;
3136 use_joystick=1;
3137 } else if ((Config_control_type>0) && (Config_control_type<5) ) {
3138 LastReadTime = ctime;
3139 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
3140
3141 for (i=0; i<6; i++ ) {
3142 #ifndef SDL_INPUT
3143 if (channel_masks&(1<<i)) {
3144 #endif
3145 int joy_null_value = 10;
3146
3147 if ( (i==3) && (Config_control_type==CONTROL_THRUSTMASTER_FCS) ) {
3148 kconfig_read_fcs( raw_joy_axis[i] );
3149 } else {
3150 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
3151
3152 if (kc_joystick[23].value==i) // If this is the throttle
3153 joy_null_value = 20; // Then use a larger dead-zone
3154
3155 if (raw_joy_axis[i] > joy_null_value)
3156 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
3157 else if (raw_joy_axis[i] < -joy_null_value)
3158 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
3159 else
3160 raw_joy_axis[i] = 0;
3161 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
3162 }
3163 #ifndef SDL_INPUT
3164 } else {
3165 joy_axis[i] = 0;
3166 }
3167 #endif
3168 }
3169 use_joystick=1;
3170 } else {
3171 for (i=0; i<4; i++ )
3172 joy_axis[i] = 0;
3173 use_joystick=0;
3174 }
3175 #else // MACINTOSH
3176 //--------- Read Joystick -----------
3177 if ((Config_control_type>0) && (Config_control_type<5) ) {
3178 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
3179 for (i=0; i<4; i++ ) {
3180 if (channel_masks&(1<<i)) {
3181 int joy_null_value = 10;
3182
3183 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
3184
3185 if (kc_joystick[23].value==i) // If this is the throttle
3186 joy_null_value = 20; // Then use a larger dead-zone
3187
3188 if (raw_joy_axis[i] > joy_null_value)
3189 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
3190 else if (raw_joy_axis[i] < -joy_null_value)
3191 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
3192 else
3193 raw_joy_axis[i] = 0;
3194 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
3195 } else {
3196 joy_axis[i] = 0;
3197 }
3198 }
3199 use_joystick=1;
3200 } else {
3201 for (i=0; i<4; i++ )
3202 joy_axis[i] = 0;
3203 use_joystick=0;
3204 }
3205 #endif // ifndef MACINTOSH
3206
3207 if (Config_control_type==5 && !CybermouseActive) {
3208 //--------- Read Mouse -----------
3209 #ifdef SDL_INPUT
3210 mouse_get_delta_z( &dx, &dy, &dz );
3211 #else
3212 mouse_get_delta( &dx, &dy );
3213 #endif
3214 mouse_axis[0] = (dx*FrameTime)/35;
3215 mouse_axis[1] = (dy*FrameTime)/25;
3216 #ifdef SDL_INPUT
3217 mouse_axis[2] = (dz*FrameTime);
3218 #endif
3219 mouse_buttons = mouse_get_btns();
3220 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
3221 use_mouse=1;
3222 } else if (Config_control_type==6 && !CybermouseActive) {
3223 //--------- Read Cyberman -----------
3224 mouse_get_cyberman_pos(&idx,&idy );
3225 mouse_axis[0] = (idx*FrameTime)/128;
3226 mouse_axis[1] = (idy*FrameTime)/128;
3227 mouse_buttons = mouse_get_btns();
3228 use_mouse=1;
3229 } else if (CybermouseActive) {
3230 // ReadOWL (kc_external_control);
3231 // CybermouseAdjust();
3232 } else {
3233 mouse_axis[0] = 0;
3234 mouse_axis[1] = 0;
3235 mouse_buttons = 0;
3236 use_mouse=0;
3237 }
3238
3239 //added on 2/4/99 by Victor Rachels for d1x keys
3240 //--------- Read primary weapon select -------------
3241 //the following "if" added by WraithX to stop deadies from switchin weapons, 4/14/00
3242 if (!Player_is_dead)
3243 {
3244 {
3245 int d2x_joystick_state[10];
3246
3247 for(i=0;i<10;i++)
3248 d2x_joystick_state[i] = joy_get_button_state(kc_d2x[i*2+1].value);
3249
3250
3251 //----------------Weapon 1----------------
3252 if(key_down_count(kc_d2x[0].value) ||
3253 (joy_get_button_state(kc_d2x[1].value) &&
3254 (d2x_joystick_state[0]!=d2x_joystick_ostate[0]) ) )
3255 {
3256 //int i, valu=0;
3257 do_weapon_select(0,0);
3258 /*
3259 for(i=MAX_PRIMARY_WEAPONS;i<MAX_PRIMARY_WEAPONS+NEWPRIMS;i++)
3260 if(primary_order[i]>primary_order[valu]&&player_has_weapon(i,0))
3261 valu = i;
3262 LaserPowSelected = valu;
3263 */
3264 }
3265 //----------------Weapon 2----------------
3266 if(key_down_count(kc_d2x[2].value) ||
3267 (joy_get_button_state(kc_d2x[3].value) &&
3268 (d2x_joystick_state[1]!=d2x_joystick_ostate[1]) ) )
3269 do_weapon_select(1,0);
3270 //----------------Weapon 3----------------
3271 if(key_down_count(kc_d2x[4].value) ||
3272 (joy_get_button_state(kc_d2x[5].value) &&
3273 (d2x_joystick_state[2]!=d2x_joystick_ostate[2]) ) )
3274 do_weapon_select(2,0);
3275 //----------------Weapon 4----------------
3276 if(key_down_count(kc_d2x[6].value) ||
3277 (joy_get_button_state(kc_d2x[7].value) &&
3278 (d2x_joystick_state[3]!=d2x_joystick_ostate[3]) ) )
3279 do_weapon_select(3,0);
3280 //----------------Weapon 5----------------
3281 if(key_down_count(kc_d2x[8].value) ||
3282 (joy_get_button_state(kc_d2x[9].value) &&
3283 (d2x_joystick_state[4]!=d2x_joystick_ostate[4]) ) )
3284 do_weapon_select(4,0);
3285
3286 //--------- Read secondary weapon select ----------
3287 //----------------Weapon 6----------------
3288 if(key_down_count(kc_d2x[10].value) ||
3289 (joy_get_button_state(kc_d2x[11].value) &&
3290 (d2x_joystick_state[5]!=d2x_joystick_ostate[5]) ) )
3291 do_weapon_select(0,1);
3292 //----------------Weapon 7----------------
3293 if(key_down_count(kc_d2x[12].value) ||
3294 (joy_get_button_state(kc_d2x[13].value) &&
3295 (d2x_joystick_state[6]!=d2x_joystick_ostate[6]) ) )
3296 do_weapon_select(1,1);
3297 //----------------Weapon 8----------------
3298 if(key_down_count(kc_d2x[14].value) ||
3299 (joy_get_button_state(kc_d2x[15].value) &&
3300 (d2x_joystick_state[7]!=d2x_joystick_ostate[7]) ) )
3301 do_weapon_select(2,1);
3302 //----------------Weapon 9----------------
3303 if(key_down_count(kc_d2x[16].value) ||
3304 (joy_get_button_state(kc_d2x[17].value) &&
3305 (d2x_joystick_state[8]!=d2x_joystick_ostate[8]) ) )
3306 do_weapon_select(3,1);
3307 //----------------Weapon 0----------------
3308 if(key_down_count(kc_d2x[18].value) ||
3309 (joy_get_button_state(kc_d2x[19].value) &&
3310 (d2x_joystick_state[9]!=d2x_joystick_ostate[9]) ) )
3311 do_weapon_select(4,1);
3312 memcpy(d2x_joystick_ostate,d2x_joystick_state,10*sizeof(int));
3313 }
3314 //end this section addition - VR
3315
3316
3317 }//end "if (!Player_is_dead)" - WraithX
3318
3319
3320 //------------- Read slide_on -------------
3321
3322 // From keyboard...
3323 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
3324 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
3325 // From joystick...
3326 if ((use_joystick)&&(kc_joystick[5].value<255)) slide_on |= joy_get_button_state( kc_joystick[5].value );
3327 // From mouse...
3328 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
3329
3330 //------------- Read bank_on ---------------
3331
3332 // From keyboard...
3333 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
3334 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
3335 // From joystick...
3336 if ( (use_joystick)&&(kc_joystick[10].value < 255 )) bank_on |= joy_get_button_state( kc_joystick[10].value );
3337 // From mouse...
3338 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
3339
3340 //------------ Read pitch_time -----------
3341 if ( !slide_on ) {
3342 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
3343 kp = 0;
3344 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
3345 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
3346 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
3347 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
3348
3349 // From keyboard...
3350 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
3351 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
3352 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
3353 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
3354
3355 // From Cyberman...
3356 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3357 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
3358 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
3359 }
3360
3361 if (kp == 0)
3362 Controls.pitch_time = 0;
3363 else if (kp > 0) {
3364 if (Controls.pitch_time < 0)
3365 Controls.pitch_time = 0;
3366 } else // kp < 0
3367 if (Controls.pitch_time > 0)
3368 Controls.pitch_time = 0;
3369 Controls.pitch_time += kp;
3370
3371 // From joystick...
3372 if ( (use_joystick)&&(kc_joystick[13].value < 255 )) {
3373 if ( !kc_joystick[14].value ) // If not inverted...
3374 Controls.pitch_time -= (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
3375 else
3376 Controls.pitch_time += (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
3377 }
3378
3379 // From mouse...
3380 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
3381 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
3382 if ( !kc_mouse[14].value ) // If not inverted...
3383 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
3384 else
3385 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
3386 }
3387 } else {
3388 Controls.pitch_time = 0;
3389 }
3390
3391
3392 //----------- Read vertical_thrust_time -----------------
3393
3394 if ( slide_on ) {
3395 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
3396 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
3397 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
3398 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
3399
3400 // From keyboard...
3401 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
3402 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
3403 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
3404 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
3405
3406 // From Cyberman...
3407 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3408 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
3409 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
3410 }
3411
3412 // From joystick...
3413 if ((use_joystick)&&( kc_joystick[13].value < 255 )) {
3414 if ( !kc_joystick[14].value ) // If not inverted...
3415 Controls.vertical_thrust_time += joy_axis[kc_joystick[13].value];
3416 else
3417 Controls.vertical_thrust_time -= joy_axis[kc_joystick[13].value];
3418 }
3419
3420 // From mouse...
3421 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
3422 if ( !kc_mouse[14].value ) // If not inverted...
3423 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
3424 else
3425 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
3426 }
3427 }
3428
3429 // From keyboard...
3430 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
3431 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
3432 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
3433 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
3434
3435 // From joystick...
3436 if ((use_joystick)&&( kc_joystick[19].value < 255 )) {
3437 if ( !kc_joystick[20].value ) // If not inverted...
3438 Controls.vertical_thrust_time += joy_axis[kc_joystick[19].value];
3439 else
3440 Controls.vertical_thrust_time -= joy_axis[kc_joystick[19].value];
3441 }
3442
3443 // From joystick buttons
3444 if ( (use_joystick)&&(kc_joystick[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_joystick[8].value );
3445 if ( (use_joystick)&&(kc_joystick[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_joystick[9].value );
3446
3447 // From mouse buttons
3448 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
3449 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
3450
3451 // From mouse...
3452 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
3453 if ( !kc_mouse[20].value ) // If not inverted...
3454 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
3455 else
3456 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
3457 }
3458
3459 // From Cyberman...
3460 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3461 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
3462 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
3463 }
3464
3465 //---------- Read heading_time -----------
3466
3467 if (!slide_on && !bank_on) {
3468 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
3469 kh = 0;
3470 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
3471 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
3472 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
3473 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
3474
3475 // From keyboard...
3476 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
3477 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
3478 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
3479 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
3480
3481 // From Cyberman...
3482 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3483 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
3484 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
3485 }
3486
3487 if (kh == 0)
3488 Controls.heading_time = 0;
3489 else if (kh > 0) {
3490 if (Controls.heading_time < 0)
3491 Controls.heading_time = 0;
3492 } else // kh < 0
3493 if (Controls.heading_time > 0)
3494 Controls.heading_time = 0;
3495 Controls.heading_time += kh;
3496
3497 // From joystick...
3498 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
3499 if ( !kc_joystick[16].value ) // If not inverted...
3500 Controls.heading_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3501 else
3502 Controls.heading_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3503 }
3504
3505 // From mouse...
3506 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3507 if ( !kc_mouse[16].value ) // If not inverted...
3508 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3509 else
3510 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3511 }
3512 } else {
3513 Controls.heading_time = 0;
3514 }
3515
3516 //----------- Read sideways_thrust_time -----------------
3517
3518 if ( slide_on ) {
3519 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3520 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3521 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3522 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3523
3524 // From keyboard...
3525 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
3526 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
3527 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
3528 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
3529
3530 // From joystick...
3531 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
3532 if ( !kc_joystick[16].value ) // If not inverted...
3533 Controls.sideways_thrust_time += joy_axis[kc_joystick[15].value];
3534 else
3535 Controls.sideways_thrust_time -= joy_axis[kc_joystick[15].value];
3536 }
3537
3538 // From cyberman
3539 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3540 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
3541 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
3542 }
3543
3544 // From mouse...
3545 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3546 if ( !kc_mouse[16].value ) // If not inverted...
3547 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
3548 else
3549 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
3550 }
3551 }
3552
3553 // From keyboard...
3554 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
3555 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
3556 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
3557 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
3558
3559 // From joystick...
3560 if ( (use_joystick)&&(kc_joystick[17].value < 255 )) {
3561 if ( !kc_joystick[18].value ) // If not inverted...
3562 Controls.sideways_thrust_time -= joy_axis[kc_joystick[17].value];
3563 else
3564 Controls.sideways_thrust_time += joy_axis[kc_joystick[17].value];
3565 }
3566
3567 // From joystick buttons
3568 if ( (use_joystick)&&(kc_joystick[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_joystick[6].value );
3569 if ( (use_joystick)&&(kc_joystick[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_joystick[7].value );
3570
3571 // From mouse buttons
3572 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
3573 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
3574
3575 // From mouse...
3576 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
3577 if ( !kc_mouse[18].value ) // If not inverted...
3578 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
3579 else
3580 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
3581 }
3582
3583 //----------- Read bank_time -----------------
3584
3585 if ( bank_on ) {
3586 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3587 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3588 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3589 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3590
3591 // From keyboard...
3592 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
3593 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
3594 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
3595 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
3596
3597 // From Cyberman...
3598 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3599 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
3600 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
3601 }
3602
3603 // From joystick...
3604 if ( (use_joystick)&&(kc_joystick[15].value < 255) ) {
3605 if ( !kc_joystick[16].value ) // If not inverted...
3606 Controls.bank_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3607 else
3608 Controls.bank_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3609 }
3610
3611 // From mouse...
3612 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3613 if ( !kc_mouse[16].value ) // If not inverted...
3614 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3615 else
3616 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3617 }
3618 }
3619
3620 // From keyboard...
3621 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
3622 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
3623 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
3624 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
3625
3626 // From joystick...
3627 if ( (use_joystick)&&(kc_joystick[21].value < 255) ) {
3628 if ( !kc_joystick[22].value ) // If not inverted...
3629 Controls.bank_time -= joy_axis[kc_joystick[21].value];
3630 else
3631 Controls.bank_time += joy_axis[kc_joystick[21].value];
3632 }
3633
3634 // From joystick buttons
3635 if ( (use_joystick)&&(kc_joystick[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_joystick[11].value );
3636 if ( (use_joystick)&&(kc_joystick[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_joystick[12].value );
3637
3638 // From mouse buttons
3639 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
3640 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
3641
3642 // From mouse...
3643 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
3644 if ( !kc_mouse[22].value ) // If not inverted...
3645 Controls.bank_time += mouse_axis[kc_mouse[21].value];
3646 else
3647 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
3648 }
3649
3650 // From Cyberman
3651 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3652 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
3653 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
3654 }
3655
3656 //----------- Read forward_thrust_time -------------
3657
3658 // From keyboard...
3659 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
3660 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
3661 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
3662 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
3663
3664 // From joystick...
3665 if ( (use_joystick)&&(kc_joystick[23].value < 255 )) {
3666 if ( !kc_joystick[24].value ) // If not inverted...
3667 Controls.forward_thrust_time -= joy_axis[kc_joystick[23].value];
3668 else
3669 Controls.forward_thrust_time += joy_axis[kc_joystick[23].value];
3670 }
3671
3672 // From joystick buttons
3673 if ( (use_joystick)&&(kc_joystick[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_joystick[2].value );
3674 if ( (use_joystick)&&(kc_joystick[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_joystick[3].value );
3675
3676 // From mouse...
3677 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
3678 if ( !kc_mouse[24].value ) // If not inverted...
3679 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
3680 else
3681 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
3682 }
3683
3684 // From mouse buttons
3685 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
3686 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
3687
3688 //----------- Read afterburner_state -------------
3689
3690 // From keyboard...
3691 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
3692 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
3693
3694 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
3695
3696 if ( (use_joystick)&&(kc_joystick[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_joystick[27].value);
3697
3698 //-------Read headlight key--------------------------
3699
3700 if (kc_keyboard[52].value < 255 )
3701 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
3702 if (kc_keyboard[53].value < 255 )
3703 Controls.headlight_count+=key_down_count(kc_keyboard[53].value);
3704 if ((use_joystick)&&(kc_joystick[30].value < 255 ))
3705 Controls.headlight_count+=joy_get_button_down_cnt(kc_joystick[30].value);
3706
3707 //--------Read Cycle Primary Key------------------
3708
3709 if (kc_keyboard[48].value<255)
3710 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
3711 if (kc_keyboard[49].value<255)
3712 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
3713 if ((use_joystick)&&(kc_joystick[28].value < 255 ))
3714 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_joystick[28].value);
3715
3716
3717 //--------Read Cycle Secondary Key------------------
3718
3719 if (kc_keyboard[50].value<255)
3720 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
3721 if (kc_keyboard[51].value<255)
3722 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
3723 if ((use_joystick)&&(kc_joystick[29].value < 255 ))
3724 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_joystick[29].value);
3725
3726 //--------Read Toggle Bomb key----------------------
3727
3728 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
3729 {
3730 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
3731
3732 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
3733 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
3734 {
3735 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3736 HUD_init_message ("No bombs available!");
3737 }
3738 else
3739 {
3740 if (Players[Player_num].secondary_ammo[bomb]==0)
3741 {
3742 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3743 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
3744 }
3745 else
3746 {
3747 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
3748 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
3749 }
3750 }
3751 }
3752
3753 //---------Read Energy->Shield key----------
3754
3755 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
3756 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
3757 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
3758 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
3759
3760 //----------- Read fire_primary_down_count
3761 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
3762 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
3763 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_joystick[0].value);
3764 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
3765
3766 //----------- Read fire_primary_state
3767 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
3768 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
3769 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_joystick[0].value);
3770 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
3771
3772 //----------- Read fire_secondary_down_count
3773 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
3774 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
3775 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_joystick[1].value);
3776 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
3777
3778 //----------- Read fire_secondary_state
3779 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
3780 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
3781 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_joystick[1].value);
3782 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
3783
3784 //----------- Read fire_flare_down_count
3785 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
3786 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
3787 if ((use_joystick)&&(kc_joystick[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_joystick[4].value);
3788 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
3789
3790 //----------- Read drop_bomb_down_count
3791 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
3792 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
3793 if ((use_joystick)&&(kc_joystick[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_joystick[26].value);
3794 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
3795
3796 //----------- Read rear_view_down_count
3797 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
3798 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
3799 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_joystick[25].value);
3800 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
3801
3802 //----------- Read rear_view_down_state
3803 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
3804 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
3805 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_joystick[25].value);
3806 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
3807
3808 //----------- Read automap_down_count
3809 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
3810 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
3811
3812 //----------- Read automap_state
3813 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
3814 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
3815
3816 //----------- Read stupid-cruise-control-type of throttle.
3817 {
3818 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
3819 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
3820 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
3821 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
3822 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
3823 Cruise_speed = 0;
3824 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
3825 Cruise_speed = 0;
3826
3827 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
3828 if (Cruise_speed < 0 ) Cruise_speed = 0;
3829
3830 if (Controls.forward_thrust_time==0)
3831 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
3832 }
3833
3834 #if !defined(MACINTOSH)
3835 //read_head_tracker();
3836
3837 // Read external controls
3838 // if (kc_use_external_control || CybermouseActive)
3839 // kconfig_read_external_controls();
3840 #endif
3841
3842 //----------- Clamp values between -FrameTime and FrameTime
3843 if (FrameTime > F1_0 )
3844 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
3845
3846 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
3847 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
3848 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
3849 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
3850 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
3851 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
3852 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
3853
3854 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
3855 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
3856 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
3857 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
3858 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
3859 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
3860 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
3861
3862
3863 //--------- Don't do anything if in debug mode
3864 #ifndef RELEASE
3865 if ( keyd_pressed[KEY_DELETE] ) {
3866 memset( &Controls, 0, sizeof(control_info) );
3867 }
3868 #endif
3869 }
3870 #endif
3871
3872 void reset_cruise(void)
3873 {
3874 Cruise_speed=0;
3875 }
3876
3877
3878 void kc_set_controls()
3879 {
3880 int i;
3881
3882 for (i=0; i<NUM_KEY_CONTROLS; i++ )
3883 kc_keyboard[i].value = kconfig_settings[0][i];
3884
3885 if ( (Config_control_type>0) && (Config_control_type<5)) {
3886 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3887 kc_joystick[i].value = kconfig_settings[Config_control_type][i];
3888 if (kc_joystick[i].type == BT_INVERT ) {
3889 if (kc_joystick[i].value!=1)
3890 kc_joystick[i].value = 0;
3891 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
3892 }
3893 }
3894 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
3895 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3896 kc_mouse[i].value = kconfig_settings[Config_control_type][i];
3897 if (kc_mouse[i].type == BT_INVERT ) {
3898 if (kc_mouse[i].value!=1)
3899 kc_mouse[i].value = 0;
3900 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
3901 }
3902 }
3903 } else if (Config_control_type == CONTROL_WINJOYSTICK) {
3904 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3905 kc_superjoy[i].value = kconfig_settings[Config_control_type][i];
3906 if (kc_superjoy[i].type == BT_INVERT ) {
3907 if (kc_superjoy[i].value!=1)
3908 kc_superjoy[i].value = 0;
3909 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
3910 }
3911 }
3912 }
3913
3914 for (i=0; i<NUM_D2X_CONTROLS; i++ )
3915 kc_d2x[i].value = kconfig_d2x_settings[i];
3916 }
3917
3918 #if 0 //ndef MACINTOSH // no mac support for vr headset
3919
3920 void kconfig_center_headset()
3921 {
3922 #ifndef WINDOWS
3923 if (vfx1_installed)
3924 vfx_center_headset();
3925 #endif
3926 // } else if (iglasses_headset_installed) {
3927 // } else if (Victor_headset_installed) {
3928 // } else {
3929 // }
3930
3931 }
3932
3933 #endif // end of #ifndef MACINTOSH for kconfig_center_headset
3934
3935 void CybermouseAdjust ()
3936 {
3937 /* if ( Player_num > -1 ) {
3938 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3939 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3940 Auto_leveling_on = 0;
3941
3942 if ( kc_external_version > 0 ) {
3943 vms_matrix tempm, ViewMatrix;
3944 vms_angvec * Kconfig_abs_movement;
3945 char * oem_message;
3946
3947 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
3948
3949 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3950 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3951 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3952 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3953 }
3954 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3955 if (oem_message[0] != '\0' )
3956 HUD_init_message( oem_message );
3957 }
3958 }*/
3959
3960 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3961 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3962 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3963 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3964 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3965 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3966 // Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3967 // Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3968 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3969 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3970 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3971 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3972 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3973 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3974 // Controls.automap_down_count += kc_external_control->automap_down_count;
3975 // Controls.automap_state |= kc_external_control->automap_state;
3976 }
3977
3978 char GetKeyValue (char key)
3979 {
3980 mprintf ((0,"Returning %c!\n",kc_keyboard[(int)key].value));
3981 return (kc_keyboard[(int)key].value);
3982 }
3983
3984 #if !defined(MACINTOSH)
3985
3986
3987 extern object *obj_find_first_of_type (int);
3988 void kconfig_read_external_controls()
3989 {
3990 //union REGS r;
3991 int i;
3992
3993 if ( !kc_enable_external_control ) return;
3994
3995 if ( kc_external_version == 0 )
3996 memset( kc_external_control, 0, sizeof(ext_control_info));
3997 else if ( kc_external_version > 0 ) {
3998
3999 if (kc_external_version>=4)
4000 memset( kc_external_control, 0, sizeof(advanced_ext_control_info));
4001 else if (kc_external_version>0)
4002 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 );
4003 else if (kc_external_version>2)
4004 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof(vms_matrix) +4 );
4005
4006 if ( kc_external_version > 1 ) {
4007 // Write ship pos and angles to external controls...
4008 ubyte *temp_ptr = (ubyte *)kc_external_control;
4009 vms_vector *ship_pos;
4010 vms_matrix *ship_orient;
4011 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
4012 temp_ptr += sizeof(ext_control_info) + sizeof(vms_angvec) + 64;
4013 ship_pos = (vms_vector *)temp_ptr;
4014 temp_ptr += sizeof(vms_vector);
4015 ship_orient = (vms_matrix *)temp_ptr;
4016 // Fill in ship postion...
4017 *ship_pos = Objects[Players[Player_num].objnum].pos;
4018 // Fill in ship orientation...
4019 *ship_orient = Objects[Players[Player_num].objnum].orient;
4020 }
4021 if (kc_external_version>=4)
4022 {
4023 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
4024
4025 temp_ptr->headlight_state=(Players[Player_num].flags & PLAYER_FLAGS_HEADLIGHT_ON);
4026 temp_ptr->primary_weapon_flags=Players[Player_num].primary_weapon_flags;
4027 temp_ptr->secondary_weapon_flags=Players[Player_num].secondary_weapon_flags;
4028 temp_ptr->current_primary_weapon=Primary_weapon;
4029 temp_ptr->current_secondary_weapon=Secondary_weapon;
4030
4031 temp_ptr->current_guidebot_command=Escort_goal_object;
4032
4033 temp_ptr->force_vector=ExtForceVec;
4034 temp_ptr->force_matrix=ExtApplyForceMatrix;
4035 for (i=0;i<3;i++)
4036 temp_ptr->joltinfo[i]=ExtJoltInfo[i];
4037 for (i=0;i<2;i++)
4038 temp_ptr->x_vibrate_info[i]=ExtXVibrateInfo[i];
4039 temp_ptr->x_vibrate_clear=ExtXVibrateClear;
4040 temp_ptr->game_status=ExtGameStatus;
4041
4042 memset ((void *)&ExtForceVec,0,sizeof(vms_vector));
4043 memset ((void *)&ExtApplyForceMatrix,0,sizeof(vms_matrix));
4044
4045 for (i=0;i<3;i++)
4046 ExtJoltInfo[i]=0;
4047 for (i=0;i<2;i++)
4048 ExtXVibrateInfo[i]=0;
4049 ExtXVibrateClear=0;
4050 }
4051 }
4052
4053 if ( Automap_active ) // (If in automap...)
4054 kc_external_control->automap_state = 1;
4055 //memset(&r,0,sizeof(r));
4056
4057 #if 0
4058
4059 int386 ( kc_external_intno, &r, &r); // Read external info...
4060
4061 #endif
4062
4063 if ( Player_num > -1 ) {
4064 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
4065 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
4066 Auto_leveling_on = 0;
4067
4068 if ( kc_external_version > 0 ) {
4069 vms_matrix tempm, ViewMatrix;
4070 vms_angvec * Kconfig_abs_movement;
4071 char * oem_message;
4072
4073 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(ext_control_info));
4074
4075 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
4076 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
4077 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
4078 Objects[Players[Player_num].objnum].orient = ViewMatrix;
4079 }
4080 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
4081 if (oem_message[0] != '\0' )
4082 HUD_init_message( oem_message );
4083 }
4084 }
4085
4086 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
4087 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
4088 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
4089 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
4090 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
4091 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
4092 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
4093 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
4094 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
4095 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
4096 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
4097 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
4098 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
4099 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
4100 Controls.automap_down_count += kc_external_control->automap_down_count;
4101 Controls.automap_state |= kc_external_control->automap_state;
4102
4103 if (kc_external_version>=3)
4104 {
4105 ubyte *temp_ptr = (ubyte *)kc_external_control;
4106 temp_ptr += (sizeof(ext_control_info) + sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof (vms_matrix));
4107
4108 if (*(temp_ptr))
4109 Controls.cycle_primary_count=(*(temp_ptr));
4110 if (*(temp_ptr+1))
4111 Controls.cycle_secondary_count=(*(temp_ptr+1));
4112
4113 if (*(temp_ptr+2))
4114 Controls.afterburner_state=(*(temp_ptr+2));
4115 if (*(temp_ptr+3))
4116 Controls.headlight_count=(*(temp_ptr+3));
4117 }
4118 if (kc_external_version>=4)
4119 {
4120 int i;
4121 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
4122
4123 for (i=0;i<128;i++)
4124 if (temp_ptr->keyboard[i])
4125 key_putkey (i);
4126
4127 if (temp_ptr->Reactor_blown)
4128 {
4129 if (Game_mode & GM_MULTI)
4130 net_destroy_controlcen (obj_find_first_of_type (OBJ_CNTRLCEN));
4131 else
4132 do_controlcen_destroyed_stuff(obj_find_first_of_type (OBJ_CNTRLCEN));
4133 }
4134 }
4135
4136 }
4137 #endif
4138
4139