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 * Routines to configure keyboard, joystick, etc..
75 ubyte ExtGameStatus=1;
77 vms_vector ExtForceVec;
78 vms_matrix ExtApplyForceMatrix;
80 int ExtJoltInfo[3]={0,0,0};
81 int ExtXVibrateInfo[2]={0,0};
82 int ExtYVibrateInfo[2]={0,0};
83 ubyte ExtXVibrateClear=0;
84 ubyte ExtYVibrateClear=0;
86 #define TABLE_CREATION 1
88 // Array used to 'blink' the cursor while waiting for a keypress.
89 sbyte 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 };
91 //char * invert_text[2] = { "N", "Y" };
92 //char * joyaxis_text[4] = { "X1", "Y1", "X2", "Y2" };
93 //char * mouseaxis_text[2] = { "L/R", "F/B" };
95 int invert_text[2] = { TNUM_N, TNUM_Y };
98 #if defined(SDL_INPUT)
99 char *joyaxis_text[JOY_MAX_AXES];
101 int joyaxis_text[7] = { TNUM_X1, TNUM_Y1, TNUM_Z1, TNUM_UN, TNUM_P1,TNUM_R1,TNUM_YA1 };
102 // int joyaxis_text[4] = { TNUM_X1, TNUM_Y1, TNUM_X2, TNUM_Y2 };
106 int mouseaxis_text[3] = { TNUM_L_R, TNUM_F_B, TNUM_Z1 };
108 #if !defined OGL && !defined SDL_INPUT
109 char * key_text[256] = { \
110 "","ESC","1","2","3","4","5","6","7","8","9","0","-", \
111 "=","BSPC","TAB","Q","W","E","R","T","Y","U","I","O", \
112 "P","[","]","\x83","LCTRL","A","S","D","F", \
113 "G","H","J","K","L",";","'","`", \
114 "LSHFT","\\","Z","X","C","V","B","N","M",",", \
115 ".","/","RSHFT","PAD*","LALT","SPC", \
116 "CPSLK","F1","F2","F3","F4","F5","F6","F7","F8","F9", \
117 "F10","NMLCK","SCLK","PAD7","PAD8","PAD9","PAD-", \
118 "PAD4","PAD5","PAD6","PAD+","PAD1","PAD2","PAD3","PAD0", \
119 "PAD.","","","","F11","F12","","","","","","","","","", \
120 "","","","","","","","","","","","","","","","","","","","", \
121 "","","","","","","","","","","","","","","","","","","","", \
122 "","","","","","","","","","","","","","","","","","", \
123 "PAD\x83","RCTRL","","","","","","","","","","","","","", \
124 "","","","","","","","","","","PAD/","","","RALT","", \
125 "","","","","","","","","","","","","","HOME","\x82","PGUP", \
126 "","\x81","","\x7f","","END","\x80","PGDN","INS", \
127 "DEL","","","","","","","","","","","","","","","","","", \
128 "","","","","","","","","","","","","","","","","","","","", \
129 "","","","","","","" };
132 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_MINUS, KEY_EQUAL, KEY_PRINT_SCREEN };
134 //extern void GameLoop(int, int );
136 extern void transfer_energy_to_shield(fix);
137 extern char CybermouseActive;
139 control_info Controls;
143 // macros for drawing lo/hi res kconfig screens (see scores.c as well)
145 #define LHX(x) ((x)*(MenuHires?2:1))
146 #define LHY(y) ((y)*(MenuHires?2.4:1))
150 //#define BT_MOUSE_BUTTON 1
151 #define BT_MOUSE_AXIS 2
152 //#define BT_JOY_BUTTON 3
153 #define BT_JOY_AXIS 4
156 char *btype_text[] = { "BT_KEY", "BT_MOUSE_BUTTON", "BT_MOUSE_AXIS", "BT_JOY_BUTTON", "BT_JOY_AXIS", "BT_INVERT" };
160 typedef struct kc_item {
161 short id; // The id of this item
169 ubyte value; // what key,button,etc
176 //----------- WARNING!!!!!!! -------------------------------------------
177 // THESE NEXT FOUR BLOCKS OF DATA ARE GENERATED BY PRESSING DEL+F12 WHEN
178 // IN THE KEYBOARD CONFIG SCREEN. BASICALLY, THAT PROCEDURE MODIFIES THE
179 // U,D,L,R FIELDS OF THE ARRAYS AND DUMPS THE NEW ARRAYS INTO KCONFIG.COD
180 //-------------------------------------------------------------------------
182 kc_item kc_keyboard[NUM_KEY_CONTROLS] = {
183 { 0, 15, 49, 71, 26, 55, 2, 55, 1,"Pitch forward", BT_KEY, 255 },
184 { 1, 15, 49,100, 26, 50, 3, 0, 24,"Pitch forward", BT_KEY, 255 },
185 { 2, 15, 57, 71, 26, 0, 4, 25, 3,"Pitch backward", BT_KEY, 255 },
186 { 3, 15, 57,100, 26, 1, 5, 2, 26,"Pitch backward", BT_KEY, 255 },
187 { 4, 15, 65, 71, 26, 2, 6, 27, 5,"Turn left", BT_KEY, 255 },
188 { 5, 15, 65,100, 26, 3, 7, 4, 28,"Turn left", BT_KEY, 255 },
189 { 6, 15, 73, 71, 26, 4, 8, 29, 7,"Turn right", BT_KEY, 255 },
190 { 7, 15, 73,100, 26, 5, 9, 6, 34,"Turn right", BT_KEY, 255 },
191 { 8, 15, 85, 71, 26, 6, 10, 35, 9,"Slide on", BT_KEY, 255 },
192 { 9, 15, 85,100, 26, 7, 11, 8, 36,"Slide on", BT_KEY, 255 },
193 { 10, 15, 93, 71, 26, 8, 12, 37, 11,"Slide left", BT_KEY, 255 },
194 { 11, 15, 93,100, 26, 9, 13, 10, 44,"Slide left", BT_KEY, 255 },
195 { 12, 15,101, 71, 26, 10, 14, 45, 13,"Slide right", BT_KEY, 255 },
196 { 13, 15,101,100, 26, 11, 15, 12, 30,"Slide right", BT_KEY, 255 },
197 { 14, 15,109, 71, 26, 12, 16, 31, 15,"Slide up", BT_KEY, 255 },
198 { 15, 15,109,100, 26, 13, 17, 14, 32,"Slide up", BT_KEY, 255 },
199 { 16, 15,117, 71, 26, 14, 18, 33, 17,"Slide down", BT_KEY, 255 },
200 { 17, 15,117,100, 26, 15, 19, 16, 46,"Slide down", BT_KEY, 255 },
201 { 18, 15,129, 71, 26, 16, 20, 47, 19,"Bank on", BT_KEY, 255 },
202 { 19, 15,129,100, 26, 17, 21, 18, 38,"Bank on", BT_KEY, 255 },
203 { 20, 15,137, 71, 26, 18, 22, 39, 21,"Bank left", BT_KEY, 255 },
204 { 21, 15,137,100, 26, 19, 23, 20, 40,"Bank left", BT_KEY, 255 },
205 { 22, 15,145, 71, 26, 20, 48, 41, 23,"Bank right", BT_KEY, 255 },
206 { 23, 15,145,100, 26, 21, 49, 22, 42,"Bank right", BT_KEY, 255 },
207 { 24,158, 49, 83, 26, 51, 26, 1, 25,"Fire primary", BT_KEY, 255 },
208 { 25,158, 49,112, 26, 54, 27, 24, 2,"Fire primary", BT_KEY, 255 },
209 { 26,158, 57, 83, 26, 24, 28, 3, 27,"Fire secondary", BT_KEY, 255 },
210 { 27,158, 57,112, 26, 25, 29, 26, 4,"Fire secondary", BT_KEY, 255 },
211 { 28,158, 65, 83, 26, 26, 34, 5, 29,"Fire flare", BT_KEY, 255 },
212 { 29,158, 65,112, 26, 27, 35, 28, 6,"Fire flare", BT_KEY, 255 },
213 { 30,158,105, 83, 26, 44, 32, 13, 31,"Accelerate", BT_KEY, 255 },
214 { 31,158,105,112, 26, 45, 33, 30, 14,"Accelerate", BT_KEY, 255 },
215 { 32,158,113, 83, 26, 30, 46, 15, 33,"reverse", BT_KEY, 255 },
216 { 33,158,113,112, 26, 31, 47, 32, 16,"reverse", BT_KEY, 255 },
217 { 34,158, 73, 83, 26, 28, 36, 7, 35,"Drop Bomb", BT_KEY, 255 },
218 { 35,158, 73,112, 26, 29, 37, 34, 8,"Drop Bomb", BT_KEY, 255 },
219 { 36,158, 85, 83, 26, 34, 44, 9, 37,"REAR VIEW", BT_KEY, 255 },
220 { 37,158, 85,112, 26, 35, 45, 36, 10,"REAR VIEW", BT_KEY, 255 },
221 { 38,158,133, 83, 26, 46, 40, 19, 39,"Cruise Faster", BT_KEY, 255 },
222 { 39,158,133,112, 26, 47, 41, 38, 20,"Cruise Faster", BT_KEY, 255 },
223 { 40,158,141, 83, 26, 38, 42, 21, 41,"Cruise Slower", BT_KEY, 255 },
224 { 41,158,141,112, 26, 39, 43, 40, 22,"Cruise Slower", BT_KEY, 255 },
225 { 42,158,149, 83, 26, 40, 52, 23, 43,"Cruise Off", BT_KEY, 255 },
226 { 43,158,149,112, 26, 41, 53, 42, 48,"Cruise Off", BT_KEY, 255 },
227 { 44,158, 93, 83, 26, 36, 30, 11, 45,"Automap", BT_KEY, 255 },
228 { 45,158, 93,112, 26, 37, 31, 44, 12,"Automap", BT_KEY, 255 },
229 { 46,158,121, 83, 26, 32, 38, 17, 47,"Afterburner", BT_KEY, 255 },
230 { 47,158,121,112, 26, 33, 39, 46, 18,"Afterburner", BT_KEY, 255 },
231 { 48, 15,161, 71, 26, 22, 50, 43, 49,"Cycle Primary", BT_KEY, 255 },
232 { 49, 15,161,100, 26, 23, 51, 48, 52,"Cycle Primary", BT_KEY, 255 },
233 { 50, 15,169, 71, 26, 48, 1, 53, 51,"Cycle Second", BT_KEY, 255 },
234 { 51, 15,169,100, 26, 49, 24, 50, 54,"Cycle Second", BT_KEY, 255 },
235 { 52,158,163, 83, 26, 42, 54, 49, 53,"Headlight", BT_KEY, 255 },
236 { 53,158,163,112, 26, 43, 55, 52, 50,"Headlight", BT_KEY, 255 },
237 { 54,158,171, 83, 26, 52, 56, 51, 55,"Energy->Shield", BT_KEY, 255 },
238 { 55,158,171,112, 26, 53, 0, 54, 0,"Energy->Shield", BT_KEY, 255 },
239 { 56,158,179, 83, 26, 54, 0, 0, 0,"Toggle Bomb", BT_KEY, 255 },
242 char *kc_key_bind_text[NUM_KEY_CONTROLS] = {
243 "+lookdown", "+lookdown",
244 "+lookup", "+lookup",
247 "+strafe", "+strafe",
248 "+moveleft", "+moveleft",
249 "+moveright", "+moveright",
250 "+moveup", "+moveup",
251 "+movedown", "+movedown",
253 "+bankleft", "+bankleft",
254 "+bankright", "+bankright",
255 "+attack", "+attack",
256 "+attack2", "+attack2",
258 "+forward", "+forward",
261 "+rearview", "+rearview",
262 "+cruiseup", "+cruiseup",
263 "+cruisedown", "+cruisedown",
264 "+cruiseoff", "+cruiseoff",
265 "+automap", "+automap",
266 "+afterburner", "+afterburner",
268 "+cycle2", "+cycle2",
269 "+headlight", "+headlight",
270 "+nrgshield", "+nrgshield",
274 ubyte default_kc_keyboard_settings[MAX_CONTROLS] = {0x48,0xc8,0x50,0xd0,0x4b,0xcb,0x4d,0xcd,0x38,0xff,0x4f,0xff,0x51,0xff,0x4a,0xff,0x4e,0xff,0x2a,0xff,0x10,0x47,0x12,0x49,0x1d,0x80,0x39,0x81,0x21,0x24,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,0x80,0x0,0x0};
276 kc_item kc_other[NUM_OTHER_CONTROLS] = {
277 { 0, 22,138, 51, 40, 23, 2, 23, 1,"Pitch U/D", BT_JOY_AXIS, 255 },
278 { 1, 22,138, 99, 8, 10, 3, 0, 12,"Pitch U/D", BT_INVERT, 255 },
279 { 2, 22,146, 51, 40, 0, 4, 13, 3,"Turn L/R", BT_JOY_AXIS, 255 },
280 { 3, 22,146, 99, 8, 1, 5, 2, 14,"Turn L/R", BT_INVERT, 255 },
281 { 4, 22,154, 51, 40, 2, 6, 15, 5,"Slide L/R", BT_JOY_AXIS, 255 },
282 { 5, 22,154, 99, 8, 3, 7, 4, 16,"Slide L/R", BT_INVERT, 255 },
283 { 6, 22,162, 51, 40, 4, 8, 17, 7,"Slide U/D", BT_JOY_AXIS, 255 },
284 { 7, 22,162, 99, 8, 5, 9, 6, 18,"Slide U/D", BT_INVERT, 255 },
285 { 8, 22,170, 51, 40, 6, 10, 19, 9,"Bank L/R", BT_JOY_AXIS, 255 },
286 { 9, 22,170, 99, 8, 7, 11, 8, 20,"Bank L/R", BT_INVERT, 255 },
287 { 10, 22,182, 51, 40, 8, 1, 21, 11,"throttle", BT_JOY_AXIS, 255 },
288 { 11, 22,182, 99, 8, 9, 12, 10, 22,"throttle", BT_INVERT, 255 },
289 { 12,182,138, 51, 40, 11, 14, 1, 13,"Pitch U/D", BT_MOUSE_AXIS, 255 },
290 { 13,182,138, 99, 8, 22, 15, 12, 2,"Pitch U/D", BT_INVERT, 255 },
291 { 14,182,146, 51, 40, 12, 16, 3, 15,"Turn L/R", BT_MOUSE_AXIS, 255 },
292 { 15,182,146, 99, 8, 13, 17, 14, 4,"Turn L/R", BT_INVERT, 255 },
293 { 16,182,154, 51, 40, 14, 18, 5, 17,"Slide L/R", BT_MOUSE_AXIS, 255 },
294 { 17,182,154, 99, 8, 15, 19, 16, 6,"Slide L/R", BT_INVERT, 255 },
295 { 18,182,162, 51, 40, 16, 20, 7, 19,"Slide U/D", BT_MOUSE_AXIS, 255 },
296 { 19,182,162, 99, 8, 17, 21, 18, 8,"Slide U/D", BT_INVERT, 255 },
297 { 20,182,170, 51, 40, 18, 22, 9, 21,"Bank L/R", BT_MOUSE_AXIS, 255 },
298 { 21,182,170, 99, 8, 19, 23, 20, 10,"Bank L/R", BT_INVERT, 255 },
299 { 22,182,182, 51, 40, 20, 13, 11, 23,"throttle", BT_MOUSE_AXIS, 255 },
300 { 23,182,182, 99, 8, 21, 0, 22, 0,"throttle", BT_INVERT, 255 },
303 kc_axis_map kc_other_axismap[NUM_OTHER_CONTROLS] = {
304 AXIS_PITCH, AXIS_NONE,
305 AXIS_TURN, AXIS_NONE,
306 AXIS_LEFTRIGHT, AXIS_NONE,
307 AXIS_UPDOWN, AXIS_NONE,
308 AXIS_BANK, AXIS_NONE,
309 AXIS_THROTTLE, AXIS_NONE,
310 AXIS_PITCH, AXIS_NONE,
311 AXIS_TURN, AXIS_NONE,
312 AXIS_LEFTRIGHT, AXIS_NONE,
313 AXIS_UPDOWN, AXIS_NONE,
314 AXIS_BANK, AXIS_NONE,
315 AXIS_THROTTLE, AXIS_NONE,
318 ubyte default_kc_other_settings[MAX_CONTROLS] = {0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0x2,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0x0,0xff,0x0,0x3f};
320 kc_item kc_d2x[NUM_D2X_CONTROLS] = {
321 // id,x,y,w1,w2,u,d,l,r,text_num1,type,value
322 { 0, 15, 49, 71, 26, 19, 2, 27, 1,"WEAPON 1", BT_KEY, 255 },
323 { 1, 15, 49,100, 26, 18, 3, 0, 2,"WEAPON 1", BT_KEY, 255 },
324 { 2, 15, 57, 71, 26, 0, 4, 1, 3,"WEAPON 2", BT_KEY, 255 },
325 { 3, 15, 57,100, 26, 1, 5, 2, 4,"WEAPON 2", BT_KEY, 255 },
326 { 4, 15, 65, 71, 26, 2, 6, 3, 5,"WEAPON 3", BT_KEY, 255 },
327 { 5, 15, 65,100, 26, 3, 7, 4, 6,"WEAPON 3", BT_KEY, 255 },
328 { 6, 15, 73, 71, 26, 4, 8, 5, 7,"WEAPON 4", BT_KEY, 255 },
329 { 7, 15, 73,100, 26, 5, 9, 6, 8,"WEAPON 4", BT_KEY, 255 },
330 { 8, 15, 81, 71, 26, 6, 10, 7, 9,"WEAPON 5", BT_KEY, 255 },
331 { 9, 15, 81,100, 26, 7, 11, 8, 10,"WEAPON 5", BT_KEY, 255 },
332 { 10, 15, 89, 71, 26, 8, 12, 9, 11,"WEAPON 6", BT_KEY, 255 },
333 { 11, 15, 89,100, 26, 9, 13, 10, 12,"WEAPON 6", BT_KEY, 255 },
334 { 12, 15, 97, 71, 26, 10, 14, 11, 13,"WEAPON 7", BT_KEY, 255 },
335 { 13, 15, 97,100, 26, 11, 15, 12, 14,"WEAPON 7", BT_KEY, 255 },
336 { 14, 15,105, 71, 26, 12, 16, 13, 15,"WEAPON 8", BT_KEY, 255 },
337 { 15, 15,105,100, 26, 13, 17, 14, 16,"WEAPON 8", BT_KEY, 255 },
338 { 16, 15,113, 71, 26, 14, 18, 15, 17,"WEAPON 9", BT_KEY, 255 },
339 { 17, 15,113,100, 26, 15, 19, 16, 18,"WEAPON 9", BT_KEY, 255 },
340 { 18, 15,121, 71, 26, 16, 1, 17, 19,"WEAPON 0", BT_KEY, 255 },
341 { 19, 15,121,100, 26, 17, 0, 18, 0,"WEAPON 0", BT_KEY, 255 },
342 //{ 20, 15,131, 71, 26, 18, 22, 19, 21, "CYC PRIMARY", BT_KEY, 255},
343 //{ 21, 15,131,100, 26, 19, 23, 20, 22, "CYC PRIMARY", BT_KEY, 255},
344 //{ 22, 15,139, 71, 26, 20, 24, 21, 23, "CYC SECONDARY", BT_KEY, 255},
345 //{ 23, 15,139,100, 26, 21, 25, 22, 24, "CYC SECONDARY", BT_KEY, 255},
346 //{ 24, 8,147, 78, 26, 22, 26, 23, 25, "TOGGLE_PRIM AUTO", BT_KEY, 255},
347 //{ 25, 8,147,107, 26, 23, 27, 24, 26, "TOGGLE_PRIM_AUTO", BT_KEY, 255},
348 //{ 26, 8,155, 78, 26, 24, 1, 25, 27, "TOGGLE SEC AUTO", BT_KEY, 255},
349 //{ 27, 8,155,107, 26, 25, 0, 26, 0, "TOGGLE SEC AUTO", BT_KEY, 255},
352 ubyte default_kc_d2x_settings[MAX_CONTROLS] = {0x2,0xff,0x3,0xff,0x4,0xff,0x5,0xff,0x6,0xff,0x7,0xff,0x8,0xff,0x9,0xff,0xa,0xff,0xb,0xff,0xff,0x0,0xff,0xff,0x12,0xf,0x80,0x80,0x80,0x0,0x4,0x4,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x20,0x57,0x52,0x0,0x12,0xa2,0xa2,0xa4,0xa4,0xa4,0xa4,0xa4,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xff,0xff};
355 void kc_drawitem( kc_item *item, int is_current );
356 void kc_change_key( kc_item * item );
357 void kc_next_joyaxis(kc_item *item); //added by WraithX on 11/22/00
358 void kc_change_joyaxis( kc_item * item );
359 void kc_change_mouseaxis( kc_item * item );
360 void kc_change_invert( kc_item * item );
361 void kconfig_read_external_controls( void );
363 int kconfig_is_axes_used(int axis)
366 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
367 if (( kc_other[i].type == BT_JOY_AXIS ) && (kc_other[i].value == axis ))
373 #ifdef TABLE_CREATION
374 int find_item_at( kc_item * items, int nitems, int x, int y )
378 for (i=0; i<nitems; i++ ) {
379 if ( ((items[i].x+items[i].w1)==x) && (items[i].y==y))
385 int find_next_item_up( kc_item * items, int nitems, int citem )
390 x = items[citem].x+items[citem].w1;
395 y = grd_curcanv->cv_bitmap.bm_h-1;
398 x = grd_curcanv->cv_bitmap.bm_w-1;
401 i = find_item_at( items, nitems, x, y );
407 int find_next_item_down( kc_item * items, int nitems, int citem )
412 x = items[citem].x+items[citem].w1;
416 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
419 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
423 i = find_item_at( items, nitems, x, y );
429 int find_next_item_right( kc_item * items, int nitems, int citem )
434 x = items[citem].x+items[citem].w1;
438 if ( x > grd_curcanv->cv_bitmap.bm_w-1 ) {
441 if ( y > grd_curcanv->cv_bitmap.bm_h-1 ) {
445 i = find_item_at( items, nitems, x, y );
451 int find_next_item_left( kc_item * items, int nitems, int citem )
456 x = items[citem].x+items[citem].w1;
461 x = grd_curcanv->cv_bitmap.bm_w-1;
464 y = grd_curcanv->cv_bitmap.bm_h-1;
467 i = find_item_at( items, nitems, x, y );
475 int get_item_height(kc_item *item)
480 if (item->value==255) {
483 switch( item->type ) {
485 strncpy( btext, key_text[item->value], 10 ); break;
487 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
490 sprintf( btext, "J%d A%d", j_axis[item->value].joydev, j_Get_joydev_axis_number (item->value) );
491 #elif defined(SDL_INPUT)
492 if (joyaxis_text[item->value])
493 strncpy(btext, joyaxis_text[item->value], 10);
495 sprintf(btext, "AXIS%2d", item->value + 1);
497 strncpy(btext, Text_string[joyaxis_text[item->value]], 10);
501 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
504 gr_get_string_size(btext, &w, &h, &aw );
510 void kconfig_sub(kc_item * items,int nitems, char * title)
512 grs_canvas * save_canvas;
513 grs_font * save_font;
516 int mouse_state, omouse_state, mx, my, x1, x2, y1, y2;
517 int close_x, close_y, close_size;
520 int i,k,ocitem,citem;
521 int time_stopped = 0;
526 if (!((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence)) )
532 save_canvas = grd_curcanv;
535 gr_set_current_canvas(NULL);
536 save_font = grd_curcanv->cv_font;
539 old_keyd_repeat = keyd_repeat;
542 //gr_clear_canvas( BM_XRGB(0,0,0) );
544 nm_draw_background(0, 0, grd_curcanv->cv_bitmap.bm_w - 1, grd_curcanv->cv_bitmap.bm_h - 1);
545 gr_palette_load (gr_palette);
547 grd_curcanv->cv_font = MEDIUM3_FONT;
551 p = strchr( title, '\n' );
553 gr_string( 0x8000, LHY(8), title );
558 // if ( items == kc_keyboard ) {
559 // gr_string( 0x8000, 8, "Keyboard" );
560 // } else if ( items == kc_other ) {
561 // gr_string( 0x8000, 8, "Others" );
565 close_x = close_y = MenuHires?15:7;
566 close_size = MenuHires?10:5;
568 gr_setcolor( BM_XRGB(0, 0, 0) );
569 gr_rect(close_x, close_y, close_x + close_size, close_y + close_size);
570 gr_setcolor( BM_XRGB(21, 21, 21) );
571 gr_rect(close_x + LHX(1), close_y + LHX(1), close_x + close_size - LHX(1), close_y + close_size - LHX(1));
575 grd_curcanv->cv_font = GAME_FONT;
576 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
578 gr_string( 0x8000, LHY(20), TXT_KCONFIG_STRING_1 );
579 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
580 if ( items == kc_keyboard ) {
581 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
582 gr_setcolor( BM_XRGB(31,27,6) );
584 gr_scanline( LHX(98), LHX(106), LHY(42) );
585 gr_scanline( LHX(120), LHX(128), LHY(42) );
586 gr_pixel( LHX(98), LHY(43) );
587 gr_pixel( LHX(98), LHY(44) );
588 gr_pixel( LHX(128), LHY(43) );
589 gr_pixel( LHX(128), LHY(44) );
591 gr_string( LHX(109), LHY(40), "OR" );
593 gr_scanline( LHX(253), LHX(261), LHY(42) );
594 gr_scanline( LHX(274), LHX(283), LHY(42) );
595 gr_pixel( LHX(253), LHY(43) );
596 gr_pixel( LHX(253), LHY(44) );
597 gr_pixel( LHX(283), LHY(43) );
598 gr_pixel( LHX(283), LHY(44) );
600 gr_string( LHX(264), LHY(40), "OR" );
602 } if ( items == kc_other ) {
603 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
604 gr_setcolor( BM_XRGB(31,27,6) );
605 gr_scanline( LHX(18), LHX(60), LHY(119+5) );
606 gr_scanline( LHX(102), LHX(144), LHY(119+5) );
607 gr_string( LHX(63), LHY(117+5), TXT_CONTROL_JOYSTICK );
608 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
609 gr_string( LHX(84), LHY(129), TXT_AXIS );
610 gr_string( LHX(110), LHY(129), TXT_INVERT );
612 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
613 gr_setcolor( BM_XRGB(31,27,6) );
614 gr_scanline( LHX(178), LHX(226), LHY(119+5) );
615 gr_scanline( LHX(256), LHX(304), LHY(119+5) );
616 gr_string( LHX(229), LHY(117+5), TXT_CONTROL_MOUSE );
617 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
618 gr_string( LHX(244), LHY(129), TXT_AXIS );
619 gr_string( LHX(270), LHY(129), TXT_INVERT );
621 else if ( items == kc_d2x )
623 gr_set_fontcolor( BM_XRGB(31,27,6), -1 );
624 gr_setcolor( BM_XRGB(31,27,6) );
626 gr_scanline( LHX(98), LHX(106), LHY(42) );
627 gr_scanline( LHX(120), LHX(128), LHY(42) );
628 gr_pixel( LHX(98), LHY(43) );
629 gr_pixel( LHX(98), LHY(44) );
630 gr_pixel( LHX(128), LHY(43) );
631 gr_pixel( LHX(128), LHY(44) );
633 gr_string(LHX(109), LHY(40), "OR");
636 for (i=0; i<nitems; i++ ) {
637 kc_drawitem( &items[i], 0 );
641 while(items[citem].id == -1)
643 kc_drawitem( &items[citem], 1 );
645 newmenu_show_cursor();
648 mouse_state = omouse_state = 0;
652 // Windows addendum to allow for kconfig input.
655 //see if redbook song needs to be restarted
656 songs_check_redbook_repeat();
661 omouse_state = mouse_state;
662 mouse_state = mouse_button_state(0);
665 if ( !time_stopped ) {
667 if (multi_menu_poll() == -1)
676 case KEY_COMMAND+KEY_SHIFTED+KEY_3:
677 case KEY_PRINT_SCREEN:
680 case KEY_CTRLED+KEY_D:
681 items[citem].value = 255;
682 kc_drawitem( &items[citem], 1 );
684 case KEY_CTRLED+KEY_R:
685 if ( items == kc_keyboard )
686 for (i = 0; i < NUM_KEY_CONTROLS; i++) {
687 items[i].value = default_kc_keyboard_settings[i];
688 kc_drawitem( &items[i], 0 );
690 else if ( items == kc_other )
691 for (i = 0; i < NUM_OTHER_CONTROLS; i++) {
692 items[i].value = default_kc_other_settings[i];
693 kc_drawitem( &items[i], 0 );
695 else if ( items == kc_d2x )
696 for (i = 0; i < NUM_D2X_CONTROLS; i++)
698 items[i].value = default_kc_d2x_settings[i];
699 kc_drawitem( &items[i], 0 );
701 kc_drawitem( &items[citem], 1 );
704 items[citem].value=255;
705 kc_drawitem( &items[citem], 1 );
709 #ifdef TABLE_CREATION
710 if (items[citem].u==-1) items[citem].u=find_next_item_up( items,nitems, citem);
712 citem = items[citem].u;
717 #ifdef TABLE_CREATION
718 if (items[citem].d==-1) items[citem].d=find_next_item_down( items,nitems, citem);
720 citem = items[citem].d;
724 #ifdef TABLE_CREATION
725 if (items[citem].l==-1) items[citem].l=find_next_item_left( items,nitems, citem);
727 citem = items[citem].l;
731 #ifdef TABLE_CREATION
732 if (items[citem].r==-1) items[citem].r=find_next_item_right( items,nitems, citem);
734 citem = items[citem].r;
738 switch( items[citem].type ) {
739 case BT_KEY: kc_change_key( &items[citem] ); break;
740 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
741 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
742 case BT_INVERT: kc_change_invert( &items[citem] ); break;
745 //the following case added by WraithX on 11/22/00 to work around the weird joystick bug...
747 switch(items[citem].type)
750 kc_next_joyaxis(&items[citem]);
754 //end addition by WraithX
757 grd_curcanv->cv_font = save_font;
759 gr_set_current_canvas( save_canvas );
760 keyd_repeat = old_keyd_repeat;
762 newmenu_hide_cursor();
766 #ifdef TABLE_CREATION
767 case KEY_DEBUGGED+KEY_SHIFTED+KEY_2:
768 case KEY_DEBUGGED+KEY_F12: {
772 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
773 kc_keyboard[i].u = find_next_item_up( kc_keyboard,NUM_KEY_CONTROLS, i);
774 kc_keyboard[i].d = find_next_item_down( kc_keyboard,NUM_KEY_CONTROLS, i);
775 kc_keyboard[i].l = find_next_item_left( kc_keyboard,NUM_KEY_CONTROLS, i);
776 kc_keyboard[i].r = find_next_item_right( kc_keyboard,NUM_KEY_CONTROLS, i);
778 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
779 kc_other[i].u = find_next_item_up( kc_other,NUM_OTHER_CONTROLS, i);
780 kc_other[i].d = find_next_item_down( kc_other,NUM_OTHER_CONTROLS, i);
781 kc_other[i].l = find_next_item_left( kc_other,NUM_OTHER_CONTROLS, i);
782 kc_other[i].r = find_next_item_right( kc_other,NUM_OTHER_CONTROLS, i);
784 fp = stderr; //fopen( "kconfig.cod", "wt" );
786 fprintf( fp, "kc_item kc_keyboard[NUM_KEY_CONTROLS] = {\n" );
787 for (i=0; i<NUM_KEY_CONTROLS; i++ ) {
788 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
789 kc_keyboard[i].id, kc_keyboard[i].x, kc_keyboard[i].y, kc_keyboard[i].w1, kc_keyboard[i].w2,
790 kc_keyboard[i].u, kc_keyboard[i].d, kc_keyboard[i].l, kc_keyboard[i].r,
791 34, kc_keyboard[i].text, 34, btype_text[kc_keyboard[i].type] );
793 fprintf( fp, "};\n\n" );
794 fprintf( fp, "ubyte default_kc_keyboard_settings[MAX_CONTROLS] = " );
795 fprintf( fp, "{0x%x", kc_keyboard[0].value );
796 for (j = 1; j < MAX_CONTROLS; j++)
797 fprintf( fp, ",0x%x", kc_keyboard[j].value );
798 fprintf( fp, "};\n\n" );
800 fprintf( fp, "kc_item kc_other[NUM_OTHER_CONTROLS] = {\n" );
801 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
802 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
803 kc_other[i].id, kc_other[i].x, kc_other[i].y, kc_other[i].w1, kc_other[i].w2,
804 kc_other[i].u, kc_other[i].d, kc_other[i].l, kc_other[i].r,
805 34, kc_other[i].text, 34, btype_text[kc_other[i].type] );
807 fprintf( fp, "};\n\n" );
808 fprintf( fp, "ubyte default_kc_other_settings[MAX_CONTROLS] = " );
809 fprintf( fp, "{0x%x", kc_other[0].value );
810 for (j = 1; j < MAX_CONTROLS; j++)
811 fprintf( fp, ",0x%x", kc_other[j].value );
812 fprintf( fp, "};\n" );
814 fprintf( fp, "kc_item kc_d2x[NUM_D2X_CONTROLS] = {\n" );
815 for (i=0; i<NUM_D2X_CONTROLS; i++ ) {
816 fprintf( fp, "\t{ %2d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%c%s%c, %s, 255 },\n",
817 kc_d2x[i].id, kc_d2x[i].x, kc_d2x[i].y, kc_d2x[i].w1, kc_d2x[i].w2,
818 kc_d2x[i].u, kc_d2x[i].d, kc_d2x[i].l, kc_d2x[i].r,
819 34, kc_d2x[i].text, 34, btype_text[kc_d2x[i].type] );
821 fprintf( fp, "};\n\n" );
822 fprintf( fp, "ubyte default_kc_d2x_settings[MAX_CONTROLS] = " );
823 fprintf( fp, "{0x%x", kc_d2x[0].value );
824 for (j = 1; j < MAX_CONTROLS; j++)
825 fprintf( fp, ",0x%x", kc_d2x[j].value );
826 fprintf( fp, "};\n" );
836 if ( (mouse_state && !omouse_state) || (mouse_state && omouse_state) ) {
839 mouse_get_pos(&mx, &my);
840 for (i=0; i<nitems; i++ ) {
841 item_height = get_item_height( &items[i] );
842 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[i].x) + LHX(items[i].w1);
843 x2 = x1 + LHX(items[i].w2);
844 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[i].y);
845 y2 = y1 + LHX(item_height);
846 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
852 else if ( !mouse_state && omouse_state ) {
855 mouse_get_pos(&mx, &my);
856 item_height = get_item_height( &items[citem] );
857 x1 = grd_curcanv->cv_bitmap.bm_x + LHX(items[citem].x) + LHX(items[citem].w1);
858 x2 = x1 + LHX(items[citem].w2);
859 y1 = grd_curcanv->cv_bitmap.bm_y + LHY(items[citem].y);
860 y2 = y1 + LHY(item_height);
861 if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) {
862 newmenu_hide_cursor();
863 switch( items[citem].type ) {
864 case BT_KEY: kc_change_key( &items[citem] ); break;
865 case BT_MOUSE_AXIS: kc_change_mouseaxis( &items[citem] ); break;
866 case BT_JOY_AXIS: kc_change_joyaxis( &items[citem] ); break;
867 case BT_INVERT: kc_change_invert( &items[citem] ); break;
869 newmenu_show_cursor();
871 x1 = grd_curcanv->cv_bitmap.bm_x + close_x + LHX(1);
872 x2 = x1 + close_size - LHX(1);
873 y1 = grd_curcanv->cv_bitmap.bm_y + close_y + LHX(1);
874 y2 = y1 + close_size - LHX(1);
875 if ( ((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2)) ) {
876 grd_curcanv->cv_font = save_font;
877 gr_set_current_canvas( save_canvas );
878 keyd_repeat = old_keyd_repeat;
880 newmenu_hide_cursor();
888 #endif // NEWMENU_MOUSE
891 newmenu_hide_cursor();
892 kc_drawitem( &items[ocitem], 0 );
893 kc_drawitem( &items[citem], 1 );
894 newmenu_show_cursor();
900 void kc_drawitem( kc_item *item, int is_current )
906 gr_set_fontcolor( BM_XRGB(20,20,29), -1 );
908 gr_set_fontcolor( BM_XRGB(15,15,24), -1 );
909 gr_string( LHX(item->x), LHY(item->y), item->text );
911 if (item->value==255) {
914 switch( item->type ) {
916 strncpy( btext, key_text[item->value], 10 ); break;
918 strncpy( btext, Text_string[mouseaxis_text[item->value]], 10 ); break;
921 sprintf(btext, "J%d A%d", j_axis[item->value].joydev, j_Get_joydev_axis_number(item->value));
922 #elif defined(SDL_INPUT)
923 if (joyaxis_text[item->value])
924 strncpy(btext, joyaxis_text[item->value], 10);
926 sprintf(btext, "AXIS%2d", item->value + 1);
928 strncpy(btext, Text_string[joyaxis_text[item->value]], 10);
932 strncpy( btext, Text_string[invert_text[item->value]], 10 ); break;
936 gr_get_string_size(btext, &w, &h, &aw );
939 gr_setcolor( BM_XRGB(21,0,24) );
941 gr_setcolor( BM_XRGB(16,0,19) );
942 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
944 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
946 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
948 gr_string( x, LHY(item->y), btext );
955 void kc_drawquestion( kc_item *item )
959 gr_get_string_size("?", &w, &h, &aw );
961 c = BM_XRGB(21,0,24);
963 //@@gr_setcolor( gr_fade_table[fades[looper]*256+c] );
964 gr_setcolor(BM_XRGB(21*fades[looper]/31,0,24*fades[looper]/31));
966 if (looper>63) looper=0;
968 gr_urect( LHX(item->w1+item->x), LHY(item->y-1), LHX(item->w1+item->x+item->w2), LHY(item->y)+h );
970 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
972 x = LHX(item->w1+item->x)+((LHX(item->w2)-w)/2);
974 gr_string( x, LHY(item->y), "?" );
978 void kc_change_key( kc_item * item )
983 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
985 gr_string( 0x8000, LHY(INFO_Y), TXT_PRESS_NEW_KEY );
991 while( (k!=KEY_ESC) && (keycode==255) )
994 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
997 // if ( Game_mode & GM_MULTI )
998 // GameLoop( 0, 0 ); // Continue
1000 timer_delay(f0_1/10);
1001 kc_drawquestion( item );
1003 for (i=0; i<256; i++ ) {
1004 if (keyd_pressed[i] && (strlen(key_text[i])>0)) {
1006 for (n=0; n<sizeof(system_keys); n++ )
1007 if ( system_keys[n] == i )
1016 for (i=0; i<Num_items; i++ ) {
1017 n = item - All_items;
1018 if ( (i!=n) && (All_items[i].type==BT_KEY) && (All_items[i].value==keycode) ) {
1019 All_items[i].value = 255;
1020 kc_drawitem( &All_items[i], 0 );
1023 item->value = keycode;
1025 kc_drawitem( item, 1 );
1027 gr_set_fontcolor( BM_XRGB(28,28,28), BM_XRGB(0,0,0) );
1029 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1031 game_flush_inputs();
1036 // the following function added by WraithX on 11/22/00 to work around the weird joystick bug... - modified my Matt Mueller to skip already allocated axes
1037 void kc_next_joyaxis(kc_item *item)
1039 int n, i, k, max, tries;
1046 // I modelled this ifdef after the code in the kc_change_joyaxis method.
1047 // So, if somethin's not workin here, it might not be workin there either.
1050 code = (item->value + 1) % max;
1054 for (i = 0; i < Num_items; i++)
1056 n = item - All_items;
1057 if ((i != n) && (All_items[i].type == BT_JOY_AXIS) && (All_items[i].value == code))
1060 return; // all axes allocated already
1061 i = -1; // -1 so the i++ will push back to 0
1062 code = (item->value + ++tries) % max; // try next axis
1069 kc_drawitem(item, 1);
1070 nm_restore_background(0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h);
1071 game_flush_inputs();
1073 }//method kc_next_joyaxis
1074 //end addition by WraithX
1077 void kc_change_joyaxis( kc_item * item )
1079 int axis[JOY_MAX_AXES];
1080 int old_axis[JOY_MAX_AXES];
1081 int numaxis = joy_num_axes;
1085 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1087 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_JOY_AXIS );
1089 game_flush_inputs();
1093 joystick_read_raw_axis( JOY_ALL_AXIS, old_axis );
1095 while( (k!=KEY_ESC) && (code==255))
1098 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1101 // if ( Game_mode & GM_MULTI )
1102 // GameLoop( 0, 0 ); // Continue
1104 timer_delay(f0_1/10);
1106 if (k == KEY_PRINT_SCREEN)
1107 save_screen_shot(0);
1109 kc_drawquestion( item );
1111 joystick_read_raw_axis( JOY_ALL_AXIS, axis );
1113 for (i=0; i<numaxis; i++ ) {
1114 if ( abs(axis[i]-old_axis[i])>100 )
1117 con_printf(CON_DEBUG, "Axis Movement detected: Axis %i\n", i);
1119 //old_axis[i] = axis[i];
1121 for (i=0; i<Num_items; i++ )
1123 n = item - All_items;
1124 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) )
1130 for (i=0; i<Num_items; i++ ) {
1131 n = item - All_items;
1132 if ( (i!=n) && (All_items[i].type==BT_JOY_AXIS) && (All_items[i].value==code) ) {
1133 All_items[i].value = 255;
1134 kc_drawitem( &All_items[i], 0 );
1140 kc_drawitem( item, 1 );
1141 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1142 game_flush_inputs();
1146 void kc_change_mouseaxis( kc_item * item )
1152 gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
1154 gr_string( 0x8000, LHY(INFO_Y), TXT_MOVE_NEW_MSE_AXIS );
1156 game_flush_inputs();
1160 mouse_get_delta( &dx, &dy, &dz );
1162 while( (k!=KEY_ESC) && (code==255))
1165 if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence))
1168 // if ( Game_mode & GM_MULTI )
1169 // GameLoop( 0, 0 ); // Continue
1171 timer_delay(f0_1/10);
1173 if (k == KEY_PRINT_SCREEN)
1174 save_screen_shot(0);
1176 kc_drawquestion( item );
1178 mouse_get_delta( &dx, &dy, &dz );
1179 if ( abs(dx)>20 ) code = 0;
1180 if ( abs(dy)>20 ) code = 1;
1181 if ( abs(dz)>20 ) code = 2;
1184 for (i=0; i<Num_items; i++ ) {
1185 n = item - All_items;
1186 if ( (i!=n) && (All_items[i].type==BT_MOUSE_AXIS) && (All_items[i].value==code) ) {
1187 All_items[i].value = 255;
1188 kc_drawitem( &All_items[i], 0 );
1193 kc_drawitem( item, 1 );
1194 nm_restore_background( 0, LHY(INFO_Y), LHX(310), grd_curcanv->cv_font->ft_h );
1195 game_flush_inputs();
1200 void kc_change_invert( kc_item * item )
1202 game_flush_inputs();
1209 kc_drawitem( item, 1 );
1213 #include "screens.h"
1215 void kconfig(int n, char * title)
1218 grs_bitmap *save_bm;
1220 set_screen_mode( SCREEN_MENU );
1225 save_bm = gr_create_bitmap( grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
1226 Assert( save_bm != NULL );
1228 gr_bm_bitblt(grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_w,
1229 0, 0, 0, 0, &grd_curcanv->cv_bitmap, save_bm );
1232 case 0:kconfig_sub( kc_keyboard, NUM_KEY_CONTROLS, title );break;
1233 case 1:kconfig_sub( kc_other, NUM_OTHER_CONTROLS, title );break;
1234 case 2:kconfig_sub( kc_d2x, NUM_D2X_CONTROLS, title ); break;
1241 gr_bitmap(0, 0, save_bm);
1242 gr_free_bitmap(save_bm);
1244 #if 0 // set_screen_mode always calls this later... right?
1245 reset_cockpit(); //force cockpit redraw next time
1248 // Update save values...
1250 for (j=0; j<256; j++)
1251 if (key_binding(j)) {
1252 for (i = 0; i < NUM_KEY_CONTROLS; i++)
1253 if (!stricmp(key_binding(j), kc_key_bind_text[i])) {
1254 cmd_appendf("unbind %s", key_text[j]);
1257 for (i = 0; i < NUM_D2X_CONTROLS; i++)
1258 if (kc_d2x[i].type == BT_KEY && !stricmp(key_binding(j), kc_d2x[i].text)) {
1259 cmd_appendf("unbind %s", key_text[j]);
1264 for (i=0; i<NUM_KEY_CONTROLS; i++ )
1265 if (kc_keyboard[i].value != 255)
1266 cmd_appendf("bind %s \"%s\"", key_text[kc_keyboard[i].value], kc_key_bind_text[i]);
1268 for (i = 0; i < NUM_D2X_CONTROLS; i++)
1269 if (kc_d2x[i].value != 255)
1270 cmd_appendf("bind %s \"%s\"", key_text[kc_d2x[i].value], kc_d2x[i].text);
1272 for (i = 0; i < 6; i++) {
1273 cvar_setint(&joy_advaxes[i], AXIS_NONE);
1274 cvar_setint(&joy_invert[i], 0);
1276 for (i = 0; i < 3; i++) {
1277 cvar_setint(&mouse_axes[i], AXIS_NONE);
1278 cvar_setint(&mouse_invert[i], 0);
1280 for (i = 0; i < NUM_OTHER_CONTROLS; i++) {
1281 if (kc_other[i].type == BT_JOY_AXIS && kc_other[i].value != 255) {
1282 cvar_setint(&joy_advaxes[kc_other[i].value], kc_other_axismap[i]);
1283 cvar_setint(&joy_invert[kc_other[i].value], kc_other[i+1].value);
1285 if (kc_other[i].type == BT_MOUSE_AXIS && kc_other[i].value != 255) {
1286 cvar_setint(&mouse_axes[kc_other[i].value], kc_other_axismap[i]);
1287 cvar_setint(&mouse_invert[kc_other[i].value], kc_other[i+1].value);
1291 cmd_queue_process();
1295 fix Last_angles_p = 0;
1296 fix Last_angles_b = 0;
1297 fix Last_angles_h = 0;
1298 ubyte Last_angles_read = 0;
1300 extern int VR_sensitivity;
1302 int VR_sense_range[3] = { 25, 50, 75 };
1307 fix yaw, pitch, roll;
1310 //------ read vfx1 helmet --------
1311 if (vfx1_installed) {
1312 vfx_get_data(&yaw,&pitch,&roll,&buttons);
1313 } else if (iglasses_headset_installed) {
1314 iglasses_read_headset( &yaw, &pitch, &roll );
1315 } else if (Victor_headset_installed) {
1316 victor_read_headset_filtered( &yaw, &pitch, &roll );
1321 Use_player_head_angles = 0;
1322 if ( Last_angles_read ) {
1326 if ( (Last_angles_h < (F1_0/4) ) && (yaw > ((F1_0*3)/4) ) )
1328 else if ( (yaw < (F1_0/4) ) && (Last_angles_h > ((F1_0*3)/4) ) )
1331 Controls.pitch_time += fixmul((pitch- Last_angles_p)*VR_sense_range[VR_sensitivity],FrameTime);
1332 Controls.heading_time+= fixmul((yaw1 - Last_angles_h)*VR_sense_range[VR_sensitivity],FrameTime);
1333 Controls.bank_time += fixmul((roll - Last_angles_b)*VR_sense_range[VR_sensitivity],FrameTime);
1335 Last_angles_read = 1;
1336 Last_angles_p = pitch;
1337 Last_angles_h = yaw;
1338 Last_angles_b = roll;
1345 #define JOYSTICK_READ_TIME (F1_0/40) // Read joystick at 40 Hz.
1347 #define JOYSTICK_READ_TIME (F1_0/10) // Read joystick at 10 Hz.
1350 fix LastReadTime = 0;
1352 fix joy_axis[JOY_MAX_AXES];
1354 ubyte kc_use_external_control = 0;
1355 ubyte kc_enable_external_control = 0;
1356 ubyte kc_external_intno = 0;
1357 ext_control_info *kc_external_control = NULL;
1358 char *kc_external_name = NULL;
1359 ubyte kc_external_version = 0;
1360 extern int Automap_active;
1362 void kconfig_init_external_controls(int intno, int address)
1365 kc_external_intno = intno;
1366 kc_external_control = (ext_control_info *)address;
1367 kc_use_external_control = 1;
1368 kc_enable_external_control = 1;
1370 i = FindArg ( "-xname" );
1372 kc_external_name = Args[i+1];
1374 kc_external_name = "External Controller";
1376 for (i=0;i<strlen (kc_external_name);i++)
1377 if (kc_external_name[i]=='_')
1378 kc_external_name[i]=' ';
1380 i = FindArg ( "-xver" );
1382 kc_external_version = atoi(Args[i+1]);
1384 printf( "%s int: 0x%x, data: 0x%p, ver:%d\n", kc_external_name, kc_external_intno, kc_external_control, kc_external_version );
1389 fix Next_toggle_time[3]={0,0,0};
1391 int allowed_to_toggle(int i)
1393 //used for keeping tabs of when its ok to toggle headlight,primary,and secondary
1395 if (Next_toggle_time[i] > GameTime)
1396 if (Next_toggle_time[i] < GameTime + (F1_0/8)) // In case time is bogus, never wait > 1 second.
1399 Next_toggle_time[i] = GameTime + (F1_0/8);
1405 void controls_read_all()
1408 int slide_on, bank_on;
1411 int raw_joy_axis[JOY_MAX_AXES];
1413 ubyte channel_masks;
1414 fix analog_control[7]; // indexed on kc_axis_map
1416 memset(analog_control, 0, sizeof(analog_control));
1419 fix temp = Controls.heading_time;
1420 fix temp1 = Controls.pitch_time;
1421 memset( &Controls, 0, sizeof(control_info) );
1422 Controls.heading_time = temp;
1423 Controls.pitch_time = temp1;
1428 ctime = timer_get_fixed_seconds();
1430 //--------- Read Joystick -----------
1431 if ( (LastReadTime + JOYSTICK_READ_TIME > ctime) ) {
1433 if ((ctime < 0) && (LastReadTime >= 0))
1435 if ((ctime < 0) && (LastReadTime > 0))
1437 LastReadTime = ctime;
1438 } else if (Config_control_joystick.intval) {
1439 LastReadTime = ctime;
1440 channel_masks = joystick_read_raw_axis( JOY_ALL_AXIS, raw_joy_axis );
1442 Assert(joy_num_axes <= 6); // don't have cvar mapping above 6 yet
1443 for (i = 0; i < joy_num_axes; i++)
1446 if (channel_masks&(1<<i)) {
1448 int joy_null_value = Config_joystick_deadzone[joy_advaxes[i].intval-1].intval;
1450 raw_joy_axis[i] = joy_get_scaled_reading( raw_joy_axis[i], i );
1452 if (raw_joy_axis[i] > joy_null_value)
1453 raw_joy_axis[i] = ((raw_joy_axis[i]-joy_null_value)*128)/(128-joy_null_value);
1454 else if (raw_joy_axis[i] < -joy_null_value)
1455 raw_joy_axis[i] = ((raw_joy_axis[i]+joy_null_value)*128)/(128-joy_null_value);
1457 raw_joy_axis[i] = 0;
1458 joy_axis[i] = (raw_joy_axis[i]*FrameTime)/128;
1466 for (i = 0; i < joy_num_axes; i++)
1470 if (Config_control_joystick.intval)
1471 for (i = 0; i < 6; i++)
1472 analog_control[joy_advaxes[i].intval] += joy_axis[i] * (joy_invert[i].intval ? -1 : 1) * Config_joystick_sensitivity[joy_advaxes[i].intval-1].intval / 8;
1474 if (Config_control_mouse.intval) {
1475 //--------- Read Mouse -----------
1476 mouse_get_delta( &dx, &dy, &dz );
1478 analog_control[mouse_axes[0].intval] += dx * FrameTime / 35 * (mouse_invert[0].intval ? -1 : 1) * Config_mouse_sensitivity[mouse_axes[0].intval-1].intval / 8;
1479 analog_control[mouse_axes[1].intval] += dy * FrameTime / 25 * (mouse_invert[1].intval ? -1 : 1) * Config_mouse_sensitivity[mouse_axes[1].intval-1].intval / 8;
1480 analog_control[mouse_axes[2].intval] += dz * FrameTime * (mouse_invert[2].intval ? -1 : 1) * Config_mouse_sensitivity[mouse_axes[2].intval-1].intval / 8;
1483 //------------- Read slide_on -------------
1485 slide_on |= console_control_state(CONCNTL_STRAFE);
1487 //------------- Read bank_on ---------------
1489 bank_on |= console_control_state(CONCNTL_BANK);
1491 //------------ Read pitch_time -----------
1493 // mprintf((0, "pitch: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
1496 kp += console_control_down_time(CONCNTL_LOOKDOWN) / (PH_SCALE * 2);
1497 kp -= console_control_down_time(CONCNTL_LOOKUP) / (PH_SCALE * 2);
1500 Controls.pitch_time = 0;
1502 if (Controls.pitch_time < 0)
1503 Controls.pitch_time = 0;
1505 if (Controls.pitch_time > 0)
1506 Controls.pitch_time = 0;
1507 Controls.pitch_time += kp;
1509 Controls.pitch_time -= analog_control[AXIS_PITCH];
1512 Controls.pitch_time = 0;
1514 // the following "if" added by WraithX, 4/14/00
1515 // done so that dead players can't move
1516 if (!Player_is_dead)
1518 //----------- Read vertical_thrust_time -----------------
1521 Controls.vertical_thrust_time += console_control_down_time(CONCNTL_LOOKDOWN);
1522 Controls.vertical_thrust_time -= console_control_down_time(CONCNTL_LOOKUP);
1523 Controls.vertical_thrust_time += analog_control[AXIS_PITCH];
1526 Controls.vertical_thrust_time += console_control_down_time(CONCNTL_MOVEUP);
1527 Controls.vertical_thrust_time -= console_control_down_time(CONCNTL_MOVEDOWN);
1528 Controls.vertical_thrust_time += analog_control[AXIS_UPDOWN];
1530 }// end "if" added by WraithX
1532 //---------- Read heading_time -----------
1534 if (!slide_on && !bank_on) {
1535 //mprintf((0, "heading: %7.3f %7.3f: %7.3f\n", f2fl(k4), f2fl(k6), f2fl(Controls.heading_time)));
1538 kh -= console_control_down_time(CONCNTL_LEFT) / PH_SCALE;
1539 kh += console_control_down_time(CONCNTL_RIGHT) / PH_SCALE;
1542 Controls.heading_time = 0;
1544 if (Controls.heading_time < 0)
1545 Controls.heading_time = 0;
1547 if (Controls.heading_time > 0)
1548 Controls.heading_time = 0;
1549 Controls.heading_time += kh;
1551 Controls.heading_time += analog_control[AXIS_TURN];
1554 Controls.heading_time = 0;
1556 // the following "if" added by WraithX, 4/14/00
1557 // done so that dead players can't move
1558 if (!Player_is_dead)
1560 //----------- Read sideways_thrust_time -----------------
1563 Controls.sideways_thrust_time -= console_control_down_time(CONCNTL_LEFT);
1564 Controls.sideways_thrust_time += console_control_down_time(CONCNTL_RIGHT);
1565 Controls.sideways_thrust_time += analog_control[AXIS_TURN];
1568 Controls.sideways_thrust_time -= console_control_down_time(CONCNTL_MOVELEFT);
1569 Controls.sideways_thrust_time += console_control_down_time(CONCNTL_MOVERIGHT);
1570 Controls.sideways_thrust_time += analog_control[AXIS_LEFTRIGHT];
1572 }// end "if" added by WraithX
1574 //----------- Read bank_time -----------------
1577 Controls.bank_time += console_control_down_time(CONCNTL_LEFT);
1578 Controls.bank_time -= console_control_down_time(CONCNTL_RIGHT);
1579 Controls.bank_time -= analog_control[AXIS_TURN];
1582 Controls.bank_time += console_control_down_time(CONCNTL_BANKLEFT);
1583 Controls.bank_time -= console_control_down_time(CONCNTL_BANKRIGHT);
1584 Controls.bank_time += analog_control[AXIS_BANK];
1586 // the following "if" added by WraithX, 4/14/00
1587 // done so that dead players can't move
1588 if (!Player_is_dead)
1590 //----------- Read forward_thrust_time -------------
1592 Controls.forward_thrust_time += console_control_down_time(CONCNTL_FORWARD);
1593 Controls.forward_thrust_time -= console_control_down_time(CONCNTL_BACK);
1594 Controls.forward_thrust_time -= analog_control[AXIS_THROTTLE];
1596 //----------- Read afterburner_state -------------
1598 Controls.afterburner_state |= console_control_state(CONCNTL_AFTERBURN);
1600 //-------Read headlight key--------------------------
1602 Controls.headlight_count += console_control_down_count(CONCNTL_HEADLIGHT);
1604 //--------Read Cycle Primary Key------------------
1606 Controls.cycle_primary_count += console_control_down_count(CONCNTL_CYCLE);
1608 //--------Read Cycle Secondary Key------------------
1610 Controls.cycle_secondary_count += console_control_down_count(CONCNTL_CYCLE2);
1612 //--------Read Toggle Bomb key----------------------
1614 if (console_control_down_count(CONCNTL_TOGGLEBOMB)) {
1615 int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX;
1617 if (!Players[Player_num].secondary_ammo[PROXIMITY_INDEX] &&
1618 !Players[Player_num].secondary_ammo[SMART_MINE_INDEX])
1620 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
1621 HUD_init_message ("No bombs available!");
1623 if (Players[Player_num].secondary_ammo[bomb] == 0) {
1624 digi_play_sample_once( SOUND_BAD_SELECTION, F1_0 );
1625 HUD_init_message("No %s available!", (bomb == SMART_MINE_INDEX)?"Smart mines":"Proximity bombs");
1627 Secondary_last_was_super[PROXIMITY_INDEX]=!Secondary_last_was_super[PROXIMITY_INDEX];
1628 digi_play_sample_once( SOUND_GOOD_SELECTION_SECONDARY, F1_0 );
1633 //---------Read Energy->Shield key----------
1635 if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && console_control_state(CONCNTL_NRGSHIELD))
1636 transfer_energy_to_shield(console_control_down_time(CONCNTL_NRGSHIELD));
1638 //----------- Read fire_primary_down_count
1640 Controls.fire_primary_down_count += console_control_down_count(CONCNTL_ATTACK);
1642 //----------- Read fire_primary_state
1644 Controls.fire_primary_state |= console_control_state(CONCNTL_ATTACK);
1646 //----------- Read fire_secondary_down_count
1648 Controls.fire_secondary_down_count += console_control_down_count(CONCNTL_ATTACK2);
1650 //----------- Read fire_secondary_state
1652 Controls.fire_secondary_state |= console_control_state(CONCNTL_ATTACK2);
1654 //----------- Read fire_flare_down_count
1656 Controls.fire_flare_down_count += console_control_down_count(CONCNTL_FLARE);
1658 //----------- Read drop_bomb_down_count
1660 Controls.drop_bomb_down_count += console_control_down_count(CONCNTL_BOMB);
1662 //----------- Read rear_view_down_count
1664 Controls.rear_view_down_count += console_control_down_count(CONCNTL_REARVIEW);
1666 //----------- Read rear_view_down_state
1668 Controls.rear_view_down_state |= console_control_state(CONCNTL_REARVIEW);
1670 }//end "if" added by WraithX
1672 //----------- Read automap_down_count
1674 Controls.automap_down_count += console_control_down_count(CONCNTL_AUTOMAP);
1676 //----------- Read automap_state
1678 Controls.automap_state |= console_control_state(CONCNTL_AUTOMAP);
1680 //----------- Read stupid-cruise-control-type of throttle.
1682 Cruise_speed += console_control_down_time(CONCNTL_CRUISEUP);
1683 Cruise_speed -= console_control_down_time(CONCNTL_CRUISEDOWN);
1685 if (console_control_down_count(CONCNTL_CRUISEOFF))
1688 if (Cruise_speed > i2f(100))
1689 Cruise_speed = i2f(100);
1690 if (Cruise_speed < 0 )
1693 if (Controls.forward_thrust_time==0)
1694 Controls.forward_thrust_time = fixmul(Cruise_speed,FrameTime)/100;
1697 read_head_tracker();
1699 // Read external controls
1700 if (kc_use_external_control || CybermouseActive)
1701 kconfig_read_external_controls();
1704 //----------- Clamp values between -FrameTime and FrameTime
1705 if (FrameTime > F1_0 )
1706 mprintf( (1, "Bogus frame time of %.2f seconds\n", f2fl(FrameTime) ));
1708 if (Controls.pitch_time > FrameTime/2 ) Controls.pitch_time = FrameTime/2;
1709 if (Controls.vertical_thrust_time > FrameTime ) Controls.vertical_thrust_time = FrameTime;
1710 if (Controls.heading_time > FrameTime ) Controls.heading_time = FrameTime;
1711 if (Controls.sideways_thrust_time > FrameTime ) Controls.sideways_thrust_time = FrameTime;
1712 if (Controls.bank_time > FrameTime ) Controls.bank_time = FrameTime;
1713 if (Controls.forward_thrust_time > FrameTime ) Controls.forward_thrust_time = FrameTime;
1714 // if (Controls.afterburner_time > FrameTime ) Controls.afterburner_time = FrameTime;
1716 if (Controls.pitch_time < -FrameTime/2 ) Controls.pitch_time = -FrameTime/2;
1717 if (Controls.vertical_thrust_time < -FrameTime ) Controls.vertical_thrust_time = -FrameTime;
1718 if (Controls.heading_time < -FrameTime ) Controls.heading_time = -FrameTime;
1719 if (Controls.sideways_thrust_time < -FrameTime ) Controls.sideways_thrust_time = -FrameTime;
1720 if (Controls.bank_time < -FrameTime ) Controls.bank_time = -FrameTime;
1721 if (Controls.forward_thrust_time < -FrameTime ) Controls.forward_thrust_time = -FrameTime;
1722 // if (Controls.afterburner_time < -FrameTime ) Controls.afterburner_time = -FrameTime;
1725 //--------- Don't do anything if in debug mode
1727 if ( keyd_pressed[KEY_DELETE] ) {
1728 memset( &Controls, 0, sizeof(control_info) );
1734 void reset_cruise(void)
1740 void kc_set_controls()
1744 for (i=0; i<NUM_KEY_CONTROLS; i++ )
1745 kc_keyboard[i].value = 255;
1747 for (i=0; i<NUM_OTHER_CONTROLS; i++ ) {
1748 if (kc_other[i].type == BT_INVERT)
1749 kc_other[i].value = 0;
1751 kc_other[i].value = 255;
1754 for (i=0; i<NUM_D2X_CONTROLS; i++ )
1755 kc_d2x[i].value = 255;
1757 for (j = 0; j < 256; j++)
1758 if (key_binding(j)) {
1759 for (i = 0; i < NUM_KEY_CONTROLS; i++)
1760 if (kc_keyboard[i].value == 255
1761 && !stricmp(key_binding(j), kc_key_bind_text[i])) {
1762 kc_keyboard[i].value = j;
1767 for(j = 0; j < 256; j++)
1768 if (key_binding(j)) {
1769 for (i = 0; i < NUM_D2X_CONTROLS; i++)
1770 if (kc_d2x[i].value == 255
1771 && !stricmp(key_binding(j), kc_d2x[i].text)) {
1772 kc_d2x[i].value = j;
1777 for (i = 0; i < 6; i++) {
1778 int inv = joy_invert[i].intval;
1779 switch (joy_advaxes[i].intval) {
1780 case AXIS_PITCH: kc_other[ 0].value = i; kc_other[ 1].value = inv; break;
1781 case AXIS_TURN: kc_other[ 2].value = i; kc_other[ 3].value = inv; break;
1782 case AXIS_LEFTRIGHT: kc_other[ 4].value = i; kc_other[ 5].value = inv; break;
1783 case AXIS_UPDOWN: kc_other[ 6].value = i; kc_other[ 7].value = inv; break;
1784 case AXIS_BANK: kc_other[ 8].value = i; kc_other[ 9].value = inv; break;
1785 case AXIS_THROTTLE: kc_other[10].value = i; kc_other[11].value = inv; break;
1786 case AXIS_NONE: break;
1793 for (i = 0; i < 3; i++) {
1794 int inv = mouse_invert[i].intval;
1795 switch (mouse_axes[i].intval) {
1796 case AXIS_PITCH: kc_other[12].value = i; kc_other[13].value = inv; break;
1797 case AXIS_TURN: kc_other[14].value = i; kc_other[15].value = inv; break;
1798 case AXIS_LEFTRIGHT: kc_other[16].value = i; kc_other[17].value = inv; break;
1799 case AXIS_UPDOWN: kc_other[18].value = i; kc_other[19].value = inv; break;
1800 case AXIS_BANK: kc_other[20].value = i; kc_other[21].value = inv; break;
1801 case AXIS_THROTTLE: kc_other[22].value = i; kc_other[23].value = inv; break;
1802 case AXIS_NONE: break;
1810 #if 0 // no mac support for vr headset
1812 void kconfig_center_headset()
1815 vfx_center_headset();
1816 // } else if (iglasses_headset_installed) {
1817 // } else if (Victor_headset_installed) {
1823 #endif // end of #if for kconfig_center_headset
1825 void CybermouseAdjust ()
1827 /* if ( Player_num > -1 ) {
1828 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
1829 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
1830 cvar_setint(&Auto_leveling_on, 0);
1832 if ( kc_external_version > 0 ) {
1833 vms_matrix tempm, ViewMatrix;
1834 vms_angvec * Kconfig_abs_movement;
1837 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(control_info));
1839 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
1840 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
1841 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
1842 Objects[Players[Player_num].objnum].orient = ViewMatrix;
1844 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
1845 if (oem_message[0] != '\0' )
1846 HUD_init_message( oem_message );
1850 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
1851 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
1852 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
1853 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
1854 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
1855 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
1856 // Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
1857 // Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
1858 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
1859 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
1860 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
1861 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
1862 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
1863 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
1864 // Controls.automap_down_count += kc_external_control->automap_down_count;
1865 // Controls.automap_state |= kc_external_control->automap_state;
1870 extern object *obj_find_first_of_type (int);
1871 void kconfig_read_external_controls()
1876 if ( !kc_enable_external_control ) return;
1878 if ( kc_external_version == 0 )
1879 memset( kc_external_control, 0, sizeof(ext_control_info));
1880 else if ( kc_external_version > 0 ) {
1882 if (kc_external_version>=4)
1883 memset( kc_external_control, 0, sizeof(advanced_ext_control_info));
1884 else if (kc_external_version>0)
1885 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 );
1886 else if (kc_external_version>2)
1887 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof(vms_matrix) +4 );
1889 if ( kc_external_version > 1 ) {
1890 // Write ship pos and angles to external controls...
1891 ubyte *temp_ptr = (ubyte *)kc_external_control;
1892 vms_vector *ship_pos;
1893 vms_matrix *ship_orient;
1894 memset( kc_external_control, 0, sizeof(ext_control_info)+sizeof(vms_angvec) + 64 + sizeof(vms_vector)+sizeof(vms_matrix) );
1895 temp_ptr += sizeof(ext_control_info) + sizeof(vms_angvec) + 64;
1896 ship_pos = (vms_vector *)temp_ptr;
1897 temp_ptr += sizeof(vms_vector);
1898 ship_orient = (vms_matrix *)temp_ptr;
1899 // Fill in ship postion...
1900 *ship_pos = Objects[Players[Player_num].objnum].pos;
1901 // Fill in ship orientation...
1902 *ship_orient = Objects[Players[Player_num].objnum].orient;
1904 if (kc_external_version>=4)
1906 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
1908 temp_ptr->headlight_state=(Players[Player_num].flags & PLAYER_FLAGS_HEADLIGHT_ON);
1909 temp_ptr->primary_weapon_flags=Players[Player_num].primary_weapon_flags;
1910 temp_ptr->secondary_weapon_flags=Players[Player_num].secondary_weapon_flags;
1911 temp_ptr->current_primary_weapon=Primary_weapon;
1912 temp_ptr->current_secondary_weapon=Secondary_weapon;
1914 temp_ptr->current_guidebot_command=Escort_goal_object;
1916 temp_ptr->force_vector=ExtForceVec;
1917 temp_ptr->force_matrix=ExtApplyForceMatrix;
1919 temp_ptr->joltinfo[i]=ExtJoltInfo[i];
1921 temp_ptr->x_vibrate_info[i]=ExtXVibrateInfo[i];
1922 temp_ptr->x_vibrate_clear=ExtXVibrateClear;
1923 temp_ptr->game_status=ExtGameStatus;
1925 memset ((void *)&ExtForceVec,0,sizeof(vms_vector));
1926 memset ((void *)&ExtApplyForceMatrix,0,sizeof(vms_matrix));
1931 ExtXVibrateInfo[i]=0;
1936 if ( Automap_active ) // (If in automap...)
1937 kc_external_control->automap_state = 1;
1938 //memset(&r,0,sizeof(r));
1942 int386 ( kc_external_intno, &r, &r); // Read external info...
1946 if ( Player_num > -1 ) {
1947 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_TURNROLL); // Turn off roll when turning
1948 Objects[Players[Player_num].objnum].mtype.phys_info.flags &= (~PF_LEVELLING); // Turn off leveling to nearest side.
1949 cvar_setint(&Auto_leveling_on, 0);
1951 if ( kc_external_version > 0 ) {
1952 vms_matrix tempm, ViewMatrix;
1953 vms_angvec * Kconfig_abs_movement;
1956 Kconfig_abs_movement = (vms_angvec *)((uint)kc_external_control + sizeof(ext_control_info));
1958 if ( Kconfig_abs_movement->p || Kconfig_abs_movement->b || Kconfig_abs_movement->h ) {
1959 vm_angles_2_matrix(&tempm,Kconfig_abs_movement);
1960 vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);
1961 Objects[Players[Player_num].objnum].orient = ViewMatrix;
1963 oem_message = (char *)((uint)Kconfig_abs_movement + sizeof(vms_angvec));
1964 if (oem_message[0] != '\0' )
1965 HUD_init_message( oem_message );
1969 Controls.pitch_time += fixmul(kc_external_control->pitch_time,FrameTime);
1970 Controls.vertical_thrust_time += fixmul(kc_external_control->vertical_thrust_time,FrameTime);
1971 Controls.heading_time += fixmul(kc_external_control->heading_time,FrameTime);
1972 Controls.sideways_thrust_time += fixmul(kc_external_control->sideways_thrust_time ,FrameTime);
1973 Controls.bank_time += fixmul(kc_external_control->bank_time ,FrameTime);
1974 Controls.forward_thrust_time += fixmul(kc_external_control->forward_thrust_time ,FrameTime);
1975 Controls.rear_view_down_count += kc_external_control->rear_view_down_count;
1976 Controls.rear_view_down_state |= kc_external_control->rear_view_down_state;
1977 Controls.fire_primary_down_count += kc_external_control->fire_primary_down_count;
1978 Controls.fire_primary_state |= kc_external_control->fire_primary_state;
1979 Controls.fire_secondary_state |= kc_external_control->fire_secondary_state;
1980 Controls.fire_secondary_down_count += kc_external_control->fire_secondary_down_count;
1981 Controls.fire_flare_down_count += kc_external_control->fire_flare_down_count;
1982 Controls.drop_bomb_down_count += kc_external_control->drop_bomb_down_count;
1983 Controls.automap_down_count += kc_external_control->automap_down_count;
1984 Controls.automap_state |= kc_external_control->automap_state;
1986 if (kc_external_version>=3)
1988 ubyte *temp_ptr = (ubyte *)kc_external_control;
1989 temp_ptr += (sizeof(ext_control_info) + sizeof(vms_angvec) + 64 + sizeof(vms_vector) + sizeof (vms_matrix));
1992 Controls.cycle_primary_count=(*(temp_ptr));
1994 Controls.cycle_secondary_count=(*(temp_ptr+1));
1997 Controls.afterburner_state=(*(temp_ptr+2));
1999 Controls.headlight_count=(*(temp_ptr+3));
2001 if (kc_external_version>=4)
2004 advanced_ext_control_info *temp_ptr=(advanced_ext_control_info *)kc_external_control;
2007 if (temp_ptr->keyboard[i])
2010 if (temp_ptr->Reactor_blown)
2012 if (Game_mode & GM_MULTI)
2013 net_destroy_controlcen (obj_find_first_of_type (OBJ_CNTRLCEN));
2015 do_controlcen_destroyed_stuff(obj_find_first_of_type (OBJ_CNTRLCEN));