]> icculus.org git repositories - taylor/freespace2.git/blob - include/controlsconfig.h
rendering functions mostly done; more complete shader setup
[taylor/freespace2.git] / include / controlsconfig.h
1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
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
6  * the source.
7  */
8
9 /*
10  * $Logfile: /Freespace2/code/ControlConfig/ControlsConfig.h $
11  * $Revision$
12  * $Date$
13  * $Author$
14  *
15  * Header file for keyboard, joystick and mouse configuration
16  *
17  * $Log$
18  * Revision 1.2  2002/06/09 04:41:12  relnev
19  * added copyright header
20  *
21  * Revision 1.1.1.1  2002/05/03 03:28:11  root
22  * Initial import.
23  *
24  * 
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.
28  * 
29  * 5     8/19/99 10:59a Dave
30  * Packet loss detection.
31  * 
32  * 4     8/01/99 12:39p Dave
33  * Added HUD contrast control key (for nebula).
34  * 
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
38  * format.
39  * 
40  * 2     10/07/98 10:52a Dave
41  * Initial checkin.
42  * 
43  * 1     10/07/98 10:48a Dave
44  * 
45  * 26    6/13/98 5:19p Hoffoss
46  * externalized control config texts.
47  * 
48  * 25    5/15/98 8:37p Lawrance
49  * Add 'equalize recharge rates' and 'target ship that sent last
50  * transmission' key bindings
51  * 
52  * 24    5/14/98 5:32p Hoffoss
53  * Improved axis binding code some more.
54  * 
55  * 23    5/13/98 7:15p Hoffoss
56  * Fixed remaining bugs with axis binding.
57  * 
58  * 22    5/13/98 1:17a Hoffoss
59  * Added joystick axes configurability.
60  * 
61  * 21    4/30/98 9:43p Hoffoss
62  * Added new actions for free look movement which are default bounded to
63  * the hat.
64  * 
65  * 20    4/25/98 1:59p Lawrance
66  * fix merge typo
67  * 
68  * 19    4/25/98 1:24p Lawrance
69  * Add time compression keys to key config
70  * 
71  * 18    4/25/98 12:43p Allender
72  * added new shortcut key for attack my subsystem
73  * 
74  * 17    4/18/98 5:00p Dave
75  * Put in observer zoom key. Made mission sync screen more informative.
76  * 
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
80  * 
81  * 15    4/08/98 11:11a Hoffoss
82  * Fixed some bugs that showed up due to fixing other bugs the other day
83  * with controls.
84  * 
85  * 14    3/31/98 4:15p Hoffoss
86  * Disabled the show objectives action.
87  * 
88  * 13    3/23/98 12:27p Hoffoss
89  * Whoops, changed order in list but forget to actually change the number.
90  * 
91  * 12    3/23/98 11:35a Hoffoss
92  * Fixed #defines that were out of sync.
93  * 
94  * 11    3/19/98 5:04p Dave
95  * Put in support for targeted multiplayer text and voice messaging (all,
96  * friendly, hostile, individual).
97  * 
98  * 10    3/11/98 5:28p Hoffoss
99  * Added control config debug display info to possibly aid in tracking
100  * down a bug.
101  * 
102  * 9     2/28/98 7:02p Lawrance
103  * overhaul on-line help
104  * 
105  * 8     2/26/98 12:33a Lawrance
106  * Added back slew mode,  lots of changes to external and chase views.
107  * 
108  * 7     2/02/98 6:59p Lawrance
109  * Adding new targeting keys (bomb, uninspected cargo, new ship, live
110  * turrets).
111  * 
112  * 6     1/30/98 10:40a Lawrance
113  * remove any binding references to hotkey screen
114  * 
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.
118  * 
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.
122  * 
123  * 3     1/02/98 4:42p Allender
124  * removed unused key bindings from control config list
125  * 
126  * 2     12/30/97 4:47p Allender
127  * work with ignore my target command.  Added new keyboard hotkey.  Made
128  * it work globally
129  * 
130  * 1     12/24/97 11:59a Hoffoss
131  * 
132  * 41    11/24/97 10:20p Lawrance
133  * Add key 'KEY_N' to target next ship on monitoring view
134  * 
135  * 40    11/21/97 5:57p Hoffoss
136  * Fixed bug where timef type controls weren't checking joystick buttons.
137  * 
138  * 39    11/20/97 1:08a Lawrance
139  * add support for 'R' key - target closest friendly repair ship
140  * 
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'
144  * 
145  * 37    11/02/97 1:15p Hoffoss
146  * Externed an array I need elsewhere.
147  * 
148  * 36    10/28/97 12:12a Lawrance
149  * remove unused keys (Alt-H and Alt-F)
150  * 
151  * 35    10/24/97 11:00p Hoffoss
152  * Controls config screen much improved.
153  * 
154  * 34    10/22/97 4:50p Hoffoss
155  * Disabled throttle by default.
156  * 
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.
160  * 
161  * 32    10/18/97 7:19p Hoffoss
162  * Added timestamp recording when a key is pressed.
163  * 
164  * 31    9/14/97 10:24p Lawrance
165  * add damage screen popup window
166  * 
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.
170  * 
171  * 29    9/09/97 9:18a Hoffoss
172  * Added message token translation (phase 1) to FreeSpace for training
173  * missions support.
174  * 
175  * 28    8/31/97 6:38p Lawrance
176  * pass in frametime to do_frame loop
177  * 
178  * 27    8/29/97 5:02p Sandeep
179  * fixed joystick support for shield config
180  * 
181  * 26    8/25/97 12:24a Lawrance
182  * added keys for shield management
183  * 
184  * 25    8/22/97 10:44p Sandeep
185  * Added Configurable support for energy management keys, keyboard and
186  * joystick
187  * 
188  * 24    8/21/97 5:03p Sandeep
189  * Fixed joystick functions past "Target Closest Hostile Targeting Self"
190  * bug.
191  * 
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
195  * version 33
196  * 
197  * 22    8/07/97 11:27p Lawrance
198  * add support for 4th joystick axis (rudder), add new option to roll ship
199  * 
200  * 21    7/08/97 11:37a Lawrance
201  * add joystick support for afterburners
202  * 
203  * 20    7/01/97 11:52a Lawrance
204  * add targeting key, allow player to clear all bindings
205  * 
206  * 19    6/24/97 12:38a Lawrance
207  * added in some new joystick bindings
208  * 
209  * 18    6/17/97 8:57p Lawrance
210  * added target previous hostile/friendly
211  * 
212  * 17    6/03/97 1:39a Allender
213  * made macros for joystick button id's
214  * 
215  * 16    5/28/97 9:53a Lawrance
216  * move goals keys and squadmate message key from function keys to
217  * assignable keys
218  * 
219  * 15    5/26/97 5:49p Lawrance
220  * supporting max range on radar
221  * 
222  * 14    5/26/97 3:31p Lawrance
223  * assign key bindings for view modes and view controls
224  * 
225  * 13    5/14/97 10:50a Mike
226  * More countermeasure stuff.
227  * 
228  * 12    4/24/97 2:40p Lawrance
229  * add key for targeting closest ship attacking self
230  * 
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
234  * 
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
238  * 
239  * 9     3/10/97 8:30a Lawrance
240  * changed -/+ 5% throttle keys to 1/3 2/3 throttle keys
241  * 
242  * 8     12/18/96 6:09p Lawrance
243  * allowing shift+alt+ctrl modifiers on keyboard bindings
244  * 
245  * 7     12/18/96 10:18a Lawrance
246  * integrating joystick axis configuration
247  * 
248  * 6     12/17/96 11:10a Lawrance
249  * added targeting of subsystem in reticle
250  * 
251  * 5     12/06/96 12:27a Lawrance
252  * adding support for joystick configuration
253  * 
254  * 4     12/05/96 2:47p Lawrance
255  * changed how keyboard configuration was done to make code more easily
256  * changeable
257  * 
258  * 3     12/03/96 10:11p Lawrance
259  * Integrating keyboard configuration
260  * 
261  * 2     12/03/96 3:45p Lawrance
262  *
263  * $NoKeywords: $
264  *
265 */
266
267 #ifndef CONTROLS_CONFIG_H
268 #define CONTROLS_CONFIG_H
269
270 #define CONTROL_CONFIG_XSTR     507
271
272 #define JOY_X_AXIS      0
273 #define JOY_Y_AXIS      1
274 #define JOY_Z_AXIS      2
275 #define JOY_RX_AXIS     3
276 #define JOY_RY_AXIS     4
277 #define JOY_RZ_AXIS     5
278
279 #define NUM_JOY_AXIS_ACTIONS    5
280
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
286
287 // --------------------------------------------------
288 // different types of controls that can be assigned 
289 // --------------------------------------------------
290
291 #define CC_TYPE_TRIGGER         0
292 #define CC_TYPE_CONTINUOUS      1
293
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
303 } config_item;
304
305 // --------------------------------------------------
306 // Keyboard #defines for the actions  
307 // This is the value of the id field in config_item
308 // --------------------------------------------------
309
310 // targeting a ship
311
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
323
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
329
330 // speed matching 
331 #define MATCH_TARGET_SPEED                                                              15
332 #define TOGGLE_AUTO_MATCH_TARGET_SPEED                          16
333
334 // weapons
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
342
343 // controls
344 #define FORWARD_THRUST                                                                  24
345 #define REVERSE_THRUST                                                                  25
346 #define BANK_LEFT                                                                                       26
347 #define BANK_RIGHT                                                                              27
348 #define PITCH_FORWARD                                                                   28
349 #define PITCH_BACK                                                                              29
350 #define YAW_LEFT                                                                                        30
351 #define YAW_RIGHT                                                                                       31
352
353 // throttle control
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
360
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
374
375 #define TARGET_CLOSEST_SHIP_ATTACKING_SELF              50
376
377 // Views
378 #define VIEW_CHASE                                                                              51
379 #define VIEW_EXTERNAL                                                                   52
380 #define VIEW_EXTERNAL_TOGGLE_CAMERA_LOCK                        53
381 #define VIEW_SLEW                                                                                       54
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
390
391
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
398
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
411
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
415
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
421
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
428
429 #define TARGET_NEXT_BOMB                                                                95
430 #define TARGET_PREV_BOMB                                                                96
431
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
437
438 // multiplayer misc keys
439 #define MULTI_OBSERVER_ZOOM_TO                                          101
440
441 #define TIME_SPEED_UP                                                                   102
442 #define TIME_SLOW_DOWN                                                                  103
443
444 #ifndef MAKE_FS1
445 #define TOGGLE_HUD_CONTRAST                                                     104
446
447 #define MULTI_TOGGLE_NETINFO                                                    105
448
449 #define MULTI_SELF_DESTRUCT                                                     106
450
451 // this should be the total number of control action defines above (or last define + 1)
452 #define CCFG_MAX 107
453 #else
454 // this should be the total number of control action defines above (or last define + 1)
455 #define CCFG_MAX 104
456 #endif
457
458 extern int Failed_key_index;
459 extern int Invert_heading;
460 extern int Invert_pitch;
461 extern int Invert_roll;
462 extern int Invert_thrust;
463 extern int Disable_axis2;
464 extern int Disable_axis3;
465
466 extern int Axis_map_to[];
467 extern int Invert_axis[];
468 extern int Invert_axis_defaults[];
469
470 extern config_item Control_config[];    // stores the keyboard configuration
471 extern const char **Scan_code_text;
472 extern const char **Joy_button_text;
473
474 // initialize common control config stuff - call at game startup after localization has been initialized
475 void control_config_common_init();
476
477 void control_config_init();
478 void control_config_do_frame(float frametime);
479 void control_config_close();
480
481 void control_config_cancel_exit();
482
483 void control_config_reset_defaults();
484 int translate_key_to_index(const char *key);
485 const char *translate_key(const char *key);
486 const char *textify_scancode(int code);
487 float check_control_timef(int id);
488 int check_control(int id, int key = -1);
489 void control_get_axes_readings(int *h, int *p, int *b, int *ta, int *tr);
490 void control_used(int id);
491 void control_config_clear();
492 void clear_key_binding(short key);
493 void control_check_indicate();
494 void control_config_clear_used_status();
495
496 #endif
497