2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
16 static char rcsid[] = "$Id: kconfig.c,v 1.1.1.2 2001-01-19 03:33:43 bradleyb Exp $";
31 #include "pa_enabl.h" //$$POLY_ACC
70 ubyte ExtGameStatus=1;
72 vms_vector ExtForceVec;
73 vms_matrix ExtApplyForceMatrix;
75 int ExtJoltInfo[3]={0,0,0};
76 int ExtXVibrateInfo[2]={0,0};
77 int ExtYVibrateInfo[2]={0,0};
78 ubyte ExtXVibrateClear=0;
79 ubyte ExtYVibrateClear=0;
81 #define TABLE_CREATION 1
83 // Array used to 'blink' the cursor while waiting for a keypress.
84 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 };
86 //char * invert_text[2] = { "N", "Y" };
87 //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" };
88 //char * joyaxis_text[4] = { "X1", "Y1", "X2", "Y2" };
89 //char * mouseaxis_text[2] = { "L/R", "F/B" };
90 //char * mousebutton_text[3] = { "Left", "Right", "Mid" };
92 int invert_text[2] = { TNUM_N, TNUM_Y };
95 int joybutton_text[28] =
96 { TNUM_BTN_1, TNUM_BTN_2, TNUM_BTN_3, TNUM_BTN_4,
100 TNUM_HAT_L, TNUM_HAT_R, TNUM_HAT_U, TNUM_HAT_D,
104 int joyaxis_text[7] = { TNUM_X1, TNUM_Y1, TNUM_Z1, TNUM_UN, TNUM_P1,TNUM_R1,TNUM_YA1 };
106 int joybutton_text[28] =
107 { TNUM_BTN_1, TNUM_BTN_2, TNUM_BTN_3, TNUM_BTN_4,
108 -1, TNUM_TRIG, TNUM_LEFT, TNUM_HAT_L,
109 TNUM_RIGHT, -1, TNUM_HAT2_D, TNUM_HAT_R,
110 TNUM_MID, -1, TNUM_HAT2_R, TNUM_HAT_U,
111 TNUM_HAT2_L, -1, TNUM_HAT2_U, TNUM_HAT_D,
112 TNUM_TRIG, TNUM_LEFT, TNUM_RIGHT, -1,
113 TNUM_UP, TNUM_DOWN, TNUM_LEFT, TNUM_RIGHT };
115 int joyaxis_text[4] = { TNUM_X1, TNUM_Y1, TNUM_X2, TNUM_Y2 };
118 int mouseaxis_text[2] = { TNUM_L_R, TNUM_F_B };
120 int mousebutton_text[3] = { TNUM_LEFT, TNUM_RIGHT, TNUM_MID };
122 char *mousebutton_text[3] = { "Btn", "", "" }; // only one silly mouse button on the mac
126 char * key_text[256] = {
127 "","S","D","F","H","G","Z","X","C","V","","B","Q", "W", "E", "R",
128 "Y","T","1","2","3","4","6","5","=","9","7","-", "8", "0", "]", "O",
129 "U","[","I","P","RET","L","J","'","K", ";", "\\", ",", "/", "N", "M", ".",
130 "TAB","SPC","`","DEL","","ESC","","APL","SHIFT","CAPSL","OPTN","CTRL","","","","A",
131 "","PAD.","","PAD*","","PAD+","","NMLCK","","","","PAD/","ENTER","","PAD-","",
132 "","PAD=","PAD0","PAD1","PAD2","PAD3","PAD4","PAD5","PAD6","PAD7","","PAD8","PAD9","","","",
133 "F5","F6","F7","","F8","F9","","F11","","F13","","F14","","F10","","F12",
134 "","PAUSE","HELP","HOME","PGUP","DEL","","END","F2","","F1","LARW","RARW","DARW","UARW","",
135 "","","","","","","","","","","","","","","","",
136 "","","","","","","","","","","","","","","","",
137 "","","","","","","","","","","","","","","","",
138 "","","","","","","","","","","","","","","","",
139 "","","","","","","","","","","","","","","","",
140 "","","","","","","","","","","","","","","","",
141 "","","","","","","","","","","","","","","","",
142 "","","","","","","","","","","","","","","",""};
145 char * key_text[256] = { \
146 "","ESC","1","2","3","4","5","6","7","8","9","0","-", \
147 "=","BSPC","TAB","Q","W","E","R","T","Y","U","I","O", \
148 "P","[","]","
\83","LCTRL","A","S","D","F", \
149 "G","H","J","K","L",";","'","`", \
150 "LSHFT","\\","Z","X","C","V","B","N","M",",", \
151 ".","/","RSHFT","PAD*","LALT","SPC", \
152 "CPSLK","F1","F2","F3","F4","F5","F6","F7","F8","F9", \
153 "F10","NMLCK","SCLK","PAD7","PAD8","PAD9","PAD-", \
154 "PAD4","PAD5","PAD6","PAD+","PAD1","PAD2","PAD3","PAD0", \
155 "PAD.","","","","F11","F12","","","","","","","","","", \
156 "","","","","","","","","","","","","","","","","","","","", \
157 "","","","","","","","","","","","","","","","","","","","", \
158 "","","","","","","","","","","","","","","","","","", \
159 "PAD
\83","RCTRL","","","","","","","","","","","","","", \
160 "","","","","","","","","","","PAD/","","","RALT","", \
161 "","","","","","","","","","","","","","HOME","
\82","PGUP", \
162 "","
\81","","
\7f","","END","
\80","PGDN","INS", \
163 "DEL","","","","","","","","","","","","","","","","","", \
164 "","","","","","","","","","","","","","","","","","","","", \
165 "","","","","","","" };
169 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 };
171 //extern void GameLoop(int, int );
173 extern void transfer_energy_to_shield(fix);
174 extern void CyclePrimary(),CycleSecondary(),InitMarkerInput();
175 extern ubyte DefiningMarkerMessage;
176 extern char CybermouseActive;
179 extern int joydefsw_do_button();
180 extern int joydefsw_do_winjoybutton(int *axis);
181 extern joydefsw_win_joyselect(char *title);
184 control_info Controls;
188 // macros for drawing lo/hi res kconfig screens (see scores.c as well)
190 #define LHX(x) ((x)*(MenuHires?2:1))
191 #define LHY(y) ((y)*(MenuHires?2.4:1))
195 #define BT_MOUSE_BUTTON 1
196 #define BT_MOUSE_AXIS 2
197 #define BT_JOY_BUTTON 3
198 #define BT_JOY_AXIS 4
201 char *btype_text[] = { "BT_KEY", "BT_MOUSE_BUTTON", "BT_MOUSE_AXIS", "BT_JOY_BUTTON", "BT_JOY_AXIS", "BT_INVERT" };
205 typedef struct kc_item {
206 short id; // The id of this item
214 ubyte value; // what key,button,etc
220 ubyte kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS];
222 //----------- WARNING!!!!!!! -------------------------------------------
223 // THESE NEXT FOUR BLOCKS OF DATA ARE GENERATED BY PRESSING DEL+F12 WHEN
224 // IN THE KEYBOARD CONFIG SCREEN. BASICALLY, THAT PROCEDURE MODIFIES THE
225 // U,D,L,R FIELDS OF THE ARRAYS AND DUMPS THE NEW ARRAYS INTO KCONFIG.COD
226 //-------------------------------------------------------------------------
227 /*ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
228 {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},
229 {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},
230 {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},
231 {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},
232 {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},
233 {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},
234 {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},
238 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
239 {0xc8,0x48,0xd0,0x50,0xcb,0x4b,0xcd,0x4d,0x38,0xff,0xff,0x4f,0xff,0x51,0xff,0x4a,0xff,0x4e,0xff,0xff,0x10,0x47,0x12,0x49,0x1d,0x9d,0x39,0xff,0x21,0xff,0x1e,0xff,0x2c,0xff,0x30,0xff,0x13,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf,0xff,0x1f,0xff,0x33,0xff,0x34,0xff,0x23,0xff,0x14,0xff,0xff,0xff,0x0,0x0},
240 {0x0,0x1,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0},
241 {0x5,0xc,0xff,0xff,0xff,0xff,0x7,0xf,0x13,0xb,0xff,0x6,0x8,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0},
242 {0x0,0x1,0xff,0xff,0x2,0xff,0x7,0xf,0x13,0xb,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,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},
243 {0x3,0x0,0x1,0x2,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0},
244 {0x0,0x1,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0},
245 {0x0,0x1,0xff,0xff,0x2,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0},
247 {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},
253 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
254 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
255 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
256 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
257 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
258 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
259 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
260 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
261 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
262 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
263 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
264 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
265 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
266 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
267 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
268 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
269 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
270 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
271 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
272 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
273 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
274 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
275 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
276 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
277 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
278 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
279 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
280 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
281 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
282 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
283 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
284 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
285 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
286 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
287 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
288 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
289 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
290 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
291 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
292 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
293 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
294 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
295 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
296 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
297 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
298 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
299 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
300 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
301 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
302 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
303 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
304 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
305 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
306 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
307 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
308 { 54,158,171, 83, 26, 52, 56, 51, 55,"Energy->Shield", BT_KEY, 255 },
309 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
310 { 56,158,179,83, 26, 54, 0, 0, 0, "Toggle Bomb", BT_KEY,255},
312 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
313 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
314 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
315 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
316 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
317 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
318 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
319 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
320 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
321 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
322 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
323 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
324 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
325 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
326 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
327 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
328 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
329 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
330 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
331 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
332 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
333 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
334 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
335 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
336 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
337 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
338 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
339 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
340 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
341 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
342 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
343 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
345 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
346 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
347 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
348 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
349 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
350 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
351 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
352 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
353 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
354 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
355 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
356 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
357 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
358 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
359 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
360 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
361 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
362 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
363 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
364 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
365 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
366 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
367 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
368 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
369 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
370 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
371 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
372 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
373 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
374 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
375 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
376 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
379 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
380 { 0, 25, 46, 85, 26, 12, 1, 24, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
381 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
382 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
383 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
384 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
385 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
386 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
387 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
388 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
389 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
390 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
391 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
392 { 12,180,106, 59, 26, 11, 0, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
393 { 13,103,138, 58, 26, 27, 15, 25, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
394 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
395 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
396 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
397 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
398 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
399 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
400 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
401 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
402 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
403 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
404 { 24,103,182,106, 8, 22, 5, 23, 0,"throttle", BT_INVERT, 255 },
405 { 25, 25,109, 85, 26, 3, 27, 12, 13,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
406 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
407 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
410 #else // ifndef MACINTOSH (following are macintosh controls)
412 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
413 {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},
414 {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},
415 {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},
416 {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},
417 {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},
418 {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},
419 {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},
422 ubyte default_firebird_settings[MAX_CONTROLS] =
423 {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};
425 ubyte default_mousestick_settings[MAX_CONTROLS] =
426 {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};
428 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
429 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
430 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
431 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
432 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
433 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
434 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
435 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
436 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
437 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
438 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
439 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
440 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
441 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
442 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
443 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
444 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
445 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
446 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
447 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
448 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
449 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
450 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
451 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
452 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
453 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
454 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
455 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
456 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
457 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
458 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
459 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
460 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
461 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
462 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
463 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
464 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
465 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
466 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
467 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
468 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
469 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
470 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
471 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
472 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
473 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
474 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
475 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
476 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
477 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
478 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
479 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
480 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
481 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
482 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
483 { 54,158,171, 83, 26, 52, 25, 51, 55,"Energy->Shield", BT_KEY, 255 },
484 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
486 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
487 { 0, 25, 46, 85, 28, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
488 { 1, 25, 54, 85, 28, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
489 { 2, 25, 85, 85, 28, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
490 { 3, 25, 93, 85, 28, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
491 { 4, 25, 62, 85, 28, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
492 { 5,180, 46, 79, 28, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
493 { 6,180, 54, 79, 28, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
494 { 7,180, 62, 79, 28, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
495 { 8,180, 70, 79, 28, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
496 { 9,180, 78, 79, 28, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
497 { 10,180, 90, 79, 28, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
498 { 11,180, 98, 79, 28, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
499 { 12,180,106, 79, 28, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
500 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
501 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
502 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
503 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
504 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
505 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
506 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
507 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
508 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
509 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
510 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
511 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
512 { 25, 25,109, 85, 28, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
513 { 26, 25, 70, 85, 28, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
514 { 27, 25,117, 85, 28, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
515 { 28,180,114, 79, 28, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
516 { 29,180,122, 79, 28, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
517 { 30, 25,125, 85, 28, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
519 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
520 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
521 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
522 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
523 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
524 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
525 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
526 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
527 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
528 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
529 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
530 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
531 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
532 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
533 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
534 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
535 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
536 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
537 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
538 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
539 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
540 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
541 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
542 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
543 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
544 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
545 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
546 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
547 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
548 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
549 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
550 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
553 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
554 { 0, 25, 46, 85, 26, 28, 1, 28, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
555 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
556 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
557 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
558 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
559 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
560 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
561 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
562 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
563 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
564 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
565 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
566 { 12,180,106, 59, 26, 11, 28, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
567 { 13,103,138, 58, 26, 27, 15, 27, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
568 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
569 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
570 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
571 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
572 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
573 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
574 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
575 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
576 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
577 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
578 { 24,103,182,106, 8, 22, 5, 23, 28,"throttle", BT_INVERT, 255 },
579 { 25, 25,109, 85, 26, 3, 27, 12, 27,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
580 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
581 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
586 int kconfig_is_axes_used(int axis)
589 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
590 if (( kc_joystick[i].type == BT_JOY_AXIS ) && (kc_joystick[i].value == axis ))
596 #ifdef TABLE_CREATION
597 int find_item_at( kc_item * items, int nitems, int x, int y )
601 for (i=0; i<nitems; i++ ) {
602 if ( ((items[i].x+items[i].w1)==x) && (items[i].y==y))
608 int find_next_item_up( kc_item * items, int nitems, int citem )
613 x = items[citem].x+items[citem].w1;
618 y = grd_curcanv->cv_bitmap.bm_h-1;
621 x = grd_curcanv->cv_bitmap.bm_w-1;
624 i = find_item_at( items, nitems, x, y );
630 int find_next_item_down( kc_item * items, int nitems, int citem )
635 x = items[citem].x+items[citem].w1;
639 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
642 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
646 i = find_item_at( items, nitems, x, y );
652 int find_next_item_right( kc_item * items, int nitems, int citem )
657 x = items[citem].x+items[citem].w1;
661 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
664 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
668 i = find_item_at( items, nitems, x, y );
674 int find_next_item_left( kc_item * items, int nitems, int citem )
679 x = items[citem].x+items[citem].w1;
684 x = grd_curcanv->cv_bitmap.bm_w-1;
687 y = grd_curcanv->cv_bitmap.bm_h-1;
690 i = find_item_at( items, nitems, x, y );
697 #if defined(MACINTOSH) || defined(WINDOWS)
698 int get_item_height(kc_item *item)
703 if (item->value==255) {
704 sprintf( btext, "" );
706 switch( item->type ) {
708 strncpy( btext, key_text[item->value], 10 ); break;
709 case BT_MOUSE_BUTTON:
711 strncpy( btext, Text_string[mousebutton_text[item->value]], 10); break;
713 strncpy( btext, mousebutton_text[item->value], 10 ); break;
716 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
718 if ( joybutton_text[item->value] !=-1 )
719 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
721 sprintf( btext, "BTN%d", item->value );
724 strncpy( btext, Text_string[joyaxis_text[item->value]], 10 ); break;
726 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
729 gr_get_string_size(btext, &w, &h, &aw );
735 void kconfig_sub(kc_item * items,int nitems, char * title)
738 dd_grs_canvas * save_canvas,
739 grs_canvas * save_canvas
741 grs_font * save_font;
743 #if defined(MACINTOSH) || defined(WINDOWS)
744 int mouse_state, omouse_state, mx, my, x1, x2, y1, y2;
745 int close_x, close_y, close_size;
748 int i,k,ocitem,citem;
749 int time_stopped = 0;
750 WIN(char *old_bg_pcx);
752 WIN(old_bg_pcx = _SCRContext.bkg_filename);
753 WIN(DEFINE_SCREEN(NULL));
758 if (!((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence)) )
764 // if (Config_control_type == CONTROL_WINJOYSTICK) {
766 // joydefsw_win_joyselect(title2); title = title2,
768 // ); // Get Samir...
772 save_canvas = dd_grd_curcanv,
773 save_canvas = grd_curcanv
778 dd_gr_set_current_canvas(NULL),
779 gr_set_current_canvas(NULL)
781 save_font = grd_curcanv->cv_font;
785 old_keyd_repeat = keyd_repeat;
788 //gr_clear_canvas( BM_XRGB(0,0,0) );
790 nm_draw_background(0,0,grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
791 gr_palette_load (gr_palette);
793 grd_curcanv->cv_font = MEDIUM3_FONT;
795 WIN(DDGRLOCK(dd_grd_curcanv));
798 p = strchr( title, '\n' );
800 gr_string( 0x8000, LHY(8), title );
805 // if ( items == kc_keyboard ) {
806 // gr_string( 0x8000, 8, "Keyboard" );
807 // } else if ( items == kc_joystick ) {
808 // gr_string( 0x8000, 8, "Joysticks" );
809 // } else if ( items == kc_mouse ) {
810 // gr_string( 0x8000, 8, "Mouse" );
813 #if defined(MACINTOSH) || defined(WINDOWS)
814 close_x = close_y = 15;
816 gr_setcolor( BM_XRGB(0, 0, 0) );
817 gr_rect(close_x, close_y, close_x + close_size, close_y + close_size);
818 gr_setcolor( BM_XRGB(21, 21, 21) );
819 gr_rect( close_x + 2, close_y + 2, close_x + close_size - 2, close_y + close_size -2 );
822 grd_curcanv->cv_font = GAME_FONT;
823 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
826 gr_string( 0x8000, LHY(20), TXT_KCONFIG_STRING_1 );
828 gr_string( 0x8000, LHY(20), "Enter changes, ctrl-d deletes, ctrl-r resets defaults, ESC exits");
830 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
831 if ( items == kc_keyboard ) {
832 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
833 gr_setcolor( BM_XRGB(31,27,6) );
835 gr_scanline( LHX(98), LHX(106), LHY(42) );
836 gr_scanline( LHX(120), LHX(128), LHY(42) );
837 gr_pixel( LHX(98), LHY(43) );
838 gr_pixel( LHX(98), LHY(44) );
839 gr_pixel( LHX(128), LHY(43) );
840 gr_pixel( LHX(128), LHY(44) );
842 gr_string( LHX(109), LHY(40), "OR" );
844 gr_scanline( LHX(253), LHX(261), LHY(42) );
845 gr_scanline( LHX(274), LHX(283), LHY(42) );
846 gr_pixel( LHX(253), LHY(43) );
847 gr_pixel( LHX(253), LHY(44) );
848 gr_pixel( LHX(283), LHY(43) );
849 gr_pixel( LHX(283), LHY(44) );
851 gr_string( LHX(264), LHY(40), "OR" );
853 } if ( items == kc_joystick ) {
854 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
855 gr_setcolor( BM_XRGB(31,27,6) );
856 gr_scanline( LHX(18), LHX(135), LHY(37) );
857 gr_scanline( LHX(181), LHX(294), LHY(37) );
858 gr_scanline( LHX(18), LHX(144), LHY(119+18) );
859 gr_scanline( LHX(174), LHX(294), LHY(119+18) );
860 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
861 gr_string( 0x8000,LHY(117+18), TXT_AXES );
862 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
863 gr_string( LHX(81), LHY(137+8), TXT_AXIS );
864 gr_string( LHX(111), LHY(137+8), TXT_INVERT );
865 gr_string( LHX(222), LHY(137+8), TXT_AXIS );
866 gr_string( LHX(252), LHY(137+8), TXT_INVERT );
867 } else if ( items == kc_mouse ) {
868 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
869 gr_setcolor( BM_XRGB(31,27,6) );
870 gr_scanline( LHX(18), LHX(135), LHY(37) );
871 gr_scanline( LHX(181), LHX(294), LHY(37) );
872 gr_scanline( LHX(18), LHX(144), LHY(119+5) );
873 gr_scanline( LHX(174), LHX(294), LHY(119+5) );
874 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
875 gr_string( 0x8000,LHY(117+5), TXT_AXES );
876 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
877 gr_string( LHX(169), LHY(129), TXT_AXIS );
878 gr_string( LHX(199), LHY(129), TXT_INVERT );
880 WIN(DDGRUNLOCK(dd_grd_curcanv));
882 for (i=0; i<nitems; i++ ) {
883 kc_drawitem( &items[i], 0 );
887 kc_drawitem( &items[citem], 1 );
892 #if defined(MACINTOSH) || defined(WINDOWS)
893 mouse_state = omouse_state = 0;
897 // Windows addendum to allow for kconfig input.
902 DoMessageStuff(&msg);
905 _RedrawScreen = FALSE;
907 dd_gr_set_current_canvas(NULL);
917 //see if redbook song needs to be restarted
918 songs_check_redbook_repeat();
922 #if defined(MACINTOSH) || defined(WINDOWS)
923 omouse_state = mouse_state;
924 mouse_state = mouse_button_state(0);
927 if ( !time_stopped ) {
929 if (multi_menu_poll() == -1)
938 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_3:)
939 case KEY_PRINT_SCREEN:
942 case KEY_CTRLED+KEY_D:
943 items[citem].value = 255;
944 kc_drawitem( &items[citem], 1 );
946 case KEY_CTRLED+KEY_R:
947 if ( items==kc_keyboard ) {
948 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
949 items[i].value=default_kconfig_settings[0][i];
950 kc_drawitem( &items[i], 0 );
953 #ifdef MACINTOSH // hack for firebire and mousestick default controls since I made them the same control type -- dumb dumb dumb
954 if (joy_have_firebird())
955 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
956 items[i].value = default_firebird_settings[i];
957 kc_drawitem( &items[i], 0 );
959 else if (joy_have_mousestick())
960 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
961 items[i].value = default_mousestick_settings[i];
962 kc_drawitem( &items[i], 0 );
965 #endif // note link to above else
966 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
967 items[i].value = default_kconfig_settings[Config_control_type][i];
968 kc_drawitem( &items[i], 0 );
971 kc_drawitem( &items[citem], 1 );
974 items[citem].value=255;
975 kc_drawitem( &items[citem], 1 );
979 #ifdef TABLE_CREATION
980 if (items[citem].u==-1) items[citem].u=find_next_item_up( items,nitems, citem);
982 citem = items[citem].u;
987 #ifdef TABLE_CREATION
988 if (items[citem].d==-1) items[citem].d=find_next_item_down( items,nitems, citem);
990 citem = items[citem].d;
994 #ifdef TABLE_CREATION
995 if (items[citem].l==-1) items[citem].l=find_next_item_left( items,nitems, citem);
997 citem = items[citem].l;
1001 #ifdef TABLE_CREATION
1002 if (items[citem].r==-1) items[citem].r=find_next_item_right( items,nitems, citem);
1004 citem = items[citem].r;
1008 switch( items[citem].type ) {
1009 case BT_KEY: kc_change_key( &items[citem] ); break;
1010 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1011 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1012 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1013 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1014 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1019 grd_curcanv->cv_font = save_font;
1021 WIN(DEFINE_SCREEN(old_bg_pcx));
1024 dd_gr_set_current_canvas(save_canvas),
1025 gr_set_current_canvas( save_canvas )
1027 keyd_repeat = old_keyd_repeat;
1028 game_flush_inputs();
1029 WIN( HideCursorW());
1030 MAC( hide_cursor(); )
1034 #ifdef TABLE_CREATION
1035 case KEY_DEBUGGED+KEY_F12: {
1037 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1038 kc_keyboard[i].u = find_next_item_up( kc_keyboard,NUM_KEY_CONTROLS, i);
1039 kc_keyboard[i].d = find_next_item_down( kc_keyboard,NUM_KEY_CONTROLS, i);
1040 kc_keyboard[i].l = find_next_item_left( kc_keyboard,NUM_KEY_CONTROLS, i);
1041 kc_keyboard[i].r = find_next_item_right( kc_keyboard,NUM_KEY_CONTROLS, i);
1043 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1044 kc_joystick[i].u = find_next_item_up( kc_joystick,NUM_OTHER_CONTROLS, i);
1045 kc_joystick[i].d = find_next_item_down( kc_joystick,NUM_OTHER_CONTROLS, i);
1046 kc_joystick[i].l = find_next_item_left( kc_joystick,NUM_OTHER_CONTROLS, i);
1047 kc_joystick[i].r = find_next_item_right( kc_joystick,NUM_OTHER_CONTROLS, i);
1049 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1050 kc_mouse[i].u = find_next_item_up( kc_mouse,NUM_OTHER_CONTROLS, i);
1051 kc_mouse[i].d = find_next_item_down( kc_mouse,NUM_OTHER_CONTROLS, i);
1052 kc_mouse[i].l = find_next_item_left( kc_mouse,NUM_OTHER_CONTROLS, i);
1053 kc_mouse[i].r = find_next_item_right( kc_mouse,NUM_OTHER_CONTROLS, i);
1055 fp = fopen( "kconfig.cod", "wt" );
1057 fprintf( fp, "ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {\n" );
1058 for (i=0; i<CONTROL_MAX_TYPES; i++ ) {
1060 fprintf( fp, "{0x%x", kconfig_settings[i][0] );
1061 for (j=1; j<MAX_CONTROLS; j++ )
1062 fprintf( fp, ",0x%x", kconfig_settings[i][j] );
1063 fprintf( fp, "},\n" );
1065 fprintf( fp, "};\n" );
1067 fprintf( fp, "\nkc_item kc_keyboard[NUM_KEY_CONTROLS] = {\n" );
1068 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1069 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1070 kc_keyboard[i].id, kc_keyboard[i].x, kc_keyboard[i].y, kc_keyboard[i].w1, kc_keyboard[i].w2,
1071 kc_keyboard[i].u, kc_keyboard[i].d, kc_keyboard[i].l, kc_keyboard[i].r,
1072 34, kc_keyboard[i].text, 34, btype_text[kc_keyboard[i].type] );
1074 fprintf( fp, "};" );
1076 fprintf( fp, "\nkc_item kc_joystick[NUM_OTHER_CONTROLS] = {\n" );
1077 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1078 if (kc_joystick[i].type == BT_JOY_BUTTON)
1079 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1080 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1081 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1082 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1084 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1085 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1086 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1087 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1089 fprintf( fp, "};" );
1091 fprintf( fp, "\nkc_item kc_mouse[NUM_OTHER_CONTROLS] = {\n" );
1092 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1093 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1094 kc_mouse[i].id, kc_mouse[i].x, kc_mouse[i].y, kc_mouse[i].w1, kc_mouse[i].w2,
1095 kc_mouse[i].u, kc_mouse[i].d, kc_mouse[i].l, kc_mouse[i].r,
1096 34, kc_mouse[i].text, 34, btype_text[kc_mouse[i].type] );
1098 fprintf( fp, "};" );
1107 #if defined (MACINTOSH) || defined(WINDOWS)
1108 if ( (mouse_state && !omouse_state) || (mouse_state && omouse_state) ) {
1111 mouse_get_pos(&mx, &my);
1112 for (i=0; i<nitems; i++ ) {
1113 item_height = get_item_height( &items[i] );
1114 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[i].x) + LHX(items[i].w1);
1115 x2 = x1 + LHX(items[i].w2);
1116 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[i].y);
1117 y2 = y1 + LHX(item_height);
1118 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1124 else if ( !mouse_state && omouse_state ) {
1127 mouse_get_pos(&mx, &my);
1128 item_height = get_item_height( &items[citem] );
1129 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[citem].x) + LHX(items[citem].w1);
1130 x2 = x1 + LHX(items[citem].w2);
1131 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[citem].y);
1132 y2 = y1 + LHY(item_height);
1133 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1136 switch( items[citem].type ) {
1137 case BT_KEY: kc_change_key( &items[citem] ); break;
1138 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1139 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1140 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1141 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1142 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1147 x1 = grd_curcanv->cv_bitmap.bm_x + close_x + 2;
1148 x2 = x1 + close_size - 2;
1149 y1 = grd_curcanv->cv_bitmap.bm_y + close_y + 2;
1150 y2 = y1 + close_size - 2;
1151 if ( ((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2)) ) {
1152 grd_curcanv->cv_font = save_font;
1153 WINDOS(dd_gr_set_current_canvas( save_canvas ),
1154 gr_set_current_canvas( save_canvas ));
1155 keyd_repeat = old_keyd_repeat;
1156 game_flush_inputs();
1166 #endif // MACINTOSH WINDOWS
1168 if (ocitem!=citem) {
1171 kc_drawitem( &items[ocitem], 0 );
1172 kc_drawitem( &items[citem], 1 );
1180 void kc_drawitem( kc_item *item, int is_current )
1184 // PA_DFX (pa_set_frontbuffer_current());
1185 WIN(DDGRLOCK(dd_grd_curcanv));
1188 gr_set_fontcolor( BM_XRGB(20,20,29), -1 );
1190 gr_set_fontcolor( BM_XRGB(15,15,24), -1 );
1191 gr_string( LHX(item->x), LHY(item->y), item->text );
1192 WIN(DDGRUNLOCK(dd_grd_curcanv));
1194 if (item->value==255) {
1195 sprintf( btext, "" );
1197 switch( item->type ) {
1199 strncpy( btext, key_text[item->value], 10 ); break;
1200 case BT_MOUSE_BUTTON:
1202 strncpy( btext, Text_string[mousebutton_text[item->value]], 10 ); break;
1204 strncpy( btext, mousebutton_text[item->value], 10 ); break;
1207 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
1211 if (joybutton_text[item->value] != -1)
1212 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1214 sprintf( btext, "BTN%2d", item->value+1 );
1216 if ( joybutton_text[item->value] !=-1 )
1217 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1219 sprintf( btext, "BTN%d", item->value );
1222 strncpy( btext, joy_btn_name( item->value ), 10);
1224 sprintf( btext, "BTN%d", item->value );
1228 strncpy( btext, Text_string[joyaxis_text[item->value]], 10 ); break;
1230 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
1234 WIN(DDGRLOCK(dd_grd_curcanv));
1235 gr_get_string_size(btext, &w, &h, &aw );
1238 gr_setcolor( BM_XRGB(21,0,24) );
1240 gr_setcolor( BM_XRGB(16,0,19) );
1241 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1243 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1245 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1247 gr_string( x, LHY(item->y), btext );
1248 // PA_DFX (pa_set_backbuffer_current());
1250 WIN(DDGRUNLOCK(dd_grd_curcanv));
1255 static int looper=0;
1257 void kc_drawquestion( kc_item *item )
1261 WIN(DDGRLOCK(dd_grd_curcanv));
1262 // PA_DFX (pa_set_frontbuffer_current());
1264 gr_get_string_size("?", &w, &h, &aw );
1266 c = BM_XRGB(21,0,24);
1268 //@@gr_setcolor( gr_fade_table[fades[looper]*256+c] );
1269 gr_setcolor(BM_XRGB(21*fades[looper]/31,0,24*fades[looper]/31));
1271 if (looper>63) looper=0;
1273 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1275 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1277 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1279 gr_string( x, LHY(item->y), "?" );
1280 // PA_DFX (pa_set_backbuffer_current());
1281 WIN(DDGRUNLOCK(dd_grd_curcanv));
1285 void kc_change_key( kc_item * item )
1290 WIN(DDGRLOCK(dd_grd_curcanv));
1291 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1293 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_KEY );
1294 WIN(DDGRUNLOCK(dd_grd_curcanv));
1296 game_flush_inputs();
1300 while( (k!=KEY_ESC) && (keycode==255) )
1306 DoMessageStuff(&msg);
1313 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1316 // if ( Game_mode & GM_MULTI )
1317 // GameLoop( 0, 0 ); // Continue
1320 kc_drawquestion( item );
1322 for (i=0; i<256; i++ ) {
1323 if (keyd_pressed[i] && (strlen(key_text[i])>0)) {
1325 for (n=0; n<sizeof(system_keys); n++ )
1326 if ( system_keys[n] == i )
1335 for (i=0; i<Num_items; i++ ) {
1336 n = item - All_items;
1337 if ( (i!=n) && (All_items[i].type==BT_KEY) && (All_items[i].value==keycode) ) {
1338 All_items[i].value = 255;
1339 kc_drawitem( &All_items[i], 0 );
1342 item->value = keycode;
1344 kc_drawitem( item, 1 );
1346 WIN(DDGRLOCK(dd_grd_curcanv));
1347 gr_set_fontcolor( BM_XRGB(28,28,28), BM_XRGB(0,0,0) );
1348 WIN(DDGRUNLOCK(dd_grd_curcanv));
1350 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1352 game_flush_inputs();
1356 void kc_change_joybutton( kc_item * item )
1361 WIN(DDGRLOCK(dd_grd_curcanv));
1362 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1364 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_JBUTTON );
1365 WIN(DDGRUNLOCK(dd_grd_curcanv));
1367 game_flush_inputs();
1371 while( (k!=KEY_ESC) && (code==255))
1376 DoMessageStuff(&msg);
1382 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1385 // if ( Game_mode & GM_MULTI )
1386 // GameLoop( 0, 0 ); // Continue
1390 if (k == KEY_PRINT_SCREEN)
1391 save_screen_shot(0);
1393 kc_drawquestion( item );
1395 WIN(code = joydefsw_do_button());
1398 code = joy_do_buttons();
1401 #if !defined(WINDOWS) && !defined(MACINTOSH)
1402 if (Config_control_type==CONTROL_THRUSTMASTER_FCS) {
1404 joystick_read_raw_axis( JOY_ALL_AXIS, axis );
1405 kconfig_read_fcs( axis[3] );
1406 if ( joy_get_button_state(7) ) code = 7;
1407 if ( joy_get_button_state(11) ) code = 11;
1408 if ( joy_get_button_state(15) ) code = 15;
1409 if ( joy_get_button_state(19) ) code = 19;
1410 for (i=0; i<4; i++ ) {
1411 if ( joy_get_button_state(i) )
1414 } else if (Config_control_type==CONTROL_FLIGHTSTICK_PRO) {
1415 for (i=4; i<20; i++ ) {
1416 if ( joy_get_button_state(i) ) {
1418 mprintf(( 0, "JB: %d\n", code ));
1422 for (i=0; i<4; i++ ) {
1423 if ( joy_get_button_state(i) )
1430 for (i=0; i<Num_items; i++ ) {
1431 n = item - All_items;
1432 if ( (i!=n) && (All_items[i].type==BT_JOY_BUTTON) && (All_items[i].value==code) ) {
1433 All_items[i].value = 255;
1434 kc_drawitem( &All_items[i], 0 );
1439 kc_drawitem( item, 1 );
1440 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1441 game_flush_inputs();
1444 void kc_change_mousebutton( kc_item * item )
1449 WIN(DDGRLOCK(dd_grd_curcanv));
1450 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1452 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_MBUTTON );
1453 WIN(DDGRUNLOCK(dd_grd_curcanv));
1456 game_flush_inputs();
1460 while( (k!=KEY_ESC) && (code==255))
1465 DoMessageStuff(&msg);
1471 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1474 // if ( Game_mode & GM_MULTI )
1475 // GameLoop( 0, 0 ); // Continue
1479 if (k == KEY_PRINT_SCREEN)
1480 save_screen_shot(0);
1482 kc_drawquestion( item );
1484 b = mouse_get_btns();
1485 for (i=0; i<3; i++ ) {
1491 for (i=0; i<Num_items; i++ ) {
1492 n = item - All_items;
1493 if ( (i!=n) && (All_items[i].type==BT_MOUSE_BUTTON) && (All_items[i].value==code) ) {
1494 All_items[i].value = 255;
1495 kc_drawitem( &All_items[i], 0 );
1500 kc_drawitem( item, 1 );
1501 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1502 game_flush_inputs();
1506 void kc_change_joyaxis( kc_item * item )
1517 WIN(DDGRLOCK(dd_grd_curcanv));
1518 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1520 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_JOY_AXIS );
1521 WIN(DDGRUNLOCK(dd_grd_curcanv));
1523 game_flush_inputs();
1528 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, old_axis ),
1529 joystick_read_raw_axis( JOY_ALL_AXIS, old_axis )
1532 while( (k!=KEY_ESC) && (code==255))
1537 DoMessageStuff(&msg);
1543 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1546 // if ( Game_mode & GM_MULTI )
1547 // GameLoop( 0, 0 ); // Continue
1551 if (k == KEY_PRINT_SCREEN)
1552 save_screen_shot(0);
1554 kc_drawquestion( item );
1557 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, axis ),
1558 joystick_read_raw_axis( JOY_ALL_AXIS, axis )
1561 for (i=0; i<numaxis; i++ ) {
1562 #if defined (MACINTOSH)
1563 if ( abs(axis[i]-old_axis[i])>100 ) {
1564 #elif defined(WINDOWS)
1565 if ( abs(axis[i]-old_axis[i])>1024 ) {
1567 if ( abs(axis[i]-old_axis[i])>200 ) {
1571 //old_axis[i] = axis[i];
1573 for (i=0; i<Num_items; i++ )
1575 n = item - All_items;
1576 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) )
1582 for (i=0; i<Num_items; i++ ) {
1583 n = item - All_items;
1584 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) ) {
1585 All_items[i].value = 255;
1586 kc_drawitem( &All_items[i], 0 );
1592 kc_drawitem( item, 1 );
1593 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1594 game_flush_inputs();
1598 void kc_change_mouseaxis( kc_item * item )
1604 WIN(DDGRLOCK(dd_grd_curcanv));
1605 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1607 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_MSE_AXIS );
1608 WIN(DDGRUNLOCK(dd_grd_curcanv));
1610 game_flush_inputs();
1614 mouse_get_delta( &dx, &dy );
1616 while( (k!=KEY_ESC) && (code==255))
1621 DoMessageStuff(&msg);
1627 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1630 // if ( Game_mode & GM_MULTI )
1631 // GameLoop( 0, 0 ); // Continue
1635 if (k == KEY_PRINT_SCREEN)
1636 save_screen_shot(0);
1638 kc_drawquestion( item );
1640 mouse_get_delta( &dx, &dy );
1641 if ( abs(dx)>20 ) code = 0;
1642 if ( abs(dy)>20 ) code = 1;
1645 for (i=0; i<Num_items; i++ ) {
1646 n = item - All_items;
1647 if ( (i!=n) && (All_items[i].type==BT_MOUSE_AXIS) && (All_items[i].value==code) ) {
1648 All_items[i].value = 255;
1649 kc_drawitem( &All_items[i], 0 );
1654 kc_drawitem( item, 1 );
1655 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1656 game_flush_inputs();
1661 void kc_change_invert( kc_item * item )
1663 game_flush_inputs();
1670 kc_drawitem( item, 1 );
1674 #include "screens.h"
1676 extern void gr_bm_bitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
1678 void kconfig(int n, char * title)
1681 grs_bitmap *save_bm;
1683 set_screen_mode( SCREEN_MENU );
1688 WIN(mouse_set_mode(0));
1689 WIN(dd_gr_set_current_canvas(NULL));
1691 #if defined(POLY_ACC)
1692 save_bm = gr_create_bitmap2( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h, grd_curcanv->cv_bitmap.bm_type, NULL );
1694 save_bm = gr_create_bitmap( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
1696 Assert( save_bm != NULL );
1698 WIN(DDGRLOCK(dd_grd_curcanv));
1699 gr_bm_bitblt(grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_w,
1700 0, 0, 0, 0, &grd_curcanv->cv_bitmap, save_bm );
1701 WIN(DDGRUNLOCK(dd_grd_curcanv));
1704 case 0:kconfig_sub( kc_keyboard, NUM_KEY_CONTROLS, title );break;
1705 case 1:kconfig_sub( kc_joystick, NUM_OTHER_CONTROLS, title );break;
1706 case 2:kconfig_sub( kc_mouse, NUM_OTHER_CONTROLS, title ); break;
1707 case 3:kconfig_sub( kc_superjoy, NUM_OTHER_CONTROLS, title); break;
1714 WIN(mouse_set_mode(1));
1715 WIN(dd_gr_set_current_canvas(NULL));
1716 WIN(DDGRLOCK(dd_grd_curcanv));
1717 gr_bitmap(0, 0, save_bm);
1718 WIN(DDGRUNLOCK(dd_grd_curcanv));
1719 gr_free_bitmap(save_bm);
1721 reset_cockpit(); //force cockpit redraw next time
1723 // Update save values...
1725 for (i=0; i<NUM_KEY_CONTROLS; i++ )
1726 kconfig_settings[0][i] = kc_keyboard[i].value;
1728 if ( (Config_control_type>0) && (Config_control_type<5)) {
1729 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1730 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
1731 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
1732 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1733 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
1735 else if (Config_control_type == CONTROL_WINJOYSTICK) {
1736 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1737 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
1742 void kconfig_read_fcs( int raw_axis )
1744 int raw_button, button, axis_min[4], axis_center[4], axis_max[4];
1746 if (Config_control_type!=CONTROL_THRUSTMASTER_FCS) return;
1748 joy_get_cal_vals(axis_min, axis_center, axis_max);
1750 if ( axis_max[3] > 1 )
1751 raw_button = (raw_axis*100)/axis_max[3];
1755 if ( raw_button > 88 )
1757 else if ( raw_button > 63 )
1759 else if ( raw_button > 39 )
1761 else if ( raw_button > 15 )
1766 kconfig_set_fcs_button( 19, button );
1767 kconfig_set_fcs_button( 15, button );
1768 kconfig_set_fcs_button( 11, button );
1769 kconfig_set_fcs_button( 7, button );
1773 void kconfig_set_fcs_button( int btn, int button )
1775 int state,time_down,upcount,downcount;
1776 state = time_down = upcount = downcount = 0;
1778 if ( joy_get_button_state(btn) ) {
1779 if ( btn==button ) {
1781 time_down = FrameTime;
1786 if ( btn==button ) {
1788 time_down = FrameTime;
1795 joy_set_btn_values( btn, state, time_down, downcount, upcount );
1801 fix Last_angles_p = 0;
1802 fix Last_angles_b = 0;
1803 fix Last_angles_h = 0;
1804 ubyte Last_angles_read = 0;
1806 extern int VR_sensitivity;
1808 int VR_sense_range[3] = { 25, 50, 75 };
1810 #if 0 //ndef MACINTOSH
1815 fix yaw, pitch, roll;
1818 //------ read vfx1 helmet --------
1819 if (vfx1_installed) {
1820 vfx_get_data(&yaw,&pitch,&roll,&buttons);
1821 } else if (iglasses_headset_installed) {
1822 iglasses_read_headset( &yaw, &pitch, &roll );
1823 } else if (Victor_headset_installed) {
1824 victor_read_headset_filtered( &yaw, &pitch, &roll );
1829 Use_player_head_angles = 0;
1830 if ( Last_angles_read ) {
1834 if ( (Last_angles_h < (F1_0/4) ) && (yaw > ((F1_0*3)/4) ) )
1836 else if ( (yaw < (F1_0/4) ) && (Last_angles_h > ((F1_0*3)/4) ) )
1839 Controls.pitch_time += fixmul((pitch- Last_angles_p)*VR_sense_range[VR_sensitivity],FrameTime);
1840 Controls.heading_time+= fixmul((yaw1 - Last_angles_h)*VR_sense_range[VR_sensitivity],FrameTime);
1841 Controls.bank_time += fixmul((roll - Last_angles_b)*VR_sense_range[VR_sensitivity],FrameTime);
1843 Last_angles_read = 1;
1844 Last_angles_p = pitch;
1845 Last_angles_h = yaw;
1846 Last_angles_b = roll;
1854 #define JOYSTICK_READ_TIME (F1_0/40) // Read joystick at 40 Hz.
1856 #define JOYSTICK_READ_TIME (F1_0/10) // Read joystick at 10 Hz.
1859 fix LastReadTime = 0;
1863 ubyte kc_use_external_control = 0;
1864 ubyte kc_enable_external_control = 0;
1865 ubyte kc_external_intno = 0;
1866 ext_control_info *kc_external_control = NULL;
1867 ubyte *kc_external_name = NULL;
1868 ubyte kc_external_version = 0;
1869 extern int Automap_active;
1871 void kconfig_init_external_controls(int intno, int address)
1874 kc_external_intno = intno;
1875 kc_external_control = (ext_control_info *)address;
1876 kc_use_external_control = 1;
1877 kc_enable_external_control = 1;
1879 i = args_find ( "-xname" );
1881 kc_external_name = Args[i+1];
1883 kc_external_name = "External Controller";
1885 for (i=0;i<strlen (kc_external_name);i++)
1886 if (kc_external_name[i]=='_')
1887 kc_external_name[i]=' ';
1889 i = args_find ( "-xver" );
1891 kc_external_version = atoi(Args[i+1]);
1893 printf( "%s int: 0x%x, data: 0x%x, ver:%d\n", kc_external_name, kc_external_intno, kc_external_control, kc_external_version );
1897 #if !defined(MACINTOSH)
1898 /*void kconfig_read_external_controls()
1902 if ( !kc_enable_external_control && !CybermouseActive)
1905 if ( kc_external_version == 0 )
1906 memset( kc_external_control, 0, sizeof(control_info) );
1907 else if ( kc_external_version > 0 ) {
1908 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 );
1909 if ( kc_external_version > 1 ) {
1910 // Write ship pos and angles to external controls...
1911 ubyte *temp_ptr = (ubyte *)kc_external_control;
1912 vms_vector *ship_pos;
1913 vms_matrix *ship_orient;
1914 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
1915 temp_ptr += sizeof(control_info)+sizeof(vms_angvec) + 64;
1916 ship_pos = (vms_vector *)temp_ptr;
1917 temp_ptr += sizeof(vms_vector);
1918 ship_orient = (vms_matrix *)temp_ptr;
1919 // Fill in ship postion...
1920 *ship_pos = Objects[Players[Player_num].objnum].pos;
1921 // Fill in ship orientation...
1922 *ship_orient = Objects[Players[Player_num].objnum].orient;
1926 if ( Automap_active ) // (If in automap...)
1927 kc_external_control->automap_state = 1;
1928 memset(&r,0,sizeof(r));
1932 if (!CybermouseActive)
1933 int386 ( kc_external_intno, &r, &r); // Read external info...
1935 // ReadOWL (kc_external_control);
1939 if ( Player_num > -1 ) {
1940 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
1941 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
1942 Auto_leveling_on = 0;
1944 if ( kc_external_version > 0 ) {
1945 vms_matrix tempm, ViewMatrix;
1946 vms_angvec * Kconfig_abs_movement;
1949 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
1951 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
1952 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
1953 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
1954 Objects[Players[Player_num].objnum].orient = ViewMatrix;
1956 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
1957 if (oem_message[0] != '\0' )
1958 HUD_init_message( oem_message );
1962 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
1963 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
1964 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
1965 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
1966 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
1967 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
1968 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
1969 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
1970 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
1971 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
1972 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
1973 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
1974 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
1975 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
1976 Controls.automap_down_count += kc_external_control->automap_down_count;
1977 Controls.automap_state |= kc_external_control->automap_state;
1982 void controls_read_all_win()
1985 int slide_on, bank_on;
1989 int raw_joy_axis[7];
1991 fix k0, k1, k2, k3, kp;
1992 fix k4, k5, k6, k7, kh;
1993 ubyte channel_masks;
1994 int use_mouse, use_joystick;
1997 if (Game_turbo_mode)
2001 fix temp = Controls.heading_time;
2002 fix temp1 = Controls.pitch_time;
2003 memset( &Controls, 0, sizeof(control_info) );
2004 Controls.heading_time = temp;
2005 Controls.pitch_time = temp1;
2010 ctime = timer_get_fixed_seconds();
2012 // DO JOYSTICK (X,Y,Z R,U,V)
2013 // ----------------------------------------------------------------------------
2014 if ( (LastReadTime + JOYSTICK_READ_TIME) > ctime ) {
2015 if ((ctime < 0) && (LastReadTime > 0))
2016 LastReadTime = ctime;
2018 } else if ((Config_control_type==CONTROL_WINJOYSTICK)) {
2019 LastReadTime = ctime;
2020 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, raw_joy_axis );
2022 for (i=0; i<7; i++ ) {
2023 if (channel_masks&(1<<i)) {
2024 int joy_null_value = 28;
2026 // DO POV if joystick has a hat.
2027 // --------------------------------------------------------------------
2029 joydefsw_do_winjoybutton(raw_joy_axis);
2033 // --------------------------------------------------------------------
2034 // mprintf((0, "(%d)=%d,", i, raw_joy_axis[i]));
2035 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2036 // mprintf((0, "%d ",raw_joy_axis[i]));
2037 // if (i%2) mprintf((0,"\n"));
2040 if (kc_superjoy[23].value==i) // If this is the throttle
2041 joy_null_value = 32; // Then use a larger dead-zone
2043 if (raw_joy_axis[i] > (joy_null_value-2))
2044 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2045 else if (raw_joy_axis[i] < -(joy_null_value+2))
2046 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2048 raw_joy_axis[i] = 0;
2049 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2058 for (i=0; i<6; i++ )
2064 // ----------------------------------------------------------------------------
2065 if (Config_control_type==5) {
2066 mouse_get_delta( &dx, &dy );
2067 mouse_axis[0] = (dx*FrameTime)/35;
2068 mouse_axis[1] = (dy*FrameTime)/25;
2069 mouse_buttons = mouse_get_btns();
2070 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2079 //------------- Read slide_on -------------
2082 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
2083 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
2085 if ((use_joystick)&&(kc_superjoy[5].value<255)) slide_on |= joy_get_button_state( kc_superjoy[5].value );
2087 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
2089 //------------- Read bank_on ---------------
2092 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
2093 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
2095 if ( (use_joystick)&&(kc_superjoy[10].value < 255 )) bank_on |= joy_get_button_state( kc_superjoy[10].value );
2097 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
2099 //------------ Read pitch_time -----------
2101 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2103 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
2104 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
2105 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
2106 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
2109 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
2110 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
2111 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
2112 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
2115 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2116 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
2117 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
2121 Controls.pitch_time = 0;
2123 if (Controls.pitch_time < 0)
2124 Controls.pitch_time = 0;
2126 if (Controls.pitch_time > 0)
2127 Controls.pitch_time = 0;
2128 Controls.pitch_time += kp;
2131 if ( (use_joystick)&&(kc_superjoy[13].value < 255 )) {
2132 if ( !kc_superjoy[14].value ) // If not inverted...
2133 Controls.pitch_time -= (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2135 Controls.pitch_time += (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2139 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
2140 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
2141 if ( !kc_mouse[14].value ) // If not inverted...
2142 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2144 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2147 Controls.pitch_time = 0;
2151 //----------- Read vertical_thrust_time -----------------
2154 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
2155 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
2156 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
2157 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
2160 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
2161 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
2162 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
2163 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
2166 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2167 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
2168 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
2172 if ((use_joystick)&&( kc_superjoy[13].value < 255 )) {
2173 if ( !kc_superjoy[14].value ) // If not inverted...
2174 Controls.vertical_thrust_time += joy_axis[kc_superjoy[13].value];
2176 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[13].value];
2180 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
2181 if ( !kc_mouse[14].value ) // If not inverted...
2182 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
2184 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
2189 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
2190 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
2191 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
2192 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
2195 if ((use_joystick)&&( kc_superjoy[19].value < 255 )) {
2196 if ( !kc_superjoy[20].value ) // If not inverted...
2197 Controls.vertical_thrust_time += joy_axis[kc_superjoy[19].value];
2199 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[19].value];
2202 // From joystick buttons
2203 if ( (use_joystick)&&(kc_superjoy[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_superjoy[8].value );
2204 if ( (use_joystick)&&(kc_superjoy[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_superjoy[9].value );
2206 // From mouse buttons
2207 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
2208 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
2211 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
2212 if ( !kc_mouse[20].value ) // If not inverted...
2213 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
2215 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
2219 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2220 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
2221 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
2224 //---------- Read heading_time -----------
2226 if (!slide_on && !bank_on) {
2227 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2229 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
2230 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
2231 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
2232 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
2235 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
2236 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
2237 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
2238 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
2241 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2242 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
2243 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
2247 Controls.heading_time = 0;
2249 if (Controls.heading_time < 0)
2250 Controls.heading_time = 0;
2252 if (Controls.heading_time > 0)
2253 Controls.heading_time = 0;
2254 Controls.heading_time += kh;
2257 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2258 if ( !kc_superjoy[16].value ) // If not inverted...
2259 Controls.heading_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2261 Controls.heading_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2265 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2266 if ( !kc_mouse[16].value ) // If not inverted...
2267 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2269 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2272 Controls.heading_time = 0;
2275 //----------- Read sideways_thrust_time -----------------
2278 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2279 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2280 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2281 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2284 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
2285 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
2286 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
2287 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
2290 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2291 if ( !kc_superjoy[16].value ) // If not inverted...
2292 Controls.sideways_thrust_time += joy_axis[kc_superjoy[15].value];
2294 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[15].value];
2298 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2299 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
2300 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
2304 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2305 if ( !kc_mouse[16].value ) // If not inverted...
2306 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
2308 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
2313 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
2314 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
2315 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
2316 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
2319 if ( (use_joystick)&&(kc_superjoy[17].value < 255 )) {
2320 if ( !kc_superjoy[18].value ) // If not inverted...
2321 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[17].value];
2323 Controls.sideways_thrust_time += joy_axis[kc_superjoy[17].value];
2326 // From joystick buttons
2327 if ( (use_joystick)&&(kc_superjoy[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_superjoy[6].value );
2328 if ( (use_joystick)&&(kc_superjoy[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_superjoy[7].value );
2330 // From mouse buttons
2331 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
2332 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
2335 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
2336 if ( !kc_mouse[18].value ) // If not inverted...
2337 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
2339 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
2342 //----------- Read bank_time -----------------
2345 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2346 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2347 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2348 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2351 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
2352 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
2353 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
2354 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
2357 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2358 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
2359 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
2363 if ( (use_joystick)&&(kc_superjoy[15].value < 255) ) {
2364 if ( !kc_superjoy[16].value ) // If not inverted...
2365 Controls.bank_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2367 Controls.bank_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2371 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2372 if ( !kc_mouse[16].value ) // If not inverted...
2373 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2375 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2380 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
2381 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
2382 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
2383 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
2386 if ( (use_joystick)&&(kc_superjoy[21].value < 255) ) {
2387 if ( !kc_superjoy[22].value ) // If not inverted...
2388 Controls.bank_time -= joy_axis[kc_superjoy[21].value];
2390 Controls.bank_time += joy_axis[kc_superjoy[21].value];
2393 // From joystick buttons
2394 if ( (use_joystick)&&(kc_superjoy[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_superjoy[11].value );
2395 if ( (use_joystick)&&(kc_superjoy[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_superjoy[12].value );
2397 // From mouse buttons
2398 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
2399 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
2402 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
2403 if ( !kc_mouse[22].value ) // If not inverted...
2404 Controls.bank_time += mouse_axis[kc_mouse[21].value];
2406 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
2410 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2411 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
2412 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
2415 //----------- Read forward_thrust_time -------------
2418 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
2419 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
2420 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
2421 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
2424 if ( (use_joystick)&&(kc_superjoy[23].value < 255 )) {
2425 if ( !kc_superjoy[24].value ) // If not inverted...
2426 Controls.forward_thrust_time -= joy_axis[kc_superjoy[23].value];
2428 Controls.forward_thrust_time += joy_axis[kc_superjoy[23].value];
2431 // From joystick buttons
2432 if ( (use_joystick)&&(kc_superjoy[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_superjoy[2].value );
2433 if ( (use_joystick)&&(kc_superjoy[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_superjoy[3].value );
2436 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
2437 if ( !kc_mouse[24].value ) // If not inverted...
2438 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
2440 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
2443 // From mouse buttons
2444 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
2445 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
2447 //----------- Read afterburner_state -------------
2450 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
2451 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
2453 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
2455 if ( (use_joystick)&&(kc_superjoy[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_superjoy[27].value);
2457 //-------Read headlight key--------------------------
2458 if (kc_keyboard[52].value < 255 )
2459 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
2460 if (kc_keyboard[53].value < 255 )
2461 Controls.headlight_count=key_down_count(kc_keyboard[53].value);
2462 if ((use_joystick)&&(kc_superjoy[30].value < 255 ))
2463 Controls.headlight_count=joy_get_button_down_cnt(kc_superjoy[30].value);
2465 //--------Read Cycle Primary Key------------------
2467 if (kc_keyboard[48].value<255)
2468 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
2469 if (kc_keyboard[49].value<255)
2470 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
2471 if ((use_joystick)&&(kc_superjoy[28].value < 255 ))
2472 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_superjoy[28].value);
2474 //--------Read Cycle Secondary Key------------------
2476 if (kc_keyboard[50].value<255)
2477 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
2478 if (kc_keyboard[51].value<255)
2479 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
2480 if ((use_joystick)&&(kc_superjoy[29].value < 255 ))
2481 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_superjoy[29].value);
2483 //--------Read Toggle Bomb key----------------------
2485 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
2487 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
2489 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
2490 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
2492 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2493 HUD_init_message ("No bombs available!");
2497 if (Players[Player_num].secondary_ammo[bomb]==0)
2499 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2500 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
2504 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
2505 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
2510 //---------Read Energy->Shield key----------
2512 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
2513 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
2514 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
2515 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
2517 //----------- Read fire_primary_down_count
2518 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
2519 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
2520 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_superjoy[0].value);
2521 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
2523 //----------- Read fire_primary_state
2524 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
2525 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
2526 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_superjoy[0].value);
2527 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
2529 //----------- Read fire_secondary_down_count
2530 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
2531 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
2532 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_superjoy[1].value);
2533 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
2535 //----------- Read fire_secondary_state
2536 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
2537 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
2538 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_superjoy[1].value);
2539 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
2541 //----------- Read fire_flare_down_count
2542 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
2543 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
2544 if ((use_joystick)&&(kc_superjoy[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_superjoy[4].value);
2545 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
2547 //----------- Read drop_bomb_down_count
2548 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
2549 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
2550 if ((use_joystick)&&(kc_superjoy[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_superjoy[26].value);
2551 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
2553 //----------- Read rear_view_down_count
2554 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
2555 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
2556 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_superjoy[25].value);
2557 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
2559 //----------- Read rear_view_down_state
2560 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
2561 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
2562 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_superjoy[25].value);
2563 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
2565 //----------- Read automap_down_count
2566 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
2567 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
2569 //----------- Read automap_state
2570 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
2571 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
2573 //----------- Read stupid-cruise-control-type of throttle.
2575 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
2576 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
2577 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
2578 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
2579 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
2581 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
2584 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
2585 if (Cruise_speed < 0 ) Cruise_speed = 0;
2587 if (Controls.forward_thrust_time==0)
2588 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
2591 //read_head_tracker();
2593 // Read external controls
2594 if (kc_use_external_control || CybermouseActive)
2595 kconfig_read_external_controls();
2597 //----------- Clamp values between -FrameTime and FrameTime
2598 if (FrameTime > F1_0 )
2599 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
2601 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
2602 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
2603 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
2604 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
2605 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
2606 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
2607 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
2609 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
2610 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
2611 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
2612 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
2613 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
2614 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
2615 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
2618 //--------- Don't do anything if in debug mode
2620 if ( keyd_pressed[KEY_DELETE] ) {
2621 memset( &Controls, 0, sizeof(control_info) );
2628 fix Next_toggle_time[3]={0,0,0};
2630 int allowed_to_toggle(int i)
2632 //used for keeping tabs of when its ok to toggle headlight,primary,and secondary
2634 if (Next_toggle_time[i] > GameTime)
2635 if (Next_toggle_time[i] < GameTime + (F1_0/8)) // In case time is bogus, never wait > 1 second.
2638 Next_toggle_time[i] = GameTime + (F1_0/8);
2645 void controls_read_all()
2648 int slide_on, bank_on;
2653 int raw_joy_axis[4];
2655 fix k0, k1, k2, k3, kp;
2656 fix k4, k5, k6, k7, kh;
2657 ubyte channel_masks;
2658 int use_mouse, use_joystick;
2661 if (Game_turbo_mode)
2665 fix temp = Controls.heading_time;
2666 fix temp1 = Controls.pitch_time;
2667 memset( &Controls, 0, sizeof(control_info) );
2668 Controls.heading_time = temp;
2669 Controls.pitch_time = temp1;
2674 ctime = timer_get_fixed_seconds();
2676 //--------- Read Joystick -----------
2678 if ( (LastReadTime + JOYSTICK_READ_TIME > ctime) && (Config_control_type!=CONTROL_THRUSTMASTER_FCS) ) {
2679 if ((ctime < 0) && (LastReadTime > 0))
2680 LastReadTime = ctime;
2682 } else if ((Config_control_type>0) && (Config_control_type<5) ) {
2683 LastReadTime = ctime;
2684 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
2686 for (i=0; i<4; i++ ) {
2687 if (channel_masks&(1<<i)) {
2688 int joy_null_value = 10;
2690 if ( (i==3) && (Config_control_type==CONTROL_THRUSTMASTER_FCS) ) {
2691 kconfig_read_fcs( raw_joy_axis[i] );
2693 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2695 if (kc_joystick[23].value==i) // If this is the throttle
2696 joy_null_value = 20; // Then use a larger dead-zone
2698 if (raw_joy_axis[i] > joy_null_value)
2699 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2700 else if (raw_joy_axis[i] < -joy_null_value)
2701 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2703 raw_joy_axis[i] = 0;
2704 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2712 for (i=0; i<4; i++ )
2717 //--------- Read Joystick -----------
2718 if ((Config_control_type>0) && (Config_control_type<5) ) {
2719 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
2720 for (i=0; i<4; i++ ) {
2721 if (channel_masks&(1<<i)) {
2722 int joy_null_value = 10;
2724 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2726 if (kc_joystick[23].value==i) // If this is the throttle
2727 joy_null_value = 20; // Then use a larger dead-zone
2729 if (raw_joy_axis[i] > joy_null_value)
2730 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2731 else if (raw_joy_axis[i] < -joy_null_value)
2732 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2734 raw_joy_axis[i] = 0;
2735 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2742 for (i=0; i<4; i++ )
2746 #endif // ifndef MACINTOSH
2748 if (Config_control_type==5 && !CybermouseActive) {
2749 //--------- Read Mouse -----------
2750 mouse_get_delta( &dx, &dy );
2751 mouse_axis[0] = (dx*FrameTime)/35;
2752 mouse_axis[1] = (dy*FrameTime)/25;
2753 mouse_buttons = mouse_get_btns();
2754 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2756 } else if (Config_control_type==6 && !CybermouseActive) {
2757 //--------- Read Cyberman -----------
2758 mouse_get_cyberman_pos(&idx,&idy );
2759 mouse_axis[0] = (idx*FrameTime)/128;
2760 mouse_axis[1] = (idy*FrameTime)/128;
2761 mouse_buttons = mouse_get_btns();
2763 } else if (CybermouseActive) {
2764 // ReadOWL (kc_external_control);
2765 // CybermouseAdjust();
2773 //------------- Read slide_on -------------
2776 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
2777 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
2779 if ((use_joystick)&&(kc_joystick[5].value<255)) slide_on |= joy_get_button_state( kc_joystick[5].value );
2781 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
2783 //------------- Read bank_on ---------------
2786 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
2787 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
2789 if ( (use_joystick)&&(kc_joystick[10].value < 255 )) bank_on |= joy_get_button_state( kc_joystick[10].value );
2791 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
2793 //------------ Read pitch_time -----------
2795 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2797 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
2798 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
2799 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
2800 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
2803 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
2804 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
2805 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
2806 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
2809 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2810 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
2811 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
2815 Controls.pitch_time = 0;
2817 if (Controls.pitch_time < 0)
2818 Controls.pitch_time = 0;
2820 if (Controls.pitch_time > 0)
2821 Controls.pitch_time = 0;
2822 Controls.pitch_time += kp;
2825 if ( (use_joystick)&&(kc_joystick[13].value < 255 )) {
2826 if ( !kc_joystick[14].value ) // If not inverted...
2827 Controls.pitch_time -= (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
2829 Controls.pitch_time += (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
2833 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
2834 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
2835 if ( !kc_mouse[14].value ) // If not inverted...
2836 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2838 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2841 Controls.pitch_time = 0;
2845 //----------- Read vertical_thrust_time -----------------
2848 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
2849 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
2850 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
2851 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
2854 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
2855 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
2856 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
2857 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
2860 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2861 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
2862 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
2866 if ((use_joystick)&&( kc_joystick[13].value < 255 )) {
2867 if ( !kc_joystick[14].value ) // If not inverted...
2868 Controls.vertical_thrust_time += joy_axis[kc_joystick[13].value];
2870 Controls.vertical_thrust_time -= joy_axis[kc_joystick[13].value];
2874 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
2875 if ( !kc_mouse[14].value ) // If not inverted...
2876 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
2878 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
2883 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
2884 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
2885 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
2886 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
2889 if ((use_joystick)&&( kc_joystick[19].value < 255 )) {
2890 if ( !kc_joystick[20].value ) // If not inverted...
2891 Controls.vertical_thrust_time += joy_axis[kc_joystick[19].value];
2893 Controls.vertical_thrust_time -= joy_axis[kc_joystick[19].value];
2896 // From joystick buttons
2897 if ( (use_joystick)&&(kc_joystick[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_joystick[8].value );
2898 if ( (use_joystick)&&(kc_joystick[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_joystick[9].value );
2900 // From mouse buttons
2901 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
2902 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
2905 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
2906 if ( !kc_mouse[20].value ) // If not inverted...
2907 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
2909 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
2913 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2914 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
2915 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
2918 //---------- Read heading_time -----------
2920 if (!slide_on && !bank_on) {
2921 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2923 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
2924 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
2925 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
2926 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
2929 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
2930 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
2931 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
2932 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
2935 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2936 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
2937 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
2941 Controls.heading_time = 0;
2943 if (Controls.heading_time < 0)
2944 Controls.heading_time = 0;
2946 if (Controls.heading_time > 0)
2947 Controls.heading_time = 0;
2948 Controls.heading_time += kh;
2951 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
2952 if ( !kc_joystick[16].value ) // If not inverted...
2953 Controls.heading_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
2955 Controls.heading_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
2959 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2960 if ( !kc_mouse[16].value ) // If not inverted...
2961 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2963 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2966 Controls.heading_time = 0;
2969 //----------- Read sideways_thrust_time -----------------
2972 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2973 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2974 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2975 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2978 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
2979 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
2980 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
2981 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
2984 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
2985 if ( !kc_joystick[16].value ) // If not inverted...
2986 Controls.sideways_thrust_time += joy_axis[kc_joystick[15].value];
2988 Controls.sideways_thrust_time -= joy_axis[kc_joystick[15].value];
2992 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2993 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
2994 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
2998 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2999 if ( !kc_mouse[16].value ) // If not inverted...
3000 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
3002 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
3007 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
3008 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
3009 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
3010 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
3013 if ( (use_joystick)&&(kc_joystick[17].value < 255 )) {
3014 if ( !kc_joystick[18].value ) // If not inverted...
3015 Controls.sideways_thrust_time -= joy_axis[kc_joystick[17].value];
3017 Controls.sideways_thrust_time += joy_axis[kc_joystick[17].value];
3020 // From joystick buttons
3021 if ( (use_joystick)&&(kc_joystick[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_joystick[6].value );
3022 if ( (use_joystick)&&(kc_joystick[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_joystick[7].value );
3024 // From mouse buttons
3025 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
3026 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
3029 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
3030 if ( !kc_mouse[18].value ) // If not inverted...
3031 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
3033 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
3036 //----------- Read bank_time -----------------
3039 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3040 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3041 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3042 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3045 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
3046 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
3047 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
3048 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
3051 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3052 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
3053 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
3057 if ( (use_joystick)&&(kc_joystick[15].value < 255) ) {
3058 if ( !kc_joystick[16].value ) // If not inverted...
3059 Controls.bank_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3061 Controls.bank_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3065 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3066 if ( !kc_mouse[16].value ) // If not inverted...
3067 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3069 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3074 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
3075 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
3076 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
3077 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
3080 if ( (use_joystick)&&(kc_joystick[21].value < 255) ) {
3081 if ( !kc_joystick[22].value ) // If not inverted...
3082 Controls.bank_time -= joy_axis[kc_joystick[21].value];
3084 Controls.bank_time += joy_axis[kc_joystick[21].value];
3087 // From joystick buttons
3088 if ( (use_joystick)&&(kc_joystick[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_joystick[11].value );
3089 if ( (use_joystick)&&(kc_joystick[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_joystick[12].value );
3091 // From mouse buttons
3092 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
3093 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
3096 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
3097 if ( !kc_mouse[22].value ) // If not inverted...
3098 Controls.bank_time += mouse_axis[kc_mouse[21].value];
3100 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
3104 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3105 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
3106 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
3109 //----------- Read forward_thrust_time -------------
3112 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
3113 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
3114 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
3115 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
3118 if ( (use_joystick)&&(kc_joystick[23].value < 255 )) {
3119 if ( !kc_joystick[24].value ) // If not inverted...
3120 Controls.forward_thrust_time -= joy_axis[kc_joystick[23].value];
3122 Controls.forward_thrust_time += joy_axis[kc_joystick[23].value];
3125 // From joystick buttons
3126 if ( (use_joystick)&&(kc_joystick[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_joystick[2].value );
3127 if ( (use_joystick)&&(kc_joystick[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_joystick[3].value );
3130 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
3131 if ( !kc_mouse[24].value ) // If not inverted...
3132 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
3134 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
3137 // From mouse buttons
3138 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
3139 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
3141 //----------- Read afterburner_state -------------
3144 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
3145 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
3147 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
3149 if ( (use_joystick)&&(kc_joystick[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_joystick[27].value);
3151 //-------Read headlight key--------------------------
3153 if (kc_keyboard[52].value < 255 )
3154 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
3155 if (kc_keyboard[53].value < 255 )
3156 Controls.headlight_count+=key_down_count(kc_keyboard[53].value);
3157 if ((use_joystick)&&(kc_joystick[30].value < 255 ))
3158 Controls.headlight_count+=joy_get_button_down_cnt(kc_joystick[30].value);
3160 //--------Read Cycle Primary Key------------------
3162 if (kc_keyboard[48].value<255)
3163 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
3164 if (kc_keyboard[49].value<255)
3165 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
3166 if ((use_joystick)&&(kc_joystick[28].value < 255 ))
3167 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_joystick[28].value);
3170 //--------Read Cycle Secondary Key------------------
3172 if (kc_keyboard[50].value<255)
3173 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
3174 if (kc_keyboard[51].value<255)
3175 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
3176 if ((use_joystick)&&(kc_joystick[29].value < 255 ))
3177 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_joystick[29].value);
3179 //--------Read Toggle Bomb key----------------------
3181 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
3183 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
3185 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
3186 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
3188 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3189 HUD_init_message ("No bombs available!");
3193 if (Players[Player_num].secondary_ammo[bomb]==0)
3195 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3196 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
3200 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
3201 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
3206 //---------Read Energy->Shield key----------
3208 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
3209 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
3210 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
3211 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
3213 //----------- Read fire_primary_down_count
3214 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
3215 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
3216 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_joystick[0].value);
3217 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
3219 //----------- Read fire_primary_state
3220 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
3221 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
3222 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_joystick[0].value);
3223 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
3225 //----------- Read fire_secondary_down_count
3226 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
3227 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
3228 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_joystick[1].value);
3229 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
3231 //----------- Read fire_secondary_state
3232 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
3233 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
3234 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_joystick[1].value);
3235 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
3237 //----------- Read fire_flare_down_count
3238 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
3239 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
3240 if ((use_joystick)&&(kc_joystick[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_joystick[4].value);
3241 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
3243 //----------- Read drop_bomb_down_count
3244 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
3245 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
3246 if ((use_joystick)&&(kc_joystick[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_joystick[26].value);
3247 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
3249 //----------- Read rear_view_down_count
3250 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
3251 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
3252 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_joystick[25].value);
3253 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
3255 //----------- Read rear_view_down_state
3256 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
3257 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
3258 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_joystick[25].value);
3259 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
3261 //----------- Read automap_down_count
3262 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
3263 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
3265 //----------- Read automap_state
3266 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
3267 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
3269 //----------- Read stupid-cruise-control-type of throttle.
3271 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
3272 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
3273 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
3274 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
3275 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
3277 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
3280 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
3281 if (Cruise_speed < 0 ) Cruise_speed = 0;
3283 if (Controls.forward_thrust_time==0)
3284 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
3287 #if !defined(MACINTOSH)
3288 //read_head_tracker();
3290 // Read external controls
3291 if (kc_use_external_control || CybermouseActive)
3292 kconfig_read_external_controls();
3295 //----------- Clamp values between -FrameTime and FrameTime
3296 if (FrameTime > F1_0 )
3297 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
3299 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
3300 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
3301 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
3302 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
3303 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
3304 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
3305 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
3307 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
3308 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
3309 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
3310 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
3311 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
3312 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
3313 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
3316 //--------- Don't do anything if in debug mode
3318 if ( keyd_pressed[KEY_DELETE] ) {
3319 memset( &Controls, 0, sizeof(control_info) );
3325 void reset_cruise(void)
3331 void kc_set_controls()
3335 for (i=0; i<NUM_KEY_CONTROLS; i++ )
3336 kc_keyboard[i].value = kconfig_settings[0][i];
3338 if ( (Config_control_type>0) && (Config_control_type<5)) {
3339 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3340 kc_joystick[i].value = kconfig_settings[Config_control_type][i];
3341 if (kc_joystick[i].type == BT_INVERT ) {
3342 if (kc_joystick[i].value!=1)
3343 kc_joystick[i].value = 0;
3344 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
3347 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
3348 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3349 kc_mouse[i].value = kconfig_settings[Config_control_type][i];
3350 if (kc_mouse[i].type == BT_INVERT ) {
3351 if (kc_mouse[i].value!=1)
3352 kc_mouse[i].value = 0;
3353 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
3356 } else if (Config_control_type == CONTROL_WINJOYSTICK) {
3357 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3358 kc_superjoy[i].value = kconfig_settings[Config_control_type][i];
3359 if (kc_superjoy[i].type == BT_INVERT ) {
3360 if (kc_superjoy[i].value!=1)
3361 kc_superjoy[i].value = 0;
3362 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
3368 #if 0 //ndef MACINTOSH // no mac support for vr headset
3370 void kconfig_center_headset()
3374 vfx_center_headset();
3376 // } else if (iglasses_headset_installed) {
3377 // } else if (Victor_headset_installed) {
3383 #endif // end of #ifndef MACINTOSH for kconfig_center_headset
3385 void CybermouseAdjust ()
3387 /* if ( Player_num > -1 ) {
3388 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3389 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3390 Auto_leveling_on = 0;
3392 if ( kc_external_version > 0 ) {
3393 vms_matrix tempm, ViewMatrix;
3394 vms_angvec * Kconfig_abs_movement;
3397 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
3399 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3400 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3401 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3402 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3404 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3405 if (oem_message[0] != '\0' )
3406 HUD_init_message( oem_message );
3410 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3411 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3412 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3413 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3414 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3415 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3416 // Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3417 // Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3418 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3419 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3420 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3421 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3422 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3423 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3424 // Controls.automap_down_count += kc_external_control->automap_down_count;
3425 // Controls.automap_state |= kc_external_control->automap_state;
3428 char GetKeyValue (char key)
3430 mprintf ((0,"Returning %c!\n",kc_keyboard[key].value));
3431 return (kc_keyboard[key].value);
3434 #if !defined(MACINTOSH)
3437 extern object *obj_find_first_of_type (int);
3438 void kconfig_read_external_controls()
3443 if ( !kc_enable_external_control ) return;
3445 if ( kc_external_version == 0 )
3446 memset( kc_external_control, 0, sizeof(ext_control_info));
3447 else if ( kc_external_version > 0 ) {
3449 if (kc_external_version>=4)
3450 memset( kc_external_control, 0, sizeof(advanced_ext_control_info));
3451 else if (kc_external_version>0)
3452 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 );
3453 else if (kc_external_version>2)
3454 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof(vms_matrix) +4 );
3456 if ( kc_external_version > 1 ) {
3457 // Write ship pos and angles to external controls...
3458 ubyte *temp_ptr = (ubyte *)kc_external_control;
3459 vms_vector *ship_pos;
3460 vms_matrix *ship_orient;
3461 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
3462 temp_ptr += sizeof(ext_control_info) + sizeof(vms_angvec) + 64;
3463 ship_pos = (vms_vector *)temp_ptr;
3464 temp_ptr += sizeof(vms_vector);
3465 ship_orient = (vms_matrix *)temp_ptr;
3466 // Fill in ship postion...
3467 *ship_pos = Objects[Players[Player_num].objnum].pos;
3468 // Fill in ship orientation...
3469 *ship_orient = Objects[Players[Player_num].objnum].orient;
3471 if (kc_external_version>=4)
3473 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3475 temp_ptr->headlight_state=(Players[Player_num].flags & PLAYER_FLAGS_HEADLIGHT_ON);
3476 temp_ptr->primary_weapon_flags=Players[Player_num].primary_weapon_flags;
3477 temp_ptr->secondary_weapon_flags=Players[Player_num].secondary_weapon_flags;
3478 temp_ptr->current_primary_weapon=Primary_weapon;
3479 temp_ptr->current_secondary_weapon=Secondary_weapon;
3481 temp_ptr->current_guidebot_command=Escort_goal_object;
3483 temp_ptr->force_vector=ExtForceVec;
3484 temp_ptr->force_matrix=ExtApplyForceMatrix;
3486 temp_ptr->joltinfo[i]=ExtJoltInfo[i];
3488 temp_ptr->x_vibrate_info[i]=ExtXVibrateInfo[i];
3489 temp_ptr->x_vibrate_clear=ExtXVibrateClear;
3490 temp_ptr->game_status=ExtGameStatus;
3492 memset ((void *)&ExtForceVec,0,sizeof(vms_vector));
3493 memset ((void *)&ExtApplyForceMatrix,0,sizeof(vms_matrix));
3498 ExtXVibrateInfo[i]=0;
3503 if ( Automap_active ) // (If in automap...)
3504 kc_external_control->automap_state = 1;
3505 //memset(&r,0,sizeof(r));
3507 #if !defined WINDOWS && !defined __ENV_LINUX__ && !defined __ENV_DJGPP__
3509 int386 ( kc_external_intno, &r, &r); // Read external info...
3513 if ( Player_num > -1 ) {
3514 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3515 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3516 Auto_leveling_on = 0;
3518 if ( kc_external_version > 0 ) {
3519 vms_matrix tempm, ViewMatrix;
3520 vms_angvec * Kconfig_abs_movement;
3523 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(ext_control_info));
3525 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3526 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3527 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3528 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3530 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3531 if (oem_message[0] != '\0' )
3532 HUD_init_message( oem_message );
3536 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3537 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3538 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3539 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3540 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3541 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3542 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3543 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3544 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3545 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3546 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3547 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3548 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3549 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3550 Controls.automap_down_count += kc_external_control->automap_down_count;
3551 Controls.automap_state |= kc_external_control->automap_state;
3553 if (kc_external_version>=3)
3555 ubyte *temp_ptr = (ubyte *)kc_external_control;
3556 temp_ptr += (sizeof(ext_control_info) + sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof (vms_matrix));
3559 Controls.cycle_primary_count=(*(temp_ptr));
3561 Controls.cycle_secondary_count=(*(temp_ptr+1));
3564 Controls.afterburner_state=(*(temp_ptr+2));
3566 Controls.headlight_count=(*(temp_ptr+3));
3568 if (kc_external_version>=4)
3571 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3574 if (temp_ptr->keyboard[i])
3577 if (temp_ptr->Reactor_blown)
3579 if (Game_mode & GM_MULTI)
3580 net_destroy_controlcen (obj_find_first_of_type (OBJ_CNTRLCEN));
3582 do_controlcen_destroyed_stuff(obj_find_first_of_type (OBJ_CNTRLCEN));