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.2 2001-01-20 13:49:15 bradleyb Exp $";
31 #include "pa_enabl.h" //$$POLY_ACC
73 ubyte ExtGameStatus=1;
75 vms_vector ExtForceVec;
76 vms_matrix ExtApplyForceMatrix;
78 int ExtJoltInfo[3]={0,0,0};
79 int ExtXVibrateInfo[2]={0,0};
80 int ExtYVibrateInfo[2]={0,0};
81 ubyte ExtXVibrateClear=0;
82 ubyte ExtYVibrateClear=0;
84 #define TABLE_CREATION 1
86 // Array used to 'blink' the cursor while waiting for a keypress.
87 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 };
89 //char * invert_text[2] = { "N", "Y" };
90 //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" };
91 //char * joyaxis_text[4] = { "X1", "Y1", "X2", "Y2" };
92 //char * mouseaxis_text[2] = { "L/R", "F/B" };
93 //char * mousebutton_text[3] = { "Left", "Right", "Mid" };
95 int invert_text[2] = { TNUM_N, TNUM_Y };
98 int joybutton_text[28] =
99 { TNUM_BTN_1, TNUM_BTN_2, TNUM_BTN_3, TNUM_BTN_4,
103 TNUM_HAT_L, TNUM_HAT_R, TNUM_HAT_U, TNUM_HAT_D,
107 int joyaxis_text[7] = { TNUM_X1, TNUM_Y1, TNUM_Z1, TNUM_UN, TNUM_P1,TNUM_R1,TNUM_YA1 };
109 int joybutton_text[28] =
110 { TNUM_BTN_1, TNUM_BTN_2, TNUM_BTN_3, TNUM_BTN_4,
111 -1, TNUM_TRIG, TNUM_LEFT, TNUM_HAT_L,
112 TNUM_RIGHT, -1, TNUM_HAT2_D, TNUM_HAT_R,
113 TNUM_MID, -1, TNUM_HAT2_R, TNUM_HAT_U,
114 TNUM_HAT2_L, -1, TNUM_HAT2_U, TNUM_HAT_D,
115 TNUM_TRIG, TNUM_LEFT, TNUM_RIGHT, -1,
116 TNUM_UP, TNUM_DOWN, TNUM_LEFT, TNUM_RIGHT };
118 int joyaxis_text[4] = { TNUM_X1, TNUM_Y1, TNUM_X2, TNUM_Y2 };
121 int mouseaxis_text[2] = { TNUM_L_R, TNUM_F_B };
123 int mousebutton_text[3] = { TNUM_LEFT, TNUM_RIGHT, TNUM_MID };
125 char *mousebutton_text[3] = { "Btn", "", "" }; // only one silly mouse button on the mac
129 char * key_text[256] = {
130 "","S","D","F","H","G","Z","X","C","V","","B","Q", "W", "E", "R",
131 "Y","T","1","2","3","4","6","5","=","9","7","-", "8", "0", "]", "O",
132 "U","[","I","P","RET","L","J","'","K", ";", "\\", ",", "/", "N", "M", ".",
133 "TAB","SPC","`","DEL","","ESC","","APL","SHIFT","CAPSL","OPTN","CTRL","","","","A",
134 "","PAD.","","PAD*","","PAD+","","NMLCK","","","","PAD/","ENTER","","PAD-","",
135 "","PAD=","PAD0","PAD1","PAD2","PAD3","PAD4","PAD5","PAD6","PAD7","","PAD8","PAD9","","","",
136 "F5","F6","F7","","F8","F9","","F11","","F13","","F14","","F10","","F12",
137 "","PAUSE","HELP","HOME","PGUP","DEL","","END","F2","","F1","LARW","RARW","DARW","UARW","",
138 "","","","","","","","","","","","","","","","",
139 "","","","","","","","","","","","","","","","",
140 "","","","","","","","","","","","","","","","",
141 "","","","","","","","","","","","","","","","",
142 "","","","","","","","","","","","","","","","",
143 "","","","","","","","","","","","","","","","",
144 "","","","","","","","","","","","","","","","",
145 "","","","","","","","","","","","","","","",""};
148 char * key_text[256] = { \
149 "","ESC","1","2","3","4","5","6","7","8","9","0","-", \
150 "=","BSPC","TAB","Q","W","E","R","T","Y","U","I","O", \
151 "P","[","]","
\83","LCTRL","A","S","D","F", \
152 "G","H","J","K","L",";","'","`", \
153 "LSHFT","\\","Z","X","C","V","B","N","M",",", \
154 ".","/","RSHFT","PAD*","LALT","SPC", \
155 "CPSLK","F1","F2","F3","F4","F5","F6","F7","F8","F9", \
156 "F10","NMLCK","SCLK","PAD7","PAD8","PAD9","PAD-", \
157 "PAD4","PAD5","PAD6","PAD+","PAD1","PAD2","PAD3","PAD0", \
158 "PAD.","","","","F11","F12","","","","","","","","","", \
159 "","","","","","","","","","","","","","","","","","","","", \
160 "","","","","","","","","","","","","","","","","","","","", \
161 "","","","","","","","","","","","","","","","","","", \
162 "PAD
\83","RCTRL","","","","","","","","","","","","","", \
163 "","","","","","","","","","","PAD/","","","RALT","", \
164 "","","","","","","","","","","","","","HOME","
\82","PGUP", \
165 "","
\81","","
\7f","","END","
\80","PGDN","INS", \
166 "DEL","","","","","","","","","","","","","","","","","", \
167 "","","","","","","","","","","","","","","","","","","","", \
168 "","","","","","","" };
172 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 };
174 //extern void GameLoop(int, int );
176 extern void transfer_energy_to_shield(fix);
177 extern void CyclePrimary(),CycleSecondary(),InitMarkerInput();
178 extern ubyte DefiningMarkerMessage;
179 extern char CybermouseActive;
182 extern int joydefsw_do_button();
183 extern int joydefsw_do_winjoybutton(int *axis);
184 extern joydefsw_win_joyselect(char *title);
187 control_info Controls;
191 // macros for drawing lo/hi res kconfig screens (see scores.c as well)
193 #define LHX(x) ((x)*(MenuHires?2:1))
194 #define LHY(y) ((y)*(MenuHires?2.4:1))
198 #define BT_MOUSE_BUTTON 1
199 #define BT_MOUSE_AXIS 2
200 #define BT_JOY_BUTTON 3
201 #define BT_JOY_AXIS 4
204 char *btype_text[] = { "BT_KEY", "BT_MOUSE_BUTTON", "BT_MOUSE_AXIS", "BT_JOY_BUTTON", "BT_JOY_AXIS", "BT_INVERT" };
208 typedef struct kc_item {
209 short id; // The id of this item
217 ubyte value; // what key,button,etc
223 ubyte kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS];
225 //----------- WARNING!!!!!!! -------------------------------------------
226 // THESE NEXT FOUR BLOCKS OF DATA ARE GENERATED BY PRESSING DEL+F12 WHEN
227 // IN THE KEYBOARD CONFIG SCREEN. BASICALLY, THAT PROCEDURE MODIFIES THE
228 // U,D,L,R FIELDS OF THE ARRAYS AND DUMPS THE NEW ARRAYS INTO KCONFIG.COD
229 //-------------------------------------------------------------------------
230 /*ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
231 {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},
232 {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},
233 {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},
234 {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},
235 {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},
236 {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},
237 {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},
241 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
242 {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},
243 {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},
244 {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},
245 {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},
246 {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},
247 {0x0,0x1,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0},
248 {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},
250 {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},
256 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
257 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
258 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
259 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
260 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
261 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
262 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
263 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
264 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
265 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
266 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
267 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
268 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
269 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
270 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
271 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
272 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
273 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
274 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
275 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
276 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
277 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
278 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
279 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
280 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
281 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
282 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
283 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
284 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
285 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
286 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
287 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
288 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
289 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
290 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
291 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
292 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
293 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
294 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
295 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
296 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
297 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
298 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
299 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
300 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
301 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
302 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
303 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
304 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
305 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
306 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
307 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
308 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
309 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
310 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
311 { 54,158,171, 83, 26, 52, 56, 51, 55,"Energy->Shield", BT_KEY, 255 },
312 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
313 { 56,158,179,83, 26, 54, 0, 0, 0, "Toggle Bomb", BT_KEY,255},
315 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
316 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
317 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
318 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
319 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
320 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
321 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
322 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
323 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
324 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
325 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
326 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
327 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
328 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
329 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
330 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
331 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
332 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
333 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
334 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
335 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
336 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
337 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
338 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
339 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
340 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
341 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
342 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
343 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
344 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
345 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
346 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
348 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
349 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
350 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
351 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
352 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
353 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
354 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
355 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
356 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
357 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
358 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
359 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
360 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
361 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
362 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
363 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
364 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
365 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
366 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
367 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
368 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
369 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
370 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
371 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
372 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
373 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
374 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
375 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
376 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
377 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
378 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
379 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
382 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
383 { 0, 25, 46, 85, 26, 12, 1, 24, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
384 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
385 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
386 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
387 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
388 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
389 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
390 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
391 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
392 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
393 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
394 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
395 { 12,180,106, 59, 26, 11, 0, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
396 { 13,103,138, 58, 26, 27, 15, 25, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
397 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
398 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
399 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
400 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
401 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
402 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
403 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
404 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
405 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
406 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
407 { 24,103,182,106, 8, 22, 5, 23, 0,"throttle", BT_INVERT, 255 },
408 { 25, 25,109, 85, 26, 3, 27, 12, 13,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
409 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
410 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
413 #else // ifndef MACINTOSH (following are macintosh controls)
415 ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {
416 {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},
417 {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},
418 {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},
419 {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},
420 {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},
421 {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},
422 {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},
425 ubyte default_firebird_settings[MAX_CONTROLS] =
426 {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};
428 ubyte default_mousestick_settings[MAX_CONTROLS] =
429 {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};
431 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
432 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
433 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
434 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
435 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
436 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
437 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
438 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
439 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
440 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
441 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
442 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
443 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
444 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
445 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
446 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
447 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
448 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
449 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
450 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
451 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
452 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
453 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
454 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
455 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
456 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
457 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
458 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
459 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
460 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
461 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
462 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
463 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
464 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
465 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
466 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
467 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
468 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
469 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
470 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
471 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
472 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
473 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
474 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
475 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
476 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
477 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
478 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
479 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
480 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
481 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
482 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
483 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
484 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
485 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
486 { 54,158,171, 83, 26, 52, 25, 51, 55,"Energy->Shield", BT_KEY, 255 },
487 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
489 kc_item kc_joystick[NUM_OTHER_CONTROLS] = {
490 { 0, 25, 46, 85, 28, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
491 { 1, 25, 54, 85, 28, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
492 { 2, 25, 85, 85, 28, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
493 { 3, 25, 93, 85, 28, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
494 { 4, 25, 62, 85, 28, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
495 { 5,180, 46, 79, 28, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
496 { 6,180, 54, 79, 28, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
497 { 7,180, 62, 79, 28, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
498 { 8,180, 70, 79, 28, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
499 { 9,180, 78, 79, 28, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
500 { 10,180, 90, 79, 28, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
501 { 11,180, 98, 79, 28, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
502 { 12,180,106, 79, 28, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
503 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
504 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
505 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
506 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
507 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
508 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
509 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
510 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
511 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
512 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
513 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
514 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
515 { 25, 25,109, 85, 28, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
516 { 26, 25, 70, 85, 28, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
517 { 27, 25,117, 85, 28, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
518 { 28,180,114, 79, 28, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
519 { 29,180,122, 79, 28, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
520 { 30, 25,125, 85, 28, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
522 kc_item kc_superjoy[NUM_OTHER_CONTROLS] = {
523 { 0, 25, 46, 85, 26, 15, 1, 24, 5,"Fire primary", BT_JOY_BUTTON, 255 },
524 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_JOY_BUTTON, 255 },
525 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_JOY_BUTTON, 255 },
526 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_JOY_BUTTON, 255 },
527 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_JOY_BUTTON, 255 },
528 { 5,180, 46, 79, 26, 23, 6, 0, 1,"Slide on", BT_JOY_BUTTON, 255 },
529 { 6,180, 54, 79, 26, 5, 7, 1, 4,"Slide left", BT_JOY_BUTTON, 255 },
530 { 7,180, 62, 79, 26, 6, 8, 4, 26,"Slide right", BT_JOY_BUTTON, 255 },
531 { 8,180, 70, 79, 26, 7, 9, 26, 9,"Slide up", BT_JOY_BUTTON, 255 },
532 { 9,180, 78, 79, 26, 8, 10, 8, 2,"Slide down", BT_JOY_BUTTON, 255 },
533 { 10,180, 90, 79, 26, 9, 11, 2, 3,"Bank on", BT_JOY_BUTTON, 255 },
534 { 11,180, 98, 79, 26, 10, 12, 3, 12,"Bank left", BT_JOY_BUTTON, 255 },
535 { 12,180,106, 79, 26, 11, 28, 11, 25,"Bank right", BT_JOY_BUTTON, 255 },
536 { 13, 22,154, 51, 26, 24, 15, 30, 14,"Pitch U/D", BT_JOY_AXIS, 255 },
537 { 14, 22,154, 99, 8, 30, 16, 13, 17,"Pitch U/D", BT_INVERT, 255 },
538 { 15, 22,162, 51, 26, 13, 0, 18, 16,"Turn L/R", BT_JOY_AXIS, 255 },
539 { 16, 22,162, 99, 8, 14, 17, 15, 19,"Turn L/R", BT_INVERT, 255 },
540 { 17,164,154, 58, 26, 16, 19, 14, 18,"Slide L/R", BT_JOY_AXIS, 255 },
541 { 18,164,154,106, 8, 29, 20, 17, 15,"Slide L/R", BT_INVERT, 255 },
542 { 19,164,162, 58, 26, 17, 21, 16, 20,"Slide U/D", BT_JOY_AXIS, 255 },
543 { 20,164,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
544 { 21,164,172, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_JOY_AXIS, 255 },
545 { 22,164,172,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
546 { 23,164,180, 58, 26, 21, 5, 22, 24,"throttle", BT_JOY_AXIS, 255 },
547 { 24,164,180,106, 8, 22, 13, 23, 0,"throttle", BT_INVERT, 255 },
548 { 25, 25,109, 85, 26, 3, 27, 12, 28,"REAR VIEW", BT_JOY_BUTTON, 255 },
549 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_JOY_BUTTON, 255 },
550 { 27, 25,117, 85, 26, 25, 30, 28, 29,"Afterburner", BT_JOY_BUTTON, 255 },
551 { 28,180,114, 79, 26, 12, 29, 25, 27,"Cycle Primary", BT_JOY_BUTTON, 255 },
552 { 29,180,122, 79, 26, 28, 18, 27, 30,"Cycle Secondary", BT_JOY_BUTTON, 255 },
553 { 30, 25,125, 85, 26, 27, 14, 29, 13,"Headlight", BT_JOY_BUTTON, 255 },
556 kc_item kc_mouse[NUM_OTHER_CONTROLS] = {
557 { 0, 25, 46, 85, 26, 28, 1, 28, 5,"Fire primary", BT_MOUSE_BUTTON, 255 },
558 { 1, 25, 54, 85, 26, 0, 4, 5, 6,"Fire secondary", BT_MOUSE_BUTTON, 255 },
559 { 2, 25, 85, 85, 26, 26, 3, 9, 10,"Accelerate", BT_MOUSE_BUTTON, 255 },
560 { 3, 25, 93, 85, 26, 2, 25, 10, 11,"reverse", BT_MOUSE_BUTTON, 255 },
561 { 4, 25, 62, 85, 26, 1, 26, 6, 7,"Fire flare", BT_MOUSE_BUTTON, 255 },
562 { 5,180, 46, 59, 26, 24, 6, 0, 1,"Slide on", BT_MOUSE_BUTTON, 255 },
563 { 6,180, 54, 59, 26, 5, 7, 1, 4,"Slide left", BT_MOUSE_BUTTON, 255 },
564 { 7,180, 62, 59, 26, 6, 8, 4, 26,"Slide right", BT_MOUSE_BUTTON, 255 },
565 { 8,180, 70, 59, 26, 7, 9, 26, 9,"Slide up", BT_MOUSE_BUTTON, 255 },
566 { 9,180, 78, 59, 26, 8, 10, 8, 2,"Slide down", BT_MOUSE_BUTTON, 255 },
567 { 10,180, 90, 59, 26, 9, 11, 2, 3,"Bank on", BT_MOUSE_BUTTON, 255 },
568 { 11,180, 98, 59, 26, 10, 12, 3, 12,"Bank left", BT_MOUSE_BUTTON, 255 },
569 { 12,180,106, 59, 26, 11, 28, 11, 25,"Bank right", BT_MOUSE_BUTTON, 255 },
570 { 13,103,138, 58, 26, 27, 15, 27, 14,"Pitch U/D", BT_MOUSE_AXIS, 255 },
571 { 14,103,138,106, 8, 23, 16, 13, 15,"Pitch U/D", BT_INVERT, 255 },
572 { 15,103,146, 58, 26, 13, 17, 14, 16,"Turn L/R", BT_MOUSE_AXIS, 255 },
573 { 16,103,146,106, 8, 14, 18, 15, 17,"Turn L/R", BT_INVERT, 255 },
574 { 17,103,154, 58, 26, 15, 19, 16, 18,"Slide L/R", BT_MOUSE_AXIS, 255 },
575 { 18,103,154,106, 8, 16, 20, 17, 19,"Slide L/R", BT_INVERT, 255 },
576 { 19,103,162, 58, 26, 17, 21, 18, 20,"Slide U/D", BT_MOUSE_AXIS, 255 },
577 { 20,103,162,106, 8, 18, 22, 19, 21,"Slide U/D", BT_INVERT, 255 },
578 { 21,103,170, 58, 26, 19, 23, 20, 22,"Bank L/R", BT_MOUSE_AXIS, 255 },
579 { 22,103,170,106, 8, 20, 24, 21, 23,"Bank L/R", BT_INVERT, 255 },
580 { 23,103,182, 58, 26, 21, 14, 22, 24,"throttle", BT_MOUSE_AXIS, 255 },
581 { 24,103,182,106, 8, 22, 5, 23, 28,"throttle", BT_INVERT, 255 },
582 { 25, 25,109, 85, 26, 3, 27, 12, 27,"REAR VIEW", BT_MOUSE_BUTTON, 255 },
583 { 26, 25, 70, 85, 26, 4, 2, 7, 8,"Drop Bomb", BT_MOUSE_BUTTON, 255 },
584 { 27, 25,117, 85, 26, 25, 13, 25, 13,"Afterburner", BT_MOUSE_BUTTON, 255 },
589 void kc_drawitem( kc_item *item, int is_current );
590 void kc_change_key( kc_item * item );
591 void kc_change_joybutton( kc_item * item );
592 void kc_change_mousebutton( kc_item * item );
593 void kc_change_joyaxis( kc_item * item );
594 void kc_change_mouseaxis( kc_item * item );
595 void kc_change_invert( kc_item * item );
596 void kconfig_read_fcs( int raw_axis );
597 void kconfig_set_fcs_button( int btn, int button );
598 void kconfig_read_external_controls( void );
600 int kconfig_is_axes_used(int axis)
603 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
604 if (( kc_joystick[i].type == BT_JOY_AXIS ) && (kc_joystick[i].value == axis ))
610 #ifdef TABLE_CREATION
611 int find_item_at( kc_item * items, int nitems, int x, int y )
615 for (i=0; i<nitems; i++ ) {
616 if ( ((items[i].x+items[i].w1)==x) && (items[i].y==y))
622 int find_next_item_up( kc_item * items, int nitems, int citem )
627 x = items[citem].x+items[citem].w1;
632 y = grd_curcanv->cv_bitmap.bm_h-1;
635 x = grd_curcanv->cv_bitmap.bm_w-1;
638 i = find_item_at( items, nitems, x, y );
644 int find_next_item_down( kc_item * items, int nitems, int citem )
649 x = items[citem].x+items[citem].w1;
653 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
656 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
660 i = find_item_at( items, nitems, x, y );
666 int find_next_item_right( kc_item * items, int nitems, int citem )
671 x = items[citem].x+items[citem].w1;
675 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
678 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
682 i = find_item_at( items, nitems, x, y );
688 int find_next_item_left( kc_item * items, int nitems, int citem )
693 x = items[citem].x+items[citem].w1;
698 x = grd_curcanv->cv_bitmap.bm_w-1;
701 y = grd_curcanv->cv_bitmap.bm_h-1;
704 i = find_item_at( items, nitems, x, y );
711 #if defined(MACINTOSH) || defined(WINDOWS)
712 int get_item_height(kc_item *item)
717 if (item->value==255) {
718 sprintf( btext, "" );
720 switch( item->type ) {
722 strncpy( btext, key_text[item->value], 10 ); break;
723 case BT_MOUSE_BUTTON:
725 strncpy( btext, Text_string[mousebutton_text[item->value]], 10); break;
727 strncpy( btext, mousebutton_text[item->value], 10 ); break;
730 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
732 if ( joybutton_text[item->value] !=-1 )
733 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
735 sprintf( btext, "BTN%d", item->value );
738 strncpy( btext, Text_string[joyaxis_text[item->value]], 10 ); break;
740 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
743 gr_get_string_size(btext, &w, &h, &aw );
749 void kconfig_sub(kc_item * items,int nitems, char * title)
752 dd_grs_canvas * save_canvas,
753 grs_canvas * save_canvas
755 grs_font * save_font;
757 #if defined(MACINTOSH) || defined(WINDOWS)
758 int mouse_state, omouse_state, mx, my, x1, x2, y1, y2;
759 int close_x, close_y, close_size;
762 int i,k,ocitem,citem;
763 int time_stopped = 0;
764 WIN(char *old_bg_pcx);
766 WIN(old_bg_pcx = _SCRContext.bkg_filename);
767 WIN(DEFINE_SCREEN(NULL));
772 if (!((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence)) )
778 // if (Config_control_type == CONTROL_WINJOYSTICK) {
780 // joydefsw_win_joyselect(title2); title = title2,
782 // ); // Get Samir...
786 save_canvas = dd_grd_curcanv,
787 save_canvas = grd_curcanv
792 dd_gr_set_current_canvas(NULL),
793 gr_set_current_canvas(NULL)
795 save_font = grd_curcanv->cv_font;
801 old_keyd_repeat = keyd_repeat;
804 //gr_clear_canvas( BM_XRGB(0,0,0) );
806 nm_draw_background(0,0,grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
807 gr_palette_load (gr_palette);
809 grd_curcanv->cv_font = MEDIUM3_FONT;
811 WIN(DDGRLOCK(dd_grd_curcanv));
814 p = strchr( title, '\n' );
816 gr_string( 0x8000, LHY(8), title );
821 // if ( items == kc_keyboard ) {
822 // gr_string( 0x8000, 8, "Keyboard" );
823 // } else if ( items == kc_joystick ) {
824 // gr_string( 0x8000, 8, "Joysticks" );
825 // } else if ( items == kc_mouse ) {
826 // gr_string( 0x8000, 8, "Mouse" );
829 #if defined(MACINTOSH) || defined(WINDOWS)
830 close_x = close_y = 15;
832 gr_setcolor( BM_XRGB(0, 0, 0) );
833 gr_rect(close_x, close_y, close_x + close_size, close_y + close_size);
834 gr_setcolor( BM_XRGB(21, 21, 21) );
835 gr_rect( close_x + 2, close_y + 2, close_x + close_size - 2, close_y + close_size -2 );
838 grd_curcanv->cv_font = GAME_FONT;
839 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
842 gr_string( 0x8000, LHY(20), TXT_KCONFIG_STRING_1 );
844 gr_string( 0x8000, LHY(20), "Enter changes, ctrl-d deletes, ctrl-r resets defaults, ESC exits");
846 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
847 if ( items == kc_keyboard ) {
848 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
849 gr_setcolor( BM_XRGB(31,27,6) );
851 gr_scanline( LHX(98), LHX(106), LHY(42) );
852 gr_scanline( LHX(120), LHX(128), LHY(42) );
853 gr_pixel( LHX(98), LHY(43) );
854 gr_pixel( LHX(98), LHY(44) );
855 gr_pixel( LHX(128), LHY(43) );
856 gr_pixel( LHX(128), LHY(44) );
858 gr_string( LHX(109), LHY(40), "OR" );
860 gr_scanline( LHX(253), LHX(261), LHY(42) );
861 gr_scanline( LHX(274), LHX(283), LHY(42) );
862 gr_pixel( LHX(253), LHY(43) );
863 gr_pixel( LHX(253), LHY(44) );
864 gr_pixel( LHX(283), LHY(43) );
865 gr_pixel( LHX(283), LHY(44) );
867 gr_string( LHX(264), LHY(40), "OR" );
869 } if ( items == kc_joystick ) {
870 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
871 gr_setcolor( BM_XRGB(31,27,6) );
872 gr_scanline( LHX(18), LHX(135), LHY(37) );
873 gr_scanline( LHX(181), LHX(294), LHY(37) );
874 gr_scanline( LHX(18), LHX(144), LHY(119+18) );
875 gr_scanline( LHX(174), LHX(294), LHY(119+18) );
876 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
877 gr_string( 0x8000,LHY(117+18), TXT_AXES );
878 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
879 gr_string( LHX(81), LHY(137+8), TXT_AXIS );
880 gr_string( LHX(111), LHY(137+8), TXT_INVERT );
881 gr_string( LHX(222), LHY(137+8), TXT_AXIS );
882 gr_string( LHX(252), LHY(137+8), TXT_INVERT );
883 } else if ( items == kc_mouse ) {
884 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
885 gr_setcolor( BM_XRGB(31,27,6) );
886 gr_scanline( LHX(18), LHX(135), LHY(37) );
887 gr_scanline( LHX(181), LHX(294), LHY(37) );
888 gr_scanline( LHX(18), LHX(144), LHY(119+5) );
889 gr_scanline( LHX(174), LHX(294), LHY(119+5) );
890 gr_string( 0x8000, LHY(35), TXT_BUTTONS );
891 gr_string( 0x8000,LHY(117+5), TXT_AXES );
892 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
893 gr_string( LHX(169), LHY(129), TXT_AXIS );
894 gr_string( LHX(199), LHY(129), TXT_INVERT );
896 WIN(DDGRUNLOCK(dd_grd_curcanv));
898 for (i=0; i<nitems; i++ ) {
899 kc_drawitem( &items[i], 0 );
903 kc_drawitem( &items[citem], 1 );
908 #if defined(MACINTOSH) || defined(WINDOWS)
909 mouse_state = omouse_state = 0;
913 // Windows addendum to allow for kconfig input.
918 DoMessageStuff(&msg);
921 _RedrawScreen = FALSE;
923 dd_gr_set_current_canvas(NULL);
933 //see if redbook song needs to be restarted
934 songs_check_redbook_repeat();
938 #if defined(MACINTOSH) || defined(WINDOWS)
939 omouse_state = mouse_state;
940 mouse_state = mouse_button_state(0);
943 if ( !time_stopped ) {
945 if (multi_menu_poll() == -1)
954 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_3:)
955 case KEY_PRINT_SCREEN:
958 case KEY_CTRLED+KEY_D:
959 items[citem].value = 255;
960 kc_drawitem( &items[citem], 1 );
962 case KEY_CTRLED+KEY_R:
963 if ( items==kc_keyboard ) {
964 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
965 items[i].value=default_kconfig_settings[0][i];
966 kc_drawitem( &items[i], 0 );
969 #ifdef MACINTOSH // hack for firebire and mousestick default controls since I made them the same control type -- dumb dumb dumb
970 if (joy_have_firebird())
971 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
972 items[i].value = default_firebird_settings[i];
973 kc_drawitem( &items[i], 0 );
975 else if (joy_have_mousestick())
976 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
977 items[i].value = default_mousestick_settings[i];
978 kc_drawitem( &items[i], 0 );
981 #endif // note link to above else
982 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
983 items[i].value = default_kconfig_settings[Config_control_type][i];
984 kc_drawitem( &items[i], 0 );
987 kc_drawitem( &items[citem], 1 );
990 items[citem].value=255;
991 kc_drawitem( &items[citem], 1 );
995 #ifdef TABLE_CREATION
996 if (items[citem].u==-1) items[citem].u=find_next_item_up( items,nitems, citem);
998 citem = items[citem].u;
1003 #ifdef TABLE_CREATION
1004 if (items[citem].d==-1) items[citem].d=find_next_item_down( items,nitems, citem);
1006 citem = items[citem].d;
1010 #ifdef TABLE_CREATION
1011 if (items[citem].l==-1) items[citem].l=find_next_item_left( items,nitems, citem);
1013 citem = items[citem].l;
1017 #ifdef TABLE_CREATION
1018 if (items[citem].r==-1) items[citem].r=find_next_item_right( items,nitems, citem);
1020 citem = items[citem].r;
1024 switch( items[citem].type ) {
1025 case BT_KEY: kc_change_key( &items[citem] ); break;
1026 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1027 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1028 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1029 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1030 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1035 grd_curcanv->cv_font = save_font;
1037 WIN(DEFINE_SCREEN(old_bg_pcx));
1040 dd_gr_set_current_canvas(save_canvas),
1041 gr_set_current_canvas( save_canvas )
1043 keyd_repeat = old_keyd_repeat;
1044 game_flush_inputs();
1045 WIN( HideCursorW());
1046 MAC( hide_cursor(); )
1050 #ifdef TABLE_CREATION
1051 case KEY_DEBUGGED+KEY_F12: {
1053 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1054 kc_keyboard[i].u = find_next_item_up( kc_keyboard,NUM_KEY_CONTROLS, i);
1055 kc_keyboard[i].d = find_next_item_down( kc_keyboard,NUM_KEY_CONTROLS, i);
1056 kc_keyboard[i].l = find_next_item_left( kc_keyboard,NUM_KEY_CONTROLS, i);
1057 kc_keyboard[i].r = find_next_item_right( kc_keyboard,NUM_KEY_CONTROLS, i);
1059 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1060 kc_joystick[i].u = find_next_item_up( kc_joystick,NUM_OTHER_CONTROLS, i);
1061 kc_joystick[i].d = find_next_item_down( kc_joystick,NUM_OTHER_CONTROLS, i);
1062 kc_joystick[i].l = find_next_item_left( kc_joystick,NUM_OTHER_CONTROLS, i);
1063 kc_joystick[i].r = find_next_item_right( kc_joystick,NUM_OTHER_CONTROLS, i);
1065 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1066 kc_mouse[i].u = find_next_item_up( kc_mouse,NUM_OTHER_CONTROLS, i);
1067 kc_mouse[i].d = find_next_item_down( kc_mouse,NUM_OTHER_CONTROLS, i);
1068 kc_mouse[i].l = find_next_item_left( kc_mouse,NUM_OTHER_CONTROLS, i);
1069 kc_mouse[i].r = find_next_item_right( kc_mouse,NUM_OTHER_CONTROLS, i);
1071 fp = fopen( "kconfig.cod", "wt" );
1073 fprintf( fp, "ubyte default_kconfig_settings[CONTROL_MAX_TYPES][MAX_CONTROLS] = {\n" );
1074 for (i=0; i<CONTROL_MAX_TYPES; i++ ) {
1076 fprintf( fp, "{0x%x", kconfig_settings[i][0] );
1077 for (j=1; j<MAX_CONTROLS; j++ )
1078 fprintf( fp, ",0x%x", kconfig_settings[i][j] );
1079 fprintf( fp, "},\n" );
1081 fprintf( fp, "};\n" );
1083 fprintf( fp, "\nkc_item kc_keyboard[NUM_KEY_CONTROLS] = {\n" );
1084 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
1085 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1086 kc_keyboard[i].id, kc_keyboard[i].x, kc_keyboard[i].y, kc_keyboard[i].w1, kc_keyboard[i].w2,
1087 kc_keyboard[i].u, kc_keyboard[i].d, kc_keyboard[i].l, kc_keyboard[i].r,
1088 34, kc_keyboard[i].text, 34, btype_text[kc_keyboard[i].type] );
1090 fprintf( fp, "};" );
1092 fprintf( fp, "\nkc_item kc_joystick[NUM_OTHER_CONTROLS] = {\n" );
1093 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1094 if (kc_joystick[i].type == BT_JOY_BUTTON)
1095 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1096 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1097 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1098 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1100 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1101 kc_joystick[i].id, kc_joystick[i].x, kc_joystick[i].y, kc_joystick[i].w1, kc_joystick[i].w2,
1102 kc_joystick[i].u, kc_joystick[i].d, kc_joystick[i].l, kc_joystick[i].r,
1103 34, kc_joystick[i].text, 34, btype_text[kc_joystick[i].type] );
1105 fprintf( fp, "};" );
1107 fprintf( fp, "\nkc_item kc_mouse[NUM_OTHER_CONTROLS] = {\n" );
1108 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1109 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
1110 kc_mouse[i].id, kc_mouse[i].x, kc_mouse[i].y, kc_mouse[i].w1, kc_mouse[i].w2,
1111 kc_mouse[i].u, kc_mouse[i].d, kc_mouse[i].l, kc_mouse[i].r,
1112 34, kc_mouse[i].text, 34, btype_text[kc_mouse[i].type] );
1114 fprintf( fp, "};" );
1123 #if defined (MACINTOSH) || defined(WINDOWS)
1124 if ( (mouse_state && !omouse_state) || (mouse_state && omouse_state) ) {
1127 mouse_get_pos(&mx, &my);
1128 for (i=0; i<nitems; i++ ) {
1129 item_height = get_item_height( &items[i] );
1130 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[i].x) + LHX(items[i].w1);
1131 x2 = x1 + LHX(items[i].w2);
1132 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[i].y);
1133 y2 = y1 + LHX(item_height);
1134 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1140 else if ( !mouse_state && omouse_state ) {
1143 mouse_get_pos(&mx, &my);
1144 item_height = get_item_height( &items[citem] );
1145 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[citem].x) + LHX(items[citem].w1);
1146 x2 = x1 + LHX(items[citem].w2);
1147 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[citem].y);
1148 y2 = y1 + LHY(item_height);
1149 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
1152 switch( items[citem].type ) {
1153 case BT_KEY: kc_change_key( &items[citem] ); break;
1154 case BT_MOUSE_BUTTON: kc_change_mousebutton( &items[citem] ); break;
1155 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
1156 case BT_JOY_BUTTON: kc_change_joybutton( &items[citem] ); break;
1157 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
1158 case BT_INVERT: kc_change_invert( &items[citem] ); break;
1163 x1 = grd_curcanv->cv_bitmap.bm_x + close_x + 2;
1164 x2 = x1 + close_size - 2;
1165 y1 = grd_curcanv->cv_bitmap.bm_y + close_y + 2;
1166 y2 = y1 + close_size - 2;
1167 if ( ((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2)) ) {
1168 grd_curcanv->cv_font = save_font;
1169 WINDOS(dd_gr_set_current_canvas( save_canvas ),
1170 gr_set_current_canvas( save_canvas ));
1171 keyd_repeat = old_keyd_repeat;
1172 game_flush_inputs();
1182 #endif // MACINTOSH WINDOWS
1184 if (ocitem!=citem) {
1187 kc_drawitem( &items[ocitem], 0 );
1188 kc_drawitem( &items[citem], 1 );
1196 void kc_drawitem( kc_item *item, int is_current )
1200 // PA_DFX (pa_set_frontbuffer_current());
1201 WIN(DDGRLOCK(dd_grd_curcanv));
1204 gr_set_fontcolor( BM_XRGB(20,20,29), -1 );
1206 gr_set_fontcolor( BM_XRGB(15,15,24), -1 );
1207 gr_string( LHX(item->x), LHY(item->y), item->text );
1208 WIN(DDGRUNLOCK(dd_grd_curcanv));
1210 if (item->value==255) {
1211 strcpy( btext, "" );
1213 switch( item->type ) {
1215 strncpy( btext, key_text[item->value], 10 ); break;
1216 case BT_MOUSE_BUTTON:
1218 strncpy( btext, Text_string[mousebutton_text[item->value]], 10 ); break;
1220 strncpy( btext, mousebutton_text[item->value], 10 ); break;
1223 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
1227 if (joybutton_text[item->value] != -1)
1228 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1230 sprintf( btext, "BTN%2d", item->value+1 );
1232 if ( joybutton_text[item->value] !=-1 )
1233 strncpy( btext, Text_string[ joybutton_text[item->value] ], 10 );
1235 sprintf( btext, "BTN%d", item->value );
1238 strncpy( btext, joy_btn_name( item->value ), 10);
1240 sprintf( btext, "BTN%d", item->value );
1244 strncpy( btext, Text_string[joyaxis_text[item->value]], 10 ); break;
1246 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
1250 WIN(DDGRLOCK(dd_grd_curcanv));
1251 gr_get_string_size(btext, &w, &h, &aw );
1254 gr_setcolor( BM_XRGB(21,0,24) );
1256 gr_setcolor( BM_XRGB(16,0,19) );
1257 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1259 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1261 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1263 gr_string( x, LHY(item->y), btext );
1264 // PA_DFX (pa_set_backbuffer_current());
1266 WIN(DDGRUNLOCK(dd_grd_curcanv));
1271 static int looper=0;
1273 void kc_drawquestion( kc_item *item )
1277 WIN(DDGRLOCK(dd_grd_curcanv));
1278 // PA_DFX (pa_set_frontbuffer_current());
1280 gr_get_string_size("?", &w, &h, &aw );
1282 c = BM_XRGB(21,0,24);
1284 //@@gr_setcolor( gr_fade_table[fades[looper]*256+c] );
1285 gr_setcolor(BM_XRGB(21*fades[looper]/31,0,24*fades[looper]/31));
1287 if (looper>63) looper=0;
1289 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
1291 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1293 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
1295 gr_string( x, LHY(item->y), "?" );
1296 // PA_DFX (pa_set_backbuffer_current());
1297 WIN(DDGRUNLOCK(dd_grd_curcanv));
1301 void kc_change_key( kc_item * item )
1306 WIN(DDGRLOCK(dd_grd_curcanv));
1307 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1309 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_KEY );
1310 WIN(DDGRUNLOCK(dd_grd_curcanv));
1312 game_flush_inputs();
1316 while( (k!=KEY_ESC) && (keycode==255) )
1322 DoMessageStuff(&msg);
1329 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1332 // if ( Game_mode & GM_MULTI )
1333 // GameLoop( 0, 0 ); // Continue
1336 kc_drawquestion( item );
1338 for (i=0; i<256; i++ ) {
1339 if (keyd_pressed[i] && (strlen(key_text[i])>0)) {
1341 for (n=0; n<sizeof(system_keys); n++ )
1342 if ( system_keys[n] == i )
1351 for (i=0; i<Num_items; i++ ) {
1352 n = item - All_items;
1353 if ( (i!=n) && (All_items[i].type==BT_KEY) && (All_items[i].value==keycode) ) {
1354 All_items[i].value = 255;
1355 kc_drawitem( &All_items[i], 0 );
1358 item->value = keycode;
1360 kc_drawitem( item, 1 );
1362 WIN(DDGRLOCK(dd_grd_curcanv));
1363 gr_set_fontcolor( BM_XRGB(28,28,28), BM_XRGB(0,0,0) );
1364 WIN(DDGRUNLOCK(dd_grd_curcanv));
1366 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1368 game_flush_inputs();
1372 void kc_change_joybutton( kc_item * item )
1377 WIN(DDGRLOCK(dd_grd_curcanv));
1378 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1380 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_JBUTTON );
1381 WIN(DDGRUNLOCK(dd_grd_curcanv));
1383 game_flush_inputs();
1387 while( (k!=KEY_ESC) && (code==255))
1392 DoMessageStuff(&msg);
1398 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1401 // if ( Game_mode & GM_MULTI )
1402 // GameLoop( 0, 0 ); // Continue
1406 if (k == KEY_PRINT_SCREEN)
1407 save_screen_shot(0);
1409 kc_drawquestion( item );
1411 WIN(code = joydefsw_do_button());
1414 code = joy_do_buttons();
1417 #if !defined(WINDOWS) && !defined(MACINTOSH)
1418 if (Config_control_type==CONTROL_THRUSTMASTER_FCS) {
1420 joystick_read_raw_axis( JOY_ALL_AXIS, axis );
1421 kconfig_read_fcs( axis[3] );
1422 if ( joy_get_button_state(7) ) code = 7;
1423 if ( joy_get_button_state(11) ) code = 11;
1424 if ( joy_get_button_state(15) ) code = 15;
1425 if ( joy_get_button_state(19) ) code = 19;
1426 for (i=0; i<4; i++ ) {
1427 if ( joy_get_button_state(i) )
1430 } else if (Config_control_type==CONTROL_FLIGHTSTICK_PRO) {
1431 for (i=4; i<20; i++ ) {
1432 if ( joy_get_button_state(i) ) {
1434 mprintf(( 0, "JB: %d\n", code ));
1438 for (i=0; i<4; i++ ) {
1439 if ( joy_get_button_state(i) )
1446 for (i=0; i<Num_items; i++ ) {
1447 n = item - All_items;
1448 if ( (i!=n) && (All_items[i].type==BT_JOY_BUTTON) && (All_items[i].value==code) ) {
1449 All_items[i].value = 255;
1450 kc_drawitem( &All_items[i], 0 );
1455 kc_drawitem( item, 1 );
1456 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1457 game_flush_inputs();
1460 void kc_change_mousebutton( kc_item * item )
1465 WIN(DDGRLOCK(dd_grd_curcanv));
1466 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1468 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_MBUTTON );
1469 WIN(DDGRUNLOCK(dd_grd_curcanv));
1472 game_flush_inputs();
1476 while( (k!=KEY_ESC) && (code==255))
1481 DoMessageStuff(&msg);
1487 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1490 // if ( Game_mode & GM_MULTI )
1491 // GameLoop( 0, 0 ); // Continue
1495 if (k == KEY_PRINT_SCREEN)
1496 save_screen_shot(0);
1498 kc_drawquestion( item );
1500 b = mouse_get_btns();
1501 for (i=0; i<3; i++ ) {
1507 for (i=0; i<Num_items; i++ ) {
1508 n = item - All_items;
1509 if ( (i!=n) && (All_items[i].type==BT_MOUSE_BUTTON) && (All_items[i].value==code) ) {
1510 All_items[i].value = 255;
1511 kc_drawitem( &All_items[i], 0 );
1516 kc_drawitem( item, 1 );
1517 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1518 game_flush_inputs();
1522 void kc_change_joyaxis( kc_item * item )
1533 WIN(DDGRLOCK(dd_grd_curcanv));
1534 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1536 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_JOY_AXIS );
1537 WIN(DDGRUNLOCK(dd_grd_curcanv));
1539 game_flush_inputs();
1544 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, old_axis ),
1545 joystick_read_raw_axis( JOY_ALL_AXIS, old_axis )
1548 while( (k!=KEY_ESC) && (code==255))
1553 DoMessageStuff(&msg);
1559 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1562 // if ( Game_mode & GM_MULTI )
1563 // GameLoop( 0, 0 ); // Continue
1567 if (k == KEY_PRINT_SCREEN)
1568 save_screen_shot(0);
1570 kc_drawquestion( item );
1573 joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, axis ),
1574 joystick_read_raw_axis( JOY_ALL_AXIS, axis )
1577 for (i=0; i<numaxis; i++ ) {
1578 #if defined (MACINTOSH)
1579 if ( abs(axis[i]-old_axis[i])>100 ) {
1580 #elif defined(WINDOWS)
1581 if ( abs(axis[i]-old_axis[i])>1024 ) {
1583 if ( abs(axis[i]-old_axis[i])>200 ) {
1587 //old_axis[i] = axis[i];
1589 for (i=0; i<Num_items; i++ )
1591 n = item - All_items;
1592 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) )
1598 for (i=0; i<Num_items; i++ ) {
1599 n = item - All_items;
1600 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) ) {
1601 All_items[i].value = 255;
1602 kc_drawitem( &All_items[i], 0 );
1608 kc_drawitem( item, 1 );
1609 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1610 game_flush_inputs();
1614 void kc_change_mouseaxis( kc_item * item )
1620 WIN(DDGRLOCK(dd_grd_curcanv));
1621 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1623 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_MSE_AXIS );
1624 WIN(DDGRUNLOCK(dd_grd_curcanv));
1626 game_flush_inputs();
1630 mouse_get_delta( &dx, &dy );
1632 while( (k!=KEY_ESC) && (code==255))
1637 DoMessageStuff(&msg);
1643 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1646 // if ( Game_mode & GM_MULTI )
1647 // GameLoop( 0, 0 ); // Continue
1651 if (k == KEY_PRINT_SCREEN)
1652 save_screen_shot(0);
1654 kc_drawquestion( item );
1656 mouse_get_delta( &dx, &dy );
1657 if ( abs(dx)>20 ) code = 0;
1658 if ( abs(dy)>20 ) code = 1;
1661 for (i=0; i<Num_items; i++ ) {
1662 n = item - All_items;
1663 if ( (i!=n) && (All_items[i].type==BT_MOUSE_AXIS) && (All_items[i].value==code) ) {
1664 All_items[i].value = 255;
1665 kc_drawitem( &All_items[i], 0 );
1670 kc_drawitem( item, 1 );
1671 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1672 game_flush_inputs();
1677 void kc_change_invert( kc_item * item )
1679 game_flush_inputs();
1686 kc_drawitem( item, 1 );
1690 #include "screens.h"
1692 extern void gr_bm_bitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
1694 void kconfig(int n, char * title)
1697 grs_bitmap *save_bm;
1699 set_screen_mode( SCREEN_MENU );
1704 WIN(mouse_set_mode(0));
1705 WIN(dd_gr_set_current_canvas(NULL));
1707 #if defined(POLY_ACC)
1708 save_bm = gr_create_bitmap2( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h, grd_curcanv->cv_bitmap.bm_type, NULL );
1710 save_bm = gr_create_bitmap( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
1712 Assert( save_bm != NULL );
1714 WIN(DDGRLOCK(dd_grd_curcanv));
1715 gr_bm_bitblt(grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_w,
1716 0, 0, 0, 0, &grd_curcanv->cv_bitmap, save_bm );
1717 WIN(DDGRUNLOCK(dd_grd_curcanv));
1720 case 0:kconfig_sub( kc_keyboard, NUM_KEY_CONTROLS, title );break;
1721 case 1:kconfig_sub( kc_joystick, NUM_OTHER_CONTROLS, title );break;
1722 case 2:kconfig_sub( kc_mouse, NUM_OTHER_CONTROLS, title ); break;
1723 case 3:kconfig_sub( kc_superjoy, NUM_OTHER_CONTROLS, title); break;
1730 WIN(mouse_set_mode(1));
1731 WIN(dd_gr_set_current_canvas(NULL));
1732 WIN(DDGRLOCK(dd_grd_curcanv));
1733 gr_bitmap(0, 0, save_bm);
1734 WIN(DDGRUNLOCK(dd_grd_curcanv));
1735 gr_free_bitmap(save_bm);
1737 reset_cockpit(); //force cockpit redraw next time
1739 // Update save values...
1741 for (i=0; i<NUM_KEY_CONTROLS; i++ )
1742 kconfig_settings[0][i] = kc_keyboard[i].value;
1744 if ( (Config_control_type>0) && (Config_control_type<5)) {
1745 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1746 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
1747 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
1748 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1749 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
1751 else if (Config_control_type == CONTROL_WINJOYSTICK) {
1752 for (i=0; i<NUM_OTHER_CONTROLS; i++ )
1753 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
1758 void kconfig_read_fcs( int raw_axis )
1760 int raw_button, button, axis_min[4], axis_center[4], axis_max[4];
1762 if (Config_control_type!=CONTROL_THRUSTMASTER_FCS) return;
1764 joy_get_cal_vals(axis_min, axis_center, axis_max);
1766 if ( axis_max[3] > 1 )
1767 raw_button = (raw_axis*100)/axis_max[3];
1771 if ( raw_button > 88 )
1773 else if ( raw_button > 63 )
1775 else if ( raw_button > 39 )
1777 else if ( raw_button > 15 )
1782 kconfig_set_fcs_button( 19, button );
1783 kconfig_set_fcs_button( 15, button );
1784 kconfig_set_fcs_button( 11, button );
1785 kconfig_set_fcs_button( 7, button );
1789 void kconfig_set_fcs_button( int btn, int button )
1791 int state,time_down,upcount,downcount;
1792 state = time_down = upcount = downcount = 0;
1794 if ( joy_get_button_state(btn) ) {
1795 if ( btn==button ) {
1797 time_down = FrameTime;
1802 if ( btn==button ) {
1804 time_down = FrameTime;
1811 joy_set_btn_values( btn, state, time_down, downcount, upcount );
1817 fix Last_angles_p = 0;
1818 fix Last_angles_b = 0;
1819 fix Last_angles_h = 0;
1820 ubyte Last_angles_read = 0;
1822 extern int VR_sensitivity;
1824 int VR_sense_range[3] = { 25, 50, 75 };
1826 #if 0 //ndef MACINTOSH
1831 fix yaw, pitch, roll;
1834 //------ read vfx1 helmet --------
1835 if (vfx1_installed) {
1836 vfx_get_data(&yaw,&pitch,&roll,&buttons);
1837 } else if (iglasses_headset_installed) {
1838 iglasses_read_headset( &yaw, &pitch, &roll );
1839 } else if (Victor_headset_installed) {
1840 victor_read_headset_filtered( &yaw, &pitch, &roll );
1845 Use_player_head_angles = 0;
1846 if ( Last_angles_read ) {
1850 if ( (Last_angles_h < (F1_0/4) ) && (yaw > ((F1_0*3)/4) ) )
1852 else if ( (yaw < (F1_0/4) ) && (Last_angles_h > ((F1_0*3)/4) ) )
1855 Controls.pitch_time += fixmul((pitch- Last_angles_p)*VR_sense_range[VR_sensitivity],FrameTime);
1856 Controls.heading_time+= fixmul((yaw1 - Last_angles_h)*VR_sense_range[VR_sensitivity],FrameTime);
1857 Controls.bank_time += fixmul((roll - Last_angles_b)*VR_sense_range[VR_sensitivity],FrameTime);
1859 Last_angles_read = 1;
1860 Last_angles_p = pitch;
1861 Last_angles_h = yaw;
1862 Last_angles_b = roll;
1870 #define JOYSTICK_READ_TIME (F1_0/40) // Read joystick at 40 Hz.
1872 #define JOYSTICK_READ_TIME (F1_0/10) // Read joystick at 10 Hz.
1875 fix LastReadTime = 0;
1879 ubyte kc_use_external_control = 0;
1880 ubyte kc_enable_external_control = 0;
1881 ubyte kc_external_intno = 0;
1882 ext_control_info *kc_external_control = NULL;
1883 ubyte *kc_external_name = NULL;
1884 ubyte kc_external_version = 0;
1885 extern int Automap_active;
1887 void kconfig_init_external_controls(int intno, int address)
1890 kc_external_intno = intno;
1891 kc_external_control = (ext_control_info *)address;
1892 kc_use_external_control = 1;
1893 kc_enable_external_control = 1;
1895 i = args_find ( "-xname" );
1897 kc_external_name = Args[i+1];
1899 kc_external_name = "External Controller";
1901 for (i=0;i<strlen (kc_external_name);i++)
1902 if (kc_external_name[i]=='_')
1903 kc_external_name[i]=' ';
1905 i = args_find ( "-xver" );
1907 kc_external_version = atoi(Args[i+1]);
1909 printf( "%s int: 0x%x, data: 0x%p, ver:%d\n", kc_external_name, kc_external_intno, kc_external_control, kc_external_version );
1913 #if !defined(MACINTOSH)
1914 /*void kconfig_read_external_controls()
1918 if ( !kc_enable_external_control && !CybermouseActive)
1921 if ( kc_external_version == 0 )
1922 memset( kc_external_control, 0, sizeof(control_info) );
1923 else if ( kc_external_version > 0 ) {
1924 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 );
1925 if ( kc_external_version > 1 ) {
1926 // Write ship pos and angles to external controls...
1927 ubyte *temp_ptr = (ubyte *)kc_external_control;
1928 vms_vector *ship_pos;
1929 vms_matrix *ship_orient;
1930 memset( kc_external_control, 0, sizeof(control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
1931 temp_ptr += sizeof(control_info)+sizeof(vms_angvec) + 64;
1932 ship_pos = (vms_vector *)temp_ptr;
1933 temp_ptr += sizeof(vms_vector);
1934 ship_orient = (vms_matrix *)temp_ptr;
1935 // Fill in ship postion...
1936 *ship_pos = Objects[Players[Player_num].objnum].pos;
1937 // Fill in ship orientation...
1938 *ship_orient = Objects[Players[Player_num].objnum].orient;
1942 if ( Automap_active ) // (If in automap...)
1943 kc_external_control->automap_state = 1;
1944 memset(&r,0,sizeof(r));
1948 if (!CybermouseActive)
1949 int386 ( kc_external_intno, &r, &r); // Read external info...
1951 // ReadOWL (kc_external_control);
1955 if ( Player_num > -1 ) {
1956 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
1957 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
1958 Auto_leveling_on = 0;
1960 if ( kc_external_version > 0 ) {
1961 vms_matrix tempm, ViewMatrix;
1962 vms_angvec * Kconfig_abs_movement;
1965 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
1967 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
1968 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
1969 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
1970 Objects[Players[Player_num].objnum].orient = ViewMatrix;
1972 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
1973 if (oem_message[0] != '\0' )
1974 HUD_init_message( oem_message );
1978 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
1979 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
1980 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
1981 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
1982 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
1983 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
1984 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
1985 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
1986 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
1987 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
1988 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
1989 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
1990 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
1991 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
1992 Controls.automap_down_count += kc_external_control->automap_down_count;
1993 Controls.automap_state |= kc_external_control->automap_state;
1998 void controls_read_all_win()
2001 int slide_on, bank_on;
2005 int raw_joy_axis[7];
2007 fix k0, k1, k2, k3, kp;
2008 fix k4, k5, k6, k7, kh;
2009 ubyte channel_masks;
2010 int use_mouse, use_joystick;
2013 if (Game_turbo_mode)
2017 fix temp = Controls.heading_time;
2018 fix temp1 = Controls.pitch_time;
2019 memset( &Controls, 0, sizeof(control_info) );
2020 Controls.heading_time = temp;
2021 Controls.pitch_time = temp1;
2026 ctime = timer_get_fixed_seconds();
2028 // DO JOYSTICK (X,Y,Z R,U,V)
2029 // ----------------------------------------------------------------------------
2030 if ( (LastReadTime + JOYSTICK_READ_TIME) > ctime ) {
2031 if ((ctime < 0) && (LastReadTime > 0))
2032 LastReadTime = ctime;
2034 } else if ((Config_control_type==CONTROL_WINJOYSTICK)) {
2035 LastReadTime = ctime;
2036 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS+JOY_EXT_AXIS, raw_joy_axis );
2038 for (i=0; i<7; i++ ) {
2039 if (channel_masks&(1<<i)) {
2040 int joy_null_value = 28;
2042 // DO POV if joystick has a hat.
2043 // --------------------------------------------------------------------
2045 joydefsw_do_winjoybutton(raw_joy_axis);
2049 // --------------------------------------------------------------------
2050 // mprintf((0, "(%d)=%d,", i, raw_joy_axis[i]));
2051 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2052 // mprintf((0, "%d ",raw_joy_axis[i]));
2053 // if (i%2) mprintf((0,"\n"));
2056 if (kc_superjoy[23].value==i) // If this is the throttle
2057 joy_null_value = 32; // Then use a larger dead-zone
2059 if (raw_joy_axis[i] > (joy_null_value-2))
2060 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2061 else if (raw_joy_axis[i] < -(joy_null_value+2))
2062 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2064 raw_joy_axis[i] = 0;
2065 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2074 for (i=0; i<6; i++ )
2080 // ----------------------------------------------------------------------------
2081 if (Config_control_type==5) {
2082 mouse_get_delta( &dx, &dy );
2083 mouse_axis[0] = (dx*FrameTime)/35;
2084 mouse_axis[1] = (dy*FrameTime)/25;
2085 mouse_buttons = mouse_get_btns();
2086 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2095 //------------- Read slide_on -------------
2098 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
2099 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
2101 if ((use_joystick)&&(kc_superjoy[5].value<255)) slide_on |= joy_get_button_state( kc_superjoy[5].value );
2103 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
2105 //------------- Read bank_on ---------------
2108 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
2109 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
2111 if ( (use_joystick)&&(kc_superjoy[10].value < 255 )) bank_on |= joy_get_button_state( kc_superjoy[10].value );
2113 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
2115 //------------ Read pitch_time -----------
2117 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2119 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
2120 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
2121 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
2122 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
2125 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
2126 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
2127 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
2128 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
2131 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2132 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
2133 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
2137 Controls.pitch_time = 0;
2139 if (Controls.pitch_time < 0)
2140 Controls.pitch_time = 0;
2142 if (Controls.pitch_time > 0)
2143 Controls.pitch_time = 0;
2144 Controls.pitch_time += kp;
2147 if ( (use_joystick)&&(kc_superjoy[13].value < 255 )) {
2148 if ( !kc_superjoy[14].value ) // If not inverted...
2149 Controls.pitch_time -= (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2151 Controls.pitch_time += (joy_axis[kc_superjoy[13].value]*Config_joystick_sensitivity)/8;
2155 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
2156 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
2157 if ( !kc_mouse[14].value ) // If not inverted...
2158 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2160 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2163 Controls.pitch_time = 0;
2167 //----------- Read vertical_thrust_time -----------------
2170 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
2171 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
2172 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
2173 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
2176 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
2177 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
2178 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
2179 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
2182 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2183 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
2184 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
2188 if ((use_joystick)&&( kc_superjoy[13].value < 255 )) {
2189 if ( !kc_superjoy[14].value ) // If not inverted...
2190 Controls.vertical_thrust_time += joy_axis[kc_superjoy[13].value];
2192 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[13].value];
2196 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
2197 if ( !kc_mouse[14].value ) // If not inverted...
2198 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
2200 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
2205 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
2206 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
2207 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
2208 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
2211 if ((use_joystick)&&( kc_superjoy[19].value < 255 )) {
2212 if ( !kc_superjoy[20].value ) // If not inverted...
2213 Controls.vertical_thrust_time += joy_axis[kc_superjoy[19].value];
2215 Controls.vertical_thrust_time -= joy_axis[kc_superjoy[19].value];
2218 // From joystick buttons
2219 if ( (use_joystick)&&(kc_superjoy[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_superjoy[8].value );
2220 if ( (use_joystick)&&(kc_superjoy[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_superjoy[9].value );
2222 // From mouse buttons
2223 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
2224 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
2227 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
2228 if ( !kc_mouse[20].value ) // If not inverted...
2229 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
2231 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
2235 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2236 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
2237 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
2240 //---------- Read heading_time -----------
2242 if (!slide_on && !bank_on) {
2243 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2245 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
2246 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
2247 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
2248 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
2251 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
2252 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
2253 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
2254 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
2257 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2258 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
2259 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
2263 Controls.heading_time = 0;
2265 if (Controls.heading_time < 0)
2266 Controls.heading_time = 0;
2268 if (Controls.heading_time > 0)
2269 Controls.heading_time = 0;
2270 Controls.heading_time += kh;
2273 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2274 if ( !kc_superjoy[16].value ) // If not inverted...
2275 Controls.heading_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2277 Controls.heading_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2281 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2282 if ( !kc_mouse[16].value ) // If not inverted...
2283 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2285 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2288 Controls.heading_time = 0;
2291 //----------- Read sideways_thrust_time -----------------
2294 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2295 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2296 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2297 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2300 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
2301 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
2302 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
2303 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
2306 if ( (use_joystick)&&(kc_superjoy[15].value < 255 )) {
2307 if ( !kc_superjoy[16].value ) // If not inverted...
2308 Controls.sideways_thrust_time += joy_axis[kc_superjoy[15].value];
2310 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[15].value];
2314 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2315 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
2316 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
2320 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2321 if ( !kc_mouse[16].value ) // If not inverted...
2322 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
2324 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
2329 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
2330 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
2331 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
2332 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
2335 if ( (use_joystick)&&(kc_superjoy[17].value < 255 )) {
2336 if ( !kc_superjoy[18].value ) // If not inverted...
2337 Controls.sideways_thrust_time -= joy_axis[kc_superjoy[17].value];
2339 Controls.sideways_thrust_time += joy_axis[kc_superjoy[17].value];
2342 // From joystick buttons
2343 if ( (use_joystick)&&(kc_superjoy[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_superjoy[6].value );
2344 if ( (use_joystick)&&(kc_superjoy[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_superjoy[7].value );
2346 // From mouse buttons
2347 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
2348 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
2351 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
2352 if ( !kc_mouse[18].value ) // If not inverted...
2353 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
2355 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
2358 //----------- Read bank_time -----------------
2361 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2362 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2363 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2364 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2367 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
2368 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
2369 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
2370 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
2373 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2374 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
2375 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
2379 if ( (use_joystick)&&(kc_superjoy[15].value < 255) ) {
2380 if ( !kc_superjoy[16].value ) // If not inverted...
2381 Controls.bank_time -= (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2383 Controls.bank_time += (joy_axis[kc_superjoy[15].value]*Config_joystick_sensitivity)/8;
2387 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2388 if ( !kc_mouse[16].value ) // If not inverted...
2389 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2391 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2396 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
2397 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
2398 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
2399 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
2402 if ( (use_joystick)&&(kc_superjoy[21].value < 255) ) {
2403 if ( !kc_superjoy[22].value ) // If not inverted...
2404 Controls.bank_time -= joy_axis[kc_superjoy[21].value];
2406 Controls.bank_time += joy_axis[kc_superjoy[21].value];
2409 // From joystick buttons
2410 if ( (use_joystick)&&(kc_superjoy[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_superjoy[11].value );
2411 if ( (use_joystick)&&(kc_superjoy[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_superjoy[12].value );
2413 // From mouse buttons
2414 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
2415 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
2418 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
2419 if ( !kc_mouse[22].value ) // If not inverted...
2420 Controls.bank_time += mouse_axis[kc_mouse[21].value];
2422 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
2426 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2427 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
2428 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
2431 //----------- Read forward_thrust_time -------------
2434 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
2435 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
2436 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
2437 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
2440 if ( (use_joystick)&&(kc_superjoy[23].value < 255 )) {
2441 if ( !kc_superjoy[24].value ) // If not inverted...
2442 Controls.forward_thrust_time -= joy_axis[kc_superjoy[23].value];
2444 Controls.forward_thrust_time += joy_axis[kc_superjoy[23].value];
2447 // From joystick buttons
2448 if ( (use_joystick)&&(kc_superjoy[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_superjoy[2].value );
2449 if ( (use_joystick)&&(kc_superjoy[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_superjoy[3].value );
2452 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
2453 if ( !kc_mouse[24].value ) // If not inverted...
2454 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
2456 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
2459 // From mouse buttons
2460 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
2461 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
2463 //----------- Read afterburner_state -------------
2466 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
2467 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
2469 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
2471 if ( (use_joystick)&&(kc_superjoy[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_superjoy[27].value);
2473 //-------Read headlight key--------------------------
2474 if (kc_keyboard[52].value < 255 )
2475 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
2476 if (kc_keyboard[53].value < 255 )
2477 Controls.headlight_count=key_down_count(kc_keyboard[53].value);
2478 if ((use_joystick)&&(kc_superjoy[30].value < 255 ))
2479 Controls.headlight_count=joy_get_button_down_cnt(kc_superjoy[30].value);
2481 //--------Read Cycle Primary Key------------------
2483 if (kc_keyboard[48].value<255)
2484 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
2485 if (kc_keyboard[49].value<255)
2486 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
2487 if ((use_joystick)&&(kc_superjoy[28].value < 255 ))
2488 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_superjoy[28].value);
2490 //--------Read Cycle Secondary Key------------------
2492 if (kc_keyboard[50].value<255)
2493 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
2494 if (kc_keyboard[51].value<255)
2495 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
2496 if ((use_joystick)&&(kc_superjoy[29].value < 255 ))
2497 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_superjoy[29].value);
2499 //--------Read Toggle Bomb key----------------------
2501 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
2503 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
2505 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
2506 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
2508 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2509 HUD_init_message ("No bombs available!");
2513 if (Players[Player_num].secondary_ammo[bomb]==0)
2515 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
2516 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
2520 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
2521 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
2526 //---------Read Energy->Shield key----------
2528 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
2529 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
2530 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
2531 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
2533 //----------- Read fire_primary_down_count
2534 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
2535 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
2536 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_superjoy[0].value);
2537 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
2539 //----------- Read fire_primary_state
2540 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
2541 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
2542 if ((use_joystick)&&(kc_superjoy[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_superjoy[0].value);
2543 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
2545 //----------- Read fire_secondary_down_count
2546 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
2547 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
2548 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_superjoy[1].value);
2549 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
2551 //----------- Read fire_secondary_state
2552 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
2553 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
2554 if ((use_joystick)&&(kc_superjoy[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_superjoy[1].value);
2555 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
2557 //----------- Read fire_flare_down_count
2558 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
2559 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
2560 if ((use_joystick)&&(kc_superjoy[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_superjoy[4].value);
2561 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
2563 //----------- Read drop_bomb_down_count
2564 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
2565 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
2566 if ((use_joystick)&&(kc_superjoy[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_superjoy[26].value);
2567 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
2569 //----------- Read rear_view_down_count
2570 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
2571 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
2572 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_superjoy[25].value);
2573 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
2575 //----------- Read rear_view_down_state
2576 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
2577 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
2578 if ((use_joystick)&&(kc_superjoy[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_superjoy[25].value);
2579 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
2581 //----------- Read automap_down_count
2582 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
2583 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
2585 //----------- Read automap_state
2586 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
2587 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
2589 //----------- Read stupid-cruise-control-type of throttle.
2591 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
2592 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
2593 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
2594 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
2595 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
2597 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
2600 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
2601 if (Cruise_speed < 0 ) Cruise_speed = 0;
2603 if (Controls.forward_thrust_time==0)
2604 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
2607 //read_head_tracker();
2609 // Read external controls
2610 if (kc_use_external_control || CybermouseActive)
2611 kconfig_read_external_controls();
2613 //----------- Clamp values between -FrameTime and FrameTime
2614 if (FrameTime > F1_0 )
2615 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
2617 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
2618 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
2619 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
2620 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
2621 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
2622 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
2623 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
2625 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
2626 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
2627 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
2628 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
2629 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
2630 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
2631 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
2634 //--------- Don't do anything if in debug mode
2636 if ( keyd_pressed[KEY_DELETE] ) {
2637 memset( &Controls, 0, sizeof(control_info) );
2644 fix Next_toggle_time[3]={0,0,0};
2646 int allowed_to_toggle(int i)
2648 //used for keeping tabs of when its ok to toggle headlight,primary,and secondary
2650 if (Next_toggle_time[i] > GameTime)
2651 if (Next_toggle_time[i] < GameTime + (F1_0/8)) // In case time is bogus, never wait > 1 second.
2654 Next_toggle_time[i] = GameTime + (F1_0/8);
2661 void controls_read_all()
2664 int slide_on, bank_on;
2669 int raw_joy_axis[4];
2671 fix k0, k1, k2, k3, kp;
2672 fix k4, k5, k6, k7, kh;
2673 ubyte channel_masks;
2674 int use_mouse, use_joystick;
2680 if (Game_turbo_mode)
2684 fix temp = Controls.heading_time;
2685 fix temp1 = Controls.pitch_time;
2686 memset( &Controls, 0, sizeof(control_info) );
2687 Controls.heading_time = temp;
2688 Controls.pitch_time = temp1;
2693 ctime = timer_get_fixed_seconds();
2695 //--------- Read Joystick -----------
2697 if ( (LastReadTime + JOYSTICK_READ_TIME > ctime) && (Config_control_type!=CONTROL_THRUSTMASTER_FCS) ) {
2698 if ((ctime < 0) && (LastReadTime > 0))
2699 LastReadTime = ctime;
2701 } else if ((Config_control_type>0) && (Config_control_type<5) ) {
2702 LastReadTime = ctime;
2703 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
2705 for (i=0; i<4; i++ ) {
2706 if (channel_masks&(1<<i)) {
2707 int joy_null_value = 10;
2709 if ( (i==3) && (Config_control_type==CONTROL_THRUSTMASTER_FCS) ) {
2710 kconfig_read_fcs( raw_joy_axis[i] );
2712 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2714 if (kc_joystick[23].value==i) // If this is the throttle
2715 joy_null_value = 20; // Then use a larger dead-zone
2717 if (raw_joy_axis[i] > joy_null_value)
2718 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2719 else if (raw_joy_axis[i] < -joy_null_value)
2720 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2722 raw_joy_axis[i] = 0;
2723 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2731 for (i=0; i<4; i++ )
2736 //--------- Read Joystick -----------
2737 if ((Config_control_type>0) && (Config_control_type<5) ) {
2738 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
2739 for (i=0; i<4; i++ ) {
2740 if (channel_masks&(1<<i)) {
2741 int joy_null_value = 10;
2743 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
2745 if (kc_joystick[23].value==i) // If this is the throttle
2746 joy_null_value = 20; // Then use a larger dead-zone
2748 if (raw_joy_axis[i] > joy_null_value)
2749 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
2750 else if (raw_joy_axis[i] < -joy_null_value)
2751 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
2753 raw_joy_axis[i] = 0;
2754 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
2761 for (i=0; i<4; i++ )
2765 #endif // ifndef MACINTOSH
2767 if (Config_control_type==5 && !CybermouseActive) {
2768 //--------- Read Mouse -----------
2769 mouse_get_delta( &dx, &dy );
2770 mouse_axis[0] = (dx*FrameTime)/35;
2771 mouse_axis[1] = (dy*FrameTime)/25;
2772 mouse_buttons = mouse_get_btns();
2773 //mprintf(( 0, "Mouse %d,%d b:%d, 0x%x\n", mouse_axis[0], mouse_axis[1], mouse_buttons, FrameTime ));
2775 } else if (Config_control_type==6 && !CybermouseActive) {
2776 //--------- Read Cyberman -----------
2777 mouse_get_cyberman_pos(&idx,&idy );
2778 mouse_axis[0] = (idx*FrameTime)/128;
2779 mouse_axis[1] = (idy*FrameTime)/128;
2780 mouse_buttons = mouse_get_btns();
2782 } else if (CybermouseActive) {
2783 // ReadOWL (kc_external_control);
2784 // CybermouseAdjust();
2792 //------------- Read slide_on -------------
2795 if ( kc_keyboard[8].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[8].value ];
2796 if ( kc_keyboard[9].value < 255 ) slide_on |= keyd_pressed[ kc_keyboard[9].value ];
2798 if ((use_joystick)&&(kc_joystick[5].value<255)) slide_on |= joy_get_button_state( kc_joystick[5].value );
2800 if ((use_mouse)&&(kc_mouse[5].value<255)) slide_on |= mouse_buttons & (1<<kc_mouse[5].value);
2802 //------------- Read bank_on ---------------
2805 if ( kc_keyboard[18].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[18].value ];
2806 if ( kc_keyboard[19].value < 255 ) bank_on |= keyd_pressed[ kc_keyboard[19].value ];
2808 if ( (use_joystick)&&(kc_joystick[10].value < 255 )) bank_on |= joy_get_button_state( kc_joystick[10].value );
2810 if ( (use_mouse)&&(kc_mouse[10].value < 255 )) bank_on |= mouse_buttons & (1<<kc_mouse[10].value);
2812 //------------ Read pitch_time -----------
2814 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2816 k0 = speed_factor*key_down_time( kc_keyboard[0].value )/2; // Divide by two since we want pitch to go slower
2817 k1 = speed_factor*key_down_time( kc_keyboard[1].value )/2;
2818 k2 = speed_factor*key_down_time( kc_keyboard[2].value )/2;
2819 k3 = speed_factor*key_down_time( kc_keyboard[3].value )/2;
2822 if ( kc_keyboard[0].value < 255 ) kp += k0/PH_SCALE;
2823 if ( kc_keyboard[1].value < 255 ) kp += k1/PH_SCALE;
2824 if ( kc_keyboard[2].value < 255 ) kp -= k2/PH_SCALE;
2825 if ( kc_keyboard[3].value < 255 ) kp -= k3/PH_SCALE;
2828 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2829 kp += mouse_button_down_time(MB_PITCH_FORWARD)/(PH_SCALE*2);
2830 kp -= mouse_button_down_time(MB_PITCH_BACKWARD)/(PH_SCALE*2);
2834 Controls.pitch_time = 0;
2836 if (Controls.pitch_time < 0)
2837 Controls.pitch_time = 0;
2839 if (Controls.pitch_time > 0)
2840 Controls.pitch_time = 0;
2841 Controls.pitch_time += kp;
2844 if ( (use_joystick)&&(kc_joystick[13].value < 255 )) {
2845 if ( !kc_joystick[14].value ) // If not inverted...
2846 Controls.pitch_time -= (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
2848 Controls.pitch_time += (joy_axis[kc_joystick[13].value]*Config_joystick_sensitivity)/8;
2852 //mprintf(( 0, "UM: %d, PV: %d\n", use_mouse, kc_mouse[13].value ));
2853 if ( (use_mouse)&&(kc_mouse[13].value < 255) ) {
2854 if ( !kc_mouse[14].value ) // If not inverted...
2855 Controls.pitch_time -= (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2857 Controls.pitch_time += (mouse_axis[kc_mouse[13].value]*Config_joystick_sensitivity)/8;
2860 Controls.pitch_time = 0;
2864 //----------- Read vertical_thrust_time -----------------
2867 k0 = speed_factor*key_down_time( kc_keyboard[0].value );
2868 k1 = speed_factor*key_down_time( kc_keyboard[1].value );
2869 k2 = speed_factor*key_down_time( kc_keyboard[2].value );
2870 k3 = speed_factor*key_down_time( kc_keyboard[3].value );
2873 if ( kc_keyboard[0].value < 255 ) Controls.vertical_thrust_time += k0;
2874 if ( kc_keyboard[1].value < 255 ) Controls.vertical_thrust_time += k1;
2875 if ( kc_keyboard[2].value < 255 ) Controls.vertical_thrust_time -= k2;
2876 if ( kc_keyboard[3].value < 255 ) Controls.vertical_thrust_time -= k3;
2879 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2880 Controls.vertical_thrust_time -= mouse_button_down_time(MB_PITCH_FORWARD);
2881 Controls.vertical_thrust_time += mouse_button_down_time(MB_PITCH_BACKWARD);
2885 if ((use_joystick)&&( kc_joystick[13].value < 255 )) {
2886 if ( !kc_joystick[14].value ) // If not inverted...
2887 Controls.vertical_thrust_time += joy_axis[kc_joystick[13].value];
2889 Controls.vertical_thrust_time -= joy_axis[kc_joystick[13].value];
2893 if ( (use_mouse)&&(kc_mouse[13].value < 255 )) {
2894 if ( !kc_mouse[14].value ) // If not inverted...
2895 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[13].value];
2897 Controls.vertical_thrust_time += mouse_axis[kc_mouse[13].value];
2902 if ( kc_keyboard[14].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[14].value );
2903 if ( kc_keyboard[15].value < 255 ) Controls.vertical_thrust_time += speed_factor*key_down_time( kc_keyboard[15].value );
2904 if ( kc_keyboard[16].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[16].value );
2905 if ( kc_keyboard[17].value < 255 ) Controls.vertical_thrust_time -= speed_factor*key_down_time( kc_keyboard[17].value );
2908 if ((use_joystick)&&( kc_joystick[19].value < 255 )) {
2909 if ( !kc_joystick[20].value ) // If not inverted...
2910 Controls.vertical_thrust_time += joy_axis[kc_joystick[19].value];
2912 Controls.vertical_thrust_time -= joy_axis[kc_joystick[19].value];
2915 // From joystick buttons
2916 if ( (use_joystick)&&(kc_joystick[8].value < 255 )) Controls.vertical_thrust_time += joy_get_button_down_time( kc_joystick[8].value );
2917 if ( (use_joystick)&&(kc_joystick[9].value < 255 )) Controls.vertical_thrust_time -= joy_get_button_down_time( kc_joystick[9].value );
2919 // From mouse buttons
2920 if ( (use_mouse)&&(kc_mouse[8].value < 255 )) Controls.vertical_thrust_time += mouse_button_down_time( kc_mouse[8].value );
2921 if ( (use_mouse)&&(kc_mouse[9].value < 255 )) Controls.vertical_thrust_time -= mouse_button_down_time( kc_mouse[9].value );
2924 if ( (use_mouse)&&(kc_mouse[19].value < 255 )) {
2925 if ( !kc_mouse[20].value ) // If not inverted...
2926 Controls.vertical_thrust_time += mouse_axis[kc_mouse[19].value];
2928 Controls.vertical_thrust_time -= mouse_axis[kc_mouse[19].value];
2932 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2933 Controls.vertical_thrust_time += mouse_button_down_time(MB_Z_UP)/2;
2934 Controls.vertical_thrust_time -= mouse_button_down_time(MB_Z_DOWN)/2;
2937 //---------- Read heading_time -----------
2939 if (!slide_on && !bank_on) {
2940 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
2942 k4 = speed_factor*key_down_time( kc_keyboard[4].value );
2943 k5 = speed_factor*key_down_time( kc_keyboard[5].value );
2944 k6 = speed_factor*key_down_time( kc_keyboard[6].value );
2945 k7 = speed_factor*key_down_time( kc_keyboard[7].value );
2948 if ( kc_keyboard[4].value < 255 ) kh -= k4/PH_SCALE;
2949 if ( kc_keyboard[5].value < 255 ) kh -= k5/PH_SCALE;
2950 if ( kc_keyboard[6].value < 255 ) kh += k6/PH_SCALE;
2951 if ( kc_keyboard[7].value < 255 ) kh += k7/PH_SCALE;
2954 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
2955 kh -= mouse_button_down_time(MB_HEAD_LEFT)/PH_SCALE;
2956 kh += mouse_button_down_time(MB_HEAD_RIGHT)/PH_SCALE;
2960 Controls.heading_time = 0;
2962 if (Controls.heading_time < 0)
2963 Controls.heading_time = 0;
2965 if (Controls.heading_time > 0)
2966 Controls.heading_time = 0;
2967 Controls.heading_time += kh;
2970 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
2971 if ( !kc_joystick[16].value ) // If not inverted...
2972 Controls.heading_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
2974 Controls.heading_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
2978 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
2979 if ( !kc_mouse[16].value ) // If not inverted...
2980 Controls.heading_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2982 Controls.heading_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
2985 Controls.heading_time = 0;
2988 //----------- Read sideways_thrust_time -----------------
2991 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
2992 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
2993 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
2994 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
2997 if ( kc_keyboard[4].value < 255 ) Controls.sideways_thrust_time -= k0;
2998 if ( kc_keyboard[5].value < 255 ) Controls.sideways_thrust_time -= k1;
2999 if ( kc_keyboard[6].value < 255 ) Controls.sideways_thrust_time += k2;
3000 if ( kc_keyboard[7].value < 255 ) Controls.sideways_thrust_time += k3;
3003 if ( (use_joystick)&&(kc_joystick[15].value < 255 )) {
3004 if ( !kc_joystick[16].value ) // If not inverted...
3005 Controls.sideways_thrust_time += joy_axis[kc_joystick[15].value];
3007 Controls.sideways_thrust_time -= joy_axis[kc_joystick[15].value];
3011 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3012 Controls.sideways_thrust_time -= mouse_button_down_time(MB_HEAD_LEFT);
3013 Controls.sideways_thrust_time += mouse_button_down_time(MB_HEAD_RIGHT);
3017 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3018 if ( !kc_mouse[16].value ) // If not inverted...
3019 Controls.sideways_thrust_time += mouse_axis[kc_mouse[15].value];
3021 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[15].value];
3026 if ( kc_keyboard[10].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[10].value );
3027 if ( kc_keyboard[11].value < 255 ) Controls.sideways_thrust_time -= speed_factor*key_down_time( kc_keyboard[11].value );
3028 if ( kc_keyboard[12].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[12].value );
3029 if ( kc_keyboard[13].value < 255 ) Controls.sideways_thrust_time += speed_factor*key_down_time( kc_keyboard[13].value );
3032 if ( (use_joystick)&&(kc_joystick[17].value < 255 )) {
3033 if ( !kc_joystick[18].value ) // If not inverted...
3034 Controls.sideways_thrust_time -= joy_axis[kc_joystick[17].value];
3036 Controls.sideways_thrust_time += joy_axis[kc_joystick[17].value];
3039 // From joystick buttons
3040 if ( (use_joystick)&&(kc_joystick[6].value < 255 )) Controls.sideways_thrust_time -= joy_get_button_down_time( kc_joystick[6].value );
3041 if ( (use_joystick)&&(kc_joystick[7].value < 255 )) Controls.sideways_thrust_time += joy_get_button_down_time( kc_joystick[7].value );
3043 // From mouse buttons
3044 if ( (use_mouse)&&(kc_mouse[6].value < 255 )) Controls.sideways_thrust_time -= mouse_button_down_time( kc_mouse[6].value );
3045 if ( (use_mouse)&&(kc_mouse[7].value < 255 )) Controls.sideways_thrust_time += mouse_button_down_time( kc_mouse[7].value );
3048 if ( (use_mouse)&&(kc_mouse[17].value < 255 )) {
3049 if ( !kc_mouse[18].value ) // If not inverted...
3050 Controls.sideways_thrust_time += mouse_axis[kc_mouse[17].value];
3052 Controls.sideways_thrust_time -= mouse_axis[kc_mouse[17].value];
3055 //----------- Read bank_time -----------------
3058 k0 = speed_factor*key_down_time( kc_keyboard[4].value );
3059 k1 = speed_factor*key_down_time( kc_keyboard[5].value );
3060 k2 = speed_factor*key_down_time( kc_keyboard[6].value );
3061 k3 = speed_factor*key_down_time( kc_keyboard[7].value );
3064 if ( kc_keyboard[4].value < 255 ) Controls.bank_time += k0;
3065 if ( kc_keyboard[5].value < 255 ) Controls.bank_time += k1;
3066 if ( kc_keyboard[6].value < 255 ) Controls.bank_time -= k2;
3067 if ( kc_keyboard[7].value < 255 ) Controls.bank_time -= k3;
3070 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3071 Controls.bank_time -= mouse_button_down_time(MB_HEAD_LEFT);
3072 Controls.bank_time += mouse_button_down_time(MB_HEAD_RIGHT);
3076 if ( (use_joystick)&&(kc_joystick[15].value < 255) ) {
3077 if ( !kc_joystick[16].value ) // If not inverted...
3078 Controls.bank_time -= (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3080 Controls.bank_time += (joy_axis[kc_joystick[15].value]*Config_joystick_sensitivity)/8;
3084 if ( (use_mouse)&&(kc_mouse[15].value < 255 )) {
3085 if ( !kc_mouse[16].value ) // If not inverted...
3086 Controls.bank_time += (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3088 Controls.bank_time -= (mouse_axis[kc_mouse[15].value]*Config_joystick_sensitivity)/8;
3093 if ( kc_keyboard[20].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[20].value );
3094 if ( kc_keyboard[21].value < 255 ) Controls.bank_time += speed_factor*key_down_time( kc_keyboard[21].value );
3095 if ( kc_keyboard[22].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[22].value );
3096 if ( kc_keyboard[23].value < 255 ) Controls.bank_time -= speed_factor*key_down_time( kc_keyboard[23].value );
3099 if ( (use_joystick)&&(kc_joystick[21].value < 255) ) {
3100 if ( !kc_joystick[22].value ) // If not inverted...
3101 Controls.bank_time -= joy_axis[kc_joystick[21].value];
3103 Controls.bank_time += joy_axis[kc_joystick[21].value];
3106 // From joystick buttons
3107 if ( (use_joystick)&&(kc_joystick[11].value < 255 )) Controls.bank_time += joy_get_button_down_time( kc_joystick[11].value );
3108 if ( (use_joystick)&&(kc_joystick[12].value < 255 )) Controls.bank_time -= joy_get_button_down_time( kc_joystick[12].value );
3110 // From mouse buttons
3111 if ( (use_mouse)&&(kc_mouse[11].value < 255 )) Controls.bank_time += mouse_button_down_time( kc_mouse[11].value );
3112 if ( (use_mouse)&&(kc_mouse[12].value < 255 )) Controls.bank_time -= mouse_button_down_time( kc_mouse[12].value );
3115 if ( (use_mouse)&&(kc_mouse[21].value < 255 )) {
3116 if ( !kc_mouse[22].value ) // If not inverted...
3117 Controls.bank_time += mouse_axis[kc_mouse[21].value];
3119 Controls.bank_time -= mouse_axis[kc_mouse[21].value];
3123 if ((use_mouse)&&(Config_control_type==CONTROL_CYBERMAN)) {
3124 Controls.bank_time += mouse_button_down_time(MB_BANK_LEFT);
3125 Controls.bank_time -= mouse_button_down_time(MB_BANK_RIGHT);
3128 //----------- Read forward_thrust_time -------------
3131 if ( kc_keyboard[30].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[30].value );
3132 if ( kc_keyboard[31].value < 255 ) Controls.forward_thrust_time += speed_factor*key_down_time( kc_keyboard[31].value );
3133 if ( kc_keyboard[32].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[32].value );
3134 if ( kc_keyboard[33].value < 255 ) Controls.forward_thrust_time -= speed_factor*key_down_time( kc_keyboard[33].value );
3137 if ( (use_joystick)&&(kc_joystick[23].value < 255 )) {
3138 if ( !kc_joystick[24].value ) // If not inverted...
3139 Controls.forward_thrust_time -= joy_axis[kc_joystick[23].value];
3141 Controls.forward_thrust_time += joy_axis[kc_joystick[23].value];
3144 // From joystick buttons
3145 if ( (use_joystick)&&(kc_joystick[2].value < 255 )) Controls.forward_thrust_time += joy_get_button_down_time( kc_joystick[2].value );
3146 if ( (use_joystick)&&(kc_joystick[3].value < 255 )) Controls.forward_thrust_time -= joy_get_button_down_time( kc_joystick[3].value );
3149 if ( (use_mouse)&&(kc_mouse[23].value < 255 )) {
3150 if ( !kc_mouse[24].value ) // If not inverted...
3151 Controls.forward_thrust_time -= mouse_axis[kc_mouse[23].value];
3153 Controls.forward_thrust_time += mouse_axis[kc_mouse[23].value];
3156 // From mouse buttons
3157 if ( (use_mouse)&&(kc_mouse[2].value < 255 )) Controls.forward_thrust_time += mouse_button_down_time( kc_mouse[2].value );
3158 if ( (use_mouse)&&(kc_mouse[3].value < 255 )) Controls.forward_thrust_time -= mouse_button_down_time( kc_mouse[3].value );
3160 //----------- Read afterburner_state -------------
3163 if ( kc_keyboard[46].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[46].value];
3164 if ( kc_keyboard[47].value < 255 ) Controls.afterburner_state |= keyd_pressed[kc_keyboard[47].value];
3166 if ( (use_mouse)&&(kc_mouse[27].value < 255 )) Controls.afterburner_state |= mouse_button_state(kc_mouse[27].value);
3168 if ( (use_joystick)&&(kc_joystick[27].value < 255 )) Controls.afterburner_state |= joy_get_button_state(kc_joystick[27].value);
3170 //-------Read headlight key--------------------------
3172 if (kc_keyboard[52].value < 255 )
3173 Controls.headlight_count=key_down_count(kc_keyboard[52].value);
3174 if (kc_keyboard[53].value < 255 )
3175 Controls.headlight_count+=key_down_count(kc_keyboard[53].value);
3176 if ((use_joystick)&&(kc_joystick[30].value < 255 ))
3177 Controls.headlight_count+=joy_get_button_down_cnt(kc_joystick[30].value);
3179 //--------Read Cycle Primary Key------------------
3181 if (kc_keyboard[48].value<255)
3182 Controls.cycle_primary_count=key_down_count(kc_keyboard[48].value);
3183 if (kc_keyboard[49].value<255)
3184 Controls.cycle_primary_count+=key_down_count(kc_keyboard[49].value);
3185 if ((use_joystick)&&(kc_joystick[28].value < 255 ))
3186 Controls.cycle_primary_count+=joy_get_button_down_cnt(kc_joystick[28].value);
3189 //--------Read Cycle Secondary Key------------------
3191 if (kc_keyboard[50].value<255)
3192 Controls.cycle_secondary_count=key_down_count(kc_keyboard[50].value);
3193 if (kc_keyboard[51].value<255)
3194 Controls.cycle_secondary_count+=key_down_count(kc_keyboard[51].value);
3195 if ((use_joystick)&&(kc_joystick[29].value < 255 ))
3196 Controls.cycle_secondary_count=joy_get_button_down_cnt(kc_joystick[29].value);
3198 //--------Read Toggle Bomb key----------------------
3200 if (kc_keyboard[56].value<255 && key_down_count(kc_keyboard[56].value))
3202 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
3204 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
3205 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
3207 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3208 HUD_init_message ("No bombs available!");
3212 if (Players[Player_num].secondary_ammo[bomb]==0)
3214 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
3215 HUD_init_message ("No %s available!",(bomb==SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
3219 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
3220 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
3225 //---------Read Energy->Shield key----------
3227 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[54].value])
3228 transfer_energy_to_shield(key_down_time(kc_keyboard[54].value));
3229 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[kc_keyboard[55].value])
3230 transfer_energy_to_shield(key_down_time(kc_keyboard[55].value));
3232 //----------- Read fire_primary_down_count
3233 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[24].value);
3234 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_down_count += key_down_count(kc_keyboard[25].value);
3235 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_down_count += joy_get_button_down_cnt(kc_joystick[0].value);
3236 if ((use_mouse)&&(kc_mouse[0].value < 255 )) Controls.fire_primary_down_count += mouse_button_down_count(kc_mouse[0].value);
3238 //----------- Read fire_primary_state
3239 if (kc_keyboard[24].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[24].value];
3240 if (kc_keyboard[25].value < 255 ) Controls.fire_primary_state |= keyd_pressed[kc_keyboard[25].value];
3241 if ((use_joystick)&&(kc_joystick[0].value < 255 )) Controls.fire_primary_state |= joy_get_button_state(kc_joystick[0].value);
3242 if ((use_mouse)&&(kc_mouse[0].value < 255) ) Controls.fire_primary_state |= mouse_button_state(kc_mouse[0].value);
3244 //----------- Read fire_secondary_down_count
3245 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[26].value);
3246 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_down_count += key_down_count(kc_keyboard[27].value);
3247 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_down_count += joy_get_button_down_cnt(kc_joystick[1].value);
3248 if ((use_mouse)&&(kc_mouse[1].value < 255 )) Controls.fire_secondary_down_count += mouse_button_down_count(kc_mouse[1].value);
3250 //----------- Read fire_secondary_state
3251 if (kc_keyboard[26].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[26].value];
3252 if (kc_keyboard[27].value < 255 ) Controls.fire_secondary_state |= keyd_pressed[kc_keyboard[27].value];
3253 if ((use_joystick)&&(kc_joystick[1].value < 255 )) Controls.fire_secondary_state |= joy_get_button_state(kc_joystick[1].value);
3254 if ((use_mouse)&&(kc_mouse[1].value < 255) ) Controls.fire_secondary_state |= mouse_button_state(kc_mouse[1].value);
3256 //----------- Read fire_flare_down_count
3257 if (kc_keyboard[28].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[28].value);
3258 if (kc_keyboard[29].value < 255 ) Controls.fire_flare_down_count += key_down_count(kc_keyboard[29].value);
3259 if ((use_joystick)&&(kc_joystick[4].value < 255 )) Controls.fire_flare_down_count += joy_get_button_down_cnt(kc_joystick[4].value);
3260 if ((use_mouse)&&(kc_mouse[4].value < 255 )) Controls.fire_flare_down_count += mouse_button_down_count(kc_mouse[4].value);
3262 //----------- Read drop_bomb_down_count
3263 if (kc_keyboard[34].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[34].value);
3264 if (kc_keyboard[35].value < 255 ) Controls.drop_bomb_down_count += key_down_count(kc_keyboard[35].value);
3265 if ((use_joystick)&&(kc_joystick[26].value < 255 )) Controls.drop_bomb_down_count += joy_get_button_down_cnt(kc_joystick[26].value);
3266 if ((use_mouse)&&(kc_mouse[26].value < 255 )) Controls.drop_bomb_down_count += mouse_button_down_count(kc_mouse[26].value);
3268 //----------- Read rear_view_down_count
3269 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[36].value);
3270 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_count += key_down_count(kc_keyboard[37].value);
3271 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_count += joy_get_button_down_cnt(kc_joystick[25].value);
3272 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_count += mouse_button_down_count(kc_mouse[25].value);
3274 //----------- Read rear_view_down_state
3275 if (kc_keyboard[36].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[36].value];
3276 if (kc_keyboard[37].value < 255 ) Controls.rear_view_down_state |= keyd_pressed[kc_keyboard[37].value];
3277 if ((use_joystick)&&(kc_joystick[25].value < 255 )) Controls.rear_view_down_state |= joy_get_button_state(kc_joystick[25].value);
3278 if ((use_mouse)&&(kc_mouse[25].value < 255 )) Controls.rear_view_down_state |= mouse_button_state(kc_mouse[25].value);
3280 //----------- Read automap_down_count
3281 if (kc_keyboard[44].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[44].value);
3282 if (kc_keyboard[45].value < 255 ) Controls.automap_down_count += key_down_count(kc_keyboard[45].value);
3284 //----------- Read automap_state
3285 if (kc_keyboard[44].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[44].value];
3286 if (kc_keyboard[45].value < 255 ) Controls.automap_state |= keyd_pressed[kc_keyboard[45].value];
3288 //----------- Read stupid-cruise-control-type of throttle.
3290 if ( kc_keyboard[38].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[38].value)*5,FrameTime);
3291 if ( kc_keyboard[39].value < 255 ) Cruise_speed += fixdiv(speed_factor*key_down_time(kc_keyboard[39].value)*5,FrameTime);
3292 if ( kc_keyboard[40].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[40].value)*5,FrameTime);
3293 if ( kc_keyboard[41].value < 255 ) Cruise_speed -= fixdiv(speed_factor*key_down_time(kc_keyboard[41].value)*5,FrameTime);
3294 if ( (kc_keyboard[42].value < 255) && (key_down_count(kc_keyboard[42].value)) )
3296 if ( (kc_keyboard[43].value < 255) && (key_down_count(kc_keyboard[43].value)) )
3299 if (Cruise_speed > i2f(100) ) Cruise_speed = i2f(100);
3300 if (Cruise_speed < 0 ) Cruise_speed = 0;
3302 if (Controls.forward_thrust_time==0)
3303 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
3306 #if !defined(MACINTOSH)
3307 //read_head_tracker();
3309 // Read external controls
3310 if (kc_use_external_control || CybermouseActive)
3311 kconfig_read_external_controls();
3314 //----------- Clamp values between -FrameTime and FrameTime
3315 if (FrameTime > F1_0 )
3316 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
3318 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
3319 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
3320 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
3321 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
3322 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
3323 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
3324 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
3326 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
3327 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
3328 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
3329 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
3330 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
3331 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
3332 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
3335 //--------- Don't do anything if in debug mode
3337 if ( keyd_pressed[KEY_DELETE] ) {
3338 memset( &Controls, 0, sizeof(control_info) );
3344 void reset_cruise(void)
3350 void kc_set_controls()
3354 for (i=0; i<NUM_KEY_CONTROLS; i++ )
3355 kc_keyboard[i].value = kconfig_settings[0][i];
3357 if ( (Config_control_type>0) && (Config_control_type<5)) {
3358 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3359 kc_joystick[i].value = kconfig_settings[Config_control_type][i];
3360 if (kc_joystick[i].type == BT_INVERT ) {
3361 if (kc_joystick[i].value!=1)
3362 kc_joystick[i].value = 0;
3363 kconfig_settings[Config_control_type][i] = kc_joystick[i].value;
3366 } else if (Config_control_type>4 && Config_control_type<CONTROL_WINJOYSTICK) {
3367 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3368 kc_mouse[i].value = kconfig_settings[Config_control_type][i];
3369 if (kc_mouse[i].type == BT_INVERT ) {
3370 if (kc_mouse[i].value!=1)
3371 kc_mouse[i].value = 0;
3372 kconfig_settings[Config_control_type][i] = kc_mouse[i].value;
3375 } else if (Config_control_type == CONTROL_WINJOYSTICK) {
3376 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
3377 kc_superjoy[i].value = kconfig_settings[Config_control_type][i];
3378 if (kc_superjoy[i].type == BT_INVERT ) {
3379 if (kc_superjoy[i].value!=1)
3380 kc_superjoy[i].value = 0;
3381 kconfig_settings[Config_control_type][i] = kc_superjoy[i].value;
3387 #if 0 //ndef MACINTOSH // no mac support for vr headset
3389 void kconfig_center_headset()
3393 vfx_center_headset();
3395 // } else if (iglasses_headset_installed) {
3396 // } else if (Victor_headset_installed) {
3402 #endif // end of #ifndef MACINTOSH for kconfig_center_headset
3404 void CybermouseAdjust ()
3406 /* if ( Player_num > -1 ) {
3407 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3408 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3409 Auto_leveling_on = 0;
3411 if ( kc_external_version > 0 ) {
3412 vms_matrix tempm, ViewMatrix;
3413 vms_angvec * Kconfig_abs_movement;
3416 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
3418 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3419 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3420 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3421 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3423 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3424 if (oem_message[0] != '\0' )
3425 HUD_init_message( oem_message );
3429 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3430 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3431 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3432 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3433 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3434 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3435 // Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3436 // Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3437 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3438 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3439 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3440 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3441 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3442 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3443 // Controls.automap_down_count += kc_external_control->automap_down_count;
3444 // Controls.automap_state |= kc_external_control->automap_state;
3447 char GetKeyValue (char key)
3449 mprintf ((0,"Returning %c!\n",kc_keyboard[(int)key].value));
3450 return (kc_keyboard[(int)key].value);
3453 #if !defined(MACINTOSH)
3456 extern object *obj_find_first_of_type (int);
3457 void kconfig_read_external_controls()
3462 if ( !kc_enable_external_control ) return;
3464 if ( kc_external_version == 0 )
3465 memset( kc_external_control, 0, sizeof(ext_control_info));
3466 else if ( kc_external_version > 0 ) {
3468 if (kc_external_version>=4)
3469 memset( kc_external_control, 0, sizeof(advanced_ext_control_info));
3470 else if (kc_external_version>0)
3471 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 );
3472 else if (kc_external_version>2)
3473 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof(vms_matrix) +4 );
3475 if ( kc_external_version > 1 ) {
3476 // Write ship pos and angles to external controls...
3477 ubyte *temp_ptr = (ubyte *)kc_external_control;
3478 vms_vector *ship_pos;
3479 vms_matrix *ship_orient;
3480 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
3481 temp_ptr += sizeof(ext_control_info) + sizeof(vms_angvec) + 64;
3482 ship_pos = (vms_vector *)temp_ptr;
3483 temp_ptr += sizeof(vms_vector);
3484 ship_orient = (vms_matrix *)temp_ptr;
3485 // Fill in ship postion...
3486 *ship_pos = Objects[Players[Player_num].objnum].pos;
3487 // Fill in ship orientation...
3488 *ship_orient = Objects[Players[Player_num].objnum].orient;
3490 if (kc_external_version>=4)
3492 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3494 temp_ptr->headlight_state=(Players[Player_num].flags & PLAYER_FLAGS_HEADLIGHT_ON);
3495 temp_ptr->primary_weapon_flags=Players[Player_num].primary_weapon_flags;
3496 temp_ptr->secondary_weapon_flags=Players[Player_num].secondary_weapon_flags;
3497 temp_ptr->current_primary_weapon=Primary_weapon;
3498 temp_ptr->current_secondary_weapon=Secondary_weapon;
3500 temp_ptr->current_guidebot_command=Escort_goal_object;
3502 temp_ptr->force_vector=ExtForceVec;
3503 temp_ptr->force_matrix=ExtApplyForceMatrix;
3505 temp_ptr->joltinfo[i]=ExtJoltInfo[i];
3507 temp_ptr->x_vibrate_info[i]=ExtXVibrateInfo[i];
3508 temp_ptr->x_vibrate_clear=ExtXVibrateClear;
3509 temp_ptr->game_status=ExtGameStatus;
3511 memset ((void *)&ExtForceVec,0,sizeof(vms_vector));
3512 memset ((void *)&ExtApplyForceMatrix,0,sizeof(vms_matrix));
3517 ExtXVibrateInfo[i]=0;
3522 if ( Automap_active ) // (If in automap...)
3523 kc_external_control->automap_state = 1;
3524 //memset(&r,0,sizeof(r));
3526 #if !defined WINDOWS && !defined __ENV_LINUX__ && !defined __ENV_DJGPP__
3528 int386 ( kc_external_intno, &r, &r); // Read external info...
3532 if ( Player_num > -1 ) {
3533 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
3534 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
3535 Auto_leveling_on = 0;
3537 if ( kc_external_version > 0 ) {
3538 vms_matrix tempm, ViewMatrix;
3539 vms_angvec * Kconfig_abs_movement;
3542 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(ext_control_info));
3544 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
3545 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
3546 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
3547 Objects[Players[Player_num].objnum].orient = ViewMatrix;
3549 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
3550 if (oem_message[0] != '\0' )
3551 HUD_init_message( oem_message );
3555 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
3556 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
3557 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
3558 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
3559 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
3560 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
3561 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
3562 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
3563 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
3564 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
3565 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
3566 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
3567 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
3568 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
3569 Controls.automap_down_count += kc_external_control->automap_down_count;
3570 Controls.automap_state |= kc_external_control->automap_state;
3572 if (kc_external_version>=3)
3574 ubyte *temp_ptr = (ubyte *)kc_external_control;
3575 temp_ptr += (sizeof(ext_control_info) + sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof (vms_matrix));
3578 Controls.cycle_primary_count=(*(temp_ptr));
3580 Controls.cycle_secondary_count=(*(temp_ptr+1));
3583 Controls.afterburner_state=(*(temp_ptr+2));
3585 Controls.headlight_count=(*(temp_ptr+3));
3587 if (kc_external_version>=4)
3590 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
3593 if (temp_ptr->keyboard[i])
3596 if (temp_ptr->Reactor_blown)
3598 if (Game_mode & GM_MULTI)
3599 net_destroy_controlcen (obj_find_first_of_type (OBJ_CNTRLCEN));
3601 do_controlcen_destroyed_stuff(obj_find_first_of_type (OBJ_CNTRLCEN));