2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/ControlConfig/ControlsConfig.h $
15 * Header file for keyboard, joystick and mouse configuration
18 * Revision 1.2 2002/06/09 04:41:12 relnev
19 * added copyright header
21 * Revision 1.1.1.1 2002/05/03 03:28:11 root
25 * 6 8/22/99 5:53p Dave
26 * Scoring fixes. Added self destruct key. Put callsigns in the logfile
27 * instead of ship designations for multiplayer players.
29 * 5 8/19/99 10:59a Dave
30 * Packet loss detection.
32 * 4 8/01/99 12:39p Dave
33 * Added HUD contrast control key (for nebula).
35 * 3 11/05/98 4:18p Dave
36 * First run nebula support. Beefed up localization a bit. Removed all
37 * conditional compiles for foreign versions. Modified mission file
40 * 2 10/07/98 10:52a Dave
43 * 1 10/07/98 10:48a Dave
45 * 26 6/13/98 5:19p Hoffoss
46 * externalized control config texts.
48 * 25 5/15/98 8:37p Lawrance
49 * Add 'equalize recharge rates' and 'target ship that sent last
50 * transmission' key bindings
52 * 24 5/14/98 5:32p Hoffoss
53 * Improved axis binding code some more.
55 * 23 5/13/98 7:15p Hoffoss
56 * Fixed remaining bugs with axis binding.
58 * 22 5/13/98 1:17a Hoffoss
59 * Added joystick axes configurability.
61 * 21 4/30/98 9:43p Hoffoss
62 * Added new actions for free look movement which are default bounded to
65 * 20 4/25/98 1:59p Lawrance
68 * 19 4/25/98 1:24p Lawrance
69 * Add time compression keys to key config
71 * 18 4/25/98 12:43p Allender
72 * added new shortcut key for attack my subsystem
74 * 17 4/18/98 5:00p Dave
75 * Put in observer zoom key. Made mission sync screen more informative.
77 * 16 4/10/98 12:47p Allender
78 * changed working on replay popup. Don't reference repair in comm menu.
79 * Added Shift-R for repair me
81 * 15 4/08/98 11:11a Hoffoss
82 * Fixed some bugs that showed up due to fixing other bugs the other day
85 * 14 3/31/98 4:15p Hoffoss
86 * Disabled the show objectives action.
88 * 13 3/23/98 12:27p Hoffoss
89 * Whoops, changed order in list but forget to actually change the number.
91 * 12 3/23/98 11:35a Hoffoss
92 * Fixed #defines that were out of sync.
94 * 11 3/19/98 5:04p Dave
95 * Put in support for targeted multiplayer text and voice messaging (all,
96 * friendly, hostile, individual).
98 * 10 3/11/98 5:28p Hoffoss
99 * Added control config debug display info to possibly aid in tracking
102 * 9 2/28/98 7:02p Lawrance
103 * overhaul on-line help
105 * 8 2/26/98 12:33a Lawrance
106 * Added back slew mode, lots of changes to external and chase views.
108 * 7 2/02/98 6:59p Lawrance
109 * Adding new targeting keys (bomb, uninspected cargo, new ship, live
112 * 6 1/30/98 10:40a Lawrance
113 * remove any binding references to hotkey screen
115 * 5 1/28/98 6:19p Dave
116 * Reduced standalone memory usage ~8 megs. Put in support for handling
117 * multiplayer submenu handling for endgame, etc.
119 * 4 1/22/98 4:53p Hoffoss
120 * Made training messages/directives display a joystick button in place of
121 * a keypress if there is no keypress bound to the action.
123 * 3 1/02/98 4:42p Allender
124 * removed unused key bindings from control config list
126 * 2 12/30/97 4:47p Allender
127 * work with ignore my target command. Added new keyboard hotkey. Made
130 * 1 12/24/97 11:59a Hoffoss
132 * 41 11/24/97 10:20p Lawrance
133 * Add key 'KEY_N' to target next ship on monitoring view
135 * 40 11/21/97 5:57p Hoffoss
136 * Fixed bug where timef type controls weren't checking joystick buttons.
138 * 39 11/20/97 1:08a Lawrance
139 * add support for 'R' key - target closest friendly repair ship
141 * 38 11/17/97 6:40p Lawrance
142 * Changed 'I' key to toggle of extended target info, moved target closest
143 * locked missile to 'L'
145 * 37 11/02/97 1:15p Hoffoss
146 * Externed an array I need elsewhere.
148 * 36 10/28/97 12:12a Lawrance
149 * remove unused keys (Alt-H and Alt-F)
151 * 35 10/24/97 11:00p Hoffoss
152 * Controls config screen much improved.
154 * 34 10/22/97 4:50p Hoffoss
155 * Disabled throttle by default.
157 * 33 10/21/97 7:05p Hoffoss
158 * Overhauled the key/joystick control structure and usage throughout the
159 * entire FreeSpace code. The whole system is very different now.
161 * 32 10/18/97 7:19p Hoffoss
162 * Added timestamp recording when a key is pressed.
164 * 31 9/14/97 10:24p Lawrance
165 * add damage screen popup window
167 * 30 9/10/97 6:02p Hoffoss
168 * Added code to check for key-pressed sexp operator in FreeSpace as part
169 * of training mission stuff.
171 * 29 9/09/97 9:18a Hoffoss
172 * Added message token translation (phase 1) to FreeSpace for training
175 * 28 8/31/97 6:38p Lawrance
176 * pass in frametime to do_frame loop
178 * 27 8/29/97 5:02p Sandeep
179 * fixed joystick support for shield config
181 * 26 8/25/97 12:24a Lawrance
182 * added keys for shield management
184 * 25 8/22/97 10:44p Sandeep
185 * Added Configurable support for energy management keys, keyboard and
188 * 24 8/21/97 5:03p Sandeep
189 * Fixed joystick functions past "Target Closest Hostile Targeting Self"
192 * 23 8/20/97 4:22p Sandeep
193 * Add support for joystick mapping to all keyboard configurable commands.
194 * Changed pilot file to allow support for new joystick, incompatible
197 * 22 8/07/97 11:27p Lawrance
198 * add support for 4th joystick axis (rudder), add new option to roll ship
200 * 21 7/08/97 11:37a Lawrance
201 * add joystick support for afterburners
203 * 20 7/01/97 11:52a Lawrance
204 * add targeting key, allow player to clear all bindings
206 * 19 6/24/97 12:38a Lawrance
207 * added in some new joystick bindings
209 * 18 6/17/97 8:57p Lawrance
210 * added target previous hostile/friendly
212 * 17 6/03/97 1:39a Allender
213 * made macros for joystick button id's
215 * 16 5/28/97 9:53a Lawrance
216 * move goals keys and squadmate message key from function keys to
219 * 15 5/26/97 5:49p Lawrance
220 * supporting max range on radar
222 * 14 5/26/97 3:31p Lawrance
223 * assign key bindings for view modes and view controls
225 * 13 5/14/97 10:50a Mike
226 * More countermeasure stuff.
228 * 12 4/24/97 2:40p Lawrance
229 * add key for targeting closest ship attacking self
231 * 11 4/05/97 3:46p Allender
232 * lots 'o messaging stuff. Make shortcut keys for squadmate messaging
233 * work. Make menus a little more dynamic
235 * 10 4/01/97 7:50p Lawrance
236 * added many new keys, don't allow Shft or Alt as action keys, only allow
237 * Ctrl as an action key
239 * 9 3/10/97 8:30a Lawrance
240 * changed -/+ 5% throttle keys to 1/3 2/3 throttle keys
242 * 8 12/18/96 6:09p Lawrance
243 * allowing shift+alt+ctrl modifiers on keyboard bindings
245 * 7 12/18/96 10:18a Lawrance
246 * integrating joystick axis configuration
248 * 6 12/17/96 11:10a Lawrance
249 * added targeting of subsystem in reticle
251 * 5 12/06/96 12:27a Lawrance
252 * adding support for joystick configuration
254 * 4 12/05/96 2:47p Lawrance
255 * changed how keyboard configuration was done to make code more easily
258 * 3 12/03/96 10:11p Lawrance
259 * Integrating keyboard configuration
261 * 2 12/03/96 3:45p Lawrance
267 #ifndef CONTROLS_CONFIG_H
268 #define CONTROLS_CONFIG_H
270 #define CONTROL_CONFIG_XSTR 507
275 #define JOY_RX_AXIS 3
276 #define JOY_RY_AXIS 4
277 #define JOY_RZ_AXIS 5
279 #define NUM_JOY_AXIS_ACTIONS 5
281 #define JOY_HEADING_AXIS 0
282 #define JOY_PITCH_AXIS 1
283 #define JOY_BANK_AXIS 2
284 #define JOY_ABS_THROTTLE_AXIS 3
285 #define JOY_REL_THROTTLE_AXIS 4
287 // --------------------------------------------------
288 // different types of controls that can be assigned
289 // --------------------------------------------------
291 #define CC_TYPE_TRIGGER 0
292 #define CC_TYPE_CONTINUOUS 1
294 typedef struct config_item {
295 int key_default; // default key bound to action
296 short joy_default; // default joystick button bound to action
297 char tab; // what tab (catagory) it belongs in
298 const char *text; // describes the action in the config screen
299 char type; // manner control should be checked in
300 int key_id; // actual key bound to action
301 short joy_id; // joystick button bound to action
302 int used; // has control been used yet in mission? If so, this is the timestamp
305 // --------------------------------------------------
306 // Keyboard #defines for the actions
307 // This is the value of the id field in config_item
308 // --------------------------------------------------
312 #define TARGET_NEXT 0
313 #define TARGET_PREV 1
314 #define TARGET_NEXT_CLOSEST_HOSTILE 2
315 #define TARGET_PREV_CLOSEST_HOSTILE 3
316 #define TOGGLE_AUTO_TARGETING 4
317 #define TARGET_NEXT_CLOSEST_FRIENDLY 5
318 #define TARGET_PREV_CLOSEST_FRIENDLY 6
319 #define TARGET_SHIP_IN_RETICLE 7
320 #define TARGET_CLOSEST_SHIP_ATTACKING_TARGET 8
321 #define TARGET_LAST_TRANMISSION_SENDER 9
322 #define STOP_TARGETING_SHIP 10
324 // targeting a ship's subsystem
325 #define TARGET_SUBOBJECT_IN_RETICLE 11
326 #define TARGET_NEXT_SUBOBJECT 12
327 #define TARGET_PREV_SUBOBJECT 13
328 #define STOP_TARGETING_SUBSYSTEM 14
331 #define MATCH_TARGET_SPEED 15
332 #define TOGGLE_AUTO_MATCH_TARGET_SPEED 16
335 #define FIRE_PRIMARY 17
336 #define FIRE_SECONDARY 18
337 #define CYCLE_NEXT_PRIMARY 19
338 #define CYCLE_PREV_PRIMARY 20
339 #define CYCLE_SECONDARY 21
340 #define CYCLE_NUM_MISSLES 22
341 #define LAUNCH_COUNTERMEASURE 23
344 #define FORWARD_THRUST 24
345 #define REVERSE_THRUST 25
347 #define BANK_RIGHT 27
348 #define PITCH_FORWARD 28
349 #define PITCH_BACK 29
354 #define ZERO_THROTTLE 32
355 #define MAX_THROTTLE 33
356 #define ONE_THIRD_THROTTLE 34
357 #define TWO_THIRDS_THROTTLE 35
358 #define PLUS_5_PERCENT_THROTTLE 36
359 #define MINUS_5_PERCENT_THROTTLE 37
361 // squadmate messaging keys
362 #define ATTACK_MESSAGE 38
363 #define DISARM_MESSAGE 39
364 #define DISABLE_MESSAGE 40
365 #define ATTACK_SUBSYSTEM_MESSAGE 41
366 #define CAPTURE_MESSAGE 42
367 #define ENGAGE_MESSAGE 43
368 #define FORM_MESSAGE 44
369 #define IGNORE_MESSAGE 45
370 #define PROTECT_MESSAGE 46
371 #define COVER_MESSAGE 47
372 #define WARP_MESSAGE 48
373 #define REARM_MESSAGE 49
375 #define TARGET_CLOSEST_SHIP_ATTACKING_SELF 50
378 #define VIEW_CHASE 51
379 #define VIEW_EXTERNAL 52
380 #define VIEW_EXTERNAL_TOGGLE_CAMERA_LOCK 53
382 #define VIEW_OTHER_SHIP 55
383 #define VIEW_DIST_INCREASE 56
384 #define VIEW_DIST_DECREASE 57
385 #define VIEW_CENTER 58
386 #define PADLOCK_UP 59
387 #define PADLOCK_DOWN 60
388 #define PADLOCK_LEFT 61
389 #define PADLOCK_RIGHT 62
392 #define RADAR_RANGE_CYCLE 63
393 #define SQUADMSG_MENU 64
394 #define SHOW_GOALS 65
395 #define END_MISSION 66
396 #define TARGET_TARGETS_TARGET 67
397 #define AFTERBURNER 68
399 #define INCREASE_WEAPON 69
400 #define DECREASE_WEAPON 70
401 #define INCREASE_SHIELD 71
402 #define DECREASE_SHIELD 72
403 #define INCREASE_ENGINE 73
404 #define DECREASE_ENGINE 74
405 #define ETS_EQUALIZE 75
406 #define SHIELD_EQUALIZE 76
407 #define SHIELD_XFER_TOP 77
408 #define SHIELD_XFER_BOTTOM 78
409 #define SHIELD_XFER_LEFT 79
410 #define SHIELD_XFER_RIGHT 80
412 #define XFER_SHIELD 81
413 #define XFER_LASER 82
414 #define SHOW_DAMAGE_POPUP 83 // AL: this binding should be removing next time the controls are reorganized
416 #define BANK_WHEN_PRESSED 84
417 #define SHOW_NAVMAP 85
418 #define ADD_REMOVE_ESCORT 86
419 #define ESCORT_CLEAR 87
420 #define TARGET_NEXT_ESCORT_SHIP 88
422 #define TARGET_CLOSEST_REPAIR_SHIP 89
423 #define TARGET_NEXT_UNINSPECTED_CARGO 90
424 #define TARGET_PREV_UNINSPECTED_CARGO 91
425 #define TARGET_NEWEST_SHIP 92
426 #define TARGET_NEXT_LIVE_TURRET 93
427 #define TARGET_PREV_LIVE_TURRET 94
429 #define TARGET_NEXT_BOMB 95
430 #define TARGET_PREV_BOMB 96
432 // multiplayer messaging keys
433 #define MULTI_MESSAGE_ALL 97
434 #define MULTI_MESSAGE_FRIENDLY 98
435 #define MULTI_MESSAGE_HOSTILE 99
436 #define MULTI_MESSAGE_TARGET 100
438 // multiplayer misc keys
439 #define MULTI_OBSERVER_ZOOM_TO 101
441 #define TIME_SPEED_UP 102
442 #define TIME_SLOW_DOWN 103
444 #define TOGGLE_HUD_CONTRAST 104
446 #define MULTI_TOGGLE_NETINFO 105
448 #define MULTI_SELF_DESTRUCT 106
450 // this should be the total number of control action defines above (or last define + 1)
453 extern int Failed_key_index;
454 extern int Invert_heading;
455 extern int Invert_pitch;
456 extern int Invert_roll;
457 extern int Invert_thrust;
458 extern int Disable_axis2;
459 extern int Disable_axis3;
461 extern int Axis_map_to[];
462 extern int Invert_axis[];
463 extern int Invert_axis_defaults[];
465 extern config_item Control_config[]; // stores the keyboard configuration
466 extern const char **Scan_code_text;
467 extern const char **Joy_button_text;
469 // initialize common control config stuff - call at game startup after localization has been initialized
470 void control_config_common_init();
472 void control_config_init();
473 void control_config_do_frame(float frametime);
474 void control_config_close();
476 void control_config_cancel_exit();
478 void control_config_reset_defaults();
479 int translate_key_to_index(const char *key);
480 const char *translate_key(const char *key);
481 const char *textify_scancode(int code);
482 float check_control_timef(int id);
483 int check_control(int id, int key = -1);
484 void control_get_axes_readings(int *h, int *p, int *b, int *ta, int *tr);
485 void control_used(int id);
486 void control_config_clear();
487 void clear_key_binding(short key);
488 void control_check_indicate();
489 void control_config_clear_used_status();