2 * $Logfile: /Freespace2/code/ControlConfig/ControlsConfig.h $
7 * Header file for keyboard, joystick and mouse configuration
10 * Revision 1.1 2002/05/03 03:28:11 root
14 * 6 8/22/99 5:53p Dave
15 * Scoring fixes. Added self destruct key. Put callsigns in the logfile
16 * instead of ship designations for multiplayer players.
18 * 5 8/19/99 10:59a Dave
19 * Packet loss detection.
21 * 4 8/01/99 12:39p Dave
22 * Added HUD contrast control key (for nebula).
24 * 3 11/05/98 4:18p Dave
25 * First run nebula support. Beefed up localization a bit. Removed all
26 * conditional compiles for foreign versions. Modified mission file
29 * 2 10/07/98 10:52a Dave
32 * 1 10/07/98 10:48a Dave
34 * 26 6/13/98 5:19p Hoffoss
35 * externalized control config texts.
37 * 25 5/15/98 8:37p Lawrance
38 * Add 'equalize recharge rates' and 'target ship that sent last
39 * transmission' key bindings
41 * 24 5/14/98 5:32p Hoffoss
42 * Improved axis binding code some more.
44 * 23 5/13/98 7:15p Hoffoss
45 * Fixed remaining bugs with axis binding.
47 * 22 5/13/98 1:17a Hoffoss
48 * Added joystick axes configurability.
50 * 21 4/30/98 9:43p Hoffoss
51 * Added new actions for free look movement which are default bounded to
54 * 20 4/25/98 1:59p Lawrance
57 * 19 4/25/98 1:24p Lawrance
58 * Add time compression keys to key config
60 * 18 4/25/98 12:43p Allender
61 * added new shortcut key for attack my subsystem
63 * 17 4/18/98 5:00p Dave
64 * Put in observer zoom key. Made mission sync screen more informative.
66 * 16 4/10/98 12:47p Allender
67 * changed working on replay popup. Don't reference repair in comm menu.
68 * Added Shift-R for repair me
70 * 15 4/08/98 11:11a Hoffoss
71 * Fixed some bugs that showed up due to fixing other bugs the other day
74 * 14 3/31/98 4:15p Hoffoss
75 * Disabled the show objectives action.
77 * 13 3/23/98 12:27p Hoffoss
78 * Whoops, changed order in list but forget to actually change the number.
80 * 12 3/23/98 11:35a Hoffoss
81 * Fixed #defines that were out of sync.
83 * 11 3/19/98 5:04p Dave
84 * Put in support for targeted multiplayer text and voice messaging (all,
85 * friendly, hostile, individual).
87 * 10 3/11/98 5:28p Hoffoss
88 * Added control config debug display info to possibly aid in tracking
91 * 9 2/28/98 7:02p Lawrance
92 * overhaul on-line help
94 * 8 2/26/98 12:33a Lawrance
95 * Added back slew mode, lots of changes to external and chase views.
97 * 7 2/02/98 6:59p Lawrance
98 * Adding new targeting keys (bomb, uninspected cargo, new ship, live
101 * 6 1/30/98 10:40a Lawrance
102 * remove any binding references to hotkey screen
104 * 5 1/28/98 6:19p Dave
105 * Reduced standalone memory usage ~8 megs. Put in support for handling
106 * multiplayer submenu handling for endgame, etc.
108 * 4 1/22/98 4:53p Hoffoss
109 * Made training messages/directives display a joystick button in place of
110 * a keypress if there is no keypress bound to the action.
112 * 3 1/02/98 4:42p Allender
113 * removed unused key bindings from control config list
115 * 2 12/30/97 4:47p Allender
116 * work with ignore my target command. Added new keyboard hotkey. Made
119 * 1 12/24/97 11:59a Hoffoss
121 * 41 11/24/97 10:20p Lawrance
122 * Add key 'KEY_N' to target next ship on monitoring view
124 * 40 11/21/97 5:57p Hoffoss
125 * Fixed bug where timef type controls weren't checking joystick buttons.
127 * 39 11/20/97 1:08a Lawrance
128 * add support for 'R' key - target closest friendly repair ship
130 * 38 11/17/97 6:40p Lawrance
131 * Changed 'I' key to toggle of extended target info, moved target closest
132 * locked missile to 'L'
134 * 37 11/02/97 1:15p Hoffoss
135 * Externed an array I need elsewhere.
137 * 36 10/28/97 12:12a Lawrance
138 * remove unused keys (Alt-H and Alt-F)
140 * 35 10/24/97 11:00p Hoffoss
141 * Controls config screen much improved.
143 * 34 10/22/97 4:50p Hoffoss
144 * Disabled throttle by default.
146 * 33 10/21/97 7:05p Hoffoss
147 * Overhauled the key/joystick control structure and usage throughout the
148 * entire FreeSpace code. The whole system is very different now.
150 * 32 10/18/97 7:19p Hoffoss
151 * Added timestamp recording when a key is pressed.
153 * 31 9/14/97 10:24p Lawrance
154 * add damage screen popup window
156 * 30 9/10/97 6:02p Hoffoss
157 * Added code to check for key-pressed sexp operator in FreeSpace as part
158 * of training mission stuff.
160 * 29 9/09/97 9:18a Hoffoss
161 * Added message token translation (phase 1) to FreeSpace for training
164 * 28 8/31/97 6:38p Lawrance
165 * pass in frametime to do_frame loop
167 * 27 8/29/97 5:02p Sandeep
168 * fixed joystick support for shield config
170 * 26 8/25/97 12:24a Lawrance
171 * added keys for shield management
173 * 25 8/22/97 10:44p Sandeep
174 * Added Configurable support for energy management keys, keyboard and
177 * 24 8/21/97 5:03p Sandeep
178 * Fixed joystick functions past "Target Closest Hostile Targeting Self"
181 * 23 8/20/97 4:22p Sandeep
182 * Add support for joystick mapping to all keyboard configurable commands.
183 * Changed pilot file to allow support for new joystick, incompatible
186 * 22 8/07/97 11:27p Lawrance
187 * add support for 4th joystick axis (rudder), add new option to roll ship
189 * 21 7/08/97 11:37a Lawrance
190 * add joystick support for afterburners
192 * 20 7/01/97 11:52a Lawrance
193 * add targeting key, allow player to clear all bindings
195 * 19 6/24/97 12:38a Lawrance
196 * added in some new joystick bindings
198 * 18 6/17/97 8:57p Lawrance
199 * added target previous hostile/friendly
201 * 17 6/03/97 1:39a Allender
202 * made macros for joystick button id's
204 * 16 5/28/97 9:53a Lawrance
205 * move goals keys and squadmate message key from function keys to
208 * 15 5/26/97 5:49p Lawrance
209 * supporting max range on radar
211 * 14 5/26/97 3:31p Lawrance
212 * assign key bindings for view modes and view controls
214 * 13 5/14/97 10:50a Mike
215 * More countermeasure stuff.
217 * 12 4/24/97 2:40p Lawrance
218 * add key for targeting closest ship attacking self
220 * 11 4/05/97 3:46p Allender
221 * lots 'o messaging stuff. Make shortcut keys for squadmate messaging
222 * work. Make menus a little more dynamic
224 * 10 4/01/97 7:50p Lawrance
225 * added many new keys, don't allow Shft or Alt as action keys, only allow
226 * Ctrl as an action key
228 * 9 3/10/97 8:30a Lawrance
229 * changed -/+ 5% throttle keys to 1/3 2/3 throttle keys
231 * 8 12/18/96 6:09p Lawrance
232 * allowing shift+alt+ctrl modifiers on keyboard bindings
234 * 7 12/18/96 10:18a Lawrance
235 * integrating joystick axis configuration
237 * 6 12/17/96 11:10a Lawrance
238 * added targeting of subsystem in reticle
240 * 5 12/06/96 12:27a Lawrance
241 * adding support for joystick configuration
243 * 4 12/05/96 2:47p Lawrance
244 * changed how keyboard configuration was done to make code more easily
247 * 3 12/03/96 10:11p Lawrance
248 * Integrating keyboard configuration
250 * 2 12/03/96 3:45p Lawrance
256 #ifndef CONTROLS_CONFIG_H
257 #define CONTROLS_CONFIG_H
259 #define CONTROL_CONFIG_XSTR 507
264 #define JOY_RX_AXIS 3
265 #define JOY_RY_AXIS 4
266 #define JOY_RZ_AXIS 5
268 #define NUM_JOY_AXIS_ACTIONS 5
270 #define JOY_HEADING_AXIS 0
271 #define JOY_PITCH_AXIS 1
272 #define JOY_BANK_AXIS 2
273 #define JOY_ABS_THROTTLE_AXIS 3
274 #define JOY_REL_THROTTLE_AXIS 4
276 // --------------------------------------------------
277 // different types of controls that can be assigned
278 // --------------------------------------------------
280 #define CC_TYPE_TRIGGER 0
281 #define CC_TYPE_CONTINUOUS 1
283 typedef struct config_item {
284 short key_default; // default key bound to action
285 short joy_default; // default joystick button bound to action
286 char tab; // what tab (catagory) it belongs in
287 char *text; // describes the action in the config screen
288 char type; // manner control should be checked in
289 short key_id; // actual key bound to action
290 short joy_id; // joystick button bound to action
291 int used; // has control been used yet in mission? If so, this is the timestamp
294 // --------------------------------------------------
295 // Keyboard #defines for the actions
296 // This is the value of the id field in config_item
297 // --------------------------------------------------
301 #define TARGET_NEXT 0
302 #define TARGET_PREV 1
303 #define TARGET_NEXT_CLOSEST_HOSTILE 2
304 #define TARGET_PREV_CLOSEST_HOSTILE 3
305 #define TOGGLE_AUTO_TARGETING 4
306 #define TARGET_NEXT_CLOSEST_FRIENDLY 5
307 #define TARGET_PREV_CLOSEST_FRIENDLY 6
308 #define TARGET_SHIP_IN_RETICLE 7
309 #define TARGET_CLOSEST_SHIP_ATTACKING_TARGET 8
310 #define TARGET_LAST_TRANMISSION_SENDER 9
311 #define STOP_TARGETING_SHIP 10
313 // targeting a ship's subsystem
314 #define TARGET_SUBOBJECT_IN_RETICLE 11
315 #define TARGET_NEXT_SUBOBJECT 12
316 #define TARGET_PREV_SUBOBJECT 13
317 #define STOP_TARGETING_SUBSYSTEM 14
320 #define MATCH_TARGET_SPEED 15
321 #define TOGGLE_AUTO_MATCH_TARGET_SPEED 16
324 #define FIRE_PRIMARY 17
325 #define FIRE_SECONDARY 18
326 #define CYCLE_NEXT_PRIMARY 19
327 #define CYCLE_PREV_PRIMARY 20
328 #define CYCLE_SECONDARY 21
329 #define CYCLE_NUM_MISSLES 22
330 #define LAUNCH_COUNTERMEASURE 23
333 #define FORWARD_THRUST 24
334 #define REVERSE_THRUST 25
336 #define BANK_RIGHT 27
337 #define PITCH_FORWARD 28
338 #define PITCH_BACK 29
343 #define ZERO_THROTTLE 32
344 #define MAX_THROTTLE 33
345 #define ONE_THIRD_THROTTLE 34
346 #define TWO_THIRDS_THROTTLE 35
347 #define PLUS_5_PERCENT_THROTTLE 36
348 #define MINUS_5_PERCENT_THROTTLE 37
350 // squadmate messaging keys
351 #define ATTACK_MESSAGE 38
352 #define DISARM_MESSAGE 39
353 #define DISABLE_MESSAGE 40
354 #define ATTACK_SUBSYSTEM_MESSAGE 41
355 #define CAPTURE_MESSAGE 42
356 #define ENGAGE_MESSAGE 43
357 #define FORM_MESSAGE 44
358 #define IGNORE_MESSAGE 45
359 #define PROTECT_MESSAGE 46
360 #define COVER_MESSAGE 47
361 #define WARP_MESSAGE 48
362 #define REARM_MESSAGE 49
364 #define TARGET_CLOSEST_SHIP_ATTACKING_SELF 50
367 #define VIEW_CHASE 51
368 #define VIEW_EXTERNAL 52
369 #define VIEW_EXTERNAL_TOGGLE_CAMERA_LOCK 53
371 #define VIEW_OTHER_SHIP 55
372 #define VIEW_DIST_INCREASE 56
373 #define VIEW_DIST_DECREASE 57
374 #define VIEW_CENTER 58
375 #define PADLOCK_UP 59
376 #define PADLOCK_DOWN 60
377 #define PADLOCK_LEFT 61
378 #define PADLOCK_RIGHT 62
381 #define RADAR_RANGE_CYCLE 63
382 #define SQUADMSG_MENU 64
383 #define SHOW_GOALS 65
384 #define END_MISSION 66
385 #define TARGET_TARGETS_TARGET 67
386 #define AFTERBURNER 68
388 #define INCREASE_WEAPON 69
389 #define DECREASE_WEAPON 70
390 #define INCREASE_SHIELD 71
391 #define DECREASE_SHIELD 72
392 #define INCREASE_ENGINE 73
393 #define DECREASE_ENGINE 74
394 #define ETS_EQUALIZE 75
395 #define SHIELD_EQUALIZE 76
396 #define SHIELD_XFER_TOP 77
397 #define SHIELD_XFER_BOTTOM 78
398 #define SHIELD_XFER_LEFT 79
399 #define SHIELD_XFER_RIGHT 80
401 #define XFER_SHIELD 81
402 #define XFER_LASER 82
403 #define SHOW_DAMAGE_POPUP 83 // AL: this binding should be removing next time the controls are reorganized
405 #define BANK_WHEN_PRESSED 84
406 #define SHOW_NAVMAP 85
407 #define ADD_REMOVE_ESCORT 86
408 #define ESCORT_CLEAR 87
409 #define TARGET_NEXT_ESCORT_SHIP 88
411 #define TARGET_CLOSEST_REPAIR_SHIP 89
412 #define TARGET_NEXT_UNINSPECTED_CARGO 90
413 #define TARGET_PREV_UNINSPECTED_CARGO 91
414 #define TARGET_NEWEST_SHIP 92
415 #define TARGET_NEXT_LIVE_TURRET 93
416 #define TARGET_PREV_LIVE_TURRET 94
418 #define TARGET_NEXT_BOMB 95
419 #define TARGET_PREV_BOMB 96
421 // multiplayer messaging keys
422 #define MULTI_MESSAGE_ALL 97
423 #define MULTI_MESSAGE_FRIENDLY 98
424 #define MULTI_MESSAGE_HOSTILE 99
425 #define MULTI_MESSAGE_TARGET 100
427 // multiplayer misc keys
428 #define MULTI_OBSERVER_ZOOM_TO 101
430 #define TIME_SPEED_UP 102
431 #define TIME_SLOW_DOWN 103
433 #define TOGGLE_HUD_CONTRAST 104
435 #define MULTI_TOGGLE_NETINFO 105
437 #define MULTI_SELF_DESTRUCT 106
439 // this should be the total number of control action defines above (or last define + 1)
442 extern int Failed_key_index;
443 extern int Invert_heading;
444 extern int Invert_pitch;
445 extern int Invert_roll;
446 extern int Invert_thrust;
447 extern int Disable_axis2;
448 extern int Disable_axis3;
450 extern int Axis_map_to[];
451 extern int Invert_axis[];
452 extern int Invert_axis_defaults[];
454 extern config_item Control_config[]; // stores the keyboard configuration
455 extern char **Scan_code_text;
456 extern char **Joy_button_text;
458 // initialize common control config stuff - call at game startup after localization has been initialized
459 void control_config_common_init();
461 void control_config_init();
462 void control_config_do_frame(float frametime);
463 void control_config_close();
465 void control_config_cancel_exit();
467 void control_config_reset_defaults();
468 int translate_key_to_index(char *key);
469 char *translate_key(char *key);
470 char *textify_scancode(int code);
471 float check_control_timef(int id);
472 int check_control(int id, int key = -1);
473 void control_get_axes_readings(int *h, int *p, int *b, int *ta, int *tr);
474 void control_used(int id);
475 void control_config_clear();
476 void clear_key_binding(short key);
477 void control_check_indicate();
478 void control_config_clear_used_status();