1 /* $Id: kconfig.c,v 1.15 2002-09-19 05:43:15 btb Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
21 * Routines to configure keyboard, joystick, etc..
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
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
32 * Revision 1.16 1995/10/24 18:10:22 allender
33 * get mouse stuff working right this time?
35 * Revision 1.15 1995/10/23 14:50:50 allender
36 * corrected values for control type in kc_set_controls
38 * Revision 1.14 1995/10/21 16:36:54 allender
39 * fix up mouse read time
41 * Revision 1.13 1995/10/20 00:46:53 allender
42 * fix up mouse reading problem
44 * Revision 1.12 1995/10/19 13:36:38 allender
45 * mouse support in kconfig screens
47 * Revision 1.11 1995/10/18 21:06:06 allender
48 * removed Int3 in cruise stuff -- was in there for debugging and
51 * Revision 1.10 1995/10/17 13:12:47 allender
52 * fixed config menus so buttons don't get configured
54 * Revision 1.9 1995/10/15 23:07:55 allender
55 * added return key as second button for primary fire
57 * Revision 1.8 1995/09/05 08:49:47 allender
58 * change 'PADRTN' label to 'ENTER'
60 * Revision 1.7 1995/09/01 15:38:22 allender
61 * took out cap of reading controls max 25 times/sec
63 * Revision 1.6 1995/09/01 13:33:59 allender
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
70 * Revision 1.4 1995/07/28 15:43:13 allender
71 * make mousebutton control primary fire
73 * Revision 1.3 1995/07/26 17:04:32 allender
74 * new defaults and make joystick main button work correctly
76 * Revision 1.2 1995/07/17 08:51:03 allender
77 * fixed up configuration menus to look right
79 * Revision 1.1 1995/05/16 15:26:56 allender
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.
86 * Revision 2.10 1995/07/07 16:48:01 john
87 * Fixed bug with new interface.
89 * Revision 2.9 1995/07/03 15:02:32 john
90 * Added new version of external controls for Cybermouse absolute position.
92 * Revision 2.8 1995/06/30 12:30:28 john
93 * Added -Xname command line.
95 * Revision 2.7 1995/03/30 16:36:56 mike
98 * Revision 2.6 1995/03/21 14:39:31 john
99 * Ifdef'd out the NETWORK code.
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.
105 * Revision 2.4 1995/03/10 13:47:24 john
106 * Added head tracking sensitivity.
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.
112 * Revision 2.2 1995/03/08 15:32:39 john
113 * Made VictorMaxx head tracking use Greenleaf code.
115 * Revision 2.1 1995/03/06 15:23:31 john
116 * New screen techniques.
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.
122 * Revision 1.105 1995/02/22 14:11:58 allender
123 * remove anonymous unions from object structure
125 * Revision 1.104 1995/02/13 12:01:56 john
126 * Fixed bug with buggin not mmaking player faster.
128 * Revision 1.103 1995/02/09 22:00:46 john
129 * Added i-glasses tracking.
131 * Revision 1.102 1995/01/24 21:25:47 john
132 * Fixed bug with slide/bank on not working with
135 * Revision 1.101 1995/01/24 16:09:56 john
136 * Fixed bug with Wingman extreme customize text overwriting title.
138 * Revision 1.100 1995/01/24 12:37:46 john
139 * Made Esc exit key define menu.
141 * Revision 1.99 1995/01/23 23:54:43 matt
142 * Made keypad enter work
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.
148 * Revision 1.97 1995/01/12 11:41:33 john
149 * Added external control reading.
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.
155 * Revision 1.95 1994/12/29 11:17:38 john
156 * Took out some warnings and mprintf.
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.
164 * Revision 1.93 1994/12/27 12:16:20 john
165 * Fixed bug with slide on not working with joystick or mouse buttons.
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.
171 * Revision 1.91 1994/12/16 00:11:23 matt
172 * Made delete key act normally when debug out
174 * Revision 1.90 1994/12/14 17:41:15 john
175 * Added more buttons so that Yoke would work.
177 * Revision 1.89 1994/12/13 17:25:35 allender
178 * Added Assert for bogus time for joystick reading.
180 * Revision 1.88 1994/12/13 14:48:01 john
181 * Took out some debugging mprintf's
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.
188 * Revision 1.86 1994/12/13 01:11:32 john
189 * Fixed bug with message clearing overwriting
192 * Revision 1.85 1994/12/12 00:35:58 john
193 * Added or thing for keys.
195 * Revision 1.84 1994/12/09 17:08:06 john
196 * Made mouse a bit less sensitive.
198 * Revision 1.83 1994/12/09 16:04:00 john
199 * Increased mouse sensitivity.
201 * Revision 1.82 1994/12/09 00:41:26 mike
202 * fix hang in automap print screen
204 * Revision 1.81 1994/12/08 11:50:37 john
205 * Made strcpy only copy corect number of chars,.
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.
210 * Revision 1.79 1994/12/07 14:52:28 yuan
213 * Revision 1.78 1994/12/07 13:37:40 john
214 * Made the joystick thrust work in reverse.
216 * Revision 1.77 1994/12/07 11:28:24 matt
217 * Did a little localization support
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.
223 * Revision 1.75 1994/12/03 22:35:25 yuan
226 * Revision 1.74 1994/12/03 15:39:24 john
227 * Made numeric keypad move in conifg.
229 * Revision 1.73 1994/12/01 16:23:39 john
230 * Fixed include mistake.
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.
236 * Revision 1.71 1994/12/01 12:30:49 john
237 * Made Ctrl+D delete, not Ctrl+E
239 * Revision 1.70 1994/12/01 11:52:52 john
240 * Added default values for GamePad.
242 * Revision 1.69 1994/11/30 00:59:12 mike
245 * Revision 1.68 1994/11/29 03:45:50 john
246 * Added joystick sensitivity; Added sound channels to detail menu. Removed -maxchannels
249 * Revision 1.67 1994/11/27 23:13:44 matt
250 * Made changes for new mprintf calling convention
252 * Revision 1.66 1994/11/27 19:52:12 matt
253 * Made screen shots work in a few more places
255 * Revision 1.65 1994/11/22 16:54:50 mike
256 * autorepeat on missiles.
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.
262 * Revision 1.63 1994/11/19 15:14:48 mike
263 * remove unused code and data
265 * Revision 1.62 1994/11/18 23:37:56 john
266 * Changed some shorts to ints.
268 * Revision 1.61 1994/11/17 13:36:35 rob
269 * Added better network hook in kconfig menu.
271 * Revision 1.60 1994/11/14 20:09:13 john
272 * Made Tab be default for automap.
274 * Revision 1.59 1994/11/13 16:34:07 matt
275 * Fixed victormaxx angle conversions
277 * Revision 1.58 1994/11/12 14:47:05 john
278 * Added support for victor head tracking.
280 * Revision 1.57 1994/11/08 15:14:55 john
281 * Added more calls so net doesn't die in net game.
283 * Revision 1.56 1994/11/07 14:01:07 john
284 * Changed the gamma correction sequencing.
286 * Revision 1.55 1994/11/01 16:40:08 john
287 * Added Gamma correction.
289 * Revision 1.54 1994/10/25 23:09:26 john
290 * Made the automap key configurable.
292 * Revision 1.53 1994/10/25 13:11:59 john
293 * Made keys the way Adam speced 'em for final game.
295 * Revision 1.52 1994/10/24 17:44:22 john
296 * Added stereo channel reversing.
298 * Revision 1.51 1994/10/22 13:23:18 john
299 * Made default rear view key be R.
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.
305 * Revision 1.49 1994/10/21 15:20:15 john
306 * Made PrtScr do screen dump, not F2.
308 * Revision 1.48 1994/10/21 13:41:36 john
309 * Allowed F2 to screen dump.
311 * Revision 1.47 1994/10/17 13:07:05 john
312 * Moved the descent.cfg info into the player config file.
314 * Revision 1.46 1994/10/14 15:30:22 john
315 * Added Cyberman default positions.
317 * Revision 1.45 1994/10/14 15:24:54 john
318 * Made Cyberman work with config.
320 * Revision 1.44 1994/10/14 12:46:04 john
321 * Added the ability to reset all to default.
323 * Revision 1.43 1994/10/14 12:18:31 john
324 * Made mouse invert axis always be 0 or 1.
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
332 * Revision 1.41 1994/10/13 21:27:02 john
333 * Made axis invert value always be 0 or 1.
335 * Revision 1.40 1994/10/13 20:18:15 john
336 * Added some more system keys, such as F? and CAPSLOCK.
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.
343 * Revision 1.38 1994/10/13 15:41:57 mike
344 * Remove afterburner.
349 static char rcsid[] = "$Id: kconfig.c,v 1.15 2002-09-19 05:43:15 btb Exp $";
362 #include "pa_enabl.h" //$$POLY_ACC
370 #include "gamefont.h"
382 #include "endlevel.h"
390 #include "lighting.h"
392 #include "cntrlcen.h"
393 #if defined (TACTILE)
397 #if defined(POLY_ACC)
398 #include "poly_acc.h"
405 #include "joystick.h"
408 ubyte ExtGameStatus=1;
410 vms_vector ExtForceVec;
411 vms_matrix ExtApplyForceMatrix;
413 int ExtJoltInfo[3]={0,0,0};
414 int ExtXVibrateInfo[2]={0,0};
415 int ExtYVibrateInfo[2]={0,0};
416 ubyte ExtXVibrateClear=0;
417 ubyte ExtYVibrateClear=0;
419 #define TABLE_CREATION 1
421 // Array used to 'blink' the cursor while waiting for a keypress.
422 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 };
424 //char * invert_text[2] = { "N", "Y" };
425 //char * joybutton_text[28] = { "BTN 1", "BTN 2", "BTN 3", "BTN 4", "", "TRIG", "LEFT", "HAT
\81", "RIGHT", "", "", "HAT
\80", "MID", "", "", "HAT
\7f", "", "", "", "HAT
\82", "TRIG", "LEFT", "RIGHT", "", "UP","DOWN","LEFT", "RIGHT" };
426 //char * joyaxis_text[4] = { "X1", "Y1", "X2", "Y2" };
427 //char * mouseaxis_text[2] = { "L/R", "F/B" };
428 //char * mousebutton_text[3] = { "Left", "Right", "Mid" };
430 int invert_text[2] = { TNUM_N, TNUM_Y };
433 int joybutton_text[28] =
434 { TNUM_BTN_1, TNUM_BTN_2, TNUM_BTN_3, TNUM_BTN_4,
438 TNUM_HAT_L, TNUM_HAT_R, TNUM_HAT_U, TNUM_HAT_D,
442 int joyaxis_text[7] = { TNUM_X1, TNUM_Y1, TNUM_Z1, TNUM_UN, TNUM_P1,TNUM_R1,TNUM_YA1 };
444 int joybutton_text[28] =
445 { TNUM_BTN_1, TNUM_BTN_2, TNUM_BTN_3, TNUM_BTN_4,
446 -1, TNUM_TRIG, TNUM_LEFT, TNUM_HAT_L,
447 TNUM_RIGHT, -1, TNUM_HAT2_D, TNUM_HAT_R,
448 TNUM_MID, -1, TNUM_HAT2_R, TNUM_HAT_U,
449 TNUM_HAT2_L, -1, TNUM_HAT2_U, TNUM_HAT_D,
450 TNUM_TRIG, TNUM_LEFT, TNUM_RIGHT, -1,
451 TNUM_UP, TNUM_DOWN, TNUM_LEFT, TNUM_RIGHT };
453 int joyaxis_text[7] = { TNUM_X1, TNUM_Y1, TNUM_Z1, TNUM_UN, TNUM_P1,TNUM_R1,TNUM_YA1 };
454 // int joyaxis_text[4] = { TNUM_X1, TNUM_Y1, TNUM_X2, TNUM_Y2 };
457 int mouseaxis_text[3] = { TNUM_L_R, TNUM_F_B, TNUM_Z1 };
459 int mousebutton_text[3] = { TNUM_LEFT, TNUM_RIGHT, TNUM_MID };
460 char * mousebutton_textra[13] = { "M4", "M5", "M6", "M7", "M8", "M9", "M10","M11","M12","M13","M14","M15","M16" };//text for buttons above 3. -MPM
462 char *mousebutton_text[3] = { "Btn", "", "" }; // only one silly mouse button on the mac
466 char * key_text[256] = {
467 "","S","D","F","H","G","Z","X","C","V","","B","Q", "W", "E", "R",
468 "Y","T","1","2","3","4","6","5","=","9","7","-", "8", "0", "]", "O",
469 "U","[","I","P","RET","L","J","'","K", ";", "\\", ",", "/", "N", "M", ".",
470 "TAB","SPC","`","DEL","","ESC","","APL","SHIFT","CAPSL","OPTN","CTRL","","","","A",
471 "","PAD.","","PAD*","","PAD+","","NMLCK","","","","PAD/","ENTER","","PAD-","",
472 "","PAD=","PAD0","PAD1","PAD2","PAD3","PAD4","PAD5","PAD6","PAD7","","PAD8","PAD9","","","",
473 "F5","F6","F7","","F8","F9","","F11","","F13","","F14","","F10","","F12",
474 "","PAUSE","HELP","HOME","PGUP","DEL","","END","F2","","F1","LARW","RARW","DARW","UARW","",
475 "","","","","","","","","","","","","","","","",
476 "","","","","","","","","","","","","","","","",
477 "","","","","","","","","","","","","","","","",
478 "","","","","","","","","","","","","","","","",
479 "","","","","","","","","","","","","","","","",
480 "","","","","","","","","","","","","","","","",
481 "","","","","","","","","","","","","","","","",
482 "","","","","","","","","","","","","","","",""};
484 #if !defined OGL && !defined SDL_INPUT
485 char * key_text[256] = { \
486 "","ESC","1","2","3","4","5","6","7","8","9","0","-", \
487 "=","BSPC","TAB","Q","W","E","R","T","Y","U","I","O", \
488 "P","[","]","
\83","LCTRL","A","S","D","F", \
489 "G","H","J","K","L",";","'","`", \
490 "LSHFT","\\","Z","X","C","V","B","N","M",",", \
491 ".","/","RSHFT","PAD*","LALT","SPC", \
492 "CPSLK","F1","F2","F3","F4","F5","F6","F7","F8","F9", \
493 "F10","NMLCK","SCLK","PAD7","PAD8","PAD9","PAD-", \
494 "PAD4","PAD5","PAD6","PAD+","PAD1","PAD2","PAD3","PAD0", \
495 "PAD.","","","","F11","F12","","","","","","","","","", \
496 "","","","","","","","","","","","","","","","","","","","", \
497 "","","","","","","","","","","","","","","","","","","","", \
498 "","","","","","","","","","","","","","","","","","", \
499 "PAD
\83","RCTRL","","","","","","","","","","","","","", \
500 "","","","","","","","","","","PAD/","","","RALT","", \
501 "","","","","","","","","","","","","","HOME","
\82","PGUP", \
502 "","
\81","","
\7f","","END","
\80","PGDN","INS", \
503 "DEL","","","","","","","","","","","","","","","","","", \
504 "","","","","","","","","","","","","","","","","","","","", \
505 "","","","","","","" };
509 ubyte system_keys[] = { KEY_ESC, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, KEY_MINUS, KEY_EQUAL, KEY_PRINT_SCREEN };
511 //extern void GameLoop(int, int );
513 extern void transfer_energy_to_shield(fix);
514 extern void CyclePrimary(),CycleSecondary(),InitMarkerInput();
515 extern ubyte DefiningMarkerMessage;
516 extern char CybermouseActive;
519 extern int joydefsw_do_button();
520 extern int joydefsw_do_winjoybutton(int *axis);
521 extern joydefsw_win_joyselect(char *title);
524 control_info Controls;
528 // macros for drawing lo/hi res kconfig screens (see scores.c as well)
530 #define LHX(x) ((x)*(MenuHires?2:1))
531 #define LHY(y) ((y)*(MenuHires?2.4:1))
535 #define BT_MOUSE_BUTTON 1
536 #define BT_MOUSE_AXIS 2
537 #define BT_JOY_BUTTON 3
538 #define BT_JOY_AXIS 4
541 char *btype_text[] = { "BT_KEY", "BT_MOUSE_BUTTON", "BT_MOUSE_AXIS", "BT_JOY_BUTTON", "BT_JOY_AXIS", "BT_INVERT" };
545 typedef struct kc_item {
546 short id; // The id of this item
554 ubyte value; // what key,button,etc
560 ubyte kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS];
562 //----------- WARNING!!!!!!! -------------------------------------------
563 // THESE NEXT FOUR BLOCKS OF DATA ARE GENERATED BY PRESSING DEL+F12 WHEN
564 // IN THE KEYBOARD CONFIG SCREEN. BASICALLY, THAT PROCEDURE MODIFIES THE
565 // U,D,L,R FIELDS OF THE ARRAYS AND DUMPS THE NEW ARRAYS INTO KCONFIG.COD
566 //-------------------------------------------------------------------------
567 /*ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
568 {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},
569 {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},
570 {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},
571 {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},
572 {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},
573 {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},
574 {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},
578 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
579 {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},
580 {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},
581 {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},
582 {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},
583 {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},
584 {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},
585 {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},
587 {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 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
594 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
595 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
596 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
597 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
598 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
599 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
600 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
601 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
602 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
603 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
604 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
605 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
606 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
607 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
608 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
609 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
610 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
611 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
612 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
613 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
614 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
615 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
616 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
617 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
618 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
619 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
620 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
621 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
622 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
623 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
624 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
625 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
626 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
627 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
628 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
629 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
630 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
631 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
632 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
633 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
634 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
635 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
636 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
637 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
638 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
639 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
640 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
641 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
642 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
643 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
644 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
645 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
646 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
647 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
648 { 54,158,171, 83, 26, 52, 56, 51, 55,"Energy->Shield", BT_KEY, 255 },
649 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
650 { 56,158,179,83, 26, 54, 0, 0, 0, "Toggle Bomb", BT_KEY,255},
652 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
653 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
654 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
655 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
656 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
657 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
658 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
659 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
660 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
661 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
662 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
663 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
664 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
665 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
666 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
667 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
668 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
669 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
670 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
671 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
672 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
673 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
674 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
675 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
676 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
677 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
678 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
679 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
680 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
681 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
682 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
683 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
685 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
686 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
687 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
688 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
689 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
690 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
691 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
692 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
693 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
694 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
695 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
696 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
697 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
698 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
699 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
700 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
701 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
702 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
703 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
704 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
705 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
706 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
707 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
708 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
709 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
710 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
711 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
712 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
713 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
714 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
715 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
716 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
719 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
720 { 0, 25, 46, 85, 26, 12, 1, 24, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
721 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
722 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
723 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
724 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
725 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
726 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
727 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
728 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
729 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
730 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
731 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
732 { 12,180,106, 59, 26, 11, 0, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
733 { 13,103,138, 58, 26, 27, 15, 25, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
734 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
735 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
736 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
737 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
738 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
739 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
740 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
741 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
742 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
743 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
744 { 24,103,182,106, 8, 22, 5, 23, 0,"throttle", BT_INVERT, 255 },
745 { 25, 25,109, 85, 26, 3, 27, 12, 13,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
746 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
747 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
750 #else // ifndef MACINTOSH (following are macintosh controls)
752 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
753 {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},
754 {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},
755 {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},
756 {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},
757 {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},
758 {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},
759 {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},
762 ubyte default_firebird_settings[MAX_CONTROLS] =
763 {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};
765 ubyte default_mousestick_settings[MAX_CONTROLS] =
766 {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};
768 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
769 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
770 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
771 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
772 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
773 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
774 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
775 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
776 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
777 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
778 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
779 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
780 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
781 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
782 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
783 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
784 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
785 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
786 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
787 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
788 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
789 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
790 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
791 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
792 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
793 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
794 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
795 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
796 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
797 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
798 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
799 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
800 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
801 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
802 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
803 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
804 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
805 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
806 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
807 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
808 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
809 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
810 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
811 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
812 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
813 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
814 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
815 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
816 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
817 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
818 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
819 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
820 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
821 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
822 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
823 { 54,158,171, 83, 26, 52, 25, 51, 55,"Energy->Shield", BT_KEY, 255 },
824 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
826 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
827 { 0, 25, 46, 85, 28, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
828 { 1, 25, 54, 85, 28, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
829 { 2, 25, 85, 85, 28, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
830 { 3, 25, 93, 85, 28, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
831 { 4, 25, 62, 85, 28, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
832 { 5,180, 46, 79, 28, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
833 { 6,180, 54, 79, 28, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
834 { 7,180, 62, 79, 28, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
835 { 8,180, 70, 79, 28, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
836 { 9,180, 78, 79, 28, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
837 { 10,180, 90, 79, 28, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
838 { 11,180, 98, 79, 28, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
839 { 12,180,106, 79, 28, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
840 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
841 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
842 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
843 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
844 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
845 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
846 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
847 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
848 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
849 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
850 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
851 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
852 { 25, 25,109, 85, 28, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
853 { 26, 25, 70, 85, 28, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
854 { 27, 25,117, 85, 28, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
855 { 28,180,114, 79, 28, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
856 { 29,180,122, 79, 28, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
857 { 30, 25,125, 85, 28, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
859 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
860 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
861 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
862 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
863 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
864 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
865 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
866 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
867 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
868 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
869 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
870 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
871 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
872 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
873 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
874 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
875 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
876 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
877 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
878 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
879 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
880 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
881 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
882 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
883 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
884 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
885 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
886 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
887 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
888 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
889 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
890 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
893 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
894 { 0, 25, 46, 85, 26, 28, 1, 28, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
895 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
896 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
897 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
898 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
899 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
900 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
901 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
902 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
903 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
904 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
905 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
906 { 12,180,106, 59, 26, 11, 28, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
907 { 13,103,138, 58, 26, 27, 15, 27, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
908 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
909 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
910 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
911 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
912 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
913 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
914 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
915 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
916 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
917 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
918 { 24,103,182,106, 8, 22, 5, 23, 28,"throttle", BT_INVERT, 255 },
919 { 25, 25,109, 85, 26, 3, 27, 12, 27,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
920 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
921 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
926 void kc_drawitem( kc_item *item, int is_current );
927 void kc_change_key( kc_item * item );
928 void kc_change_joybutton( kc_item * item );
929 void kc_change_mousebutton( kc_item * item );
930 void kc_change_joyaxis( kc_item * item );
931 void kc_change_mouseaxis( kc_item * item );
932 void kc_change_invert( kc_item * item );
933 void kconfig_read_fcs( int raw_axis );
934 void kconfig_set_fcs_button( int btn, int button );
935 void kconfig_read_external_controls( void );
937 int kconfig_is_axes_used(int axis)
940 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
941 if (( kc_joystick[i].type == BT_JOY_AXIS ) && (kc_joystick[i].value == axis ))
947 #ifdef TABLE_CREATION
948 int find_item_at( kc_item * items, int nitems, int x, int y )
952 for (i=0; i<nitems; i++ ) {
953 if ( ((items[i].x+items[i].w1)==x) && (items[i].y==y))
959 int find_next_item_up( kc_item * items, int nitems, int citem )
964 x = items[citem].x+items[citem].w1;
969 y = grd_curcanv->cv_bitmap.bm_h-1;
972 x = grd_curcanv->cv_bitmap.bm_w-1;
975 i = find_item_at( items, nitems, x, y );
981 int find_next_item_down( kc_item * items, int nitems, int citem )
986 x = items[citem].x+items[citem].w1;
990 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
993 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
997 i = find_item_at( items, nitems, x, y );
1003 int find_next_item_right( kc_item * items, int nitems, int citem )
1008 x = items[citem].x+items[citem].w1;
1012 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
1015 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
1019 i = find_item_at( items, nitems, x, y );
1025 int find_next_item_left( kc_item * items, int nitems, int citem )
1030 x = items[citem].x+items[citem].w1;
1035 x = grd_curcanv->cv_bitmap.bm_w-1;
1038 y = grd_curcanv->cv_bitmap.bm_h-1;
1041 i = find_item_at( items, nitems, x, y );
1048 #if defined(MACINTOSH) || defined(WINDOWS)
1049 int get_item_height(kc_item *item)
1054 if (item->value==255) {
1055 sprintf( btext, "" );
1057 switch( item->type ) {
1059 strncpy( btext, key_text[item->value], 10 ); break;
1060 case BT_MOUSE_BUTTON:
1062 strncpy( btext, Text_string[mousebutton_text[item->value]], 10); break;
1064 strncpy( btext, mousebutton_text[item->value], 10 ); break;
1067 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
1069 if ( joybutton_text[item->value] !=-1 )
1070 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1072 sprintf( btext, "BTN%d", item->value );
1075 strncpy( btext, Text_string[joyaxis_text[item->value]], 10 ); break;
1077 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
1080 gr_get_string_size(btext, &w, &h, &aw );
1086 void kconfig_sub(kc_item * items,int nitems, char * title)
1089 dd_grs_canvas * save_canvas,
1090 grs_canvas * save_canvas
1092 grs_font * save_font;
1093 int old_keyd_repeat;
1094 #if defined(MACINTOSH) || defined(WINDOWS)
1095 int mouse_state, omouse_state, mx, my, x1, x2, y1, y2;
1096 int close_x, close_y, close_size;
1099 int i,k,ocitem,citem;
1100 int time_stopped = 0;
1101 WIN(char *old_bg_pcx);
1103 WIN(old_bg_pcx = _SCRContext.bkg_filename);
1104 WIN(DEFINE_SCREEN(NULL));
1109 if (!((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence)) )
1115 // if (Config_control_type == CONTROL_WINJOYSTICK) {
1117 // joydefsw_win_joyselect(title2); title = title2,
1119 // ); // Get Samir...
1123 save_canvas = dd_grd_curcanv,
1124 save_canvas = grd_curcanv
1129 dd_gr_set_current_canvas(NULL),
1130 gr_set_current_canvas(NULL)
1132 save_font = grd_curcanv->cv_font;
1137 game_flush_inputs();
1138 old_keyd_repeat = keyd_repeat;
1141 //gr_clear_canvas( BM_XRGB(0,0,0) );
1143 nm_draw_background(0,0,grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
1144 gr_palette_load (gr_palette);
1146 grd_curcanv->cv_font = MEDIUM3_FONT;
1148 WIN(DDGRLOCK(dd_grd_curcanv));
1151 p = strchr( title, '\n' );
1153 gr_string( 0x8000, LHY(8), title );
1158 // if ( items == kc_keyboard ) {
1159 // gr_string( 0x8000, 8, "Keyboard" );
1160 // } else if ( items == kc_joystick ) {
1161 // gr_string( 0x8000, 8, "Joysticks" );
1162 // } else if ( items == kc_mouse ) {
1163 // gr_string( 0x8000, 8, "Mouse" );
1166 #if defined(MACINTOSH) || defined(WINDOWS)
1167 close_x = close_y = 15;
1169 gr_setcolor( BM_XRGB(0, 0, 0) );
1170 gr_rect(close_x, close_y, close_x + close_size, close_y + close_size);
1171 gr_setcolor( BM_XRGB(21, 21, 21) );
1172 gr_rect( close_x + 2, close_y + 2, close_x + close_size - 2, close_y + close_size -2 );
1175 grd_curcanv->cv_font = GAME_FONT;
1176 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1179 gr_string( 0x8000, LHY(20), TXT_KCONFIG_STRING_1 );
1181 gr_string( 0x8000, LHY(20), "Enter changes, ctrl-d deletes, ctrl-r resets defaults, ESC exits");
1183 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1184 if ( items == kc_keyboard ) {
1185 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
1186 gr_setcolor( BM_XRGB(31,27,6) );
1188 gr_scanline( LHX(98), LHX(106), LHY(42) );
1189 gr_scanline( LHX(120), LHX(128), LHY(42) );
1190 gr_pixel( LHX(98), LHY(43) );
1191 gr_pixel( LHX(98), LHY(44) );
1192 gr_pixel( LHX(128), LHY(43) );
1193 gr_pixel( LHX(128), LHY(44) );
1195 gr_string( LHX(109), LHY(40), "OR" );
1197 gr_scanline( LHX(253), LHX(261), LHY(42) );
1198 gr_scanline( LHX(274), LHX(283), LHY(42) );
1199 gr_pixel( LHX(253), LHY(43) );
1200 gr_pixel( LHX(253), LHY(44) );
1201 gr_pixel( LHX(283), LHY(43) );
1202 gr_pixel( LHX(283), LHY(44) );
1204 gr_string( LHX(264), LHY(40), "OR" );
1206 } if ( items == kc_joystick ) {
1207 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
1208 gr_setcolor( BM_XRGB(31,27,6) );
1209 gr_scanline( LHX(18), LHX(135), LHY(37) );
1210 gr_scanline( LHX(181), LHX(294), LHY(37) );
1211 gr_scanline( LHX(18), LHX(144), LHY(119+18) );
1212 gr_scanline( LHX(174), LHX(294), LHY(119+18) );
1213 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
1214 gr_string( 0x8000,LHY(117+18), TXT_AXES );
1215 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1216 gr_string( LHX(81), LHY(137+8), TXT_AXIS );
1217 gr_string( LHX(111), LHY(137+8), TXT_INVERT );
1218 gr_string( LHX(222), LHY(137+8), TXT_AXIS );
1219 gr_string( LHX(252), LHY(137+8), TXT_INVERT );
1220 } else if ( items == kc_mouse ) {
1221 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
1222 gr_setcolor( BM_XRGB(31,27,6) );
1223 gr_scanline( LHX(18), LHX(135), LHY(37) );
1224 gr_scanline( LHX(181), LHX(294), LHY(37) );
1225 gr_scanline( LHX(18), LHX(144), LHY(119+5) );
1226 gr_scanline( LHX(174), LHX(294), LHY(119+5) );
1227 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
1228 gr_string( 0x8000,LHY(117+5), TXT_AXES );
1229 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1230 gr_string( LHX(169), LHY(129), TXT_AXIS );
1231 gr_string( LHX(199), LHY(129), TXT_INVERT );
1233 WIN(DDGRUNLOCK(dd_grd_curcanv));
1235 for (i=0; i<nitems; i++ ) {
1236 kc_drawitem( &items[i], 0 );
1240 kc_drawitem( &items[citem], 1 );
1245 #if defined(MACINTOSH) || defined(WINDOWS)
1246 mouse_state = omouse_state = 0;
1250 // Windows addendum to allow for kconfig input.
1255 DoMessageStuff(&msg);
1257 if (_RedrawScreen) {
1258 _RedrawScreen = FALSE;
1260 dd_gr_set_current_canvas(NULL);
1270 //see if redbook song needs to be restarted
1271 songs_check_redbook_repeat();
1275 #if defined(MACINTOSH) || defined(WINDOWS)
1276 omouse_state = mouse_state;
1277 mouse_state = mouse_button_state(0);
1280 if ( !time_stopped ) {
1282 if (multi_menu_poll() == -1)
1291 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_3:)
1292 case KEY_PRINT_SCREEN:
1293 save_screen_shot(0);
1295 case KEY_CTRLED+KEY_D:
1296 items[citem].value = 255;
1297 kc_drawitem( &items[citem], 1 );
1299 case KEY_CTRLED+KEY_R:
1300 if ( items==kc_keyboard ) {
1301 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1302 items[i].value=default_kconfig_settings[0][i];
1303 kc_drawitem( &items[i], 0 );
1307 // hack for firebire and mousestick default controls since I made
1308 // them the same control type -- dumb dumb dumb
1309 if (joy_have_firebird())
1310 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1311 items[i].value = default_firebird_settings[i];
1312 kc_drawitem( &items[i], 0 );
1314 else if (joy_have_mousestick())
1315 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1316 items[i].value = default_mousestick_settings[i];
1317 kc_drawitem( &items[i], 0 );
1320 #endif // note link to above else
1321 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1322 items[i].value = default_kconfig_settings[Config_control_type][i];
1323 kc_drawitem( &items[i], 0 );
1326 kc_drawitem( &items[citem], 1 );
1329 items[citem].value=255;
1330 kc_drawitem( &items[citem], 1 );
1334 #ifdef TABLE_CREATION
1335 if (items[citem].u==-1) items[citem].u=find_next_item_up( items,nitems, citem);
1337 citem = items[citem].u;
1342 #ifdef TABLE_CREATION
1343 if (items[citem].d==-1) items[citem].d=find_next_item_down( items,nitems, citem);
1345 citem = items[citem].d;
1349 #ifdef TABLE_CREATION
1350 if (items[citem].l==-1) items[citem].l=find_next_item_left( items,nitems, citem);
1352 citem = items[citem].l;
1356 #ifdef TABLE_CREATION
1357 if (items[citem].r==-1) items[citem].r=find_next_item_right( items,nitems, citem);
1359 citem = items[citem].r;
1363 switch( items[citem].type ) {
1364 case BT_KEY: kc_change_key( &items[citem] ); break;
1365 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1366 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1367 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1368 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1369 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1374 grd_curcanv->cv_font = save_font;
1376 WIN(DEFINE_SCREEN(old_bg_pcx));
1379 dd_gr_set_current_canvas(save_canvas),
1380 gr_set_current_canvas( save_canvas )
1382 keyd_repeat = old_keyd_repeat;
1383 game_flush_inputs();
1384 WIN( HideCursorW());
1385 MAC( hide_cursor(); )
1389 #ifdef TABLE_CREATION
1390 case KEY_DEBUGGED+KEY_F12: {
1392 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1393 kc_keyboard[i].u = find_next_item_up( kc_keyboard,NUM_KEY_CONTROLS, i);
1394 kc_keyboard[i].d = find_next_item_down( kc_keyboard,NUM_KEY_CONTROLS, i);
1395 kc_keyboard[i].l = find_next_item_left( kc_keyboard,NUM_KEY_CONTROLS, i);
1396 kc_keyboard[i].r = find_next_item_right( kc_keyboard,NUM_KEY_CONTROLS, i);
1398 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1399 kc_joystick[i].u = find_next_item_up( kc_joystick,NUM_OTHER_CONTROLS, i);
1400 kc_joystick[i].d = find_next_item_down( kc_joystick,NUM_OTHER_CONTROLS, i);
1401 kc_joystick[i].l = find_next_item_left( kc_joystick,NUM_OTHER_CONTROLS, i);
1402 kc_joystick[i].r = find_next_item_right( kc_joystick,NUM_OTHER_CONTROLS, i);
1404 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1405 kc_mouse[i].u = find_next_item_up( kc_mouse,NUM_OTHER_CONTROLS, i);
1406 kc_mouse[i].d = find_next_item_down( kc_mouse,NUM_OTHER_CONTROLS, i);
1407 kc_mouse[i].l = find_next_item_left( kc_mouse,NUM_OTHER_CONTROLS, i);
1408 kc_mouse[i].r = find_next_item_right( kc_mouse,NUM_OTHER_CONTROLS, i);
1410 fp = fopen( "kconfig.cod", "wt" );
1412 fprintf( fp, "ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {\n" );
1413 for (i=0; i<CONTROL_MAX_TYPES; i++ ) {
1415 fprintf( fp, "{0x%x", kconfig_settings[i][0] );
1416 for (j=1; j<MAX_CONTROLS; j++ )
1417 fprintf( fp, ",0x%x", kconfig_settings[i][j] );
1418 fprintf( fp, "},\n" );
1420 fprintf( fp, "};\n" );
1422 fprintf( fp, "\nkc_item kc_keyboard[NUM_KEY_CONTROLS] = {\n" );
1423 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1424 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1425 kc_keyboard[i].id, kc_keyboard[i].x, kc_keyboard[i].y, kc_keyboard[i].w1, kc_keyboard[i].w2,
1426 kc_keyboard[i].u, kc_keyboard[i].d, kc_keyboard[i].l, kc_keyboard[i].r,
1427 34, kc_keyboard[i].text, 34, btype_text[kc_keyboard[i].type] );
1429 fprintf( fp, "};" );
1431 fprintf( fp, "\nkc_item kc_joystick[NUM_OTHER_CONTROLS] = {\n" );
1432 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1433 if (kc_joystick[i].type == BT_JOY_BUTTON)
1434 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1435 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1436 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1437 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1439 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1440 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1441 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1442 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1444 fprintf( fp, "};" );
1446 fprintf( fp, "\nkc_item kc_mouse[NUM_OTHER_CONTROLS] = {\n" );
1447 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1448 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1449 kc_mouse[i].id, kc_mouse[i].x, kc_mouse[i].y, kc_mouse[i].w1, kc_mouse[i].w2,
1450 kc_mouse[i].u, kc_mouse[i].d, kc_mouse[i].l, kc_mouse[i].r,
1451 34, kc_mouse[i].text, 34, btype_text[kc_mouse[i].type] );
1453 fprintf( fp, "};" );
1462 #if defined (MACINTOSH) || defined(WINDOWS)
1463 if ( (mouse_state && !omouse_state) || (mouse_state && omouse_state) ) {
1466 mouse_get_pos(&mx, &my);
1467 for (i=0; i<nitems; i++ ) {
1468 item_height = get_item_height( &items[i] );
1469 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[i].x) + LHX(items[i].w1);
1470 x2 = x1 + LHX(items[i].w2);
1471 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[i].y);
1472 y2 = y1 + LHX(item_height);
1473 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1479 else if ( !mouse_state && omouse_state ) {
1482 mouse_get_pos(&mx, &my);
1483 item_height = get_item_height( &items[citem] );
1484 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[citem].x) + LHX(items[citem].w1);
1485 x2 = x1 + LHX(items[citem].w2);
1486 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[citem].y);
1487 y2 = y1 + LHY(item_height);
1488 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1491 switch( items[citem].type ) {
1492 case BT_KEY: kc_change_key( &items[citem] ); break;
1493 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1494 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1495 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1496 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1497 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1502 x1 = grd_curcanv->cv_bitmap.bm_x + close_x + 2;
1503 x2 = x1 + close_size - 2;
1504 y1 = grd_curcanv->cv_bitmap.bm_y + close_y + 2;
1505 y2 = y1 + close_size - 2;
1506 if ( ((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2)) ) {
1507 grd_curcanv->cv_font = save_font;
1508 WINDOS(dd_gr_set_current_canvas( save_canvas ),
1509 gr_set_current_canvas( save_canvas ));
1510 keyd_repeat = old_keyd_repeat;
1511 game_flush_inputs();
1521 #endif // MACINTOSH WINDOWS
1523 if (ocitem!=citem) {
1526 kc_drawitem( &items[ocitem], 0 );
1527 kc_drawitem( &items[citem], 1 );
1535 void kc_drawitem( kc_item *item, int is_current )
1539 // PA_DFX (pa_set_frontbuffer_current());
1540 WIN(DDGRLOCK(dd_grd_curcanv));
1543 gr_set_fontcolor( BM_XRGB(20,20,29), -1 );
1545 gr_set_fontcolor( BM_XRGB(15,15,24), -1 );
1546 gr_string( LHX(item->x), LHY(item->y), item->text );
1547 WIN(DDGRUNLOCK(dd_grd_curcanv));
1549 if (item->value==255) {
1550 strcpy( btext, "" );
1552 switch( item->type ) {
1554 strncpy( btext, key_text[item->value], 10 ); break;
1555 case BT_MOUSE_BUTTON:
1557 //strncpy( btext, Text_string[mousebutton_text[item->value]], 10 ); break;
1558 strncpy( btext, (item->value <= 3)?Text_string[mousebutton_text[item->value]]:mousebutton_textra[item->value-3], 10 ); break;
1560 strncpy( btext, mousebutton_text[item->value], 10 ); break;
1563 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
1567 if (joybutton_text[item->value] != -1)
1568 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1570 sprintf( btext, "BTN%2d", item->value+1 );
1572 if ( joybutton_text[item->value] !=-1 )
1573 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1575 sprintf( btext, "BTN%d", item->value );
1578 strncpy( btext, joy_btn_name( item->value ), 10);
1580 sprintf( btext, "BTN%d", item->value );
1584 strncpy( btext, Text_string[joyaxis_text[item->value]], 10 ); break;
1586 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
1590 WIN(DDGRLOCK(dd_grd_curcanv));
1591 gr_get_string_size(btext, &w, &h, &aw );
1594 gr_setcolor( BM_XRGB(21,0,24) );
1596 gr_setcolor( BM_XRGB(16,0,19) );
1597 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1599 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1601 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1603 gr_string( x, LHY(item->y), btext );
1604 // PA_DFX (pa_set_backbuffer_current());
1606 WIN(DDGRUNLOCK(dd_grd_curcanv));
1611 static int looper=0;
1613 void kc_drawquestion( kc_item *item )
1617 WIN(DDGRLOCK(dd_grd_curcanv));
1618 // PA_DFX (pa_set_frontbuffer_current());
1620 gr_get_string_size("?", &w, &h, &aw );
1622 c = BM_XRGB(21,0,24);
1624 //@@gr_setcolor( gr_fade_table[fades[looper]*256+c] );
1625 gr_setcolor(BM_XRGB(21*fades[looper]/31,0,24*fades[looper]/31));
1627 if (looper>63) looper=0;
1629 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1631 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1633 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1635 gr_string( x, LHY(item->y), "?" );
1636 // PA_DFX (pa_set_backbuffer_current());
1637 WIN(DDGRUNLOCK(dd_grd_curcanv));
1641 void kc_change_key( kc_item * item )
1646 WIN(DDGRLOCK(dd_grd_curcanv));
1647 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1649 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_KEY );
1650 WIN(DDGRUNLOCK(dd_grd_curcanv));
1652 game_flush_inputs();
1656 while( (k!=KEY_ESC) && (keycode==255) )
1662 DoMessageStuff(&msg);
1669 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1672 // if ( Game_mode & GM_MULTI )
1673 // GameLoop( 0, 0 ); // Continue
1676 kc_drawquestion( item );
1678 for (i=0; i<256; i++ ) {
1679 if (keyd_pressed[i] && (strlen(key_text[i])>0)) {
1681 for (n=0; n<sizeof(system_keys); n++ )
1682 if ( system_keys[n] == i )
1691 for (i=0; i<Num_items; i++ ) {
1692 n = item - All_items;
1693 if ( (i!=n) && (All_items[i].type==BT_KEY) && (All_items[i].value==keycode) ) {
1694 All_items[i].value = 255;
1695 kc_drawitem( &All_items[i], 0 );
1698 item->value = keycode;
1700 kc_drawitem( item, 1 );
1702 WIN(DDGRLOCK(dd_grd_curcanv));
1703 gr_set_fontcolor( BM_XRGB(28,28,28), BM_XRGB(0,0,0) );
1704 WIN(DDGRUNLOCK(dd_grd_curcanv));
1706 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1708 game_flush_inputs();
1712 void kc_change_joybutton( kc_item * item )
1717 WIN(DDGRLOCK(dd_grd_curcanv));
1718 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1720 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_JBUTTON );
1721 WIN(DDGRUNLOCK(dd_grd_curcanv));
1723 game_flush_inputs();
1727 while( (k!=KEY_ESC) && (code==255))
1732 DoMessageStuff(&msg);
1738 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1741 // if ( Game_mode & GM_MULTI )
1742 // GameLoop( 0, 0 ); // Continue
1746 if (k == KEY_PRINT_SCREEN)
1747 save_screen_shot(0);
1749 kc_drawquestion( item );
1751 WIN(code = joydefsw_do_button());
1754 code = joy_do_buttons();
1757 #if !defined(WINDOWS) && !defined(MACINTOSH)
1758 if (Config_control_type==CONTROL_THRUSTMASTER_FCS) {
1760 joystick_read_raw_axis( JOY_ALL_AXIS, axis );
1761 kconfig_read_fcs( axis[3] );
1762 if ( joy_get_button_state(7) ) code = 7;
1763 if ( joy_get_button_state(11) ) code = 11;
1764 if ( joy_get_button_state(15) ) code = 15;
1765 if ( joy_get_button_state(19) ) code = 19;
1766 for (i=0; i<4; i++ ) {
1767 if ( joy_get_button_state(i) )
1770 } else if (Config_control_type==CONTROL_FLIGHTSTICK_PRO) {
1771 for (i=4; i<20; i++ ) {
1772 if ( joy_get_button_state(i) ) {
1774 mprintf(( 0, "JB: %d\n", code ));
1778 for (i=0; i<MAX_BUTTONS; i++ ) {
1779 if ( joy_get_button_state(i) )
1786 for (i=0; i<Num_items; i++ ) {
1787 n = item - All_items;
1788 if ( (i!=n) && (All_items[i].type==BT_JOY_BUTTON) && (All_items[i].value==code) ) {
1789 All_items[i].value = 255;
1790 kc_drawitem( &All_items[i], 0 );
1795 kc_drawitem( item, 1 );
1796 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1797 game_flush_inputs();
1800 void kc_change_mousebutton( kc_item * item )
1805 WIN(DDGRLOCK(dd_grd_curcanv));
1806 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1808 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_MBUTTON );
1809 WIN(DDGRUNLOCK(dd_grd_curcanv));
1812 game_flush_inputs();
1816 while( (k!=KEY_ESC) && (code==255))
1821 DoMessageStuff(&msg);
1827 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1830 // if ( Game_mode & GM_MULTI )
1831 // GameLoop( 0, 0 ); // Continue
1835 if (k == KEY_PRINT_SCREEN)
1836 save_screen_shot(0);
1838 kc_drawquestion( item );
1840 b = mouse_get_btns();
1841 for (i = 0; i < 16; i++ ) {
1847 for (i=0; i<Num_items; i++ ) {
1848 n = item - All_items;
1849 if ( (i!=n) && (All_items[i].type==BT_MOUSE_BUTTON) && (All_items[i].value==code) ) {
1850 All_items[i].value = 255;
1851 kc_drawitem( &All_items[i], 0 );
1856 kc_drawitem( item, 1 );
1857 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1858 game_flush_inputs();
1862 void kc_change_joyaxis( kc_item * item )
1866 int old_axis[MAX_AXES];
1868 int axis[JOY_NUM_AXES];
1869 int old_axis[JOY_NUM_AXES];
1878 WIN(DDGRLOCK(dd_grd_curcanv));
1879 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1881 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_JOY_AXIS );
1882 WIN(DDGRUNLOCK(dd_grd_curcanv));
1884 game_flush_inputs();
1889 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, old_axis ),
1890 joystick_read_raw_axis( JOY_ALL_AXIS, old_axis )
1893 while( (k!=KEY_ESC) && (code==255))
1898 DoMessageStuff(&msg);
1904 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1907 // if ( Game_mode & GM_MULTI )
1908 // GameLoop( 0, 0 ); // Continue
1912 if (k == KEY_PRINT_SCREEN)
1913 save_screen_shot(0);
1915 kc_drawquestion( item );
1918 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, axis ),
1919 joystick_read_raw_axis( JOY_ALL_AXIS, axis )
1922 for (i=0; i<numaxis; i++ ) {
1923 #if defined (MACINTOSH)
1924 if ( abs(axis[i]-old_axis[i])>100 ) {
1925 #elif defined(WINDOWS)
1926 if ( abs(axis[i]-old_axis[i])>1024 ) {
1928 if ( abs(axis[i]-old_axis[i])>200 ) {
1931 con_printf(CON_DEBUG, "Axis Movement detected: Axis %i\n", i);
1933 //old_axis[i] = axis[i];
1935 for (i=0; i<Num_items; i++ )
1937 n = item - All_items;
1938 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) )
1944 for (i=0; i<Num_items; i++ ) {
1945 n = item - All_items;
1946 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) ) {
1947 All_items[i].value = 255;
1948 kc_drawitem( &All_items[i], 0 );
1954 kc_drawitem( item, 1 );
1955 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1956 game_flush_inputs();
1960 void kc_change_mouseaxis( kc_item * item )
1969 WIN(DDGRLOCK(dd_grd_curcanv));
1970 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1972 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_MSE_AXIS );
1973 WIN(DDGRUNLOCK(dd_grd_curcanv));
1975 game_flush_inputs();
1979 mouse_get_delta( &dx, &dy );
1981 while( (k!=KEY_ESC) && (code==255))
1986 DoMessageStuff(&msg);
1992 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1995 // if ( Game_mode & GM_MULTI )
1996 // GameLoop( 0, 0 ); // Continue
2000 if (k == KEY_PRINT_SCREEN)
2001 save_screen_shot(0);
2003 kc_drawquestion( item );
2006 mouse_get_delta_z( &dx, &dy, &dz );
2008 mouse_get_delta( &dx, &dy );
2010 if ( abs(dx)>20 ) code = 0;
2011 if ( abs(dy)>20 ) code = 1;
2013 if ( abs(dz)>20 ) code = 2;
2017 for (i=0; i<Num_items; i++ ) {
2018 n = item - All_items;
2019 if ( (i!=n) && (All_items[i].type==BT_MOUSE_AXIS) && (All_items[i].value==code) ) {
2020 All_items[i].value = 255;
2021 kc_drawitem( &All_items[i], 0 );
2026 kc_drawitem( item, 1 );
2027 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
2028 game_flush_inputs();
2033 void kc_change_invert( kc_item * item )
2035 game_flush_inputs();
2042 kc_drawitem( item, 1 );
2046 #include "screens.h"
2048 extern void gr_bm_bitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
2050 void kconfig(int n, char * title)
2053 grs_bitmap *save_bm;
2055 set_screen_mode( SCREEN_MENU );
2060 WIN(mouse_set_mode(0));
2061 WIN(dd_gr_set_current_canvas(NULL));
2063 #if defined(POLY_ACC)
2064 save_bm = gr_create_bitmap2( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h, grd_curcanv->cv_bitmap.bm_type, NULL );
2066 save_bm = gr_create_bitmap( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
2068 Assert( save_bm != NULL );
2070 WIN(DDGRLOCK(dd_grd_curcanv));
2071 gr_bm_bitblt(grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_w,
2072 0, 0, 0, 0, &grd_curcanv->cv_bitmap, save_bm );
2073 WIN(DDGRUNLOCK(dd_grd_curcanv));
2076 case 0:kconfig_sub( kc_keyboard, NUM_KEY_CONTROLS, title );break;
2077 case 1:kconfig_sub( kc_joystick, NUM_OTHER_CONTROLS, title );break;
2078 case 2:kconfig_sub( kc_mouse, NUM_OTHER_CONTROLS, title ); break;
2079 case 3:kconfig_sub( kc_superjoy, NUM_OTHER_CONTROLS, title); break;
2086 WIN(mouse_set_mode(1));
2087 WIN(dd_gr_set_current_canvas(NULL));
2088 WIN(DDGRLOCK(dd_grd_curcanv));
2089 gr_bitmap(0, 0, save_bm);
2090 WIN(DDGRUNLOCK(dd_grd_curcanv));
2091 gr_free_bitmap(save_bm);
2093 reset_cockpit(); //force cockpit redraw next time
2095 // Update save values...
2097 for (i=0; i<NUM_KEY_CONTROLS; i++ )
2098 kconfig_settings[0][i] = kc_keyboard[i].value;
2100 if ( (Config_control_type>0) && (Config_control_type<5)) {
2101 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
2102 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
2103 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
2104 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
2105 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
2107 else if (Config_control_type == CONTROL_WINJOYSTICK) {
2108 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
2109 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
2114 void kconfig_read_fcs( int raw_axis )
2116 int raw_button, button, axis_min[4], axis_center[4], axis_max[4];
2118 if (Config_control_type!=CONTROL_THRUSTMASTER_FCS) return;
2120 joy_get_cal_vals(axis_min, axis_center, axis_max);
2122 if ( axis_max[3] > 1 )
2123 raw_button = (raw_axis*100)/axis_max[3];
2127 if ( raw_button > 88 )
2129 else if ( raw_button > 63 )
2131 else if ( raw_button > 39 )
2133 else if ( raw_button > 15 )
2138 kconfig_set_fcs_button( 19, button );
2139 kconfig_set_fcs_button( 15, button );
2140 kconfig_set_fcs_button( 11, button );
2141 kconfig_set_fcs_button( 7, button );
2145 void kconfig_set_fcs_button( int btn, int button )
2147 int state,time_down,upcount,downcount;
2148 state = time_down = upcount = downcount = 0;
2150 if ( joy_get_button_state(btn) ) {
2151 if ( btn==button ) {
2153 time_down = FrameTime;
2158 if ( btn==button ) {
2160 time_down = FrameTime;
2167 joy_set_btn_values( btn, state, time_down, downcount, upcount );
2173 fix Last_angles_p = 0;
2174 fix Last_angles_b = 0;
2175 fix Last_angles_h = 0;
2176 ubyte Last_angles_read = 0;
2178 extern int VR_sensitivity;
2180 int VR_sense_range[3] = { 25, 50, 75 };
2182 #if 0 //ndef MACINTOSH
2187 fix yaw, pitch, roll;
2190 //------ read vfx1 helmet --------
2191 if (vfx1_installed) {
2192 vfx_get_data(&yaw,&pitch,&roll,&buttons);
2193 } else if (iglasses_headset_installed) {
2194 iglasses_read_headset( &yaw, &pitch, &roll );
2195 } else if (Victor_headset_installed) {
2196 victor_read_headset_filtered( &yaw, &pitch, &roll );
2201 Use_player_head_angles = 0;
2202 if ( Last_angles_read ) {
2206 if ( (Last_angles_h < (F1_0/4) ) && (yaw > ((F1_0*3)/4) ) )
2208 else if ( (yaw < (F1_0/4) ) && (Last_angles_h > ((F1_0*3)/4) ) )
2211 Controls.pitch_time += fixmul((pitch- Last_angles_p)*VR_sense_range[VR_sensitivity],FrameTime);
2212 Controls.heading_time+= fixmul((yaw1 - Last_angles_h)*VR_sense_range[VR_sensitivity],FrameTime);
2213 Controls.bank_time += fixmul((roll - Last_angles_b)*VR_sense_range[VR_sensitivity],FrameTime);
2215 Last_angles_read = 1;
2216 Last_angles_p = pitch;
2217 Last_angles_h = yaw;
2218 Last_angles_b = roll;
2226 #define JOYSTICK_READ_TIME (F1_0/40) // Read joystick at 40 Hz.
2228 #define JOYSTICK_READ_TIME (F1_0/10) // Read joystick at 10 Hz.
2231 fix LastReadTime = 0;
2235 ubyte kc_use_external_control = 0;
2236 ubyte kc_enable_external_control = 0;
2237 ubyte kc_external_intno = 0;
2238 ext_control_info *kc_external_control = NULL;
2239 ubyte *kc_external_name = NULL;
2240 ubyte kc_external_version = 0;
2241 extern int Automap_active;
2243 void kconfig_init_external_controls(int intno, int address)
2246 kc_external_intno = intno;
2247 kc_external_control = (ext_control_info *)address;
2248 kc_use_external_control = 1;
2249 kc_enable_external_control = 1;
2251 i = FindArg ( "-xname" );
2253 kc_external_name = Args[i+1];
2255 kc_external_name = "External Controller";
2257 for (i=0;i<strlen (kc_external_name);i++)
2258 if (kc_external_name[i]=='_')
2259 kc_external_name[i]=' ';
2261 i = FindArg ( "-xver" );
2263 kc_external_version = atoi(Args[i+1]);
2265 printf( "%s int: 0x%x, data: 0x%p, ver:%d\n", kc_external_name, kc_external_intno, kc_external_control, kc_external_version );
2269 #if !defined(MACINTOSH)
2270 /*void kconfig_read_external_controls()
2274 if ( !kc_enable_external_control && !CybermouseActive)
2277 if ( kc_external_version == 0 )
2278 memset( kc_external_control, 0, sizeof(control_info) );
2279 else if ( kc_external_version > 0 ) {
2280 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 );
2281 if ( kc_external_version > 1 ) {
2282 // Write ship pos and angles to external controls...
2283 ubyte *temp_ptr = (ubyte *)kc_external_control;
2284 vms_vector *ship_pos;
2285 vms_matrix *ship_orient;
2286 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
2287 temp_ptr += sizeof(control_info)+sizeof(vms_angvec) + 64;
2288 ship_pos = (vms_vector *)temp_ptr;
2289 temp_ptr += sizeof(vms_vector);
2290 ship_orient = (vms_matrix *)temp_ptr;
2291 // Fill in ship postion...
2292 *ship_pos = Objects[Players[Player_num].objnum].pos;
2293 // Fill in ship orientation...
2294 *ship_orient = Objects[Players[Player_num].objnum].orient;
2298 if ( Automap_active ) // (If in automap...)
2299 kc_external_control->automap_state = 1;
2300 memset(&r,0,sizeof(r));
2304 if (!CybermouseActive)
2305 int386 ( kc_external_intno, &r, &r); // Read external info...
2307 // ReadOWL (kc_external_control);
2311 if ( Player_num > -1 ) {
2312 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
2313 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
2314 Auto_leveling_on = 0;
2316 if ( kc_external_version > 0 ) {
2317 vms_matrix tempm, ViewMatrix;
2318 vms_angvec * Kconfig_abs_movement;
2321 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
2323 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
2324 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
2325 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
2326 Objects[Players[Player_num].objnum].orient = ViewMatrix;
2328 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
2329 if (oem_message[0] != '\0' )
2330 HUD_init_message( oem_message );
2334 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
2335 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
2336 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
2337 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
2338 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
2339 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
2340 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
2341 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
2342 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
2343 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
2344 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
2345 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
2346 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
2347 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
2348 Controls.automap_down_count += kc_external_control->automap_down_count;
2349 Controls.automap_state |= kc_external_control->automap_state;
2354 void controls_read_all_win()
2357 int slide_on, bank_on;
2361 int raw_joy_axis[7];
2363 fix k0, k1, k2, k3, kp;
2364 fix k4, k5, k6, k7, kh;
2365 ubyte channel_masks;
2366 int use_mouse, use_joystick;
2369 if (Game_turbo_mode)
2373 fix temp = Controls.heading_time;
2374 fix temp1 = Controls.pitch_time;
2375 memset( &Controls, 0, sizeof(control_info) );
2376 Controls.heading_time = temp;
2377 Controls.pitch_time = temp1;
2382 ctime = timer_get_fixed_seconds();
2384 // DO JOYSTICK (X,Y,Z R,U,V)
2385 // ----------------------------------------------------------------------------
2386 if ( (LastReadTime + JOYSTICK_READ_TIME) > ctime ) {
2387 if ((ctime < 0) && (LastReadTime > 0))
2388 LastReadTime = ctime;
2390 } else if ((Config_control_type==CONTROL_WINJOYSTICK)) {
2391 LastReadTime = ctime;
2392 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, raw_joy_axis );
2394 for (i=0; i<7; i++ ) {
2395 if (channel_masks&(1<<i)) {
2396 int joy_null_value = 28;
2398 // DO POV if joystick has a hat.
2399 // --------------------------------------------------------------------
2401 joydefsw_do_winjoybutton(raw_joy_axis);
2405 // --------------------------------------------------------------------
2406 // mprintf((0, "(%d)=%d,", i, raw_joy_axis[i]));
2407 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2408 // mprintf((0, "%d ",raw_joy_axis[i]));
2409 // if (i%2) mprintf((0,"\n"));
2412 if (kc_superjoy[23].value==i) // If this is the throttle
2413 joy_null_value = 32; // Then use a larger dead-zone
2415 if (raw_joy_axis[i] > (joy_null_value-2))
2416 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2417 else if (raw_joy_axis[i] < -(joy_null_value+2))
2418 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2420 raw_joy_axis[i] = 0;
2421 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2430 for (i=0; i<6; i++ )
2436 // ----------------------------------------------------------------------------
2437 if (Config_control_type==5) {
2438 mouse_get_delta( &dx, &dy );
2439 mouse_axis[0] = (dx*FrameTime)/35;
2440 mouse_axis[1] = (dy*FrameTime)/25;
2441 mouse_buttons = mouse_get_btns();
2442 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2451 //------------- Read slide_on -------------
2454 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
2455 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
2457 if ((use_joystick)&&(kc_superjoy[5].value<255)) slide_on |= joy_get_button_state( kc_superjoy[5].value );
2459 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
2461 //------------- Read bank_on ---------------
2464 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
2465 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
2467 if ( (use_joystick)&&(kc_superjoy[10].value < 255 )) bank_on |= joy_get_button_state( kc_superjoy[10].value );
2469 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
2471 //------------ Read pitch_time -----------
2473 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2475 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
2476 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
2477 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
2478 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
2481 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
2482 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
2483 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
2484 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
2487 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2488 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
2489 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
2493 Controls.pitch_time = 0;
2495 if (Controls.pitch_time < 0)
2496 Controls.pitch_time = 0;
2498 if (Controls.pitch_time > 0)
2499 Controls.pitch_time = 0;
2500 Controls.pitch_time += kp;
2503 if ( (use_joystick)&&(kc_superjoy[13].value < 255 )) {
2504 if ( !kc_superjoy[14].value ) // If not inverted...
2505 Controls.pitch_time -= (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2507 Controls.pitch_time += (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2511 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
2512 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
2513 if ( !kc_mouse[14].value ) // If not inverted...
2514 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2516 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2519 Controls.pitch_time = 0;
2523 //----------- Read vertical_thrust_time -----------------
2526 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
2527 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
2528 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
2529 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
2532 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
2533 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
2534 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
2535 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
2538 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2539 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
2540 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
2544 if ((use_joystick)&&( kc_superjoy[13].value < 255 )) {
2545 if ( !kc_superjoy[14].value ) // If not inverted...
2546 Controls.vertical_thrust_time += joy_axis[kc_superjoy[13].value];
2548 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[13].value];
2552 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
2553 if ( !kc_mouse[14].value ) // If not inverted...
2554 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
2556 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
2561 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
2562 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
2563 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
2564 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
2567 if ((use_joystick)&&( kc_superjoy[19].value < 255 )) {
2568 if ( !kc_superjoy[20].value ) // If not inverted...
2569 Controls.vertical_thrust_time += joy_axis[kc_superjoy[19].value];
2571 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[19].value];
2574 // From joystick buttons
2575 if ( (use_joystick)&&(kc_superjoy[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_superjoy[8].value );
2576 if ( (use_joystick)&&(kc_superjoy[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_superjoy[9].value );
2578 // From mouse buttons
2579 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
2580 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
2583 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
2584 if ( !kc_mouse[20].value ) // If not inverted...
2585 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
2587 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
2591 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2592 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
2593 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
2596 //---------- Read heading_time -----------
2598 if (!slide_on && !bank_on) {
2599 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2601 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
2602 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
2603 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
2604 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
2607 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
2608 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
2609 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
2610 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
2613 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2614 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
2615 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
2619 Controls.heading_time = 0;
2621 if (Controls.heading_time < 0)
2622 Controls.heading_time = 0;
2624 if (Controls.heading_time > 0)
2625 Controls.heading_time = 0;
2626 Controls.heading_time += kh;
2629 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2630 if ( !kc_superjoy[16].value ) // If not inverted...
2631 Controls.heading_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2633 Controls.heading_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2637 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2638 if ( !kc_mouse[16].value ) // If not inverted...
2639 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2641 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2644 Controls.heading_time = 0;
2647 //----------- Read sideways_thrust_time -----------------
2650 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2651 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2652 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2653 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2656 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
2657 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
2658 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
2659 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
2662 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2663 if ( !kc_superjoy[16].value ) // If not inverted...
2664 Controls.sideways_thrust_time += joy_axis[kc_superjoy[15].value];
2666 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[15].value];
2670 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2671 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
2672 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
2676 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2677 if ( !kc_mouse[16].value ) // If not inverted...
2678 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
2680 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
2685 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
2686 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
2687 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
2688 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
2691 if ( (use_joystick)&&(kc_superjoy[17].value < 255 )) {
2692 if ( !kc_superjoy[18].value ) // If not inverted...
2693 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[17].value];
2695 Controls.sideways_thrust_time += joy_axis[kc_superjoy[17].value];
2698 // From joystick buttons
2699 if ( (use_joystick)&&(kc_superjoy[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_superjoy[6].value );
2700 if ( (use_joystick)&&(kc_superjoy[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_superjoy[7].value );
2702 // From mouse buttons
2703 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
2704 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
2707 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
2708 if ( !kc_mouse[18].value ) // If not inverted...
2709 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
2711 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
2714 //----------- Read bank_time -----------------
2717 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2718 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2719 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2720 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2723 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
2724 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
2725 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
2726 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
2729 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2730 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
2731 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
2735 if ( (use_joystick)&&(kc_superjoy[15].value < 255) ) {
2736 if ( !kc_superjoy[16].value ) // If not inverted...
2737 Controls.bank_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2739 Controls.bank_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2743 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2744 if ( !kc_mouse[16].value ) // If not inverted...
2745 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2747 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2752 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
2753 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
2754 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
2755 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
2758 if ( (use_joystick)&&(kc_superjoy[21].value < 255) ) {
2759 if ( !kc_superjoy[22].value ) // If not inverted...
2760 Controls.bank_time -= joy_axis[kc_superjoy[21].value];
2762 Controls.bank_time += joy_axis[kc_superjoy[21].value];
2765 // From joystick buttons
2766 if ( (use_joystick)&&(kc_superjoy[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_superjoy[11].value );
2767 if ( (use_joystick)&&(kc_superjoy[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_superjoy[12].value );
2769 // From mouse buttons
2770 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
2771 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
2774 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
2775 if ( !kc_mouse[22].value ) // If not inverted...
2776 Controls.bank_time += mouse_axis[kc_mouse[21].value];
2778 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
2782 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2783 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
2784 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
2787 //----------- Read forward_thrust_time -------------
2790 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
2791 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
2792 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
2793 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
2796 if ( (use_joystick)&&(kc_superjoy[23].value < 255 )) {
2797 if ( !kc_superjoy[24].value ) // If not inverted...
2798 Controls.forward_thrust_time -= joy_axis[kc_superjoy[23].value];
2800 Controls.forward_thrust_time += joy_axis[kc_superjoy[23].value];
2803 // From joystick buttons
2804 if ( (use_joystick)&&(kc_superjoy[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_superjoy[2].value );
2805 if ( (use_joystick)&&(kc_superjoy[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_superjoy[3].value );
2808 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
2809 if ( !kc_mouse[24].value ) // If not inverted...
2810 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
2812 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
2815 // From mouse buttons
2816 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
2817 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
2819 //----------- Read afterburner_state -------------
2822 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
2823 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
2825 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
2827 if ( (use_joystick)&&(kc_superjoy[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_superjoy[27].value);
2829 //-------Read headlight key--------------------------
2830 if (kc_keyboard[52].value < 255 )
2831 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
2832 if (kc_keyboard[53].value < 255 )
2833 Controls.headlight_count=key_down_count(kc_keyboard[53].value);
2834 if ((use_joystick)&&(kc_superjoy[30].value < 255 ))
2835 Controls.headlight_count=joy_get_button_down_cnt(kc_superjoy[30].value);
2837 //--------Read Cycle Primary Key------------------
2839 if (kc_keyboard[48].value<255)
2840 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
2841 if (kc_keyboard[49].value<255)
2842 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
2843 if ((use_joystick)&&(kc_superjoy[28].value < 255 ))
2844 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_superjoy[28].value);
2846 //--------Read Cycle Secondary Key------------------
2848 if (kc_keyboard[50].value<255)
2849 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
2850 if (kc_keyboard[51].value<255)
2851 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
2852 if ((use_joystick)&&(kc_superjoy[29].value < 255 ))
2853 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_superjoy[29].value);
2855 //--------Read Toggle Bomb key----------------------
2857 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
2859 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
2861 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
2862 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
2864 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2865 HUD_init_message ("No bombs available!");
2869 if (Players[Player_num].secondary_ammo[bomb]==0)
2871 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2872 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
2876 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
2877 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
2882 //---------Read Energy->Shield key----------
2884 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
2885 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
2886 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
2887 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
2889 //----------- Read fire_primary_down_count
2890 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
2891 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
2892 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_superjoy[0].value);
2893 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
2895 //----------- Read fire_primary_state
2896 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
2897 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
2898 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_superjoy[0].value);
2899 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
2901 //----------- Read fire_secondary_down_count
2902 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
2903 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
2904 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_superjoy[1].value);
2905 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
2907 //----------- Read fire_secondary_state
2908 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
2909 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
2910 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_superjoy[1].value);
2911 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
2913 //----------- Read fire_flare_down_count
2914 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
2915 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
2916 if ((use_joystick)&&(kc_superjoy[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_superjoy[4].value);
2917 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
2919 //----------- Read drop_bomb_down_count
2920 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
2921 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
2922 if ((use_joystick)&&(kc_superjoy[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_superjoy[26].value);
2923 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
2925 //----------- Read rear_view_down_count
2926 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
2927 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
2928 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_superjoy[25].value);
2929 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
2931 //----------- Read rear_view_down_state
2932 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
2933 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
2934 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_superjoy[25].value);
2935 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
2937 //----------- Read automap_down_count
2938 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
2939 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
2941 //----------- Read automap_state
2942 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
2943 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
2945 //----------- Read stupid-cruise-control-type of throttle.
2947 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
2948 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
2949 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
2950 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
2951 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
2953 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
2956 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
2957 if (Cruise_speed < 0 ) Cruise_speed = 0;
2959 if (Controls.forward_thrust_time==0)
2960 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
2963 //read_head_tracker();
2965 // Read external controls
2966 if (kc_use_external_control || CybermouseActive)
2967 kconfig_read_external_controls();
2969 //----------- Clamp values between -FrameTime and FrameTime
2970 if (FrameTime > F1_0 )
2971 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
2973 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
2974 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
2975 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
2976 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
2977 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
2978 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
2979 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
2981 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
2982 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
2983 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
2984 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
2985 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
2986 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
2987 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
2990 //--------- Don't do anything if in debug mode
2992 if ( keyd_pressed[KEY_DELETE] ) {
2993 memset( &Controls, 0, sizeof(control_info) );
3000 fix Next_toggle_time[3]={0,0,0};
3002 int allowed_to_toggle(int i)
3004 //used for keeping tabs of when its ok to toggle headlight,primary,and secondary
3006 if (Next_toggle_time[i] > GameTime)
3007 if (Next_toggle_time[i] < GameTime + (F1_0/8)) // In case time is bogus, never wait > 1 second.
3010 Next_toggle_time[i] = GameTime + (F1_0/8);
3017 void controls_read_all()
3020 int slide_on, bank_on;
3027 fix mouse_axis[3] = {0,0,0};
3029 int raw_joy_axis[MAX_AXES];
3031 int raw_joy_axis[JOY_NUM_AXES];
3034 fix k0, k1, k2, k3, kp;
3035 fix k4, k5, k6, k7, kh;
3036 ubyte channel_masks;
3037 int use_mouse, use_joystick;
3043 if (Game_turbo_mode)
3047 fix temp = Controls.heading_time;
3048 fix temp1 = Controls.pitch_time;
3049 memset( &Controls, 0, sizeof(control_info) );
3050 Controls.heading_time = temp;
3051 Controls.pitch_time = temp1;
3056 ctime = timer_get_fixed_seconds();
3058 //--------- Read Joystick -----------
3060 if ( (LastReadTime + JOYSTICK_READ_TIME > ctime) && (Config_control_type!=CONTROL_THRUSTMASTER_FCS) ) {
3061 if ((ctime < 0) && (LastReadTime > 0))
3062 LastReadTime = ctime;
3064 } else if ((Config_control_type>0) && (Config_control_type<5) ) {
3065 LastReadTime = ctime;
3066 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
3068 for (i=0; i<6; i++ ) {
3070 if (channel_masks&(1<<i)) {
3072 int joy_null_value = 10;
3074 if ( (i==3) && (Config_control_type==CONTROL_THRUSTMASTER_FCS) ) {
3075 kconfig_read_fcs( raw_joy_axis[i] );
3077 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
3079 if (kc_joystick[23].value==i) // If this is the throttle
3080 joy_null_value = 20; // Then use a larger dead-zone
3082 if (raw_joy_axis[i] > joy_null_value)
3083 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
3084 else if (raw_joy_axis[i] < -joy_null_value)
3085 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
3087 raw_joy_axis[i] = 0;
3088 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
3098 for (i=0; i<4; i++ )
3103 //--------- Read Joystick -----------
3104 if ((Config_control_type>0) && (Config_control_type<5) ) {
3105 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
3106 for (i=0; i<4; i++ ) {
3107 if (channel_masks&(1<<i)) {
3108 int joy_null_value = 10;
3110 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
3112 if (kc_joystick[23].value==i) // If this is the throttle
3113 joy_null_value = 20; // Then use a larger dead-zone
3115 if (raw_joy_axis[i] > joy_null_value)
3116 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
3117 else if (raw_joy_axis[i] < -joy_null_value)
3118 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
3120 raw_joy_axis[i] = 0;
3121 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
3128 for (i=0; i<4; i++ )
3132 #endif // ifndef MACINTOSH
3134 if (Config_control_type==5 && !CybermouseActive) {
3135 //--------- Read Mouse -----------
3137 mouse_get_delta_z( &dx, &dy, &dz );
3139 mouse_get_delta( &dx, &dy );
3141 mouse_axis[0] = (dx*FrameTime)/35;
3142 mouse_axis[1] = (dy*FrameTime)/25;
3144 mouse_axis[2] = (dz*FrameTime);
3146 mouse_buttons = mouse_get_btns();
3147 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
3149 } else if (Config_control_type==6 && !CybermouseActive) {
3150 //--------- Read Cyberman -----------
3151 mouse_get_cyberman_pos(&idx,&idy );
3152 mouse_axis[0] = (idx*FrameTime)/128;
3153 mouse_axis[1] = (idy*FrameTime)/128;
3154 mouse_buttons = mouse_get_btns();
3156 } else if (CybermouseActive) {
3157 // ReadOWL (kc_external_control);
3158 // CybermouseAdjust();
3166 //------------- Read slide_on -------------
3169 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
3170 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
3172 if ((use_joystick)&&(kc_joystick[5].value<255)) slide_on |= joy_get_button_state( kc_joystick[5].value );
3174 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
3176 //------------- Read bank_on ---------------
3179 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
3180 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
3182 if ( (use_joystick)&&(kc_joystick[10].value < 255 )) bank_on |= joy_get_button_state( kc_joystick[10].value );
3184 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
3186 //------------ Read pitch_time -----------
3188 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
3190 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
3191 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
3192 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
3193 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
3196 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
3197 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
3198 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
3199 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
3202 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3203 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
3204 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
3208 Controls.pitch_time = 0;
3210 if (Controls.pitch_time < 0)
3211 Controls.pitch_time = 0;
3213 if (Controls.pitch_time > 0)
3214 Controls.pitch_time = 0;
3215 Controls.pitch_time += kp;
3218 if ( (use_joystick)&&(kc_joystick[13].value < 255 )) {
3219 if ( !kc_joystick[14].value ) // If not inverted...
3220 Controls.pitch_time -= (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
3222 Controls.pitch_time += (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
3226 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
3227 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
3228 if ( !kc_mouse[14].value ) // If not inverted...
3229 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
3231 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
3234 Controls.pitch_time = 0;
3238 //----------- Read vertical_thrust_time -----------------
3241 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
3242 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
3243 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
3244 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
3247 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
3248 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
3249 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
3250 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
3253 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3254 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
3255 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
3259 if ((use_joystick)&&( kc_joystick[13].value < 255 )) {
3260 if ( !kc_joystick[14].value ) // If not inverted...
3261 Controls.vertical_thrust_time += joy_axis[kc_joystick[13].value];
3263 Controls.vertical_thrust_time -= joy_axis[kc_joystick[13].value];
3267 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
3268 if ( !kc_mouse[14].value ) // If not inverted...
3269 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
3271 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
3276 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
3277 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
3278 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
3279 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
3282 if ((use_joystick)&&( kc_joystick[19].value < 255 )) {
3283 if ( !kc_joystick[20].value ) // If not inverted...
3284 Controls.vertical_thrust_time += joy_axis[kc_joystick[19].value];
3286 Controls.vertical_thrust_time -= joy_axis[kc_joystick[19].value];
3289 // From joystick buttons
3290 if ( (use_joystick)&&(kc_joystick[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_joystick[8].value );
3291 if ( (use_joystick)&&(kc_joystick[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_joystick[9].value );
3293 // From mouse buttons
3294 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
3295 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
3298 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
3299 if ( !kc_mouse[20].value ) // If not inverted...
3300 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
3302 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
3306 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3307 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
3308 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
3311 //---------- Read heading_time -----------
3313 if (!slide_on && !bank_on) {
3314 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
3316 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
3317 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
3318 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
3319 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
3322 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
3323 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
3324 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
3325 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
3328 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3329 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
3330 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
3334 Controls.heading_time = 0;
3336 if (Controls.heading_time < 0)
3337 Controls.heading_time = 0;
3339 if (Controls.heading_time > 0)
3340 Controls.heading_time = 0;
3341 Controls.heading_time += kh;
3344 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
3345 if ( !kc_joystick[16].value ) // If not inverted...
3346 Controls.heading_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3348 Controls.heading_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3352 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3353 if ( !kc_mouse[16].value ) // If not inverted...
3354 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3356 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3359 Controls.heading_time = 0;
3362 //----------- Read sideways_thrust_time -----------------
3365 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3366 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3367 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3368 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3371 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
3372 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
3373 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
3374 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
3377 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
3378 if ( !kc_joystick[16].value ) // If not inverted...
3379 Controls.sideways_thrust_time += joy_axis[kc_joystick[15].value];
3381 Controls.sideways_thrust_time -= joy_axis[kc_joystick[15].value];
3385 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3386 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
3387 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
3391 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3392 if ( !kc_mouse[16].value ) // If not inverted...
3393 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
3395 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
3400 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
3401 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
3402 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
3403 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
3406 if ( (use_joystick)&&(kc_joystick[17].value < 255 )) {
3407 if ( !kc_joystick[18].value ) // If not inverted...
3408 Controls.sideways_thrust_time -= joy_axis[kc_joystick[17].value];
3410 Controls.sideways_thrust_time += joy_axis[kc_joystick[17].value];
3413 // From joystick buttons
3414 if ( (use_joystick)&&(kc_joystick[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_joystick[6].value );
3415 if ( (use_joystick)&&(kc_joystick[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_joystick[7].value );
3417 // From mouse buttons
3418 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
3419 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
3422 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
3423 if ( !kc_mouse[18].value ) // If not inverted...
3424 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
3426 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
3429 //----------- Read bank_time -----------------
3432 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3433 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3434 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3435 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3438 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
3439 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
3440 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
3441 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
3444 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3445 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
3446 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
3450 if ( (use_joystick)&&(kc_joystick[15].value < 255) ) {
3451 if ( !kc_joystick[16].value ) // If not inverted...
3452 Controls.bank_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3454 Controls.bank_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3458 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3459 if ( !kc_mouse[16].value ) // If not inverted...
3460 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3462 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3467 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
3468 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
3469 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
3470 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
3473 if ( (use_joystick)&&(kc_joystick[21].value < 255) ) {
3474 if ( !kc_joystick[22].value ) // If not inverted...
3475 Controls.bank_time -= joy_axis[kc_joystick[21].value];
3477 Controls.bank_time += joy_axis[kc_joystick[21].value];
3480 // From joystick buttons
3481 if ( (use_joystick)&&(kc_joystick[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_joystick[11].value );
3482 if ( (use_joystick)&&(kc_joystick[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_joystick[12].value );
3484 // From mouse buttons
3485 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
3486 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
3489 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
3490 if ( !kc_mouse[22].value ) // If not inverted...
3491 Controls.bank_time += mouse_axis[kc_mouse[21].value];
3493 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
3497 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3498 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
3499 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
3502 //----------- Read forward_thrust_time -------------
3505 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
3506 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
3507 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
3508 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
3511 if ( (use_joystick)&&(kc_joystick[23].value < 255 )) {
3512 if ( !kc_joystick[24].value ) // If not inverted...
3513 Controls.forward_thrust_time -= joy_axis[kc_joystick[23].value];
3515 Controls.forward_thrust_time += joy_axis[kc_joystick[23].value];
3518 // From joystick buttons
3519 if ( (use_joystick)&&(kc_joystick[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_joystick[2].value );
3520 if ( (use_joystick)&&(kc_joystick[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_joystick[3].value );
3523 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
3524 if ( !kc_mouse[24].value ) // If not inverted...
3525 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
3527 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
3530 // From mouse buttons
3531 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
3532 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
3534 //----------- Read afterburner_state -------------
3537 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
3538 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
3540 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
3542 if ( (use_joystick)&&(kc_joystick[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_joystick[27].value);
3544 //-------Read headlight key--------------------------
3546 if (kc_keyboard[52].value < 255 )
3547 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
3548 if (kc_keyboard[53].value < 255 )
3549 Controls.headlight_count+=key_down_count(kc_keyboard[53].value);
3550 if ((use_joystick)&&(kc_joystick[30].value < 255 ))
3551 Controls.headlight_count+=joy_get_button_down_cnt(kc_joystick[30].value);
3553 //--------Read Cycle Primary Key------------------
3555 if (kc_keyboard[48].value<255)
3556 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
3557 if (kc_keyboard[49].value<255)
3558 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
3559 if ((use_joystick)&&(kc_joystick[28].value < 255 ))
3560 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_joystick[28].value);
3563 //--------Read Cycle Secondary Key------------------
3565 if (kc_keyboard[50].value<255)
3566 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
3567 if (kc_keyboard[51].value<255)
3568 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
3569 if ((use_joystick)&&(kc_joystick[29].value < 255 ))
3570 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_joystick[29].value);
3572 //--------Read Toggle Bomb key----------------------
3574 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
3576 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
3578 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
3579 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
3581 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3582 HUD_init_message ("No bombs available!");
3586 if (Players[Player_num].secondary_ammo[bomb]==0)
3588 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3589 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
3593 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
3594 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
3599 //---------Read Energy->Shield key----------
3601 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
3602 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
3603 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
3604 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
3606 //----------- Read fire_primary_down_count
3607 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
3608 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
3609 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_joystick[0].value);
3610 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
3612 //----------- Read fire_primary_state
3613 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
3614 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
3615 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_joystick[0].value);
3616 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
3618 //----------- Read fire_secondary_down_count
3619 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
3620 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
3621 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_joystick[1].value);
3622 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
3624 //----------- Read fire_secondary_state
3625 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
3626 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
3627 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_joystick[1].value);
3628 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
3630 //----------- Read fire_flare_down_count
3631 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
3632 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
3633 if ((use_joystick)&&(kc_joystick[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_joystick[4].value);
3634 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
3636 //----------- Read drop_bomb_down_count
3637 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
3638 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
3639 if ((use_joystick)&&(kc_joystick[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_joystick[26].value);
3640 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
3642 //----------- Read rear_view_down_count
3643 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
3644 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
3645 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_joystick[25].value);
3646 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
3648 //----------- Read rear_view_down_state
3649 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
3650 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
3651 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_joystick[25].value);
3652 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
3654 //----------- Read automap_down_count
3655 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
3656 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
3658 //----------- Read automap_state
3659 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
3660 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
3662 //----------- Read stupid-cruise-control-type of throttle.
3664 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
3665 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
3666 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
3667 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
3668 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
3670 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
3673 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
3674 if (Cruise_speed < 0 ) Cruise_speed = 0;
3676 if (Controls.forward_thrust_time==0)
3677 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
3680 #if !defined(MACINTOSH)
3681 //read_head_tracker();
3683 // Read external controls
3684 // if (kc_use_external_control || CybermouseActive)
3685 // kconfig_read_external_controls();
3688 //----------- Clamp values between -FrameTime and FrameTime
3689 if (FrameTime > F1_0 )
3690 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
3692 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
3693 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
3694 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
3695 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
3696 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
3697 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
3698 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
3700 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
3701 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
3702 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
3703 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
3704 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
3705 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
3706 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
3709 //--------- Don't do anything if in debug mode
3711 if ( keyd_pressed[KEY_DELETE] ) {
3712 memset( &Controls, 0, sizeof(control_info) );
3718 void reset_cruise(void)
3724 void kc_set_controls()
3728 for (i=0; i<NUM_KEY_CONTROLS; i++ )
3729 kc_keyboard[i].value = kconfig_settings[0][i];
3731 if ( (Config_control_type>0) && (Config_control_type<5)) {
3732 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3733 kc_joystick[i].value = kconfig_settings[Config_control_type][i];
3734 if (kc_joystick[i].type == BT_INVERT ) {
3735 if (kc_joystick[i].value!=1)
3736 kc_joystick[i].value = 0;
3737 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
3740 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
3741 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3742 kc_mouse[i].value = kconfig_settings[Config_control_type][i];
3743 if (kc_mouse[i].type == BT_INVERT ) {
3744 if (kc_mouse[i].value!=1)
3745 kc_mouse[i].value = 0;
3746 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
3749 } else if (Config_control_type == CONTROL_WINJOYSTICK) {
3750 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3751 kc_superjoy[i].value = kconfig_settings[Config_control_type][i];
3752 if (kc_superjoy[i].type == BT_INVERT ) {
3753 if (kc_superjoy[i].value!=1)
3754 kc_superjoy[i].value = 0;
3755 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
3761 #if 0 //ndef MACINTOSH // no mac support for vr headset
3763 void kconfig_center_headset()
3767 vfx_center_headset();
3769 // } else if (iglasses_headset_installed) {
3770 // } else if (Victor_headset_installed) {
3776 #endif // end of #ifndef MACINTOSH for kconfig_center_headset
3778 void CybermouseAdjust ()
3780 /* if ( Player_num > -1 ) {
3781 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3782 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3783 Auto_leveling_on = 0;
3785 if ( kc_external_version > 0 ) {
3786 vms_matrix tempm, ViewMatrix;
3787 vms_angvec * Kconfig_abs_movement;
3790 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
3792 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3793 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3794 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3795 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3797 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3798 if (oem_message[0] != '\0' )
3799 HUD_init_message( oem_message );
3803 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3804 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3805 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3806 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3807 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3808 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3809 // Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3810 // Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3811 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3812 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3813 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3814 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3815 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3816 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3817 // Controls.automap_down_count += kc_external_control->automap_down_count;
3818 // Controls.automap_state |= kc_external_control->automap_state;
3821 char GetKeyValue (char key)
3823 mprintf ((0,"Returning %c!\n",kc_keyboard[(int)key].value));
3824 return (kc_keyboard[(int)key].value);
3827 #if !defined(MACINTOSH)
3830 extern object *obj_find_first_of_type (int);
3831 void kconfig_read_external_controls()
3836 if ( !kc_enable_external_control ) return;
3838 if ( kc_external_version == 0 )
3839 memset( kc_external_control, 0, sizeof(ext_control_info));
3840 else if ( kc_external_version > 0 ) {
3842 if (kc_external_version>=4)
3843 memset( kc_external_control, 0, sizeof(advanced_ext_control_info));
3844 else if (kc_external_version>0)
3845 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 );
3846 else if (kc_external_version>2)
3847 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof(vms_matrix) +4 );
3849 if ( kc_external_version > 1 ) {
3850 // Write ship pos and angles to external controls...
3851 ubyte *temp_ptr = (ubyte *)kc_external_control;
3852 vms_vector *ship_pos;
3853 vms_matrix *ship_orient;
3854 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
3855 temp_ptr += sizeof(ext_control_info) + sizeof(vms_angvec) + 64;
3856 ship_pos = (vms_vector *)temp_ptr;
3857 temp_ptr += sizeof(vms_vector);
3858 ship_orient = (vms_matrix *)temp_ptr;
3859 // Fill in ship postion...
3860 *ship_pos = Objects[Players[Player_num].objnum].pos;
3861 // Fill in ship orientation...
3862 *ship_orient = Objects[Players[Player_num].objnum].orient;
3864 if (kc_external_version>=4)
3866 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3868 temp_ptr->headlight_state=(Players[Player_num].flags & PLAYER_FLAGS_HEADLIGHT_ON);
3869 temp_ptr->primary_weapon_flags=Players[Player_num].primary_weapon_flags;
3870 temp_ptr->secondary_weapon_flags=Players[Player_num].secondary_weapon_flags;
3871 temp_ptr->current_primary_weapon=Primary_weapon;
3872 temp_ptr->current_secondary_weapon=Secondary_weapon;
3874 temp_ptr->current_guidebot_command=Escort_goal_object;
3876 temp_ptr->force_vector=ExtForceVec;
3877 temp_ptr->force_matrix=ExtApplyForceMatrix;
3879 temp_ptr->joltinfo[i]=ExtJoltInfo[i];
3881 temp_ptr->x_vibrate_info[i]=ExtXVibrateInfo[i];
3882 temp_ptr->x_vibrate_clear=ExtXVibrateClear;
3883 temp_ptr->game_status=ExtGameStatus;
3885 memset ((void *)&ExtForceVec,0,sizeof(vms_vector));
3886 memset ((void *)&ExtApplyForceMatrix,0,sizeof(vms_matrix));
3891 ExtXVibrateInfo[i]=0;
3896 if ( Automap_active ) // (If in automap...)
3897 kc_external_control->automap_state = 1;
3898 //memset(&r,0,sizeof(r));
3902 int386 ( kc_external_intno, &r, &r); // Read external info...
3906 if ( Player_num > -1 ) {
3907 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3908 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3909 Auto_leveling_on = 0;
3911 if ( kc_external_version > 0 ) {
3912 vms_matrix tempm, ViewMatrix;
3913 vms_angvec * Kconfig_abs_movement;
3916 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(ext_control_info));
3918 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3919 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3920 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3921 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3923 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3924 if (oem_message[0] != '\0' )
3925 HUD_init_message( oem_message );
3929 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3930 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3931 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3932 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3933 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3934 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3935 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3936 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3937 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3938 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3939 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3940 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3941 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3942 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3943 Controls.automap_down_count += kc_external_control->automap_down_count;
3944 Controls.automap_state |= kc_external_control->automap_state;
3946 if (kc_external_version>=3)
3948 ubyte *temp_ptr = (ubyte *)kc_external_control;
3949 temp_ptr += (sizeof(ext_control_info) + sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof (vms_matrix));
3952 Controls.cycle_primary_count=(*(temp_ptr));
3954 Controls.cycle_secondary_count=(*(temp_ptr+1));
3957 Controls.afterburner_state=(*(temp_ptr+2));
3959 Controls.headlight_count=(*(temp_ptr+3));
3961 if (kc_external_version>=4)
3964 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3967 if (temp_ptr->keyboard[i])
3970 if (temp_ptr->Reactor_blown)
3972 if (Game_mode & GM_MULTI)
3973 net_destroy_controlcen (obj_find_first_of_type (OBJ_CNTRLCEN));
3975 do_controlcen_destroyed_stuff(obj_find_first_of_type (OBJ_CNTRLCEN));