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.
19 static char rcsid[] = "$Id: kconfig.c,v 1.10 2001-10-24 09:30:02 bradleyb Exp $";
32 #include "pa_enabl.h" //$$POLY_ACC
78 ubyte ExtGameStatus=1;
80 vms_vector ExtForceVec;
81 vms_matrix ExtApplyForceMatrix;
83 int ExtJoltInfo[3]={0,0,0};
84 int ExtXVibrateInfo[2]={0,0};
85 int ExtYVibrateInfo[2]={0,0};
86 ubyte ExtXVibrateClear=0;
87 ubyte ExtYVibrateClear=0;
89 #define TABLE_CREATION 1
91 // Array used to 'blink' the cursor while waiting for a keypress.
92 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 };
94 //char * invert_text[2] = { "N", "Y" };
95 //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" };
96 //char * joyaxis_text[4] = { "X1", "Y1", "X2", "Y2" };
97 //char * mouseaxis_text[2] = { "L/R", "F/B" };
98 //char * mousebutton_text[3] = { "Left", "Right", "Mid" };
100 int invert_text[2] = { TNUM_N, TNUM_Y };
103 int joybutton_text[28] =
104 { TNUM_BTN_1, TNUM_BTN_2, TNUM_BTN_3, TNUM_BTN_4,
108 TNUM_HAT_L, TNUM_HAT_R, TNUM_HAT_U, TNUM_HAT_D,
112 int joyaxis_text[7] = { TNUM_X1, TNUM_Y1, TNUM_Z1, TNUM_UN, TNUM_P1,TNUM_R1,TNUM_YA1 };
114 int joybutton_text[28] =
115 { TNUM_BTN_1, TNUM_BTN_2, TNUM_BTN_3, TNUM_BTN_4,
116 -1, TNUM_TRIG, TNUM_LEFT, TNUM_HAT_L,
117 TNUM_RIGHT, -1, TNUM_HAT2_D, TNUM_HAT_R,
118 TNUM_MID, -1, TNUM_HAT2_R, TNUM_HAT_U,
119 TNUM_HAT2_L, -1, TNUM_HAT2_U, TNUM_HAT_D,
120 TNUM_TRIG, TNUM_LEFT, TNUM_RIGHT, -1,
121 TNUM_UP, TNUM_DOWN, TNUM_LEFT, TNUM_RIGHT };
123 int joyaxis_text[7] = { TNUM_X1, TNUM_Y1, TNUM_Z1, TNUM_UN, TNUM_P1,TNUM_R1,TNUM_YA1 };
124 // int joyaxis_text[4] = { TNUM_X1, TNUM_Y1, TNUM_X2, TNUM_Y2 };
127 int mouseaxis_text[2] = { TNUM_L_R, TNUM_F_B };
129 int mousebutton_text[3] = { TNUM_LEFT, TNUM_RIGHT, TNUM_MID };
131 char *mousebutton_text[3] = { "Btn", "", "" }; // only one silly mouse button on the mac
135 char * key_text[256] = {
136 "","S","D","F","H","G","Z","X","C","V","","B","Q", "W", "E", "R",
137 "Y","T","1","2","3","4","6","5","=","9","7","-", "8", "0", "]", "O",
138 "U","[","I","P","RET","L","J","'","K", ";", "\\", ",", "/", "N", "M", ".",
139 "TAB","SPC","`","DEL","","ESC","","APL","SHIFT","CAPSL","OPTN","CTRL","","","","A",
140 "","PAD.","","PAD*","","PAD+","","NMLCK","","","","PAD/","ENTER","","PAD-","",
141 "","PAD=","PAD0","PAD1","PAD2","PAD3","PAD4","PAD5","PAD6","PAD7","","PAD8","PAD9","","","",
142 "F5","F6","F7","","F8","F9","","F11","","F13","","F14","","F10","","F12",
143 "","PAUSE","HELP","HOME","PGUP","DEL","","END","F2","","F1","LARW","RARW","DARW","UARW","",
144 "","","","","","","","","","","","","","","","",
145 "","","","","","","","","","","","","","","","",
146 "","","","","","","","","","","","","","","","",
147 "","","","","","","","","","","","","","","","",
148 "","","","","","","","","","","","","","","","",
149 "","","","","","","","","","","","","","","","",
150 "","","","","","","","","","","","","","","","",
151 "","","","","","","","","","","","","","","",""};
153 #if !defined OGL && !defined SDL_INPUT
154 char * key_text[256] = { \
155 "","ESC","1","2","3","4","5","6","7","8","9","0","-", \
156 "=","BSPC","TAB","Q","W","E","R","T","Y","U","I","O", \
157 "P","[","]","
\83","LCTRL","A","S","D","F", \
158 "G","H","J","K","L",";","'","`", \
159 "LSHFT","\\","Z","X","C","V","B","N","M",",", \
160 ".","/","RSHFT","PAD*","LALT","SPC", \
161 "CPSLK","F1","F2","F3","F4","F5","F6","F7","F8","F9", \
162 "F10","NMLCK","SCLK","PAD7","PAD8","PAD9","PAD-", \
163 "PAD4","PAD5","PAD6","PAD+","PAD1","PAD2","PAD3","PAD0", \
164 "PAD.","","","","F11","F12","","","","","","","","","", \
165 "","","","","","","","","","","","","","","","","","","","", \
166 "","","","","","","","","","","","","","","","","","","","", \
167 "","","","","","","","","","","","","","","","","","", \
168 "PAD
\83","RCTRL","","","","","","","","","","","","","", \
169 "","","","","","","","","","","PAD/","","","RALT","", \
170 "","","","","","","","","","","","","","HOME","
\82","PGUP", \
171 "","
\81","","
\7f","","END","
\80","PGDN","INS", \
172 "DEL","","","","","","","","","","","","","","","","","", \
173 "","","","","","","","","","","","","","","","","","","","", \
174 "","","","","","","" };
178 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 };
180 //extern void GameLoop(int, int );
182 extern void transfer_energy_to_shield(fix);
183 extern void CyclePrimary(),CycleSecondary(),InitMarkerInput();
184 extern ubyte DefiningMarkerMessage;
185 extern char CybermouseActive;
188 extern int joydefsw_do_button();
189 extern int joydefsw_do_winjoybutton(int *axis);
190 extern joydefsw_win_joyselect(char *title);
193 control_info Controls;
197 // macros for drawing lo/hi res kconfig screens (see scores.c as well)
199 #define LHX(x) ((x)*(MenuHires?2:1))
200 #define LHY(y) ((y)*(MenuHires?2.4:1))
204 #define BT_MOUSE_BUTTON 1
205 #define BT_MOUSE_AXIS 2
206 #define BT_JOY_BUTTON 3
207 #define BT_JOY_AXIS 4
210 char *btype_text[] = { "BT_KEY", "BT_MOUSE_BUTTON", "BT_MOUSE_AXIS", "BT_JOY_BUTTON", "BT_JOY_AXIS", "BT_INVERT" };
214 typedef struct kc_item {
215 short id; // The id of this item
223 ubyte value; // what key,button,etc
229 ubyte kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS];
231 //----------- WARNING!!!!!!! -------------------------------------------
232 // THESE NEXT FOUR BLOCKS OF DATA ARE GENERATED BY PRESSING DEL+F12 WHEN
233 // IN THE KEYBOARD CONFIG SCREEN. BASICALLY, THAT PROCEDURE MODIFIES THE
234 // U,D,L,R FIELDS OF THE ARRAYS AND DUMPS THE NEW ARRAYS INTO KCONFIG.COD
235 //-------------------------------------------------------------------------
236 /*ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
237 {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},
238 {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},
239 {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},
240 {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},
241 {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},
242 {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},
243 {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},
247 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
248 {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},
249 {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},
250 {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},
251 {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},
252 {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},
253 {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},
254 {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},
256 {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},
262 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
263 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
264 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
265 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
266 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
267 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
268 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
269 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
270 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
271 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
272 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
273 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
274 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
275 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
276 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
277 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
278 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
279 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
280 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
281 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
282 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
283 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
284 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
285 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
286 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
287 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
288 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
289 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
290 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
291 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
292 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
293 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
294 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
295 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
296 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
297 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
298 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
299 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
300 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
301 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
302 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
303 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
304 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
305 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
306 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
307 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
308 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
309 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
310 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
311 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
312 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
313 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
314 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
315 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
316 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
317 { 54,158,171, 83, 26, 52, 56, 51, 55,"Energy->Shield", BT_KEY, 255 },
318 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
319 { 56,158,179,83, 26, 54, 0, 0, 0, "Toggle Bomb", BT_KEY,255},
321 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
322 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
323 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
324 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
325 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
326 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
327 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
328 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
329 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
330 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
331 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
332 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
333 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
334 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
335 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
336 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
337 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
338 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
339 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
340 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
341 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
342 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
343 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
344 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
345 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
346 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
347 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
348 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
349 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
350 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
351 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
352 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
354 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
355 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
356 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
357 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
358 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
359 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
360 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
361 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
362 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
363 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
364 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
365 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
366 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
367 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
368 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
369 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
370 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
371 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
372 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
373 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
374 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
375 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
376 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
377 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
378 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
379 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
380 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
381 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
382 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
383 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
384 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
385 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
388 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
389 { 0, 25, 46, 85, 26, 12, 1, 24, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
390 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
391 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
392 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
393 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
394 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
395 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
396 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
397 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
398 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
399 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
400 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
401 { 12,180,106, 59, 26, 11, 0, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
402 { 13,103,138, 58, 26, 27, 15, 25, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
403 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
404 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
405 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
406 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
407 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
408 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
409 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
410 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
411 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
412 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
413 { 24,103,182,106, 8, 22, 5, 23, 0,"throttle", BT_INVERT, 255 },
414 { 25, 25,109, 85, 26, 3, 27, 12, 13,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
415 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
416 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
419 #else // ifndef MACINTOSH (following are macintosh controls)
421 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
422 {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},
423 {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},
424 {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},
425 {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},
426 {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},
427 {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},
428 {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},
431 ubyte default_firebird_settings[MAX_CONTROLS] =
432 {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};
434 ubyte default_mousestick_settings[MAX_CONTROLS] =
435 {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};
437 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
438 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
439 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
440 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
441 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
442 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
443 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
444 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
445 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
446 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
447 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
448 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
449 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
450 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
451 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
452 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
453 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
454 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
455 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
456 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
457 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
458 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
459 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
460 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
461 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
462 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
463 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
464 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
465 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
466 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
467 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
468 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
469 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
470 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
471 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
472 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
473 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
474 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
475 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
476 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
477 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
478 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
479 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
480 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
481 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
482 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
483 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
484 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
485 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
486 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
487 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
488 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
489 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
490 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
491 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
492 { 54,158,171, 83, 26, 52, 25, 51, 55,"Energy->Shield", BT_KEY, 255 },
493 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
495 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
496 { 0, 25, 46, 85, 28, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
497 { 1, 25, 54, 85, 28, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
498 { 2, 25, 85, 85, 28, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
499 { 3, 25, 93, 85, 28, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
500 { 4, 25, 62, 85, 28, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
501 { 5,180, 46, 79, 28, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
502 { 6,180, 54, 79, 28, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
503 { 7,180, 62, 79, 28, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
504 { 8,180, 70, 79, 28, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
505 { 9,180, 78, 79, 28, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
506 { 10,180, 90, 79, 28, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
507 { 11,180, 98, 79, 28, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
508 { 12,180,106, 79, 28, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
509 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
510 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
511 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
512 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
513 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
514 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
515 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
516 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
517 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
518 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
519 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
520 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
521 { 25, 25,109, 85, 28, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
522 { 26, 25, 70, 85, 28, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
523 { 27, 25,117, 85, 28, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
524 { 28,180,114, 79, 28, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
525 { 29,180,122, 79, 28, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
526 { 30, 25,125, 85, 28, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
528 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
529 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
530 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
531 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
532 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
533 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
534 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
535 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
536 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
537 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
538 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
539 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
540 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
541 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
542 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
543 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
544 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
545 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
546 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
547 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
548 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
549 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
550 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
551 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
552 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
553 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
554 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
555 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
556 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
557 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
558 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
559 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
562 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
563 { 0, 25, 46, 85, 26, 28, 1, 28, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
564 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
565 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
566 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
567 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
568 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
569 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
570 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
571 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
572 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
573 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
574 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
575 { 12,180,106, 59, 26, 11, 28, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
576 { 13,103,138, 58, 26, 27, 15, 27, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
577 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
578 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
579 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
580 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
581 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
582 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
583 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
584 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
585 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
586 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
587 { 24,103,182,106, 8, 22, 5, 23, 28,"throttle", BT_INVERT, 255 },
588 { 25, 25,109, 85, 26, 3, 27, 12, 27,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
589 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
590 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
595 void kc_drawitem( kc_item *item, int is_current );
596 void kc_change_key( kc_item * item );
597 void kc_change_joybutton( kc_item * item );
598 void kc_change_mousebutton( kc_item * item );
599 void kc_change_joyaxis( kc_item * item );
600 void kc_change_mouseaxis( kc_item * item );
601 void kc_change_invert( kc_item * item );
602 void kconfig_read_fcs( int raw_axis );
603 void kconfig_set_fcs_button( int btn, int button );
604 void kconfig_read_external_controls( void );
606 int kconfig_is_axes_used(int axis)
609 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
610 if (( kc_joystick[i].type == BT_JOY_AXIS ) && (kc_joystick[i].value == axis ))
616 #ifdef TABLE_CREATION
617 int find_item_at( kc_item * items, int nitems, int x, int y )
621 for (i=0; i<nitems; i++ ) {
622 if ( ((items[i].x+items[i].w1)==x) && (items[i].y==y))
628 int find_next_item_up( kc_item * items, int nitems, int citem )
633 x = items[citem].x+items[citem].w1;
638 y = grd_curcanv->cv_bitmap.bm_h-1;
641 x = grd_curcanv->cv_bitmap.bm_w-1;
644 i = find_item_at( items, nitems, x, y );
650 int find_next_item_down( kc_item * items, int nitems, int citem )
655 x = items[citem].x+items[citem].w1;
659 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
662 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
666 i = find_item_at( items, nitems, x, y );
672 int find_next_item_right( kc_item * items, int nitems, int citem )
677 x = items[citem].x+items[citem].w1;
681 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
684 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
688 i = find_item_at( items, nitems, x, y );
694 int find_next_item_left( kc_item * items, int nitems, int citem )
699 x = items[citem].x+items[citem].w1;
704 x = grd_curcanv->cv_bitmap.bm_w-1;
707 y = grd_curcanv->cv_bitmap.bm_h-1;
710 i = find_item_at( items, nitems, x, y );
717 #if defined(MACINTOSH) || defined(WINDOWS)
718 int get_item_height(kc_item *item)
723 if (item->value==255) {
724 sprintf( btext, "" );
726 switch( item->type ) {
728 strncpy( btext, key_text[item->value], 10 ); break;
729 case BT_MOUSE_BUTTON:
731 strncpy( btext, Text_string[mousebutton_text[item->value]], 10); break;
733 strncpy( btext, mousebutton_text[item->value], 10 ); break;
736 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
738 if ( joybutton_text[item->value] !=-1 )
739 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
741 sprintf( btext, "BTN%d", item->value );
744 strncpy( btext, Text_string[joyaxis_text[item->value]], 10 ); break;
746 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
749 gr_get_string_size(btext, &w, &h, &aw );
755 void kconfig_sub(kc_item * items,int nitems, char * title)
758 dd_grs_canvas * save_canvas,
759 grs_canvas * save_canvas
761 grs_font * save_font;
763 #if defined(MACINTOSH) || defined(WINDOWS)
764 int mouse_state, omouse_state, mx, my, x1, x2, y1, y2;
765 int close_x, close_y, close_size;
768 int i,k,ocitem,citem;
769 int time_stopped = 0;
770 WIN(char *old_bg_pcx);
772 WIN(old_bg_pcx = _SCRContext.bkg_filename);
773 WIN(DEFINE_SCREEN(NULL));
778 if (!((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence)) )
784 // if (Config_control_type == CONTROL_WINJOYSTICK) {
786 // joydefsw_win_joyselect(title2); title = title2,
788 // ); // Get Samir...
792 save_canvas = dd_grd_curcanv,
793 save_canvas = grd_curcanv
798 dd_gr_set_current_canvas(NULL),
799 gr_set_current_canvas(NULL)
801 save_font = grd_curcanv->cv_font;
807 old_keyd_repeat = keyd_repeat;
810 //gr_clear_canvas( BM_XRGB(0,0,0) );
812 nm_draw_background(0,0,grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
813 gr_palette_load (gr_palette);
815 grd_curcanv->cv_font = MEDIUM3_FONT;
817 WIN(DDGRLOCK(dd_grd_curcanv));
820 p = strchr( title, '\n' );
822 gr_string( 0x8000, LHY(8), title );
827 // if ( items == kc_keyboard ) {
828 // gr_string( 0x8000, 8, "Keyboard" );
829 // } else if ( items == kc_joystick ) {
830 // gr_string( 0x8000, 8, "Joysticks" );
831 // } else if ( items == kc_mouse ) {
832 // gr_string( 0x8000, 8, "Mouse" );
835 #if defined(MACINTOSH) || defined(WINDOWS)
836 close_x = close_y = 15;
838 gr_setcolor( BM_XRGB(0, 0, 0) );
839 gr_rect(close_x, close_y, close_x + close_size, close_y + close_size);
840 gr_setcolor( BM_XRGB(21, 21, 21) );
841 gr_rect( close_x + 2, close_y + 2, close_x + close_size - 2, close_y + close_size -2 );
844 grd_curcanv->cv_font = GAME_FONT;
845 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
848 gr_string( 0x8000, LHY(20), TXT_KCONFIG_STRING_1 );
850 gr_string( 0x8000, LHY(20), "Enter changes, ctrl-d deletes, ctrl-r resets defaults, ESC exits");
852 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
853 if ( items == kc_keyboard ) {
854 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
855 gr_setcolor( BM_XRGB(31,27,6) );
857 gr_scanline( LHX(98), LHX(106), LHY(42) );
858 gr_scanline( LHX(120), LHX(128), LHY(42) );
859 gr_pixel( LHX(98), LHY(43) );
860 gr_pixel( LHX(98), LHY(44) );
861 gr_pixel( LHX(128), LHY(43) );
862 gr_pixel( LHX(128), LHY(44) );
864 gr_string( LHX(109), LHY(40), "OR" );
866 gr_scanline( LHX(253), LHX(261), LHY(42) );
867 gr_scanline( LHX(274), LHX(283), LHY(42) );
868 gr_pixel( LHX(253), LHY(43) );
869 gr_pixel( LHX(253), LHY(44) );
870 gr_pixel( LHX(283), LHY(43) );
871 gr_pixel( LHX(283), LHY(44) );
873 gr_string( LHX(264), LHY(40), "OR" );
875 } if ( items == kc_joystick ) {
876 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
877 gr_setcolor( BM_XRGB(31,27,6) );
878 gr_scanline( LHX(18), LHX(135), LHY(37) );
879 gr_scanline( LHX(181), LHX(294), LHY(37) );
880 gr_scanline( LHX(18), LHX(144), LHY(119+18) );
881 gr_scanline( LHX(174), LHX(294), LHY(119+18) );
882 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
883 gr_string( 0x8000,LHY(117+18), TXT_AXES );
884 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
885 gr_string( LHX(81), LHY(137+8), TXT_AXIS );
886 gr_string( LHX(111), LHY(137+8), TXT_INVERT );
887 gr_string( LHX(222), LHY(137+8), TXT_AXIS );
888 gr_string( LHX(252), LHY(137+8), TXT_INVERT );
889 } else if ( items == kc_mouse ) {
890 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
891 gr_setcolor( BM_XRGB(31,27,6) );
892 gr_scanline( LHX(18), LHX(135), LHY(37) );
893 gr_scanline( LHX(181), LHX(294), LHY(37) );
894 gr_scanline( LHX(18), LHX(144), LHY(119+5) );
895 gr_scanline( LHX(174), LHX(294), LHY(119+5) );
896 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
897 gr_string( 0x8000,LHY(117+5), TXT_AXES );
898 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
899 gr_string( LHX(169), LHY(129), TXT_AXIS );
900 gr_string( LHX(199), LHY(129), TXT_INVERT );
902 WIN(DDGRUNLOCK(dd_grd_curcanv));
904 for (i=0; i<nitems; i++ ) {
905 kc_drawitem( &items[i], 0 );
909 kc_drawitem( &items[citem], 1 );
914 #if defined(MACINTOSH) || defined(WINDOWS)
915 mouse_state = omouse_state = 0;
919 // Windows addendum to allow for kconfig input.
924 DoMessageStuff(&msg);
927 _RedrawScreen = FALSE;
929 dd_gr_set_current_canvas(NULL);
939 //see if redbook song needs to be restarted
940 songs_check_redbook_repeat();
944 #if defined(MACINTOSH) || defined(WINDOWS)
945 omouse_state = mouse_state;
946 mouse_state = mouse_button_state(0);
949 if ( !time_stopped ) {
951 if (multi_menu_poll() == -1)
960 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_3:)
961 case KEY_PRINT_SCREEN:
964 case KEY_CTRLED+KEY_D:
965 items[citem].value = 255;
966 kc_drawitem( &items[citem], 1 );
968 case KEY_CTRLED+KEY_R:
969 if ( items==kc_keyboard ) {
970 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
971 items[i].value=default_kconfig_settings[0][i];
972 kc_drawitem( &items[i], 0 );
976 // hack for firebire and mousestick default controls since I made
977 // them the same control type -- dumb dumb dumb
978 if (joy_have_firebird())
979 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
980 items[i].value = default_firebird_settings[i];
981 kc_drawitem( &items[i], 0 );
983 else if (joy_have_mousestick())
984 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
985 items[i].value = default_mousestick_settings[i];
986 kc_drawitem( &items[i], 0 );
989 #endif // note link to above else
990 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
991 items[i].value = default_kconfig_settings[Config_control_type][i];
992 kc_drawitem( &items[i], 0 );
995 kc_drawitem( &items[citem], 1 );
998 items[citem].value=255;
999 kc_drawitem( &items[citem], 1 );
1003 #ifdef TABLE_CREATION
1004 if (items[citem].u==-1) items[citem].u=find_next_item_up( items,nitems, citem);
1006 citem = items[citem].u;
1011 #ifdef TABLE_CREATION
1012 if (items[citem].d==-1) items[citem].d=find_next_item_down( items,nitems, citem);
1014 citem = items[citem].d;
1018 #ifdef TABLE_CREATION
1019 if (items[citem].l==-1) items[citem].l=find_next_item_left( items,nitems, citem);
1021 citem = items[citem].l;
1025 #ifdef TABLE_CREATION
1026 if (items[citem].r==-1) items[citem].r=find_next_item_right( items,nitems, citem);
1028 citem = items[citem].r;
1032 switch( items[citem].type ) {
1033 case BT_KEY: kc_change_key( &items[citem] ); break;
1034 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1035 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1036 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1037 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1038 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1043 grd_curcanv->cv_font = save_font;
1045 WIN(DEFINE_SCREEN(old_bg_pcx));
1048 dd_gr_set_current_canvas(save_canvas),
1049 gr_set_current_canvas( save_canvas )
1051 keyd_repeat = old_keyd_repeat;
1052 game_flush_inputs();
1053 WIN( HideCursorW());
1054 MAC( hide_cursor(); )
1058 #ifdef TABLE_CREATION
1059 case KEY_DEBUGGED+KEY_F12: {
1061 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1062 kc_keyboard[i].u = find_next_item_up( kc_keyboard,NUM_KEY_CONTROLS, i);
1063 kc_keyboard[i].d = find_next_item_down( kc_keyboard,NUM_KEY_CONTROLS, i);
1064 kc_keyboard[i].l = find_next_item_left( kc_keyboard,NUM_KEY_CONTROLS, i);
1065 kc_keyboard[i].r = find_next_item_right( kc_keyboard,NUM_KEY_CONTROLS, i);
1067 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1068 kc_joystick[i].u = find_next_item_up( kc_joystick,NUM_OTHER_CONTROLS, i);
1069 kc_joystick[i].d = find_next_item_down( kc_joystick,NUM_OTHER_CONTROLS, i);
1070 kc_joystick[i].l = find_next_item_left( kc_joystick,NUM_OTHER_CONTROLS, i);
1071 kc_joystick[i].r = find_next_item_right( kc_joystick,NUM_OTHER_CONTROLS, i);
1073 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1074 kc_mouse[i].u = find_next_item_up( kc_mouse,NUM_OTHER_CONTROLS, i);
1075 kc_mouse[i].d = find_next_item_down( kc_mouse,NUM_OTHER_CONTROLS, i);
1076 kc_mouse[i].l = find_next_item_left( kc_mouse,NUM_OTHER_CONTROLS, i);
1077 kc_mouse[i].r = find_next_item_right( kc_mouse,NUM_OTHER_CONTROLS, i);
1079 fp = fopen( "kconfig.cod", "wt" );
1081 fprintf( fp, "ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {\n" );
1082 for (i=0; i<CONTROL_MAX_TYPES; i++ ) {
1084 fprintf( fp, "{0x%x", kconfig_settings[i][0] );
1085 for (j=1; j<MAX_CONTROLS; j++ )
1086 fprintf( fp, ",0x%x", kconfig_settings[i][j] );
1087 fprintf( fp, "},\n" );
1089 fprintf( fp, "};\n" );
1091 fprintf( fp, "\nkc_item kc_keyboard[NUM_KEY_CONTROLS] = {\n" );
1092 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1093 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1094 kc_keyboard[i].id, kc_keyboard[i].x, kc_keyboard[i].y, kc_keyboard[i].w1, kc_keyboard[i].w2,
1095 kc_keyboard[i].u, kc_keyboard[i].d, kc_keyboard[i].l, kc_keyboard[i].r,
1096 34, kc_keyboard[i].text, 34, btype_text[kc_keyboard[i].type] );
1098 fprintf( fp, "};" );
1100 fprintf( fp, "\nkc_item kc_joystick[NUM_OTHER_CONTROLS] = {\n" );
1101 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1102 if (kc_joystick[i].type == BT_JOY_BUTTON)
1103 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1104 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1105 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1106 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1108 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1109 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1110 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1111 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1113 fprintf( fp, "};" );
1115 fprintf( fp, "\nkc_item kc_mouse[NUM_OTHER_CONTROLS] = {\n" );
1116 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1117 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1118 kc_mouse[i].id, kc_mouse[i].x, kc_mouse[i].y, kc_mouse[i].w1, kc_mouse[i].w2,
1119 kc_mouse[i].u, kc_mouse[i].d, kc_mouse[i].l, kc_mouse[i].r,
1120 34, kc_mouse[i].text, 34, btype_text[kc_mouse[i].type] );
1122 fprintf( fp, "};" );
1131 #if defined (MACINTOSH) || defined(WINDOWS)
1132 if ( (mouse_state && !omouse_state) || (mouse_state && omouse_state) ) {
1135 mouse_get_pos(&mx, &my);
1136 for (i=0; i<nitems; i++ ) {
1137 item_height = get_item_height( &items[i] );
1138 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[i].x) + LHX(items[i].w1);
1139 x2 = x1 + LHX(items[i].w2);
1140 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[i].y);
1141 y2 = y1 + LHX(item_height);
1142 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1148 else if ( !mouse_state && omouse_state ) {
1151 mouse_get_pos(&mx, &my);
1152 item_height = get_item_height( &items[citem] );
1153 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[citem].x) + LHX(items[citem].w1);
1154 x2 = x1 + LHX(items[citem].w2);
1155 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[citem].y);
1156 y2 = y1 + LHY(item_height);
1157 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1160 switch( items[citem].type ) {
1161 case BT_KEY: kc_change_key( &items[citem] ); break;
1162 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1163 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1164 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1165 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1166 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1171 x1 = grd_curcanv->cv_bitmap.bm_x + close_x + 2;
1172 x2 = x1 + close_size - 2;
1173 y1 = grd_curcanv->cv_bitmap.bm_y + close_y + 2;
1174 y2 = y1 + close_size - 2;
1175 if ( ((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2)) ) {
1176 grd_curcanv->cv_font = save_font;
1177 WINDOS(dd_gr_set_current_canvas( save_canvas ),
1178 gr_set_current_canvas( save_canvas ));
1179 keyd_repeat = old_keyd_repeat;
1180 game_flush_inputs();
1190 #endif // MACINTOSH WINDOWS
1192 if (ocitem!=citem) {
1195 kc_drawitem( &items[ocitem], 0 );
1196 kc_drawitem( &items[citem], 1 );
1204 void kc_drawitem( kc_item *item, int is_current )
1208 // PA_DFX (pa_set_frontbuffer_current());
1209 WIN(DDGRLOCK(dd_grd_curcanv));
1212 gr_set_fontcolor( BM_XRGB(20,20,29), -1 );
1214 gr_set_fontcolor( BM_XRGB(15,15,24), -1 );
1215 gr_string( LHX(item->x), LHY(item->y), item->text );
1216 WIN(DDGRUNLOCK(dd_grd_curcanv));
1218 if (item->value==255) {
1219 strcpy( btext, "" );
1221 switch( item->type ) {
1223 strncpy( btext, key_text[item->value], 10 ); break;
1224 case BT_MOUSE_BUTTON:
1226 strncpy( btext, Text_string[mousebutton_text[item->value]], 10 ); break;
1228 strncpy( btext, mousebutton_text[item->value], 10 ); break;
1231 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
1235 if (joybutton_text[item->value] != -1)
1236 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1238 sprintf( btext, "BTN%2d", item->value+1 );
1240 if ( joybutton_text[item->value] !=-1 )
1241 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1243 sprintf( btext, "BTN%d", item->value );
1246 strncpy( btext, joy_btn_name( item->value ), 10);
1248 sprintf( btext, "BTN%d", item->value );
1252 strncpy( btext, Text_string[joyaxis_text[item->value]], 10 ); break;
1254 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
1258 WIN(DDGRLOCK(dd_grd_curcanv));
1259 gr_get_string_size(btext, &w, &h, &aw );
1262 gr_setcolor( BM_XRGB(21,0,24) );
1264 gr_setcolor( BM_XRGB(16,0,19) );
1265 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1267 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1269 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1271 gr_string( x, LHY(item->y), btext );
1272 // PA_DFX (pa_set_backbuffer_current());
1274 WIN(DDGRUNLOCK(dd_grd_curcanv));
1279 static int looper=0;
1281 void kc_drawquestion( kc_item *item )
1285 WIN(DDGRLOCK(dd_grd_curcanv));
1286 // PA_DFX (pa_set_frontbuffer_current());
1288 gr_get_string_size("?", &w, &h, &aw );
1290 c = BM_XRGB(21,0,24);
1292 //@@gr_setcolor( gr_fade_table[fades[looper]*256+c] );
1293 gr_setcolor(BM_XRGB(21*fades[looper]/31,0,24*fades[looper]/31));
1295 if (looper>63) looper=0;
1297 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1299 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1301 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1303 gr_string( x, LHY(item->y), "?" );
1304 // PA_DFX (pa_set_backbuffer_current());
1305 WIN(DDGRUNLOCK(dd_grd_curcanv));
1309 void kc_change_key( kc_item * item )
1314 WIN(DDGRLOCK(dd_grd_curcanv));
1315 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1317 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_KEY );
1318 WIN(DDGRUNLOCK(dd_grd_curcanv));
1320 game_flush_inputs();
1324 while( (k!=KEY_ESC) && (keycode==255) )
1330 DoMessageStuff(&msg);
1337 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1340 // if ( Game_mode & GM_MULTI )
1341 // GameLoop( 0, 0 ); // Continue
1344 kc_drawquestion( item );
1346 for (i=0; i<256; i++ ) {
1347 if (keyd_pressed[i] && (strlen(key_text[i])>0)) {
1349 for (n=0; n<sizeof(system_keys); n++ )
1350 if ( system_keys[n] == i )
1359 for (i=0; i<Num_items; i++ ) {
1360 n = item - All_items;
1361 if ( (i!=n) && (All_items[i].type==BT_KEY) && (All_items[i].value==keycode) ) {
1362 All_items[i].value = 255;
1363 kc_drawitem( &All_items[i], 0 );
1366 item->value = keycode;
1368 kc_drawitem( item, 1 );
1370 WIN(DDGRLOCK(dd_grd_curcanv));
1371 gr_set_fontcolor( BM_XRGB(28,28,28), BM_XRGB(0,0,0) );
1372 WIN(DDGRUNLOCK(dd_grd_curcanv));
1374 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1376 game_flush_inputs();
1380 void kc_change_joybutton( kc_item * item )
1385 WIN(DDGRLOCK(dd_grd_curcanv));
1386 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1388 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_JBUTTON );
1389 WIN(DDGRUNLOCK(dd_grd_curcanv));
1391 game_flush_inputs();
1395 while( (k!=KEY_ESC) && (code==255))
1400 DoMessageStuff(&msg);
1406 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1409 // if ( Game_mode & GM_MULTI )
1410 // GameLoop( 0, 0 ); // Continue
1414 if (k == KEY_PRINT_SCREEN)
1415 save_screen_shot(0);
1417 kc_drawquestion( item );
1419 WIN(code = joydefsw_do_button());
1422 code = joy_do_buttons();
1425 #if !defined(WINDOWS) && !defined(MACINTOSH)
1426 if (Config_control_type==CONTROL_THRUSTMASTER_FCS) {
1428 joystick_read_raw_axis( JOY_ALL_AXIS, axis );
1429 kconfig_read_fcs( axis[3] );
1430 if ( joy_get_button_state(7) ) code = 7;
1431 if ( joy_get_button_state(11) ) code = 11;
1432 if ( joy_get_button_state(15) ) code = 15;
1433 if ( joy_get_button_state(19) ) code = 19;
1434 for (i=0; i<4; i++ ) {
1435 if ( joy_get_button_state(i) )
1438 } else if (Config_control_type==CONTROL_FLIGHTSTICK_PRO) {
1439 for (i=4; i<20; i++ ) {
1440 if ( joy_get_button_state(i) ) {
1442 mprintf(( 0, "JB: %d\n", code ));
1446 for (i=0; i<MAX_BUTTONS; i++ ) {
1447 if ( joy_get_button_state(i) )
1454 for (i=0; i<Num_items; i++ ) {
1455 n = item - All_items;
1456 if ( (i!=n) && (All_items[i].type==BT_JOY_BUTTON) && (All_items[i].value==code) ) {
1457 All_items[i].value = 255;
1458 kc_drawitem( &All_items[i], 0 );
1463 kc_drawitem( item, 1 );
1464 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1465 game_flush_inputs();
1468 void kc_change_mousebutton( kc_item * item )
1473 WIN(DDGRLOCK(dd_grd_curcanv));
1474 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1476 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_MBUTTON );
1477 WIN(DDGRUNLOCK(dd_grd_curcanv));
1480 game_flush_inputs();
1484 while( (k!=KEY_ESC) && (code==255))
1489 DoMessageStuff(&msg);
1495 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1498 // if ( Game_mode & GM_MULTI )
1499 // GameLoop( 0, 0 ); // Continue
1503 if (k == KEY_PRINT_SCREEN)
1504 save_screen_shot(0);
1506 kc_drawquestion( item );
1508 b = mouse_get_btns();
1509 for (i=0; i<3; i++ ) {
1515 for (i=0; i<Num_items; i++ ) {
1516 n = item - All_items;
1517 if ( (i!=n) && (All_items[i].type==BT_MOUSE_BUTTON) && (All_items[i].value==code) ) {
1518 All_items[i].value = 255;
1519 kc_drawitem( &All_items[i], 0 );
1524 kc_drawitem( item, 1 );
1525 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1526 game_flush_inputs();
1530 void kc_change_joyaxis( kc_item * item )
1534 int old_axis[MAX_AXES];
1536 int axis[JOY_NUM_AXES];
1537 int old_axis[JOY_NUM_AXES];
1546 WIN(DDGRLOCK(dd_grd_curcanv));
1547 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1549 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_JOY_AXIS );
1550 WIN(DDGRUNLOCK(dd_grd_curcanv));
1552 game_flush_inputs();
1557 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, old_axis ),
1558 joystick_read_raw_axis( JOY_ALL_AXIS, old_axis )
1561 while( (k!=KEY_ESC) && (code==255))
1566 DoMessageStuff(&msg);
1572 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1575 // if ( Game_mode & GM_MULTI )
1576 // GameLoop( 0, 0 ); // Continue
1580 if (k == KEY_PRINT_SCREEN)
1581 save_screen_shot(0);
1583 kc_drawquestion( item );
1586 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, axis ),
1587 joystick_read_raw_axis( JOY_ALL_AXIS, axis )
1590 for (i=0; i<numaxis; i++ ) {
1591 #if defined (MACINTOSH)
1592 if ( abs(axis[i]-old_axis[i])>100 ) {
1593 #elif defined(WINDOWS)
1594 if ( abs(axis[i]-old_axis[i])>1024 ) {
1596 if ( abs(axis[i]-old_axis[i])>200 ) {
1599 printf("Axis Movement detected: Axis %i\n", i);
1601 //old_axis[i] = axis[i];
1603 for (i=0; i<Num_items; i++ )
1605 n = item - All_items;
1606 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) )
1612 for (i=0; i<Num_items; i++ ) {
1613 n = item - All_items;
1614 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) ) {
1615 All_items[i].value = 255;
1616 kc_drawitem( &All_items[i], 0 );
1622 kc_drawitem( item, 1 );
1623 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1624 game_flush_inputs();
1628 void kc_change_mouseaxis( kc_item * item )
1634 WIN(DDGRLOCK(dd_grd_curcanv));
1635 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1637 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_MSE_AXIS );
1638 WIN(DDGRUNLOCK(dd_grd_curcanv));
1640 game_flush_inputs();
1644 mouse_get_delta( &dx, &dy );
1646 while( (k!=KEY_ESC) && (code==255))
1651 DoMessageStuff(&msg);
1657 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1660 // if ( Game_mode & GM_MULTI )
1661 // GameLoop( 0, 0 ); // Continue
1665 if (k == KEY_PRINT_SCREEN)
1666 save_screen_shot(0);
1668 kc_drawquestion( item );
1670 mouse_get_delta( &dx, &dy );
1671 if ( abs(dx)>20 ) code = 0;
1672 if ( abs(dy)>20 ) code = 1;
1675 for (i=0; i<Num_items; i++ ) {
1676 n = item - All_items;
1677 if ( (i!=n) && (All_items[i].type==BT_MOUSE_AXIS) && (All_items[i].value==code) ) {
1678 All_items[i].value = 255;
1679 kc_drawitem( &All_items[i], 0 );
1684 kc_drawitem( item, 1 );
1685 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1686 game_flush_inputs();
1691 void kc_change_invert( kc_item * item )
1693 game_flush_inputs();
1700 kc_drawitem( item, 1 );
1704 #include "screens.h"
1706 extern void gr_bm_bitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
1708 void kconfig(int n, char * title)
1711 grs_bitmap *save_bm;
1713 set_screen_mode( SCREEN_MENU );
1718 WIN(mouse_set_mode(0));
1719 WIN(dd_gr_set_current_canvas(NULL));
1721 #if defined(POLY_ACC)
1722 save_bm = gr_create_bitmap2( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h, grd_curcanv->cv_bitmap.bm_type, NULL );
1724 save_bm = gr_create_bitmap( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
1726 Assert( save_bm != NULL );
1728 WIN(DDGRLOCK(dd_grd_curcanv));
1729 gr_bm_bitblt(grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_w,
1730 0, 0, 0, 0, &grd_curcanv->cv_bitmap, save_bm );
1731 WIN(DDGRUNLOCK(dd_grd_curcanv));
1734 case 0:kconfig_sub( kc_keyboard, NUM_KEY_CONTROLS, title );break;
1735 case 1:kconfig_sub( kc_joystick, NUM_OTHER_CONTROLS, title );break;
1736 case 2:kconfig_sub( kc_mouse, NUM_OTHER_CONTROLS, title ); break;
1737 case 3:kconfig_sub( kc_superjoy, NUM_OTHER_CONTROLS, title); break;
1744 WIN(mouse_set_mode(1));
1745 WIN(dd_gr_set_current_canvas(NULL));
1746 WIN(DDGRLOCK(dd_grd_curcanv));
1747 gr_bitmap(0, 0, save_bm);
1748 WIN(DDGRUNLOCK(dd_grd_curcanv));
1749 gr_free_bitmap(save_bm);
1751 reset_cockpit(); //force cockpit redraw next time
1753 // Update save values...
1755 for (i=0; i<NUM_KEY_CONTROLS; i++ )
1756 kconfig_settings[0][i] = kc_keyboard[i].value;
1758 if ( (Config_control_type>0) && (Config_control_type<5)) {
1759 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1760 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
1761 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
1762 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1763 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
1765 else if (Config_control_type == CONTROL_WINJOYSTICK) {
1766 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1767 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
1772 void kconfig_read_fcs( int raw_axis )
1774 int raw_button, button, axis_min[4], axis_center[4], axis_max[4];
1776 if (Config_control_type!=CONTROL_THRUSTMASTER_FCS) return;
1778 joy_get_cal_vals(axis_min, axis_center, axis_max);
1780 if ( axis_max[3] > 1 )
1781 raw_button = (raw_axis*100)/axis_max[3];
1785 if ( raw_button > 88 )
1787 else if ( raw_button > 63 )
1789 else if ( raw_button > 39 )
1791 else if ( raw_button > 15 )
1796 kconfig_set_fcs_button( 19, button );
1797 kconfig_set_fcs_button( 15, button );
1798 kconfig_set_fcs_button( 11, button );
1799 kconfig_set_fcs_button( 7, button );
1803 void kconfig_set_fcs_button( int btn, int button )
1805 int state,time_down,upcount,downcount;
1806 state = time_down = upcount = downcount = 0;
1808 if ( joy_get_button_state(btn) ) {
1809 if ( btn==button ) {
1811 time_down = FrameTime;
1816 if ( btn==button ) {
1818 time_down = FrameTime;
1825 joy_set_btn_values( btn, state, time_down, downcount, upcount );
1831 fix Last_angles_p = 0;
1832 fix Last_angles_b = 0;
1833 fix Last_angles_h = 0;
1834 ubyte Last_angles_read = 0;
1836 extern int VR_sensitivity;
1838 int VR_sense_range[3] = { 25, 50, 75 };
1840 #if 0 //ndef MACINTOSH
1845 fix yaw, pitch, roll;
1848 //------ read vfx1 helmet --------
1849 if (vfx1_installed) {
1850 vfx_get_data(&yaw,&pitch,&roll,&buttons);
1851 } else if (iglasses_headset_installed) {
1852 iglasses_read_headset( &yaw, &pitch, &roll );
1853 } else if (Victor_headset_installed) {
1854 victor_read_headset_filtered( &yaw, &pitch, &roll );
1859 Use_player_head_angles = 0;
1860 if ( Last_angles_read ) {
1864 if ( (Last_angles_h < (F1_0/4) ) && (yaw > ((F1_0*3)/4) ) )
1866 else if ( (yaw < (F1_0/4) ) && (Last_angles_h > ((F1_0*3)/4) ) )
1869 Controls.pitch_time += fixmul((pitch- Last_angles_p)*VR_sense_range[VR_sensitivity],FrameTime);
1870 Controls.heading_time+= fixmul((yaw1 - Last_angles_h)*VR_sense_range[VR_sensitivity],FrameTime);
1871 Controls.bank_time += fixmul((roll - Last_angles_b)*VR_sense_range[VR_sensitivity],FrameTime);
1873 Last_angles_read = 1;
1874 Last_angles_p = pitch;
1875 Last_angles_h = yaw;
1876 Last_angles_b = roll;
1884 #define JOYSTICK_READ_TIME (F1_0/40) // Read joystick at 40 Hz.
1886 #define JOYSTICK_READ_TIME (F1_0/10) // Read joystick at 10 Hz.
1889 fix LastReadTime = 0;
1893 ubyte kc_use_external_control = 0;
1894 ubyte kc_enable_external_control = 0;
1895 ubyte kc_external_intno = 0;
1896 ext_control_info *kc_external_control = NULL;
1897 ubyte *kc_external_name = NULL;
1898 ubyte kc_external_version = 0;
1899 extern int Automap_active;
1901 void kconfig_init_external_controls(int intno, int address)
1904 kc_external_intno = intno;
1905 kc_external_control = (ext_control_info *)address;
1906 kc_use_external_control = 1;
1907 kc_enable_external_control = 1;
1909 i = FindArg ( "-xname" );
1911 kc_external_name = Args[i+1];
1913 kc_external_name = "External Controller";
1915 for (i=0;i<strlen (kc_external_name);i++)
1916 if (kc_external_name[i]=='_')
1917 kc_external_name[i]=' ';
1919 i = FindArg ( "-xver" );
1921 kc_external_version = atoi(Args[i+1]);
1923 printf( "%s int: 0x%x, data: 0x%p, ver:%d\n", kc_external_name, kc_external_intno, kc_external_control, kc_external_version );
1927 #if !defined(MACINTOSH)
1928 /*void kconfig_read_external_controls()
1932 if ( !kc_enable_external_control && !CybermouseActive)
1935 if ( kc_external_version == 0 )
1936 memset( kc_external_control, 0, sizeof(control_info) );
1937 else if ( kc_external_version > 0 ) {
1938 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 );
1939 if ( kc_external_version > 1 ) {
1940 // Write ship pos and angles to external controls...
1941 ubyte *temp_ptr = (ubyte *)kc_external_control;
1942 vms_vector *ship_pos;
1943 vms_matrix *ship_orient;
1944 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
1945 temp_ptr += sizeof(control_info)+sizeof(vms_angvec) + 64;
1946 ship_pos = (vms_vector *)temp_ptr;
1947 temp_ptr += sizeof(vms_vector);
1948 ship_orient = (vms_matrix *)temp_ptr;
1949 // Fill in ship postion...
1950 *ship_pos = Objects[Players[Player_num].objnum].pos;
1951 // Fill in ship orientation...
1952 *ship_orient = Objects[Players[Player_num].objnum].orient;
1956 if ( Automap_active ) // (If in automap...)
1957 kc_external_control->automap_state = 1;
1958 memset(&r,0,sizeof(r));
1962 if (!CybermouseActive)
1963 int386 ( kc_external_intno, &r, &r); // Read external info...
1965 // ReadOWL (kc_external_control);
1969 if ( Player_num > -1 ) {
1970 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
1971 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
1972 Auto_leveling_on = 0;
1974 if ( kc_external_version > 0 ) {
1975 vms_matrix tempm, ViewMatrix;
1976 vms_angvec * Kconfig_abs_movement;
1979 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
1981 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
1982 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
1983 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
1984 Objects[Players[Player_num].objnum].orient = ViewMatrix;
1986 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
1987 if (oem_message[0] != '\0' )
1988 HUD_init_message( oem_message );
1992 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
1993 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
1994 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
1995 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
1996 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
1997 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
1998 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
1999 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
2000 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
2001 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
2002 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
2003 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
2004 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
2005 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
2006 Controls.automap_down_count += kc_external_control->automap_down_count;
2007 Controls.automap_state |= kc_external_control->automap_state;
2012 void controls_read_all_win()
2015 int slide_on, bank_on;
2019 int raw_joy_axis[7];
2021 fix k0, k1, k2, k3, kp;
2022 fix k4, k5, k6, k7, kh;
2023 ubyte channel_masks;
2024 int use_mouse, use_joystick;
2027 if (Game_turbo_mode)
2031 fix temp = Controls.heading_time;
2032 fix temp1 = Controls.pitch_time;
2033 memset( &Controls, 0, sizeof(control_info) );
2034 Controls.heading_time = temp;
2035 Controls.pitch_time = temp1;
2040 ctime = timer_get_fixed_seconds();
2042 // DO JOYSTICK (X,Y,Z R,U,V)
2043 // ----------------------------------------------------------------------------
2044 if ( (LastReadTime + JOYSTICK_READ_TIME) > ctime ) {
2045 if ((ctime < 0) && (LastReadTime > 0))
2046 LastReadTime = ctime;
2048 } else if ((Config_control_type==CONTROL_WINJOYSTICK)) {
2049 LastReadTime = ctime;
2050 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, raw_joy_axis );
2052 for (i=0; i<7; i++ ) {
2053 if (channel_masks&(1<<i)) {
2054 int joy_null_value = 28;
2056 // DO POV if joystick has a hat.
2057 // --------------------------------------------------------------------
2059 joydefsw_do_winjoybutton(raw_joy_axis);
2063 // --------------------------------------------------------------------
2064 // mprintf((0, "(%d)=%d,", i, raw_joy_axis[i]));
2065 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2066 // mprintf((0, "%d ",raw_joy_axis[i]));
2067 // if (i%2) mprintf((0,"\n"));
2070 if (kc_superjoy[23].value==i) // If this is the throttle
2071 joy_null_value = 32; // Then use a larger dead-zone
2073 if (raw_joy_axis[i] > (joy_null_value-2))
2074 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2075 else if (raw_joy_axis[i] < -(joy_null_value+2))
2076 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2078 raw_joy_axis[i] = 0;
2079 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2088 for (i=0; i<6; i++ )
2094 // ----------------------------------------------------------------------------
2095 if (Config_control_type==5) {
2096 mouse_get_delta( &dx, &dy );
2097 mouse_axis[0] = (dx*FrameTime)/35;
2098 mouse_axis[1] = (dy*FrameTime)/25;
2099 mouse_buttons = mouse_get_btns();
2100 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2109 //------------- Read slide_on -------------
2112 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
2113 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
2115 if ((use_joystick)&&(kc_superjoy[5].value<255)) slide_on |= joy_get_button_state( kc_superjoy[5].value );
2117 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
2119 //------------- Read bank_on ---------------
2122 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
2123 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
2125 if ( (use_joystick)&&(kc_superjoy[10].value < 255 )) bank_on |= joy_get_button_state( kc_superjoy[10].value );
2127 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
2129 //------------ Read pitch_time -----------
2131 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2133 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
2134 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
2135 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
2136 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
2139 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
2140 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
2141 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
2142 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
2145 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2146 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
2147 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
2151 Controls.pitch_time = 0;
2153 if (Controls.pitch_time < 0)
2154 Controls.pitch_time = 0;
2156 if (Controls.pitch_time > 0)
2157 Controls.pitch_time = 0;
2158 Controls.pitch_time += kp;
2161 if ( (use_joystick)&&(kc_superjoy[13].value < 255 )) {
2162 if ( !kc_superjoy[14].value ) // If not inverted...
2163 Controls.pitch_time -= (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2165 Controls.pitch_time += (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2169 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
2170 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
2171 if ( !kc_mouse[14].value ) // If not inverted...
2172 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2174 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2177 Controls.pitch_time = 0;
2181 //----------- Read vertical_thrust_time -----------------
2184 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
2185 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
2186 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
2187 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
2190 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
2191 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
2192 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
2193 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
2196 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2197 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
2198 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
2202 if ((use_joystick)&&( kc_superjoy[13].value < 255 )) {
2203 if ( !kc_superjoy[14].value ) // If not inverted...
2204 Controls.vertical_thrust_time += joy_axis[kc_superjoy[13].value];
2206 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[13].value];
2210 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
2211 if ( !kc_mouse[14].value ) // If not inverted...
2212 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
2214 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
2219 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
2220 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
2221 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
2222 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
2225 if ((use_joystick)&&( kc_superjoy[19].value < 255 )) {
2226 if ( !kc_superjoy[20].value ) // If not inverted...
2227 Controls.vertical_thrust_time += joy_axis[kc_superjoy[19].value];
2229 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[19].value];
2232 // From joystick buttons
2233 if ( (use_joystick)&&(kc_superjoy[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_superjoy[8].value );
2234 if ( (use_joystick)&&(kc_superjoy[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_superjoy[9].value );
2236 // From mouse buttons
2237 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
2238 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
2241 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
2242 if ( !kc_mouse[20].value ) // If not inverted...
2243 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
2245 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
2249 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2250 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
2251 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
2254 //---------- Read heading_time -----------
2256 if (!slide_on && !bank_on) {
2257 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2259 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
2260 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
2261 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
2262 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
2265 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
2266 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
2267 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
2268 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
2271 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2272 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
2273 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
2277 Controls.heading_time = 0;
2279 if (Controls.heading_time < 0)
2280 Controls.heading_time = 0;
2282 if (Controls.heading_time > 0)
2283 Controls.heading_time = 0;
2284 Controls.heading_time += kh;
2287 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2288 if ( !kc_superjoy[16].value ) // If not inverted...
2289 Controls.heading_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2291 Controls.heading_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2295 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2296 if ( !kc_mouse[16].value ) // If not inverted...
2297 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2299 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2302 Controls.heading_time = 0;
2305 //----------- Read sideways_thrust_time -----------------
2308 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2309 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2310 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2311 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2314 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
2315 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
2316 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
2317 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
2320 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2321 if ( !kc_superjoy[16].value ) // If not inverted...
2322 Controls.sideways_thrust_time += joy_axis[kc_superjoy[15].value];
2324 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[15].value];
2328 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2329 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
2330 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
2334 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2335 if ( !kc_mouse[16].value ) // If not inverted...
2336 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
2338 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
2343 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
2344 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
2345 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
2346 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
2349 if ( (use_joystick)&&(kc_superjoy[17].value < 255 )) {
2350 if ( !kc_superjoy[18].value ) // If not inverted...
2351 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[17].value];
2353 Controls.sideways_thrust_time += joy_axis[kc_superjoy[17].value];
2356 // From joystick buttons
2357 if ( (use_joystick)&&(kc_superjoy[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_superjoy[6].value );
2358 if ( (use_joystick)&&(kc_superjoy[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_superjoy[7].value );
2360 // From mouse buttons
2361 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
2362 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
2365 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
2366 if ( !kc_mouse[18].value ) // If not inverted...
2367 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
2369 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
2372 //----------- Read bank_time -----------------
2375 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2376 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2377 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2378 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2381 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
2382 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
2383 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
2384 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
2387 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2388 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
2389 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
2393 if ( (use_joystick)&&(kc_superjoy[15].value < 255) ) {
2394 if ( !kc_superjoy[16].value ) // If not inverted...
2395 Controls.bank_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2397 Controls.bank_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2401 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2402 if ( !kc_mouse[16].value ) // If not inverted...
2403 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2405 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2410 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
2411 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
2412 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
2413 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
2416 if ( (use_joystick)&&(kc_superjoy[21].value < 255) ) {
2417 if ( !kc_superjoy[22].value ) // If not inverted...
2418 Controls.bank_time -= joy_axis[kc_superjoy[21].value];
2420 Controls.bank_time += joy_axis[kc_superjoy[21].value];
2423 // From joystick buttons
2424 if ( (use_joystick)&&(kc_superjoy[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_superjoy[11].value );
2425 if ( (use_joystick)&&(kc_superjoy[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_superjoy[12].value );
2427 // From mouse buttons
2428 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
2429 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
2432 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
2433 if ( !kc_mouse[22].value ) // If not inverted...
2434 Controls.bank_time += mouse_axis[kc_mouse[21].value];
2436 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
2440 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2441 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
2442 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
2445 //----------- Read forward_thrust_time -------------
2448 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
2449 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
2450 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
2451 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
2454 if ( (use_joystick)&&(kc_superjoy[23].value < 255 )) {
2455 if ( !kc_superjoy[24].value ) // If not inverted...
2456 Controls.forward_thrust_time -= joy_axis[kc_superjoy[23].value];
2458 Controls.forward_thrust_time += joy_axis[kc_superjoy[23].value];
2461 // From joystick buttons
2462 if ( (use_joystick)&&(kc_superjoy[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_superjoy[2].value );
2463 if ( (use_joystick)&&(kc_superjoy[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_superjoy[3].value );
2466 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
2467 if ( !kc_mouse[24].value ) // If not inverted...
2468 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
2470 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
2473 // From mouse buttons
2474 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
2475 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
2477 //----------- Read afterburner_state -------------
2480 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
2481 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
2483 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
2485 if ( (use_joystick)&&(kc_superjoy[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_superjoy[27].value);
2487 //-------Read headlight key--------------------------
2488 if (kc_keyboard[52].value < 255 )
2489 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
2490 if (kc_keyboard[53].value < 255 )
2491 Controls.headlight_count=key_down_count(kc_keyboard[53].value);
2492 if ((use_joystick)&&(kc_superjoy[30].value < 255 ))
2493 Controls.headlight_count=joy_get_button_down_cnt(kc_superjoy[30].value);
2495 //--------Read Cycle Primary Key------------------
2497 if (kc_keyboard[48].value<255)
2498 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
2499 if (kc_keyboard[49].value<255)
2500 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
2501 if ((use_joystick)&&(kc_superjoy[28].value < 255 ))
2502 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_superjoy[28].value);
2504 //--------Read Cycle Secondary Key------------------
2506 if (kc_keyboard[50].value<255)
2507 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
2508 if (kc_keyboard[51].value<255)
2509 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
2510 if ((use_joystick)&&(kc_superjoy[29].value < 255 ))
2511 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_superjoy[29].value);
2513 //--------Read Toggle Bomb key----------------------
2515 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
2517 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
2519 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
2520 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
2522 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2523 HUD_init_message ("No bombs available!");
2527 if (Players[Player_num].secondary_ammo[bomb]==0)
2529 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2530 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
2534 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
2535 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
2540 //---------Read Energy->Shield key----------
2542 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
2543 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
2544 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
2545 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
2547 //----------- Read fire_primary_down_count
2548 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
2549 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
2550 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_superjoy[0].value);
2551 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
2553 //----------- Read fire_primary_state
2554 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
2555 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
2556 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_superjoy[0].value);
2557 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
2559 //----------- Read fire_secondary_down_count
2560 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
2561 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
2562 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_superjoy[1].value);
2563 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
2565 //----------- Read fire_secondary_state
2566 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
2567 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
2568 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_superjoy[1].value);
2569 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
2571 //----------- Read fire_flare_down_count
2572 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
2573 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
2574 if ((use_joystick)&&(kc_superjoy[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_superjoy[4].value);
2575 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
2577 //----------- Read drop_bomb_down_count
2578 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
2579 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
2580 if ((use_joystick)&&(kc_superjoy[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_superjoy[26].value);
2581 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
2583 //----------- Read rear_view_down_count
2584 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
2585 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
2586 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_superjoy[25].value);
2587 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
2589 //----------- Read rear_view_down_state
2590 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
2591 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
2592 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_superjoy[25].value);
2593 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
2595 //----------- Read automap_down_count
2596 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
2597 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
2599 //----------- Read automap_state
2600 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
2601 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
2603 //----------- Read stupid-cruise-control-type of throttle.
2605 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
2606 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
2607 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
2608 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
2609 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
2611 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
2614 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
2615 if (Cruise_speed < 0 ) Cruise_speed = 0;
2617 if (Controls.forward_thrust_time==0)
2618 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
2621 //read_head_tracker();
2623 // Read external controls
2624 if (kc_use_external_control || CybermouseActive)
2625 kconfig_read_external_controls();
2627 //----------- Clamp values between -FrameTime and FrameTime
2628 if (FrameTime > F1_0 )
2629 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
2631 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
2632 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
2633 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
2634 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
2635 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
2636 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
2637 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
2639 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
2640 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
2641 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
2642 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
2643 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
2644 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
2645 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
2648 //--------- Don't do anything if in debug mode
2650 if ( keyd_pressed[KEY_DELETE] ) {
2651 memset( &Controls, 0, sizeof(control_info) );
2658 fix Next_toggle_time[3]={0,0,0};
2660 int allowed_to_toggle(int i)
2662 //used for keeping tabs of when its ok to toggle headlight,primary,and secondary
2664 if (Next_toggle_time[i] > GameTime)
2665 if (Next_toggle_time[i] < GameTime + (F1_0/8)) // In case time is bogus, never wait > 1 second.
2668 Next_toggle_time[i] = GameTime + (F1_0/8);
2675 void controls_read_all()
2678 int slide_on, bank_on;
2684 int raw_joy_axis[MAX_AXES];
2686 int raw_joy_axis[JOY_NUM_AXES];
2689 fix k0, k1, k2, k3, kp;
2690 fix k4, k5, k6, k7, kh;
2691 ubyte channel_masks;
2692 int use_mouse, use_joystick;
2698 if (Game_turbo_mode)
2702 fix temp = Controls.heading_time;
2703 fix temp1 = Controls.pitch_time;
2704 memset( &Controls, 0, sizeof(control_info) );
2705 Controls.heading_time = temp;
2706 Controls.pitch_time = temp1;
2711 ctime = timer_get_fixed_seconds();
2713 //--------- Read Joystick -----------
2715 if ( (LastReadTime + JOYSTICK_READ_TIME > ctime) && (Config_control_type!=CONTROL_THRUSTMASTER_FCS) ) {
2716 if ((ctime < 0) && (LastReadTime > 0))
2717 LastReadTime = ctime;
2719 } else if ((Config_control_type>0) && (Config_control_type<5) ) {
2720 LastReadTime = ctime;
2721 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
2723 for (i=0; i<6; i++ ) {
2725 if (channel_masks&(1<<i)) {
2727 int joy_null_value = 10;
2729 if ( (i==3) && (Config_control_type==CONTROL_THRUSTMASTER_FCS) ) {
2730 kconfig_read_fcs( raw_joy_axis[i] );
2732 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2734 if (kc_joystick[23].value==i) // If this is the throttle
2735 joy_null_value = 20; // Then use a larger dead-zone
2737 if (raw_joy_axis[i] > joy_null_value)
2738 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2739 else if (raw_joy_axis[i] < -joy_null_value)
2740 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2742 raw_joy_axis[i] = 0;
2743 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2753 for (i=0; i<4; i++ )
2758 //--------- Read Joystick -----------
2759 if ((Config_control_type>0) && (Config_control_type<5) ) {
2760 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
2761 for (i=0; i<4; i++ ) {
2762 if (channel_masks&(1<<i)) {
2763 int joy_null_value = 10;
2765 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2767 if (kc_joystick[23].value==i) // If this is the throttle
2768 joy_null_value = 20; // Then use a larger dead-zone
2770 if (raw_joy_axis[i] > joy_null_value)
2771 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2772 else if (raw_joy_axis[i] < -joy_null_value)
2773 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2775 raw_joy_axis[i] = 0;
2776 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2783 for (i=0; i<4; i++ )
2787 #endif // ifndef MACINTOSH
2789 if (Config_control_type==5 && !CybermouseActive) {
2790 //--------- Read Mouse -----------
2791 mouse_get_delta( &dx, &dy );
2792 mouse_axis[0] = (dx*FrameTime)/35;
2793 mouse_axis[1] = (dy*FrameTime)/25;
2794 mouse_buttons = mouse_get_btns();
2795 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2797 } else if (Config_control_type==6 && !CybermouseActive) {
2798 //--------- Read Cyberman -----------
2799 mouse_get_cyberman_pos(&idx,&idy );
2800 mouse_axis[0] = (idx*FrameTime)/128;
2801 mouse_axis[1] = (idy*FrameTime)/128;
2802 mouse_buttons = mouse_get_btns();
2804 } else if (CybermouseActive) {
2805 // ReadOWL (kc_external_control);
2806 // CybermouseAdjust();
2814 //------------- Read slide_on -------------
2817 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
2818 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
2820 if ((use_joystick)&&(kc_joystick[5].value<255)) slide_on |= joy_get_button_state( kc_joystick[5].value );
2822 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
2824 //------------- Read bank_on ---------------
2827 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
2828 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
2830 if ( (use_joystick)&&(kc_joystick[10].value < 255 )) bank_on |= joy_get_button_state( kc_joystick[10].value );
2832 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
2834 //------------ Read pitch_time -----------
2836 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2838 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
2839 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
2840 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
2841 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
2844 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
2845 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
2846 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
2847 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
2850 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2851 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
2852 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
2856 Controls.pitch_time = 0;
2858 if (Controls.pitch_time < 0)
2859 Controls.pitch_time = 0;
2861 if (Controls.pitch_time > 0)
2862 Controls.pitch_time = 0;
2863 Controls.pitch_time += kp;
2866 if ( (use_joystick)&&(kc_joystick[13].value < 255 )) {
2867 if ( !kc_joystick[14].value ) // If not inverted...
2868 Controls.pitch_time -= (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
2870 Controls.pitch_time += (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
2874 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
2875 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
2876 if ( !kc_mouse[14].value ) // If not inverted...
2877 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2879 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2882 Controls.pitch_time = 0;
2886 //----------- Read vertical_thrust_time -----------------
2889 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
2890 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
2891 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
2892 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
2895 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
2896 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
2897 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
2898 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
2901 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2902 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
2903 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
2907 if ((use_joystick)&&( kc_joystick[13].value < 255 )) {
2908 if ( !kc_joystick[14].value ) // If not inverted...
2909 Controls.vertical_thrust_time += joy_axis[kc_joystick[13].value];
2911 Controls.vertical_thrust_time -= joy_axis[kc_joystick[13].value];
2915 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
2916 if ( !kc_mouse[14].value ) // If not inverted...
2917 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
2919 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
2924 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
2925 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
2926 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
2927 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
2930 if ((use_joystick)&&( kc_joystick[19].value < 255 )) {
2931 if ( !kc_joystick[20].value ) // If not inverted...
2932 Controls.vertical_thrust_time += joy_axis[kc_joystick[19].value];
2934 Controls.vertical_thrust_time -= joy_axis[kc_joystick[19].value];
2937 // From joystick buttons
2938 if ( (use_joystick)&&(kc_joystick[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_joystick[8].value );
2939 if ( (use_joystick)&&(kc_joystick[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_joystick[9].value );
2941 // From mouse buttons
2942 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
2943 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
2946 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
2947 if ( !kc_mouse[20].value ) // If not inverted...
2948 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
2950 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
2954 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2955 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
2956 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
2959 //---------- Read heading_time -----------
2961 if (!slide_on && !bank_on) {
2962 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2964 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
2965 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
2966 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
2967 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
2970 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
2971 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
2972 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
2973 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
2976 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2977 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
2978 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
2982 Controls.heading_time = 0;
2984 if (Controls.heading_time < 0)
2985 Controls.heading_time = 0;
2987 if (Controls.heading_time > 0)
2988 Controls.heading_time = 0;
2989 Controls.heading_time += kh;
2992 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
2993 if ( !kc_joystick[16].value ) // If not inverted...
2994 Controls.heading_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
2996 Controls.heading_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3000 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3001 if ( !kc_mouse[16].value ) // If not inverted...
3002 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3004 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3007 Controls.heading_time = 0;
3010 //----------- Read sideways_thrust_time -----------------
3013 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3014 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3015 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3016 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3019 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
3020 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
3021 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
3022 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
3025 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
3026 if ( !kc_joystick[16].value ) // If not inverted...
3027 Controls.sideways_thrust_time += joy_axis[kc_joystick[15].value];
3029 Controls.sideways_thrust_time -= joy_axis[kc_joystick[15].value];
3033 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3034 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
3035 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
3039 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3040 if ( !kc_mouse[16].value ) // If not inverted...
3041 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
3043 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
3048 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
3049 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
3050 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
3051 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
3054 if ( (use_joystick)&&(kc_joystick[17].value < 255 )) {
3055 if ( !kc_joystick[18].value ) // If not inverted...
3056 Controls.sideways_thrust_time -= joy_axis[kc_joystick[17].value];
3058 Controls.sideways_thrust_time += joy_axis[kc_joystick[17].value];
3061 // From joystick buttons
3062 if ( (use_joystick)&&(kc_joystick[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_joystick[6].value );
3063 if ( (use_joystick)&&(kc_joystick[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_joystick[7].value );
3065 // From mouse buttons
3066 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
3067 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
3070 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
3071 if ( !kc_mouse[18].value ) // If not inverted...
3072 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
3074 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
3077 //----------- Read bank_time -----------------
3080 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3081 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3082 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3083 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3086 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
3087 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
3088 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
3089 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
3092 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3093 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
3094 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
3098 if ( (use_joystick)&&(kc_joystick[15].value < 255) ) {
3099 if ( !kc_joystick[16].value ) // If not inverted...
3100 Controls.bank_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3102 Controls.bank_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3106 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3107 if ( !kc_mouse[16].value ) // If not inverted...
3108 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3110 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3115 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
3116 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
3117 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
3118 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
3121 if ( (use_joystick)&&(kc_joystick[21].value < 255) ) {
3122 if ( !kc_joystick[22].value ) // If not inverted...
3123 Controls.bank_time -= joy_axis[kc_joystick[21].value];
3125 Controls.bank_time += joy_axis[kc_joystick[21].value];
3128 // From joystick buttons
3129 if ( (use_joystick)&&(kc_joystick[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_joystick[11].value );
3130 if ( (use_joystick)&&(kc_joystick[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_joystick[12].value );
3132 // From mouse buttons
3133 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
3134 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
3137 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
3138 if ( !kc_mouse[22].value ) // If not inverted...
3139 Controls.bank_time += mouse_axis[kc_mouse[21].value];
3141 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
3145 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3146 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
3147 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
3150 //----------- Read forward_thrust_time -------------
3153 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
3154 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
3155 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
3156 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
3159 if ( (use_joystick)&&(kc_joystick[23].value < 255 )) {
3160 if ( !kc_joystick[24].value ) // If not inverted...
3161 Controls.forward_thrust_time -= joy_axis[kc_joystick[23].value];
3163 Controls.forward_thrust_time += joy_axis[kc_joystick[23].value];
3166 // From joystick buttons
3167 if ( (use_joystick)&&(kc_joystick[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_joystick[2].value );
3168 if ( (use_joystick)&&(kc_joystick[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_joystick[3].value );
3171 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
3172 if ( !kc_mouse[24].value ) // If not inverted...
3173 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
3175 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
3178 // From mouse buttons
3179 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
3180 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
3182 //----------- Read afterburner_state -------------
3185 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
3186 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
3188 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
3190 if ( (use_joystick)&&(kc_joystick[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_joystick[27].value);
3192 //-------Read headlight key--------------------------
3194 if (kc_keyboard[52].value < 255 )
3195 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
3196 if (kc_keyboard[53].value < 255 )
3197 Controls.headlight_count+=key_down_count(kc_keyboard[53].value);
3198 if ((use_joystick)&&(kc_joystick[30].value < 255 ))
3199 Controls.headlight_count+=joy_get_button_down_cnt(kc_joystick[30].value);
3201 //--------Read Cycle Primary Key------------------
3203 if (kc_keyboard[48].value<255)
3204 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
3205 if (kc_keyboard[49].value<255)
3206 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
3207 if ((use_joystick)&&(kc_joystick[28].value < 255 ))
3208 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_joystick[28].value);
3211 //--------Read Cycle Secondary Key------------------
3213 if (kc_keyboard[50].value<255)
3214 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
3215 if (kc_keyboard[51].value<255)
3216 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
3217 if ((use_joystick)&&(kc_joystick[29].value < 255 ))
3218 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_joystick[29].value);
3220 //--------Read Toggle Bomb key----------------------
3222 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
3224 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
3226 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
3227 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
3229 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3230 HUD_init_message ("No bombs available!");
3234 if (Players[Player_num].secondary_ammo[bomb]==0)
3236 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3237 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
3241 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
3242 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
3247 //---------Read Energy->Shield key----------
3249 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
3250 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
3251 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
3252 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
3254 //----------- Read fire_primary_down_count
3255 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
3256 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
3257 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_joystick[0].value);
3258 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
3260 //----------- Read fire_primary_state
3261 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
3262 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
3263 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_joystick[0].value);
3264 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
3266 //----------- Read fire_secondary_down_count
3267 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
3268 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
3269 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_joystick[1].value);
3270 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
3272 //----------- Read fire_secondary_state
3273 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
3274 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
3275 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_joystick[1].value);
3276 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
3278 //----------- Read fire_flare_down_count
3279 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
3280 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
3281 if ((use_joystick)&&(kc_joystick[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_joystick[4].value);
3282 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
3284 //----------- Read drop_bomb_down_count
3285 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
3286 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
3287 if ((use_joystick)&&(kc_joystick[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_joystick[26].value);
3288 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
3290 //----------- Read rear_view_down_count
3291 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
3292 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
3293 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_joystick[25].value);
3294 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
3296 //----------- Read rear_view_down_state
3297 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
3298 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
3299 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_joystick[25].value);
3300 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
3302 //----------- Read automap_down_count
3303 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
3304 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
3306 //----------- Read automap_state
3307 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
3308 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
3310 //----------- Read stupid-cruise-control-type of throttle.
3312 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
3313 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
3314 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
3315 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
3316 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
3318 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
3321 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
3322 if (Cruise_speed < 0 ) Cruise_speed = 0;
3324 if (Controls.forward_thrust_time==0)
3325 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
3328 #if !defined(MACINTOSH)
3329 //read_head_tracker();
3331 // Read external controls
3332 // if (kc_use_external_control || CybermouseActive)
3333 // kconfig_read_external_controls();
3336 //----------- Clamp values between -FrameTime and FrameTime
3337 if (FrameTime > F1_0 )
3338 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
3340 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
3341 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
3342 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
3343 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
3344 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
3345 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
3346 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
3348 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
3349 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
3350 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
3351 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
3352 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
3353 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
3354 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
3357 //--------- Don't do anything if in debug mode
3359 if ( keyd_pressed[KEY_DELETE] ) {
3360 memset( &Controls, 0, sizeof(control_info) );
3366 void reset_cruise(void)
3372 void kc_set_controls()
3376 for (i=0; i<NUM_KEY_CONTROLS; i++ )
3377 kc_keyboard[i].value = kconfig_settings[0][i];
3379 if ( (Config_control_type>0) && (Config_control_type<5)) {
3380 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3381 kc_joystick[i].value = kconfig_settings[Config_control_type][i];
3382 if (kc_joystick[i].type == BT_INVERT ) {
3383 if (kc_joystick[i].value!=1)
3384 kc_joystick[i].value = 0;
3385 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
3388 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
3389 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3390 kc_mouse[i].value = kconfig_settings[Config_control_type][i];
3391 if (kc_mouse[i].type == BT_INVERT ) {
3392 if (kc_mouse[i].value!=1)
3393 kc_mouse[i].value = 0;
3394 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
3397 } else if (Config_control_type == CONTROL_WINJOYSTICK) {
3398 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3399 kc_superjoy[i].value = kconfig_settings[Config_control_type][i];
3400 if (kc_superjoy[i].type == BT_INVERT ) {
3401 if (kc_superjoy[i].value!=1)
3402 kc_superjoy[i].value = 0;
3403 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
3409 #if 0 //ndef MACINTOSH // no mac support for vr headset
3411 void kconfig_center_headset()
3415 vfx_center_headset();
3417 // } else if (iglasses_headset_installed) {
3418 // } else if (Victor_headset_installed) {
3424 #endif // end of #ifndef MACINTOSH for kconfig_center_headset
3426 void CybermouseAdjust ()
3428 /* if ( Player_num > -1 ) {
3429 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3430 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3431 Auto_leveling_on = 0;
3433 if ( kc_external_version > 0 ) {
3434 vms_matrix tempm, ViewMatrix;
3435 vms_angvec * Kconfig_abs_movement;
3438 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
3440 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3441 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3442 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3443 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3445 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3446 if (oem_message[0] != '\0' )
3447 HUD_init_message( oem_message );
3451 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3452 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3453 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3454 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3455 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3456 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3457 // Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3458 // Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3459 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3460 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3461 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3462 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3463 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3464 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3465 // Controls.automap_down_count += kc_external_control->automap_down_count;
3466 // Controls.automap_state |= kc_external_control->automap_state;
3469 char GetKeyValue (char key)
3471 mprintf ((0,"Returning %c!\n",kc_keyboard[(int)key].value));
3472 return (kc_keyboard[(int)key].value);
3475 #if !defined(MACINTOSH)
3478 extern object *obj_find_first_of_type (int);
3479 void kconfig_read_external_controls()
3484 if ( !kc_enable_external_control ) return;
3486 if ( kc_external_version == 0 )
3487 memset( kc_external_control, 0, sizeof(ext_control_info));
3488 else if ( kc_external_version > 0 ) {
3490 if (kc_external_version>=4)
3491 memset( kc_external_control, 0, sizeof(advanced_ext_control_info));
3492 else if (kc_external_version>0)
3493 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 );
3494 else if (kc_external_version>2)
3495 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof(vms_matrix) +4 );
3497 if ( kc_external_version > 1 ) {
3498 // Write ship pos and angles to external controls...
3499 ubyte *temp_ptr = (ubyte *)kc_external_control;
3500 vms_vector *ship_pos;
3501 vms_matrix *ship_orient;
3502 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
3503 temp_ptr += sizeof(ext_control_info) + sizeof(vms_angvec) + 64;
3504 ship_pos = (vms_vector *)temp_ptr;
3505 temp_ptr += sizeof(vms_vector);
3506 ship_orient = (vms_matrix *)temp_ptr;
3507 // Fill in ship postion...
3508 *ship_pos = Objects[Players[Player_num].objnum].pos;
3509 // Fill in ship orientation...
3510 *ship_orient = Objects[Players[Player_num].objnum].orient;
3512 if (kc_external_version>=4)
3514 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3516 temp_ptr->headlight_state=(Players[Player_num].flags & PLAYER_FLAGS_HEADLIGHT_ON);
3517 temp_ptr->primary_weapon_flags=Players[Player_num].primary_weapon_flags;
3518 temp_ptr->secondary_weapon_flags=Players[Player_num].secondary_weapon_flags;
3519 temp_ptr->current_primary_weapon=Primary_weapon;
3520 temp_ptr->current_secondary_weapon=Secondary_weapon;
3522 temp_ptr->current_guidebot_command=Escort_goal_object;
3524 temp_ptr->force_vector=ExtForceVec;
3525 temp_ptr->force_matrix=ExtApplyForceMatrix;
3527 temp_ptr->joltinfo[i]=ExtJoltInfo[i];
3529 temp_ptr->x_vibrate_info[i]=ExtXVibrateInfo[i];
3530 temp_ptr->x_vibrate_clear=ExtXVibrateClear;
3531 temp_ptr->game_status=ExtGameStatus;
3533 memset ((void *)&ExtForceVec,0,sizeof(vms_vector));
3534 memset ((void *)&ExtApplyForceMatrix,0,sizeof(vms_matrix));
3539 ExtXVibrateInfo[i]=0;
3544 if ( Automap_active ) // (If in automap...)
3545 kc_external_control->automap_state = 1;
3546 //memset(&r,0,sizeof(r));
3550 int386 ( kc_external_intno, &r, &r); // Read external info...
3554 if ( Player_num > -1 ) {
3555 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3556 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3557 Auto_leveling_on = 0;
3559 if ( kc_external_version > 0 ) {
3560 vms_matrix tempm, ViewMatrix;
3561 vms_angvec * Kconfig_abs_movement;
3564 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(ext_control_info));
3566 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3567 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3568 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3569 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3571 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3572 if (oem_message[0] != '\0' )
3573 HUD_init_message( oem_message );
3577 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3578 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3579 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3580 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3581 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3582 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3583 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3584 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3585 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3586 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3587 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3588 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3589 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3590 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3591 Controls.automap_down_count += kc_external_control->automap_down_count;
3592 Controls.automap_state |= kc_external_control->automap_state;
3594 if (kc_external_version>=3)
3596 ubyte *temp_ptr = (ubyte *)kc_external_control;
3597 temp_ptr += (sizeof(ext_control_info) + sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof (vms_matrix));
3600 Controls.cycle_primary_count=(*(temp_ptr));
3602 Controls.cycle_secondary_count=(*(temp_ptr+1));
3605 Controls.afterburner_state=(*(temp_ptr+2));
3607 Controls.headlight_count=(*(temp_ptr+3));
3609 if (kc_external_version>=4)
3612 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3615 if (temp_ptr->keyboard[i])
3618 if (temp_ptr->Reactor_blown)
3620 if (Game_mode & GM_MULTI)
3621 net_destroy_controlcen (obj_find_first_of_type (OBJ_CNTRLCEN));
3623 do_controlcen_destroyed_stuff(obj_find_first_of_type (OBJ_CNTRLCEN));