2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
16 static char rcsid[] = "$Id: kconfig.c,v 1.5 2001-01-29 14:08:24 bradleyb Exp $";
31 #include "pa_enabl.h" //$$POLY_ACC
74 #include "linux_joystick.h"
77 ubyte ExtGameStatus=1;
79 vms_vector ExtForceVec;
80 vms_matrix ExtApplyForceMatrix;
82 int ExtJoltInfo[3]={0,0,0};
83 int ExtXVibrateInfo[2]={0,0};
84 int ExtYVibrateInfo[2]={0,0};
85 ubyte ExtXVibrateClear=0;
86 ubyte ExtYVibrateClear=0;
88 #define TABLE_CREATION 1
90 // Array used to 'blink' the cursor while waiting for a keypress.
91 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 };
93 //char * invert_text[2] = { "N", "Y" };
94 //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" };
95 //char * joyaxis_text[4] = { "X1", "Y1", "X2", "Y2" };
96 //char * mouseaxis_text[2] = { "L/R", "F/B" };
97 //char * mousebutton_text[3] = { "Left", "Right", "Mid" };
99 int invert_text[2] = { TNUM_N, TNUM_Y };
102 int joybutton_text[28] =
103 { TNUM_BTN_1, TNUM_BTN_2, TNUM_BTN_3, TNUM_BTN_4,
107 TNUM_HAT_L, TNUM_HAT_R, TNUM_HAT_U, TNUM_HAT_D,
111 int joyaxis_text[7] = { TNUM_X1, TNUM_Y1, TNUM_Z1, TNUM_UN, TNUM_P1,TNUM_R1,TNUM_YA1 };
113 int joybutton_text[28] =
114 { TNUM_BTN_1, TNUM_BTN_2, TNUM_BTN_3, TNUM_BTN_4,
115 -1, TNUM_TRIG, TNUM_LEFT, TNUM_HAT_L,
116 TNUM_RIGHT, -1, TNUM_HAT2_D, TNUM_HAT_R,
117 TNUM_MID, -1, TNUM_HAT2_R, TNUM_HAT_U,
118 TNUM_HAT2_L, -1, TNUM_HAT2_U, TNUM_HAT_D,
119 TNUM_TRIG, TNUM_LEFT, TNUM_RIGHT, -1,
120 TNUM_UP, TNUM_DOWN, TNUM_LEFT, TNUM_RIGHT };
122 int joyaxis_text[7] = { TNUM_X1, TNUM_Y1, TNUM_Z1, TNUM_UN, TNUM_P1,TNUM_R1,TNUM_YA1 };
123 // int joyaxis_text[4] = { TNUM_X1, TNUM_Y1, TNUM_X2, TNUM_Y2 };
126 int mouseaxis_text[2] = { TNUM_L_R, TNUM_F_B };
128 int mousebutton_text[3] = { TNUM_LEFT, TNUM_RIGHT, TNUM_MID };
130 char *mousebutton_text[3] = { "Btn", "", "" }; // only one silly mouse button on the mac
134 char * key_text[256] = {
135 "","S","D","F","H","G","Z","X","C","V","","B","Q", "W", "E", "R",
136 "Y","T","1","2","3","4","6","5","=","9","7","-", "8", "0", "]", "O",
137 "U","[","I","P","RET","L","J","'","K", ";", "\\", ",", "/", "N", "M", ".",
138 "TAB","SPC","`","DEL","","ESC","","APL","SHIFT","CAPSL","OPTN","CTRL","","","","A",
139 "","PAD.","","PAD*","","PAD+","","NMLCK","","","","PAD/","ENTER","","PAD-","",
140 "","PAD=","PAD0","PAD1","PAD2","PAD3","PAD4","PAD5","PAD6","PAD7","","PAD8","PAD9","","","",
141 "F5","F6","F7","","F8","F9","","F11","","F13","","F14","","F10","","F12",
142 "","PAUSE","HELP","HOME","PGUP","DEL","","END","F2","","F1","LARW","RARW","DARW","UARW","",
143 "","","","","","","","","","","","","","","","",
144 "","","","","","","","","","","","","","","","",
145 "","","","","","","","","","","","","","","","",
146 "","","","","","","","","","","","","","","","",
147 "","","","","","","","","","","","","","","","",
148 "","","","","","","","","","","","","","","","",
149 "","","","","","","","","","","","","","","","",
150 "","","","","","","","","","","","","","","",""};
153 char * key_text[256] = { \
154 "","ESC","1","2","3","4","5","6","7","8","9","0","-", \
155 "=","BSPC","TAB","Q","W","E","R","T","Y","U","I","O", \
156 "P","[","]","
\83","LCTRL","A","S","D","F", \
157 "G","H","J","K","L",";","'","`", \
158 "LSHFT","\\","Z","X","C","V","B","N","M",",", \
159 ".","/","RSHFT","PAD*","LALT","SPC", \
160 "CPSLK","F1","F2","F3","F4","F5","F6","F7","F8","F9", \
161 "F10","NMLCK","SCLK","PAD7","PAD8","PAD9","PAD-", \
162 "PAD4","PAD5","PAD6","PAD+","PAD1","PAD2","PAD3","PAD0", \
163 "PAD.","","","","F11","F12","","","","","","","","","", \
164 "","","","","","","","","","","","","","","","","","","","", \
165 "","","","","","","","","","","","","","","","","","","","", \
166 "","","","","","","","","","","","","","","","","","", \
167 "PAD
\83","RCTRL","","","","","","","","","","","","","", \
168 "","","","","","","","","","","PAD/","","","RALT","", \
169 "","","","","","","","","","","","","","HOME","
\82","PGUP", \
170 "","
\81","","
\7f","","END","
\80","PGDN","INS", \
171 "DEL","","","","","","","","","","","","","","","","","", \
172 "","","","","","","","","","","","","","","","","","","","", \
173 "","","","","","","" };
177 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 };
179 //extern void GameLoop(int, int );
181 extern void transfer_energy_to_shield(fix);
182 extern void CyclePrimary(),CycleSecondary(),InitMarkerInput();
183 extern ubyte DefiningMarkerMessage;
184 extern char CybermouseActive;
187 extern int joydefsw_do_button();
188 extern int joydefsw_do_winjoybutton(int *axis);
189 extern joydefsw_win_joyselect(char *title);
192 control_info Controls;
196 // macros for drawing lo/hi res kconfig screens (see scores.c as well)
198 #define LHX(x) ((x)*(MenuHires?2:1))
199 #define LHY(y) ((y)*(MenuHires?2.4:1))
203 #define BT_MOUSE_BUTTON 1
204 #define BT_MOUSE_AXIS 2
205 #define BT_JOY_BUTTON 3
206 #define BT_JOY_AXIS 4
209 char *btype_text[] = { "BT_KEY", "BT_MOUSE_BUTTON", "BT_MOUSE_AXIS", "BT_JOY_BUTTON", "BT_JOY_AXIS", "BT_INVERT" };
213 typedef struct kc_item {
214 short id; // The id of this item
222 ubyte value; // what key,button,etc
228 ubyte kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS];
230 //----------- WARNING!!!!!!! -------------------------------------------
231 // THESE NEXT FOUR BLOCKS OF DATA ARE GENERATED BY PRESSING DEL+F12 WHEN
232 // IN THE KEYBOARD CONFIG SCREEN. BASICALLY, THAT PROCEDURE MODIFIES THE
233 // U,D,L,R FIELDS OF THE ARRAYS AND DUMPS THE NEW ARRAYS INTO KCONFIG.COD
234 //-------------------------------------------------------------------------
235 /*ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
236 {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},
237 {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},
238 {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},
239 {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},
240 {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},
241 {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},
242 {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},
246 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
247 {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},
248 {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},
249 {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},
250 {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},
251 {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},
252 {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},
253 {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},
255 {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},
261 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
262 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
263 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
264 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
265 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
266 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
267 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
268 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
269 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
270 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
271 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
272 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
273 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
274 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
275 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
276 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
277 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
278 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
279 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
280 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
281 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
282 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
283 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
284 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
285 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
286 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
287 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
288 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
289 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
290 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
291 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
292 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
293 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
294 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
295 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
296 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
297 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
298 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
299 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
300 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
301 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
302 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
303 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
304 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
305 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
306 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
307 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
308 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
309 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
310 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
311 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
312 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
313 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
314 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
315 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
316 { 54,158,171, 83, 26, 52, 56, 51, 55,"Energy->Shield", BT_KEY, 255 },
317 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
318 { 56,158,179,83, 26, 54, 0, 0, 0, "Toggle Bomb", BT_KEY,255},
320 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
321 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
322 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
323 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
324 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
325 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
326 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
327 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
328 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
329 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
330 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
331 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
332 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
333 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
334 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
335 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
336 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
337 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
338 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
339 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
340 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
341 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
342 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
343 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
344 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
345 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
346 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
347 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
348 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
349 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
350 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
351 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
353 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
354 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
355 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
356 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
357 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
358 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
359 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
360 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
361 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
362 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
363 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
364 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
365 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
366 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
367 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
368 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
369 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
370 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
371 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
372 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
373 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
374 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
375 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
376 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
377 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
378 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
379 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
380 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
381 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
382 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
383 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
384 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
387 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
388 { 0, 25, 46, 85, 26, 12, 1, 24, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
389 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
390 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
391 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
392 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
393 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
394 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
395 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
396 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
397 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
398 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
399 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
400 { 12,180,106, 59, 26, 11, 0, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
401 { 13,103,138, 58, 26, 27, 15, 25, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
402 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
403 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
404 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
405 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
406 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
407 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
408 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
409 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
410 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
411 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
412 { 24,103,182,106, 8, 22, 5, 23, 0,"throttle", BT_INVERT, 255 },
413 { 25, 25,109, 85, 26, 3, 27, 12, 13,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
414 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
415 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
418 #else // ifndef MACINTOSH (following are macintosh controls)
420 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
421 {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},
422 {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},
423 {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},
424 {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},
425 {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},
426 {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},
427 {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},
430 ubyte default_firebird_settings[MAX_CONTROLS] =
431 {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};
433 ubyte default_mousestick_settings[MAX_CONTROLS] =
434 {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};
436 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
437 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
438 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
439 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
440 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
441 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
442 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
443 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
444 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
445 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
446 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
447 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
448 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
449 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
450 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
451 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
452 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
453 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
454 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
455 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
456 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
457 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
458 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
459 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
460 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
461 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
462 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
463 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
464 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
465 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
466 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
467 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
468 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
469 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
470 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
471 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
472 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
473 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
474 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
475 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
476 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
477 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
478 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
479 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
480 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
481 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
482 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
483 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
484 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
485 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
486 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
487 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
488 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
489 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
490 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
491 { 54,158,171, 83, 26, 52, 25, 51, 55,"Energy->Shield", BT_KEY, 255 },
492 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
494 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
495 { 0, 25, 46, 85, 28, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
496 { 1, 25, 54, 85, 28, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
497 { 2, 25, 85, 85, 28, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
498 { 3, 25, 93, 85, 28, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
499 { 4, 25, 62, 85, 28, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
500 { 5,180, 46, 79, 28, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
501 { 6,180, 54, 79, 28, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
502 { 7,180, 62, 79, 28, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
503 { 8,180, 70, 79, 28, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
504 { 9,180, 78, 79, 28, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
505 { 10,180, 90, 79, 28, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
506 { 11,180, 98, 79, 28, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
507 { 12,180,106, 79, 28, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
508 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
509 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
510 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
511 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
512 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
513 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
514 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
515 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
516 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
517 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
518 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
519 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
520 { 25, 25,109, 85, 28, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
521 { 26, 25, 70, 85, 28, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
522 { 27, 25,117, 85, 28, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
523 { 28,180,114, 79, 28, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
524 { 29,180,122, 79, 28, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
525 { 30, 25,125, 85, 28, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
527 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
528 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
529 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
530 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
531 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
532 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
533 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
534 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
535 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
536 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
537 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
538 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
539 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
540 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
541 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
542 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
543 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
544 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
545 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
546 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
547 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
548 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
549 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
550 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
551 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
552 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
553 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
554 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
555 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
556 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
557 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
558 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
561 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
562 { 0, 25, 46, 85, 26, 28, 1, 28, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
563 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
564 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
565 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
566 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
567 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
568 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
569 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
570 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
571 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
572 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
573 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
574 { 12,180,106, 59, 26, 11, 28, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
575 { 13,103,138, 58, 26, 27, 15, 27, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
576 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
577 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
578 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
579 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
580 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
581 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
582 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
583 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
584 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
585 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
586 { 24,103,182,106, 8, 22, 5, 23, 28,"throttle", BT_INVERT, 255 },
587 { 25, 25,109, 85, 26, 3, 27, 12, 27,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
588 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
589 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
594 void kc_drawitem( kc_item *item, int is_current );
595 void kc_change_key( kc_item * item );
596 void kc_change_joybutton( kc_item * item );
597 void kc_change_mousebutton( kc_item * item );
598 void kc_change_joyaxis( kc_item * item );
599 void kc_change_mouseaxis( kc_item * item );
600 void kc_change_invert( kc_item * item );
601 void kconfig_read_fcs( int raw_axis );
602 void kconfig_set_fcs_button( int btn, int button );
603 void kconfig_read_external_controls( void );
605 int kconfig_is_axes_used(int axis)
608 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
609 if (( kc_joystick[i].type == BT_JOY_AXIS ) && (kc_joystick[i].value == axis ))
615 #ifdef TABLE_CREATION
616 int find_item_at( kc_item * items, int nitems, int x, int y )
620 for (i=0; i<nitems; i++ ) {
621 if ( ((items[i].x+items[i].w1)==x) && (items[i].y==y))
627 int find_next_item_up( kc_item * items, int nitems, int citem )
632 x = items[citem].x+items[citem].w1;
637 y = grd_curcanv->cv_bitmap.bm_h-1;
640 x = grd_curcanv->cv_bitmap.bm_w-1;
643 i = find_item_at( items, nitems, x, y );
649 int find_next_item_down( kc_item * items, int nitems, int citem )
654 x = items[citem].x+items[citem].w1;
658 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
661 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
665 i = find_item_at( items, nitems, x, y );
671 int find_next_item_right( kc_item * items, int nitems, int citem )
676 x = items[citem].x+items[citem].w1;
680 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
683 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
687 i = find_item_at( items, nitems, x, y );
693 int find_next_item_left( kc_item * items, int nitems, int citem )
698 x = items[citem].x+items[citem].w1;
703 x = grd_curcanv->cv_bitmap.bm_w-1;
706 y = grd_curcanv->cv_bitmap.bm_h-1;
709 i = find_item_at( items, nitems, x, y );
716 #if defined(MACINTOSH) || defined(WINDOWS)
717 int get_item_height(kc_item *item)
722 if (item->value==255) {
723 sprintf( btext, "" );
725 switch( item->type ) {
727 strncpy( btext, key_text[item->value], 10 ); break;
728 case BT_MOUSE_BUTTON:
730 strncpy( btext, Text_string[mousebutton_text[item->value]], 10); break;
732 strncpy( btext, mousebutton_text[item->value], 10 ); break;
735 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
737 if ( joybutton_text[item->value] !=-1 )
738 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
740 sprintf( btext, "BTN%d", item->value );
743 strncpy( btext, Text_string[joyaxis_text[item->value]], 10 ); break;
745 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
748 gr_get_string_size(btext, &w, &h, &aw );
754 void kconfig_sub(kc_item * items,int nitems, char * title)
757 dd_grs_canvas * save_canvas,
758 grs_canvas * save_canvas
760 grs_font * save_font;
762 #if defined(MACINTOSH) || defined(WINDOWS)
763 int mouse_state, omouse_state, mx, my, x1, x2, y1, y2;
764 int close_x, close_y, close_size;
767 int i,k,ocitem,citem;
768 int time_stopped = 0;
769 WIN(char *old_bg_pcx);
771 WIN(old_bg_pcx = _SCRContext.bkg_filename);
772 WIN(DEFINE_SCREEN(NULL));
777 if (!((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence)) )
783 // if (Config_control_type == CONTROL_WINJOYSTICK) {
785 // joydefsw_win_joyselect(title2); title = title2,
787 // ); // Get Samir...
791 save_canvas = dd_grd_curcanv,
792 save_canvas = grd_curcanv
797 dd_gr_set_current_canvas(NULL),
798 gr_set_current_canvas(NULL)
800 save_font = grd_curcanv->cv_font;
806 old_keyd_repeat = keyd_repeat;
809 //gr_clear_canvas( BM_XRGB(0,0,0) );
811 nm_draw_background(0,0,grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
812 gr_palette_load (gr_palette);
814 grd_curcanv->cv_font = MEDIUM3_FONT;
816 WIN(DDGRLOCK(dd_grd_curcanv));
819 p = strchr( title, '\n' );
821 gr_string( 0x8000, LHY(8), title );
826 // if ( items == kc_keyboard ) {
827 // gr_string( 0x8000, 8, "Keyboard" );
828 // } else if ( items == kc_joystick ) {
829 // gr_string( 0x8000, 8, "Joysticks" );
830 // } else if ( items == kc_mouse ) {
831 // gr_string( 0x8000, 8, "Mouse" );
834 #if defined(MACINTOSH) || defined(WINDOWS)
835 close_x = close_y = 15;
837 gr_setcolor( BM_XRGB(0, 0, 0) );
838 gr_rect(close_x, close_y, close_x + close_size, close_y + close_size);
839 gr_setcolor( BM_XRGB(21, 21, 21) );
840 gr_rect( close_x + 2, close_y + 2, close_x + close_size - 2, close_y + close_size -2 );
843 grd_curcanv->cv_font = GAME_FONT;
844 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
847 gr_string( 0x8000, LHY(20), TXT_KCONFIG_STRING_1 );
849 gr_string( 0x8000, LHY(20), "Enter changes, ctrl-d deletes, ctrl-r resets defaults, ESC exits");
851 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
852 if ( items == kc_keyboard ) {
853 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
854 gr_setcolor( BM_XRGB(31,27,6) );
856 gr_scanline( LHX(98), LHX(106), LHY(42) );
857 gr_scanline( LHX(120), LHX(128), LHY(42) );
858 gr_pixel( LHX(98), LHY(43) );
859 gr_pixel( LHX(98), LHY(44) );
860 gr_pixel( LHX(128), LHY(43) );
861 gr_pixel( LHX(128), LHY(44) );
863 gr_string( LHX(109), LHY(40), "OR" );
865 gr_scanline( LHX(253), LHX(261), LHY(42) );
866 gr_scanline( LHX(274), LHX(283), LHY(42) );
867 gr_pixel( LHX(253), LHY(43) );
868 gr_pixel( LHX(253), LHY(44) );
869 gr_pixel( LHX(283), LHY(43) );
870 gr_pixel( LHX(283), LHY(44) );
872 gr_string( LHX(264), LHY(40), "OR" );
874 } if ( items == kc_joystick ) {
875 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
876 gr_setcolor( BM_XRGB(31,27,6) );
877 gr_scanline( LHX(18), LHX(135), LHY(37) );
878 gr_scanline( LHX(181), LHX(294), LHY(37) );
879 gr_scanline( LHX(18), LHX(144), LHY(119+18) );
880 gr_scanline( LHX(174), LHX(294), LHY(119+18) );
881 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
882 gr_string( 0x8000,LHY(117+18), TXT_AXES );
883 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
884 gr_string( LHX(81), LHY(137+8), TXT_AXIS );
885 gr_string( LHX(111), LHY(137+8), TXT_INVERT );
886 gr_string( LHX(222), LHY(137+8), TXT_AXIS );
887 gr_string( LHX(252), LHY(137+8), TXT_INVERT );
888 } else if ( items == kc_mouse ) {
889 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
890 gr_setcolor( BM_XRGB(31,27,6) );
891 gr_scanline( LHX(18), LHX(135), LHY(37) );
892 gr_scanline( LHX(181), LHX(294), LHY(37) );
893 gr_scanline( LHX(18), LHX(144), LHY(119+5) );
894 gr_scanline( LHX(174), LHX(294), LHY(119+5) );
895 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
896 gr_string( 0x8000,LHY(117+5), TXT_AXES );
897 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
898 gr_string( LHX(169), LHY(129), TXT_AXIS );
899 gr_string( LHX(199), LHY(129), TXT_INVERT );
901 WIN(DDGRUNLOCK(dd_grd_curcanv));
903 for (i=0; i<nitems; i++ ) {
904 kc_drawitem( &items[i], 0 );
908 kc_drawitem( &items[citem], 1 );
913 #if defined(MACINTOSH) || defined(WINDOWS)
914 mouse_state = omouse_state = 0;
918 // Windows addendum to allow for kconfig input.
923 DoMessageStuff(&msg);
926 _RedrawScreen = FALSE;
928 dd_gr_set_current_canvas(NULL);
938 //see if redbook song needs to be restarted
939 songs_check_redbook_repeat();
943 #if defined(MACINTOSH) || defined(WINDOWS)
944 omouse_state = mouse_state;
945 mouse_state = mouse_button_state(0);
948 if ( !time_stopped ) {
950 if (multi_menu_poll() == -1)
959 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_3:)
960 case KEY_PRINT_SCREEN:
963 case KEY_CTRLED+KEY_D:
964 items[citem].value = 255;
965 kc_drawitem( &items[citem], 1 );
967 case KEY_CTRLED+KEY_R:
968 if ( items==kc_keyboard ) {
969 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
970 items[i].value=default_kconfig_settings[0][i];
971 kc_drawitem( &items[i], 0 );
975 // hack for firebire and mousestick default controls since I made
976 // them the same control type -- dumb dumb dumb
977 if (joy_have_firebird())
978 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
979 items[i].value = default_firebird_settings[i];
980 kc_drawitem( &items[i], 0 );
982 else if (joy_have_mousestick())
983 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
984 items[i].value = default_mousestick_settings[i];
985 kc_drawitem( &items[i], 0 );
988 #endif // note link to above else
989 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
990 items[i].value = default_kconfig_settings[Config_control_type][i];
991 kc_drawitem( &items[i], 0 );
994 kc_drawitem( &items[citem], 1 );
997 items[citem].value=255;
998 kc_drawitem( &items[citem], 1 );
1002 #ifdef TABLE_CREATION
1003 if (items[citem].u==-1) items[citem].u=find_next_item_up( items,nitems, citem);
1005 citem = items[citem].u;
1010 #ifdef TABLE_CREATION
1011 if (items[citem].d==-1) items[citem].d=find_next_item_down( items,nitems, citem);
1013 citem = items[citem].d;
1017 #ifdef TABLE_CREATION
1018 if (items[citem].l==-1) items[citem].l=find_next_item_left( items,nitems, citem);
1020 citem = items[citem].l;
1024 #ifdef TABLE_CREATION
1025 if (items[citem].r==-1) items[citem].r=find_next_item_right( items,nitems, citem);
1027 citem = items[citem].r;
1031 switch( items[citem].type ) {
1032 case BT_KEY: kc_change_key( &items[citem] ); break;
1033 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1034 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1035 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1036 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1037 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1042 grd_curcanv->cv_font = save_font;
1044 WIN(DEFINE_SCREEN(old_bg_pcx));
1047 dd_gr_set_current_canvas(save_canvas),
1048 gr_set_current_canvas( save_canvas )
1050 keyd_repeat = old_keyd_repeat;
1051 game_flush_inputs();
1052 WIN( HideCursorW());
1053 MAC( hide_cursor(); )
1057 #ifdef TABLE_CREATION
1058 case KEY_DEBUGGED+KEY_F12: {
1060 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1061 kc_keyboard[i].u = find_next_item_up( kc_keyboard,NUM_KEY_CONTROLS, i);
1062 kc_keyboard[i].d = find_next_item_down( kc_keyboard,NUM_KEY_CONTROLS, i);
1063 kc_keyboard[i].l = find_next_item_left( kc_keyboard,NUM_KEY_CONTROLS, i);
1064 kc_keyboard[i].r = find_next_item_right( kc_keyboard,NUM_KEY_CONTROLS, i);
1066 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1067 kc_joystick[i].u = find_next_item_up( kc_joystick,NUM_OTHER_CONTROLS, i);
1068 kc_joystick[i].d = find_next_item_down( kc_joystick,NUM_OTHER_CONTROLS, i);
1069 kc_joystick[i].l = find_next_item_left( kc_joystick,NUM_OTHER_CONTROLS, i);
1070 kc_joystick[i].r = find_next_item_right( kc_joystick,NUM_OTHER_CONTROLS, i);
1072 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1073 kc_mouse[i].u = find_next_item_up( kc_mouse,NUM_OTHER_CONTROLS, i);
1074 kc_mouse[i].d = find_next_item_down( kc_mouse,NUM_OTHER_CONTROLS, i);
1075 kc_mouse[i].l = find_next_item_left( kc_mouse,NUM_OTHER_CONTROLS, i);
1076 kc_mouse[i].r = find_next_item_right( kc_mouse,NUM_OTHER_CONTROLS, i);
1078 fp = fopen( "kconfig.cod", "wt" );
1080 fprintf( fp, "ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {\n" );
1081 for (i=0; i<CONTROL_MAX_TYPES; i++ ) {
1083 fprintf( fp, "{0x%x", kconfig_settings[i][0] );
1084 for (j=1; j<MAX_CONTROLS; j++ )
1085 fprintf( fp, ",0x%x", kconfig_settings[i][j] );
1086 fprintf( fp, "},\n" );
1088 fprintf( fp, "};\n" );
1090 fprintf( fp, "\nkc_item kc_keyboard[NUM_KEY_CONTROLS] = {\n" );
1091 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1092 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1093 kc_keyboard[i].id, kc_keyboard[i].x, kc_keyboard[i].y, kc_keyboard[i].w1, kc_keyboard[i].w2,
1094 kc_keyboard[i].u, kc_keyboard[i].d, kc_keyboard[i].l, kc_keyboard[i].r,
1095 34, kc_keyboard[i].text, 34, btype_text[kc_keyboard[i].type] );
1097 fprintf( fp, "};" );
1099 fprintf( fp, "\nkc_item kc_joystick[NUM_OTHER_CONTROLS] = {\n" );
1100 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1101 if (kc_joystick[i].type == BT_JOY_BUTTON)
1102 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1103 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1104 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1105 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1107 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1108 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1109 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1110 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1112 fprintf( fp, "};" );
1114 fprintf( fp, "\nkc_item kc_mouse[NUM_OTHER_CONTROLS] = {\n" );
1115 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1116 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1117 kc_mouse[i].id, kc_mouse[i].x, kc_mouse[i].y, kc_mouse[i].w1, kc_mouse[i].w2,
1118 kc_mouse[i].u, kc_mouse[i].d, kc_mouse[i].l, kc_mouse[i].r,
1119 34, kc_mouse[i].text, 34, btype_text[kc_mouse[i].type] );
1121 fprintf( fp, "};" );
1130 #if defined (MACINTOSH) || defined(WINDOWS)
1131 if ( (mouse_state && !omouse_state) || (mouse_state && omouse_state) ) {
1134 mouse_get_pos(&mx, &my);
1135 for (i=0; i<nitems; i++ ) {
1136 item_height = get_item_height( &items[i] );
1137 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[i].x) + LHX(items[i].w1);
1138 x2 = x1 + LHX(items[i].w2);
1139 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[i].y);
1140 y2 = y1 + LHX(item_height);
1141 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1147 else if ( !mouse_state && omouse_state ) {
1150 mouse_get_pos(&mx, &my);
1151 item_height = get_item_height( &items[citem] );
1152 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[citem].x) + LHX(items[citem].w1);
1153 x2 = x1 + LHX(items[citem].w2);
1154 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[citem].y);
1155 y2 = y1 + LHY(item_height);
1156 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1159 switch( items[citem].type ) {
1160 case BT_KEY: kc_change_key( &items[citem] ); break;
1161 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1162 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1163 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1164 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1165 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1170 x1 = grd_curcanv->cv_bitmap.bm_x + close_x + 2;
1171 x2 = x1 + close_size - 2;
1172 y1 = grd_curcanv->cv_bitmap.bm_y + close_y + 2;
1173 y2 = y1 + close_size - 2;
1174 if ( ((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2)) ) {
1175 grd_curcanv->cv_font = save_font;
1176 WINDOS(dd_gr_set_current_canvas( save_canvas ),
1177 gr_set_current_canvas( save_canvas ));
1178 keyd_repeat = old_keyd_repeat;
1179 game_flush_inputs();
1189 #endif // MACINTOSH WINDOWS
1191 if (ocitem!=citem) {
1194 kc_drawitem( &items[ocitem], 0 );
1195 kc_drawitem( &items[citem], 1 );
1203 void kc_drawitem( kc_item *item, int is_current )
1207 // PA_DFX (pa_set_frontbuffer_current());
1208 WIN(DDGRLOCK(dd_grd_curcanv));
1211 gr_set_fontcolor( BM_XRGB(20,20,29), -1 );
1213 gr_set_fontcolor( BM_XRGB(15,15,24), -1 );
1214 gr_string( LHX(item->x), LHY(item->y), item->text );
1215 WIN(DDGRUNLOCK(dd_grd_curcanv));
1217 if (item->value==255) {
1218 strcpy( btext, "" );
1220 switch( item->type ) {
1222 strncpy( btext, key_text[item->value], 10 ); break;
1223 case BT_MOUSE_BUTTON:
1225 strncpy( btext, Text_string[mousebutton_text[item->value]], 10 ); break;
1227 strncpy( btext, mousebutton_text[item->value], 10 ); break;
1230 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
1234 if (joybutton_text[item->value] != -1)
1235 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1237 sprintf( btext, "BTN%2d", item->value+1 );
1239 if ( joybutton_text[item->value] !=-1 )
1240 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1242 sprintf( btext, "BTN%d", item->value );
1245 strncpy( btext, joy_btn_name( item->value ), 10);
1247 sprintf( btext, "BTN%d", item->value );
1251 strncpy( btext, Text_string[joyaxis_text[item->value]], 10 ); break;
1253 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
1257 WIN(DDGRLOCK(dd_grd_curcanv));
1258 gr_get_string_size(btext, &w, &h, &aw );
1261 gr_setcolor( BM_XRGB(21,0,24) );
1263 gr_setcolor( BM_XRGB(16,0,19) );
1264 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1266 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1268 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1270 gr_string( x, LHY(item->y), btext );
1271 // PA_DFX (pa_set_backbuffer_current());
1273 WIN(DDGRUNLOCK(dd_grd_curcanv));
1278 static int looper=0;
1280 void kc_drawquestion( kc_item *item )
1284 WIN(DDGRLOCK(dd_grd_curcanv));
1285 // PA_DFX (pa_set_frontbuffer_current());
1287 gr_get_string_size("?", &w, &h, &aw );
1289 c = BM_XRGB(21,0,24);
1291 //@@gr_setcolor( gr_fade_table[fades[looper]*256+c] );
1292 gr_setcolor(BM_XRGB(21*fades[looper]/31,0,24*fades[looper]/31));
1294 if (looper>63) looper=0;
1296 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1298 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1300 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1302 gr_string( x, LHY(item->y), "?" );
1303 // PA_DFX (pa_set_backbuffer_current());
1304 WIN(DDGRUNLOCK(dd_grd_curcanv));
1308 void kc_change_key( kc_item * item )
1313 WIN(DDGRLOCK(dd_grd_curcanv));
1314 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1316 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_KEY );
1317 WIN(DDGRUNLOCK(dd_grd_curcanv));
1319 game_flush_inputs();
1323 while( (k!=KEY_ESC) && (keycode==255) )
1329 DoMessageStuff(&msg);
1336 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1339 // if ( Game_mode & GM_MULTI )
1340 // GameLoop( 0, 0 ); // Continue
1343 kc_drawquestion( item );
1345 for (i=0; i<256; i++ ) {
1346 if (keyd_pressed[i] && (strlen(key_text[i])>0)) {
1348 for (n=0; n<sizeof(system_keys); n++ )
1349 if ( system_keys[n] == i )
1358 for (i=0; i<Num_items; i++ ) {
1359 n = item - All_items;
1360 if ( (i!=n) && (All_items[i].type==BT_KEY) && (All_items[i].value==keycode) ) {
1361 All_items[i].value = 255;
1362 kc_drawitem( &All_items[i], 0 );
1365 item->value = keycode;
1367 kc_drawitem( item, 1 );
1369 WIN(DDGRLOCK(dd_grd_curcanv));
1370 gr_set_fontcolor( BM_XRGB(28,28,28), BM_XRGB(0,0,0) );
1371 WIN(DDGRUNLOCK(dd_grd_curcanv));
1373 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1375 game_flush_inputs();
1379 void kc_change_joybutton( kc_item * item )
1384 WIN(DDGRLOCK(dd_grd_curcanv));
1385 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1387 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_JBUTTON );
1388 WIN(DDGRUNLOCK(dd_grd_curcanv));
1390 game_flush_inputs();
1394 while( (k!=KEY_ESC) && (code==255))
1399 DoMessageStuff(&msg);
1405 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1408 // if ( Game_mode & GM_MULTI )
1409 // GameLoop( 0, 0 ); // Continue
1413 if (k == KEY_PRINT_SCREEN)
1414 save_screen_shot(0);
1416 kc_drawquestion( item );
1418 WIN(code = joydefsw_do_button());
1421 code = joy_do_buttons();
1424 #if !defined(WINDOWS) && !defined(MACINTOSH)
1425 if (Config_control_type==CONTROL_THRUSTMASTER_FCS) {
1427 joystick_read_raw_axis( JOY_ALL_AXIS, axis );
1428 kconfig_read_fcs( axis[3] );
1429 if ( joy_get_button_state(7) ) code = 7;
1430 if ( joy_get_button_state(11) ) code = 11;
1431 if ( joy_get_button_state(15) ) code = 15;
1432 if ( joy_get_button_state(19) ) code = 19;
1433 for (i=0; i<4; i++ ) {
1434 if ( joy_get_button_state(i) )
1437 } else if (Config_control_type==CONTROL_FLIGHTSTICK_PRO) {
1438 for (i=4; i<20; i++ ) {
1439 if ( joy_get_button_state(i) ) {
1441 mprintf(( 0, "JB: %d\n", code ));
1445 for (i=0; i<MAX_BUTTONS; i++ ) {
1446 if ( joy_get_button_state(i) )
1453 for (i=0; i<Num_items; i++ ) {
1454 n = item - All_items;
1455 if ( (i!=n) && (All_items[i].type==BT_JOY_BUTTON) && (All_items[i].value==code) ) {
1456 All_items[i].value = 255;
1457 kc_drawitem( &All_items[i], 0 );
1462 kc_drawitem( item, 1 );
1463 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1464 game_flush_inputs();
1467 void kc_change_mousebutton( kc_item * item )
1472 WIN(DDGRLOCK(dd_grd_curcanv));
1473 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1475 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_MBUTTON );
1476 WIN(DDGRUNLOCK(dd_grd_curcanv));
1479 game_flush_inputs();
1483 while( (k!=KEY_ESC) && (code==255))
1488 DoMessageStuff(&msg);
1494 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1497 // if ( Game_mode & GM_MULTI )
1498 // GameLoop( 0, 0 ); // Continue
1502 if (k == KEY_PRINT_SCREEN)
1503 save_screen_shot(0);
1505 kc_drawquestion( item );
1507 b = mouse_get_btns();
1508 for (i=0; i<3; i++ ) {
1514 for (i=0; i<Num_items; i++ ) {
1515 n = item - All_items;
1516 if ( (i!=n) && (All_items[i].type==BT_MOUSE_BUTTON) && (All_items[i].value==code) ) {
1517 All_items[i].value = 255;
1518 kc_drawitem( &All_items[i], 0 );
1523 kc_drawitem( item, 1 );
1524 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1525 game_flush_inputs();
1529 void kc_change_joyaxis( kc_item * item )
1533 int old_axis[MAX_AXES];
1535 int axis[JOY_NUM_AXES];
1536 int old_axis[JOY_NUM_AXES];
1545 WIN(DDGRLOCK(dd_grd_curcanv));
1546 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1548 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_JOY_AXIS );
1549 WIN(DDGRUNLOCK(dd_grd_curcanv));
1551 game_flush_inputs();
1556 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, old_axis ),
1557 joystick_read_raw_axis( JOY_ALL_AXIS, old_axis )
1560 while( (k!=KEY_ESC) && (code==255))
1565 DoMessageStuff(&msg);
1571 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1574 // if ( Game_mode & GM_MULTI )
1575 // GameLoop( 0, 0 ); // Continue
1579 if (k == KEY_PRINT_SCREEN)
1580 save_screen_shot(0);
1582 kc_drawquestion( item );
1585 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, axis ),
1586 joystick_read_raw_axis( JOY_ALL_AXIS, axis )
1589 for (i=0; i<numaxis; i++ ) {
1590 #if defined (MACINTOSH)
1591 if ( abs(axis[i]-old_axis[i])>100 ) {
1592 #elif defined(WINDOWS)
1593 if ( abs(axis[i]-old_axis[i])>1024 ) {
1595 if ( abs(axis[i]-old_axis[i])>200 ) {
1598 printf("Axis Movement detected: Axis %i\n", i);
1600 //old_axis[i] = axis[i];
1602 for (i=0; i<Num_items; i++ )
1604 n = item - All_items;
1605 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) )
1611 for (i=0; i<Num_items; i++ ) {
1612 n = item - All_items;
1613 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) ) {
1614 All_items[i].value = 255;
1615 kc_drawitem( &All_items[i], 0 );
1621 kc_drawitem( item, 1 );
1622 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1623 game_flush_inputs();
1627 void kc_change_mouseaxis( kc_item * item )
1633 WIN(DDGRLOCK(dd_grd_curcanv));
1634 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1636 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_MSE_AXIS );
1637 WIN(DDGRUNLOCK(dd_grd_curcanv));
1639 game_flush_inputs();
1643 mouse_get_delta( &dx, &dy );
1645 while( (k!=KEY_ESC) && (code==255))
1650 DoMessageStuff(&msg);
1656 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1659 // if ( Game_mode & GM_MULTI )
1660 // GameLoop( 0, 0 ); // Continue
1664 if (k == KEY_PRINT_SCREEN)
1665 save_screen_shot(0);
1667 kc_drawquestion( item );
1669 mouse_get_delta( &dx, &dy );
1670 if ( abs(dx)>20 ) code = 0;
1671 if ( abs(dy)>20 ) code = 1;
1674 for (i=0; i<Num_items; i++ ) {
1675 n = item - All_items;
1676 if ( (i!=n) && (All_items[i].type==BT_MOUSE_AXIS) && (All_items[i].value==code) ) {
1677 All_items[i].value = 255;
1678 kc_drawitem( &All_items[i], 0 );
1683 kc_drawitem( item, 1 );
1684 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1685 game_flush_inputs();
1690 void kc_change_invert( kc_item * item )
1692 game_flush_inputs();
1699 kc_drawitem( item, 1 );
1703 #include "screens.h"
1705 extern void gr_bm_bitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
1707 void kconfig(int n, char * title)
1710 grs_bitmap *save_bm;
1712 set_screen_mode( SCREEN_MENU );
1717 WIN(mouse_set_mode(0));
1718 WIN(dd_gr_set_current_canvas(NULL));
1720 #if defined(POLY_ACC)
1721 save_bm = gr_create_bitmap2( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h, grd_curcanv->cv_bitmap.bm_type, NULL );
1723 save_bm = gr_create_bitmap( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
1725 Assert( save_bm != NULL );
1727 WIN(DDGRLOCK(dd_grd_curcanv));
1728 gr_bm_bitblt(grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_w,
1729 0, 0, 0, 0, &grd_curcanv->cv_bitmap, save_bm );
1730 WIN(DDGRUNLOCK(dd_grd_curcanv));
1733 case 0:kconfig_sub( kc_keyboard, NUM_KEY_CONTROLS, title );break;
1734 case 1:kconfig_sub( kc_joystick, NUM_OTHER_CONTROLS, title );break;
1735 case 2:kconfig_sub( kc_mouse, NUM_OTHER_CONTROLS, title ); break;
1736 case 3:kconfig_sub( kc_superjoy, NUM_OTHER_CONTROLS, title); break;
1743 WIN(mouse_set_mode(1));
1744 WIN(dd_gr_set_current_canvas(NULL));
1745 WIN(DDGRLOCK(dd_grd_curcanv));
1746 gr_bitmap(0, 0, save_bm);
1747 WIN(DDGRUNLOCK(dd_grd_curcanv));
1748 gr_free_bitmap(save_bm);
1750 reset_cockpit(); //force cockpit redraw next time
1752 // Update save values...
1754 for (i=0; i<NUM_KEY_CONTROLS; i++ )
1755 kconfig_settings[0][i] = kc_keyboard[i].value;
1757 if ( (Config_control_type>0) && (Config_control_type<5)) {
1758 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1759 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
1760 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
1761 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1762 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
1764 else if (Config_control_type == CONTROL_WINJOYSTICK) {
1765 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1766 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
1771 void kconfig_read_fcs( int raw_axis )
1773 int raw_button, button, axis_min[4], axis_center[4], axis_max[4];
1775 if (Config_control_type!=CONTROL_THRUSTMASTER_FCS) return;
1777 joy_get_cal_vals(axis_min, axis_center, axis_max);
1779 if ( axis_max[3] > 1 )
1780 raw_button = (raw_axis*100)/axis_max[3];
1784 if ( raw_button > 88 )
1786 else if ( raw_button > 63 )
1788 else if ( raw_button > 39 )
1790 else if ( raw_button > 15 )
1795 kconfig_set_fcs_button( 19, button );
1796 kconfig_set_fcs_button( 15, button );
1797 kconfig_set_fcs_button( 11, button );
1798 kconfig_set_fcs_button( 7, button );
1802 void kconfig_set_fcs_button( int btn, int button )
1804 int state,time_down,upcount,downcount;
1805 state = time_down = upcount = downcount = 0;
1807 if ( joy_get_button_state(btn) ) {
1808 if ( btn==button ) {
1810 time_down = FrameTime;
1815 if ( btn==button ) {
1817 time_down = FrameTime;
1824 joy_set_btn_values( btn, state, time_down, downcount, upcount );
1830 fix Last_angles_p = 0;
1831 fix Last_angles_b = 0;
1832 fix Last_angles_h = 0;
1833 ubyte Last_angles_read = 0;
1835 extern int VR_sensitivity;
1837 int VR_sense_range[3] = { 25, 50, 75 };
1839 #if 0 //ndef MACINTOSH
1844 fix yaw, pitch, roll;
1847 //------ read vfx1 helmet --------
1848 if (vfx1_installed) {
1849 vfx_get_data(&yaw,&pitch,&roll,&buttons);
1850 } else if (iglasses_headset_installed) {
1851 iglasses_read_headset( &yaw, &pitch, &roll );
1852 } else if (Victor_headset_installed) {
1853 victor_read_headset_filtered( &yaw, &pitch, &roll );
1858 Use_player_head_angles = 0;
1859 if ( Last_angles_read ) {
1863 if ( (Last_angles_h < (F1_0/4) ) && (yaw > ((F1_0*3)/4) ) )
1865 else if ( (yaw < (F1_0/4) ) && (Last_angles_h > ((F1_0*3)/4) ) )
1868 Controls.pitch_time += fixmul((pitch- Last_angles_p)*VR_sense_range[VR_sensitivity],FrameTime);
1869 Controls.heading_time+= fixmul((yaw1 - Last_angles_h)*VR_sense_range[VR_sensitivity],FrameTime);
1870 Controls.bank_time += fixmul((roll - Last_angles_b)*VR_sense_range[VR_sensitivity],FrameTime);
1872 Last_angles_read = 1;
1873 Last_angles_p = pitch;
1874 Last_angles_h = yaw;
1875 Last_angles_b = roll;
1883 #define JOYSTICK_READ_TIME (F1_0/40) // Read joystick at 40 Hz.
1885 #define JOYSTICK_READ_TIME (F1_0/10) // Read joystick at 10 Hz.
1888 fix LastReadTime = 0;
1892 ubyte kc_use_external_control = 0;
1893 ubyte kc_enable_external_control = 0;
1894 ubyte kc_external_intno = 0;
1895 ext_control_info *kc_external_control = NULL;
1896 ubyte *kc_external_name = NULL;
1897 ubyte kc_external_version = 0;
1898 extern int Automap_active;
1900 void kconfig_init_external_controls(int intno, int address)
1903 kc_external_intno = intno;
1904 kc_external_control = (ext_control_info *)address;
1905 kc_use_external_control = 1;
1906 kc_enable_external_control = 1;
1908 i = FindArg ( "-xname" );
1910 kc_external_name = Args[i+1];
1912 kc_external_name = "External Controller";
1914 for (i=0;i<strlen (kc_external_name);i++)
1915 if (kc_external_name[i]=='_')
1916 kc_external_name[i]=' ';
1918 i = FindArg ( "-xver" );
1920 kc_external_version = atoi(Args[i+1]);
1922 printf( "%s int: 0x%x, data: 0x%p, ver:%d\n", kc_external_name, kc_external_intno, kc_external_control, kc_external_version );
1926 #if !defined(MACINTOSH)
1927 /*void kconfig_read_external_controls()
1931 if ( !kc_enable_external_control && !CybermouseActive)
1934 if ( kc_external_version == 0 )
1935 memset( kc_external_control, 0, sizeof(control_info) );
1936 else if ( kc_external_version > 0 ) {
1937 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 );
1938 if ( kc_external_version > 1 ) {
1939 // Write ship pos and angles to external controls...
1940 ubyte *temp_ptr = (ubyte *)kc_external_control;
1941 vms_vector *ship_pos;
1942 vms_matrix *ship_orient;
1943 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
1944 temp_ptr += sizeof(control_info)+sizeof(vms_angvec) + 64;
1945 ship_pos = (vms_vector *)temp_ptr;
1946 temp_ptr += sizeof(vms_vector);
1947 ship_orient = (vms_matrix *)temp_ptr;
1948 // Fill in ship postion...
1949 *ship_pos = Objects[Players[Player_num].objnum].pos;
1950 // Fill in ship orientation...
1951 *ship_orient = Objects[Players[Player_num].objnum].orient;
1955 if ( Automap_active ) // (If in automap...)
1956 kc_external_control->automap_state = 1;
1957 memset(&r,0,sizeof(r));
1961 if (!CybermouseActive)
1962 int386 ( kc_external_intno, &r, &r); // Read external info...
1964 // ReadOWL (kc_external_control);
1968 if ( Player_num > -1 ) {
1969 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
1970 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
1971 Auto_leveling_on = 0;
1973 if ( kc_external_version > 0 ) {
1974 vms_matrix tempm, ViewMatrix;
1975 vms_angvec * Kconfig_abs_movement;
1978 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
1980 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
1981 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
1982 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
1983 Objects[Players[Player_num].objnum].orient = ViewMatrix;
1985 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
1986 if (oem_message[0] != '\0' )
1987 HUD_init_message( oem_message );
1991 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
1992 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
1993 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
1994 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
1995 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
1996 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
1997 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
1998 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
1999 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
2000 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
2001 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
2002 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
2003 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
2004 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
2005 Controls.automap_down_count += kc_external_control->automap_down_count;
2006 Controls.automap_state |= kc_external_control->automap_state;
2011 void controls_read_all_win()
2014 int slide_on, bank_on;
2018 int raw_joy_axis[7];
2020 fix k0, k1, k2, k3, kp;
2021 fix k4, k5, k6, k7, kh;
2022 ubyte channel_masks;
2023 int use_mouse, use_joystick;
2026 if (Game_turbo_mode)
2030 fix temp = Controls.heading_time;
2031 fix temp1 = Controls.pitch_time;
2032 memset( &Controls, 0, sizeof(control_info) );
2033 Controls.heading_time = temp;
2034 Controls.pitch_time = temp1;
2039 ctime = timer_get_fixed_seconds();
2041 // DO JOYSTICK (X,Y,Z R,U,V)
2042 // ----------------------------------------------------------------------------
2043 if ( (LastReadTime + JOYSTICK_READ_TIME) > ctime ) {
2044 if ((ctime < 0) && (LastReadTime > 0))
2045 LastReadTime = ctime;
2047 } else if ((Config_control_type==CONTROL_WINJOYSTICK)) {
2048 LastReadTime = ctime;
2049 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, raw_joy_axis );
2051 for (i=0; i<7; i++ ) {
2052 if (channel_masks&(1<<i)) {
2053 int joy_null_value = 28;
2055 // DO POV if joystick has a hat.
2056 // --------------------------------------------------------------------
2058 joydefsw_do_winjoybutton(raw_joy_axis);
2062 // --------------------------------------------------------------------
2063 // mprintf((0, "(%d)=%d,", i, raw_joy_axis[i]));
2064 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2065 // mprintf((0, "%d ",raw_joy_axis[i]));
2066 // if (i%2) mprintf((0,"\n"));
2069 if (kc_superjoy[23].value==i) // If this is the throttle
2070 joy_null_value = 32; // Then use a larger dead-zone
2072 if (raw_joy_axis[i] > (joy_null_value-2))
2073 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2074 else if (raw_joy_axis[i] < -(joy_null_value+2))
2075 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2077 raw_joy_axis[i] = 0;
2078 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2087 for (i=0; i<6; i++ )
2093 // ----------------------------------------------------------------------------
2094 if (Config_control_type==5) {
2095 mouse_get_delta( &dx, &dy );
2096 mouse_axis[0] = (dx*FrameTime)/35;
2097 mouse_axis[1] = (dy*FrameTime)/25;
2098 mouse_buttons = mouse_get_btns();
2099 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2108 //------------- Read slide_on -------------
2111 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
2112 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
2114 if ((use_joystick)&&(kc_superjoy[5].value<255)) slide_on |= joy_get_button_state( kc_superjoy[5].value );
2116 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
2118 //------------- Read bank_on ---------------
2121 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
2122 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
2124 if ( (use_joystick)&&(kc_superjoy[10].value < 255 )) bank_on |= joy_get_button_state( kc_superjoy[10].value );
2126 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
2128 //------------ Read pitch_time -----------
2130 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2132 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
2133 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
2134 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
2135 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
2138 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
2139 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
2140 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
2141 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
2144 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2145 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
2146 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
2150 Controls.pitch_time = 0;
2152 if (Controls.pitch_time < 0)
2153 Controls.pitch_time = 0;
2155 if (Controls.pitch_time > 0)
2156 Controls.pitch_time = 0;
2157 Controls.pitch_time += kp;
2160 if ( (use_joystick)&&(kc_superjoy[13].value < 255 )) {
2161 if ( !kc_superjoy[14].value ) // If not inverted...
2162 Controls.pitch_time -= (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2164 Controls.pitch_time += (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2168 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
2169 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
2170 if ( !kc_mouse[14].value ) // If not inverted...
2171 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2173 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2176 Controls.pitch_time = 0;
2180 //----------- Read vertical_thrust_time -----------------
2183 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
2184 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
2185 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
2186 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
2189 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
2190 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
2191 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
2192 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
2195 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2196 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
2197 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
2201 if ((use_joystick)&&( kc_superjoy[13].value < 255 )) {
2202 if ( !kc_superjoy[14].value ) // If not inverted...
2203 Controls.vertical_thrust_time += joy_axis[kc_superjoy[13].value];
2205 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[13].value];
2209 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
2210 if ( !kc_mouse[14].value ) // If not inverted...
2211 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
2213 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
2218 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
2219 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
2220 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
2221 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
2224 if ((use_joystick)&&( kc_superjoy[19].value < 255 )) {
2225 if ( !kc_superjoy[20].value ) // If not inverted...
2226 Controls.vertical_thrust_time += joy_axis[kc_superjoy[19].value];
2228 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[19].value];
2231 // From joystick buttons
2232 if ( (use_joystick)&&(kc_superjoy[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_superjoy[8].value );
2233 if ( (use_joystick)&&(kc_superjoy[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_superjoy[9].value );
2235 // From mouse buttons
2236 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
2237 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
2240 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
2241 if ( !kc_mouse[20].value ) // If not inverted...
2242 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
2244 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
2248 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2249 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
2250 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
2253 //---------- Read heading_time -----------
2255 if (!slide_on && !bank_on) {
2256 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2258 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
2259 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
2260 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
2261 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
2264 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
2265 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
2266 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
2267 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
2270 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2271 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
2272 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
2276 Controls.heading_time = 0;
2278 if (Controls.heading_time < 0)
2279 Controls.heading_time = 0;
2281 if (Controls.heading_time > 0)
2282 Controls.heading_time = 0;
2283 Controls.heading_time += kh;
2286 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2287 if ( !kc_superjoy[16].value ) // If not inverted...
2288 Controls.heading_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2290 Controls.heading_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2294 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2295 if ( !kc_mouse[16].value ) // If not inverted...
2296 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2298 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2301 Controls.heading_time = 0;
2304 //----------- Read sideways_thrust_time -----------------
2307 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2308 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2309 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2310 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2313 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
2314 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
2315 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
2316 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
2319 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2320 if ( !kc_superjoy[16].value ) // If not inverted...
2321 Controls.sideways_thrust_time += joy_axis[kc_superjoy[15].value];
2323 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[15].value];
2327 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2328 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
2329 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
2333 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2334 if ( !kc_mouse[16].value ) // If not inverted...
2335 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
2337 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
2342 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
2343 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
2344 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
2345 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
2348 if ( (use_joystick)&&(kc_superjoy[17].value < 255 )) {
2349 if ( !kc_superjoy[18].value ) // If not inverted...
2350 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[17].value];
2352 Controls.sideways_thrust_time += joy_axis[kc_superjoy[17].value];
2355 // From joystick buttons
2356 if ( (use_joystick)&&(kc_superjoy[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_superjoy[6].value );
2357 if ( (use_joystick)&&(kc_superjoy[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_superjoy[7].value );
2359 // From mouse buttons
2360 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
2361 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
2364 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
2365 if ( !kc_mouse[18].value ) // If not inverted...
2366 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
2368 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
2371 //----------- Read bank_time -----------------
2374 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2375 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2376 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2377 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2380 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
2381 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
2382 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
2383 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
2386 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2387 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
2388 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
2392 if ( (use_joystick)&&(kc_superjoy[15].value < 255) ) {
2393 if ( !kc_superjoy[16].value ) // If not inverted...
2394 Controls.bank_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2396 Controls.bank_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2400 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2401 if ( !kc_mouse[16].value ) // If not inverted...
2402 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2404 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2409 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
2410 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
2411 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
2412 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
2415 if ( (use_joystick)&&(kc_superjoy[21].value < 255) ) {
2416 if ( !kc_superjoy[22].value ) // If not inverted...
2417 Controls.bank_time -= joy_axis[kc_superjoy[21].value];
2419 Controls.bank_time += joy_axis[kc_superjoy[21].value];
2422 // From joystick buttons
2423 if ( (use_joystick)&&(kc_superjoy[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_superjoy[11].value );
2424 if ( (use_joystick)&&(kc_superjoy[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_superjoy[12].value );
2426 // From mouse buttons
2427 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
2428 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
2431 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
2432 if ( !kc_mouse[22].value ) // If not inverted...
2433 Controls.bank_time += mouse_axis[kc_mouse[21].value];
2435 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
2439 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2440 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
2441 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
2444 //----------- Read forward_thrust_time -------------
2447 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
2448 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
2449 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
2450 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
2453 if ( (use_joystick)&&(kc_superjoy[23].value < 255 )) {
2454 if ( !kc_superjoy[24].value ) // If not inverted...
2455 Controls.forward_thrust_time -= joy_axis[kc_superjoy[23].value];
2457 Controls.forward_thrust_time += joy_axis[kc_superjoy[23].value];
2460 // From joystick buttons
2461 if ( (use_joystick)&&(kc_superjoy[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_superjoy[2].value );
2462 if ( (use_joystick)&&(kc_superjoy[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_superjoy[3].value );
2465 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
2466 if ( !kc_mouse[24].value ) // If not inverted...
2467 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
2469 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
2472 // From mouse buttons
2473 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
2474 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
2476 //----------- Read afterburner_state -------------
2479 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
2480 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
2482 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
2484 if ( (use_joystick)&&(kc_superjoy[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_superjoy[27].value);
2486 //-------Read headlight key--------------------------
2487 if (kc_keyboard[52].value < 255 )
2488 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
2489 if (kc_keyboard[53].value < 255 )
2490 Controls.headlight_count=key_down_count(kc_keyboard[53].value);
2491 if ((use_joystick)&&(kc_superjoy[30].value < 255 ))
2492 Controls.headlight_count=joy_get_button_down_cnt(kc_superjoy[30].value);
2494 //--------Read Cycle Primary Key------------------
2496 if (kc_keyboard[48].value<255)
2497 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
2498 if (kc_keyboard[49].value<255)
2499 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
2500 if ((use_joystick)&&(kc_superjoy[28].value < 255 ))
2501 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_superjoy[28].value);
2503 //--------Read Cycle Secondary Key------------------
2505 if (kc_keyboard[50].value<255)
2506 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
2507 if (kc_keyboard[51].value<255)
2508 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
2509 if ((use_joystick)&&(kc_superjoy[29].value < 255 ))
2510 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_superjoy[29].value);
2512 //--------Read Toggle Bomb key----------------------
2514 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
2516 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
2518 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
2519 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
2521 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2522 HUD_init_message ("No bombs available!");
2526 if (Players[Player_num].secondary_ammo[bomb]==0)
2528 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2529 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
2533 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
2534 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
2539 //---------Read Energy->Shield key----------
2541 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
2542 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
2543 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
2544 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
2546 //----------- Read fire_primary_down_count
2547 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
2548 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
2549 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_superjoy[0].value);
2550 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
2552 //----------- Read fire_primary_state
2553 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
2554 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
2555 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_superjoy[0].value);
2556 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
2558 //----------- Read fire_secondary_down_count
2559 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
2560 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
2561 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_superjoy[1].value);
2562 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
2564 //----------- Read fire_secondary_state
2565 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
2566 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
2567 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_superjoy[1].value);
2568 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
2570 //----------- Read fire_flare_down_count
2571 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
2572 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
2573 if ((use_joystick)&&(kc_superjoy[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_superjoy[4].value);
2574 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
2576 //----------- Read drop_bomb_down_count
2577 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
2578 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
2579 if ((use_joystick)&&(kc_superjoy[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_superjoy[26].value);
2580 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
2582 //----------- Read rear_view_down_count
2583 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
2584 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
2585 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_superjoy[25].value);
2586 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
2588 //----------- Read rear_view_down_state
2589 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
2590 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
2591 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_superjoy[25].value);
2592 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
2594 //----------- Read automap_down_count
2595 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
2596 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
2598 //----------- Read automap_state
2599 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
2600 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
2602 //----------- Read stupid-cruise-control-type of throttle.
2604 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
2605 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
2606 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
2607 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
2608 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
2610 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
2613 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
2614 if (Cruise_speed < 0 ) Cruise_speed = 0;
2616 if (Controls.forward_thrust_time==0)
2617 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
2620 //read_head_tracker();
2622 // Read external controls
2623 if (kc_use_external_control || CybermouseActive)
2624 kconfig_read_external_controls();
2626 //----------- Clamp values between -FrameTime and FrameTime
2627 if (FrameTime > F1_0 )
2628 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
2630 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
2631 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
2632 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
2633 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
2634 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
2635 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
2636 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
2638 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
2639 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
2640 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
2641 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
2642 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
2643 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
2644 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
2647 //--------- Don't do anything if in debug mode
2649 if ( keyd_pressed[KEY_DELETE] ) {
2650 memset( &Controls, 0, sizeof(control_info) );
2657 fix Next_toggle_time[3]={0,0,0};
2659 int allowed_to_toggle(int i)
2661 //used for keeping tabs of when its ok to toggle headlight,primary,and secondary
2663 if (Next_toggle_time[i] > GameTime)
2664 if (Next_toggle_time[i] < GameTime + (F1_0/8)) // In case time is bogus, never wait > 1 second.
2667 Next_toggle_time[i] = GameTime + (F1_0/8);
2674 void controls_read_all()
2677 int slide_on, bank_on;
2682 #ifdef __ENV_LINUX__
2683 int raw_joy_axis[MAX_AXES];
2685 int raw_joy_axis[JOY_NUM_AXES];
2688 fix k0, k1, k2, k3, kp;
2689 fix k4, k5, k6, k7, kh;
2690 ubyte channel_masks;
2691 int use_mouse, use_joystick;
2697 if (Game_turbo_mode)
2701 fix temp = Controls.heading_time;
2702 fix temp1 = Controls.pitch_time;
2703 memset( &Controls, 0, sizeof(control_info) );
2704 Controls.heading_time = temp;
2705 Controls.pitch_time = temp1;
2710 ctime = timer_get_fixed_seconds();
2712 //--------- Read Joystick -----------
2714 if ( (LastReadTime + JOYSTICK_READ_TIME > ctime) && (Config_control_type!=CONTROL_THRUSTMASTER_FCS) ) {
2715 if ((ctime < 0) && (LastReadTime > 0))
2716 LastReadTime = ctime;
2718 } else if ((Config_control_type>0) && (Config_control_type<5) ) {
2719 LastReadTime = ctime;
2720 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
2722 for (i=0; i<6; i++ ) {
2723 #ifndef __ENV_LINUX__
2724 if (channel_masks&(1<<i)) {
2726 int joy_null_value = 10;
2728 if ( (i==3) && (Config_control_type==CONTROL_THRUSTMASTER_FCS) ) {
2729 kconfig_read_fcs( raw_joy_axis[i] );
2731 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2733 if (kc_joystick[23].value==i) // If this is the throttle
2734 joy_null_value = 20; // Then use a larger dead-zone
2736 if (raw_joy_axis[i] > joy_null_value)
2737 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2738 else if (raw_joy_axis[i] < -joy_null_value)
2739 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2741 raw_joy_axis[i] = 0;
2742 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2744 #ifndef __ENV_LINUX__
2752 for (i=0; i<4; i++ )
2757 //--------- Read Joystick -----------
2758 if ((Config_control_type>0) && (Config_control_type<5) ) {
2759 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
2760 for (i=0; i<4; i++ ) {
2761 if (channel_masks&(1<<i)) {
2762 int joy_null_value = 10;
2764 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2766 if (kc_joystick[23].value==i) // If this is the throttle
2767 joy_null_value = 20; // Then use a larger dead-zone
2769 if (raw_joy_axis[i] > joy_null_value)
2770 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2771 else if (raw_joy_axis[i] < -joy_null_value)
2772 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2774 raw_joy_axis[i] = 0;
2775 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2782 for (i=0; i<4; i++ )
2786 #endif // ifndef MACINTOSH
2788 if (Config_control_type==5 && !CybermouseActive) {
2789 //--------- Read Mouse -----------
2790 mouse_get_delta( &dx, &dy );
2791 mouse_axis[0] = (dx*FrameTime)/35;
2792 mouse_axis[1] = (dy*FrameTime)/25;
2793 mouse_buttons = mouse_get_btns();
2794 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2796 } else if (Config_control_type==6 && !CybermouseActive) {
2797 //--------- Read Cyberman -----------
2798 mouse_get_cyberman_pos(&idx,&idy );
2799 mouse_axis[0] = (idx*FrameTime)/128;
2800 mouse_axis[1] = (idy*FrameTime)/128;
2801 mouse_buttons = mouse_get_btns();
2803 } else if (CybermouseActive) {
2804 // ReadOWL (kc_external_control);
2805 // CybermouseAdjust();
2813 //------------- Read slide_on -------------
2816 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
2817 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
2819 if ((use_joystick)&&(kc_joystick[5].value<255)) slide_on |= joy_get_button_state( kc_joystick[5].value );
2821 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
2823 //------------- Read bank_on ---------------
2826 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
2827 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
2829 if ( (use_joystick)&&(kc_joystick[10].value < 255 )) bank_on |= joy_get_button_state( kc_joystick[10].value );
2831 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
2833 //------------ Read pitch_time -----------
2835 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2837 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
2838 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
2839 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
2840 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
2843 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
2844 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
2845 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
2846 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
2849 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2850 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
2851 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
2855 Controls.pitch_time = 0;
2857 if (Controls.pitch_time < 0)
2858 Controls.pitch_time = 0;
2860 if (Controls.pitch_time > 0)
2861 Controls.pitch_time = 0;
2862 Controls.pitch_time += kp;
2865 if ( (use_joystick)&&(kc_joystick[13].value < 255 )) {
2866 if ( !kc_joystick[14].value ) // If not inverted...
2867 Controls.pitch_time -= (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
2869 Controls.pitch_time += (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
2873 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
2874 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
2875 if ( !kc_mouse[14].value ) // If not inverted...
2876 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2878 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2881 Controls.pitch_time = 0;
2885 //----------- Read vertical_thrust_time -----------------
2888 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
2889 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
2890 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
2891 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
2894 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
2895 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
2896 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
2897 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
2900 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2901 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
2902 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
2906 if ((use_joystick)&&( kc_joystick[13].value < 255 )) {
2907 if ( !kc_joystick[14].value ) // If not inverted...
2908 Controls.vertical_thrust_time += joy_axis[kc_joystick[13].value];
2910 Controls.vertical_thrust_time -= joy_axis[kc_joystick[13].value];
2914 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
2915 if ( !kc_mouse[14].value ) // If not inverted...
2916 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
2918 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
2923 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
2924 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
2925 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
2926 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
2929 if ((use_joystick)&&( kc_joystick[19].value < 255 )) {
2930 if ( !kc_joystick[20].value ) // If not inverted...
2931 Controls.vertical_thrust_time += joy_axis[kc_joystick[19].value];
2933 Controls.vertical_thrust_time -= joy_axis[kc_joystick[19].value];
2936 // From joystick buttons
2937 if ( (use_joystick)&&(kc_joystick[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_joystick[8].value );
2938 if ( (use_joystick)&&(kc_joystick[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_joystick[9].value );
2940 // From mouse buttons
2941 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
2942 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
2945 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
2946 if ( !kc_mouse[20].value ) // If not inverted...
2947 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
2949 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
2953 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2954 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
2955 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
2958 //---------- Read heading_time -----------
2960 if (!slide_on && !bank_on) {
2961 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2963 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
2964 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
2965 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
2966 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
2969 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
2970 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
2971 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
2972 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
2975 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2976 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
2977 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
2981 Controls.heading_time = 0;
2983 if (Controls.heading_time < 0)
2984 Controls.heading_time = 0;
2986 if (Controls.heading_time > 0)
2987 Controls.heading_time = 0;
2988 Controls.heading_time += kh;
2991 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
2992 if ( !kc_joystick[16].value ) // If not inverted...
2993 Controls.heading_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
2995 Controls.heading_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
2999 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3000 if ( !kc_mouse[16].value ) // If not inverted...
3001 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3003 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3006 Controls.heading_time = 0;
3009 //----------- Read sideways_thrust_time -----------------
3012 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3013 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3014 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3015 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3018 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
3019 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
3020 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
3021 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
3024 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
3025 if ( !kc_joystick[16].value ) // If not inverted...
3026 Controls.sideways_thrust_time += joy_axis[kc_joystick[15].value];
3028 Controls.sideways_thrust_time -= joy_axis[kc_joystick[15].value];
3032 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3033 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
3034 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
3038 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3039 if ( !kc_mouse[16].value ) // If not inverted...
3040 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
3042 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
3047 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
3048 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
3049 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
3050 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
3053 if ( (use_joystick)&&(kc_joystick[17].value < 255 )) {
3054 if ( !kc_joystick[18].value ) // If not inverted...
3055 Controls.sideways_thrust_time -= joy_axis[kc_joystick[17].value];
3057 Controls.sideways_thrust_time += joy_axis[kc_joystick[17].value];
3060 // From joystick buttons
3061 if ( (use_joystick)&&(kc_joystick[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_joystick[6].value );
3062 if ( (use_joystick)&&(kc_joystick[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_joystick[7].value );
3064 // From mouse buttons
3065 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
3066 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
3069 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
3070 if ( !kc_mouse[18].value ) // If not inverted...
3071 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
3073 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
3076 //----------- Read bank_time -----------------
3079 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3080 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3081 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3082 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3085 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
3086 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
3087 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
3088 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
3091 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3092 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
3093 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
3097 if ( (use_joystick)&&(kc_joystick[15].value < 255) ) {
3098 if ( !kc_joystick[16].value ) // If not inverted...
3099 Controls.bank_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3101 Controls.bank_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3105 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3106 if ( !kc_mouse[16].value ) // If not inverted...
3107 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3109 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3114 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
3115 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
3116 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
3117 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
3120 if ( (use_joystick)&&(kc_joystick[21].value < 255) ) {
3121 if ( !kc_joystick[22].value ) // If not inverted...
3122 Controls.bank_time -= joy_axis[kc_joystick[21].value];
3124 Controls.bank_time += joy_axis[kc_joystick[21].value];
3127 // From joystick buttons
3128 if ( (use_joystick)&&(kc_joystick[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_joystick[11].value );
3129 if ( (use_joystick)&&(kc_joystick[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_joystick[12].value );
3131 // From mouse buttons
3132 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
3133 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
3136 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
3137 if ( !kc_mouse[22].value ) // If not inverted...
3138 Controls.bank_time += mouse_axis[kc_mouse[21].value];
3140 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
3144 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3145 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
3146 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
3149 //----------- Read forward_thrust_time -------------
3152 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
3153 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
3154 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
3155 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
3158 if ( (use_joystick)&&(kc_joystick[23].value < 255 )) {
3159 if ( !kc_joystick[24].value ) // If not inverted...
3160 Controls.forward_thrust_time -= joy_axis[kc_joystick[23].value];
3162 Controls.forward_thrust_time += joy_axis[kc_joystick[23].value];
3165 // From joystick buttons
3166 if ( (use_joystick)&&(kc_joystick[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_joystick[2].value );
3167 if ( (use_joystick)&&(kc_joystick[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_joystick[3].value );
3170 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
3171 if ( !kc_mouse[24].value ) // If not inverted...
3172 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
3174 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
3177 // From mouse buttons
3178 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
3179 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
3181 //----------- Read afterburner_state -------------
3184 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
3185 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
3187 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
3189 if ( (use_joystick)&&(kc_joystick[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_joystick[27].value);
3191 //-------Read headlight key--------------------------
3193 if (kc_keyboard[52].value < 255 )
3194 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
3195 if (kc_keyboard[53].value < 255 )
3196 Controls.headlight_count+=key_down_count(kc_keyboard[53].value);
3197 if ((use_joystick)&&(kc_joystick[30].value < 255 ))
3198 Controls.headlight_count+=joy_get_button_down_cnt(kc_joystick[30].value);
3200 //--------Read Cycle Primary Key------------------
3202 if (kc_keyboard[48].value<255)
3203 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
3204 if (kc_keyboard[49].value<255)
3205 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
3206 if ((use_joystick)&&(kc_joystick[28].value < 255 ))
3207 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_joystick[28].value);
3210 //--------Read Cycle Secondary Key------------------
3212 if (kc_keyboard[50].value<255)
3213 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
3214 if (kc_keyboard[51].value<255)
3215 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
3216 if ((use_joystick)&&(kc_joystick[29].value < 255 ))
3217 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_joystick[29].value);
3219 //--------Read Toggle Bomb key----------------------
3221 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
3223 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
3225 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
3226 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
3228 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3229 HUD_init_message ("No bombs available!");
3233 if (Players[Player_num].secondary_ammo[bomb]==0)
3235 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3236 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
3240 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
3241 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
3246 //---------Read Energy->Shield key----------
3248 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
3249 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
3250 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
3251 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
3253 //----------- Read fire_primary_down_count
3254 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
3255 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
3256 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_joystick[0].value);
3257 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
3259 //----------- Read fire_primary_state
3260 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
3261 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
3262 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_joystick[0].value);
3263 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
3265 //----------- Read fire_secondary_down_count
3266 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
3267 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
3268 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_joystick[1].value);
3269 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
3271 //----------- Read fire_secondary_state
3272 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
3273 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
3274 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_joystick[1].value);
3275 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
3277 //----------- Read fire_flare_down_count
3278 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
3279 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
3280 if ((use_joystick)&&(kc_joystick[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_joystick[4].value);
3281 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
3283 //----------- Read drop_bomb_down_count
3284 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
3285 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
3286 if ((use_joystick)&&(kc_joystick[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_joystick[26].value);
3287 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
3289 //----------- Read rear_view_down_count
3290 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
3291 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
3292 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_joystick[25].value);
3293 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
3295 //----------- Read rear_view_down_state
3296 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
3297 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
3298 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_joystick[25].value);
3299 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
3301 //----------- Read automap_down_count
3302 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
3303 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
3305 //----------- Read automap_state
3306 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
3307 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
3309 //----------- Read stupid-cruise-control-type of throttle.
3311 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
3312 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
3313 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
3314 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
3315 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
3317 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
3320 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
3321 if (Cruise_speed < 0 ) Cruise_speed = 0;
3323 if (Controls.forward_thrust_time==0)
3324 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
3327 #if !defined(MACINTOSH)
3328 //read_head_tracker();
3330 // Read external controls
3331 // if (kc_use_external_control || CybermouseActive)
3332 // kconfig_read_external_controls();
3335 //----------- Clamp values between -FrameTime and FrameTime
3336 if (FrameTime > F1_0 )
3337 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
3339 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
3340 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
3341 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
3342 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
3343 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
3344 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
3345 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
3347 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
3348 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
3349 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
3350 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
3351 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
3352 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
3353 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
3356 //--------- Don't do anything if in debug mode
3358 if ( keyd_pressed[KEY_DELETE] ) {
3359 memset( &Controls, 0, sizeof(control_info) );
3365 void reset_cruise(void)
3371 void kc_set_controls()
3375 for (i=0; i<NUM_KEY_CONTROLS; i++ )
3376 kc_keyboard[i].value = kconfig_settings[0][i];
3378 if ( (Config_control_type>0) && (Config_control_type<5)) {
3379 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3380 kc_joystick[i].value = kconfig_settings[Config_control_type][i];
3381 if (kc_joystick[i].type == BT_INVERT ) {
3382 if (kc_joystick[i].value!=1)
3383 kc_joystick[i].value = 0;
3384 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
3387 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
3388 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3389 kc_mouse[i].value = kconfig_settings[Config_control_type][i];
3390 if (kc_mouse[i].type == BT_INVERT ) {
3391 if (kc_mouse[i].value!=1)
3392 kc_mouse[i].value = 0;
3393 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
3396 } else if (Config_control_type == CONTROL_WINJOYSTICK) {
3397 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3398 kc_superjoy[i].value = kconfig_settings[Config_control_type][i];
3399 if (kc_superjoy[i].type == BT_INVERT ) {
3400 if (kc_superjoy[i].value!=1)
3401 kc_superjoy[i].value = 0;
3402 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
3408 #if 0 //ndef MACINTOSH // no mac support for vr headset
3410 void kconfig_center_headset()
3414 vfx_center_headset();
3416 // } else if (iglasses_headset_installed) {
3417 // } else if (Victor_headset_installed) {
3423 #endif // end of #ifndef MACINTOSH for kconfig_center_headset
3425 void CybermouseAdjust ()
3427 /* if ( Player_num > -1 ) {
3428 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3429 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3430 Auto_leveling_on = 0;
3432 if ( kc_external_version > 0 ) {
3433 vms_matrix tempm, ViewMatrix;
3434 vms_angvec * Kconfig_abs_movement;
3437 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
3439 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3440 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3441 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3442 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3444 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3445 if (oem_message[0] != '\0' )
3446 HUD_init_message( oem_message );
3450 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3451 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3452 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3453 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3454 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3455 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3456 // Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3457 // Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3458 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3459 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3460 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3461 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3462 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3463 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3464 // Controls.automap_down_count += kc_external_control->automap_down_count;
3465 // Controls.automap_state |= kc_external_control->automap_state;
3468 char GetKeyValue (char key)
3470 mprintf ((0,"Returning %c!\n",kc_keyboard[(int)key].value));
3471 return (kc_keyboard[(int)key].value);
3474 #if !defined(MACINTOSH)
3477 extern object *obj_find_first_of_type (int);
3478 void kconfig_read_external_controls()
3483 if ( !kc_enable_external_control ) return;
3485 if ( kc_external_version == 0 )
3486 memset( kc_external_control, 0, sizeof(ext_control_info));
3487 else if ( kc_external_version > 0 ) {
3489 if (kc_external_version>=4)
3490 memset( kc_external_control, 0, sizeof(advanced_ext_control_info));
3491 else if (kc_external_version>0)
3492 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 );
3493 else if (kc_external_version>2)
3494 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof(vms_matrix) +4 );
3496 if ( kc_external_version > 1 ) {
3497 // Write ship pos and angles to external controls...
3498 ubyte *temp_ptr = (ubyte *)kc_external_control;
3499 vms_vector *ship_pos;
3500 vms_matrix *ship_orient;
3501 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
3502 temp_ptr += sizeof(ext_control_info) + sizeof(vms_angvec) + 64;
3503 ship_pos = (vms_vector *)temp_ptr;
3504 temp_ptr += sizeof(vms_vector);
3505 ship_orient = (vms_matrix *)temp_ptr;
3506 // Fill in ship postion...
3507 *ship_pos = Objects[Players[Player_num].objnum].pos;
3508 // Fill in ship orientation...
3509 *ship_orient = Objects[Players[Player_num].objnum].orient;
3511 if (kc_external_version>=4)
3513 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3515 temp_ptr->headlight_state=(Players[Player_num].flags & PLAYER_FLAGS_HEADLIGHT_ON);
3516 temp_ptr->primary_weapon_flags=Players[Player_num].primary_weapon_flags;
3517 temp_ptr->secondary_weapon_flags=Players[Player_num].secondary_weapon_flags;
3518 temp_ptr->current_primary_weapon=Primary_weapon;
3519 temp_ptr->current_secondary_weapon=Secondary_weapon;
3521 temp_ptr->current_guidebot_command=Escort_goal_object;
3523 temp_ptr->force_vector=ExtForceVec;
3524 temp_ptr->force_matrix=ExtApplyForceMatrix;
3526 temp_ptr->joltinfo[i]=ExtJoltInfo[i];
3528 temp_ptr->x_vibrate_info[i]=ExtXVibrateInfo[i];
3529 temp_ptr->x_vibrate_clear=ExtXVibrateClear;
3530 temp_ptr->game_status=ExtGameStatus;
3532 memset ((void *)&ExtForceVec,0,sizeof(vms_vector));
3533 memset ((void *)&ExtApplyForceMatrix,0,sizeof(vms_matrix));
3538 ExtXVibrateInfo[i]=0;
3543 if ( Automap_active ) // (If in automap...)
3544 kc_external_control->automap_state = 1;
3545 //memset(&r,0,sizeof(r));
3547 #if !defined WINDOWS && !defined __ENV_LINUX__ && !defined __ENV_DJGPP__
3549 int386 ( kc_external_intno, &r, &r); // Read external info...
3553 if ( Player_num > -1 ) {
3554 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3555 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3556 Auto_leveling_on = 0;
3558 if ( kc_external_version > 0 ) {
3559 vms_matrix tempm, ViewMatrix;
3560 vms_angvec * Kconfig_abs_movement;
3563 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(ext_control_info));
3565 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3566 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3567 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3568 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3570 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3571 if (oem_message[0] != '\0' )
3572 HUD_init_message( oem_message );
3576 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3577 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3578 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3579 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3580 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3581 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3582 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3583 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3584 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3585 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3586 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3587 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3588 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3589 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3590 Controls.automap_down_count += kc_external_control->automap_down_count;
3591 Controls.automap_state |= kc_external_control->automap_state;
3593 if (kc_external_version>=3)
3595 ubyte *temp_ptr = (ubyte *)kc_external_control;
3596 temp_ptr += (sizeof(ext_control_info) + sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof (vms_matrix));
3599 Controls.cycle_primary_count=(*(temp_ptr));
3601 Controls.cycle_secondary_count=(*(temp_ptr+1));
3604 Controls.afterburner_state=(*(temp_ptr+2));
3606 Controls.headlight_count=(*(temp_ptr+3));
3608 if (kc_external_version>=4)
3611 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3614 if (temp_ptr->keyboard[i])
3617 if (temp_ptr->Reactor_blown)
3619 if (Game_mode & GM_MULTI)
3620 net_destroy_controlcen (obj_find_first_of_type (OBJ_CNTRLCEN));
3622 do_controlcen_destroyed_stuff(obj_find_first_of_type (OBJ_CNTRLCEN));