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/ControlsConfigCommon.cpp $
15 * C module for keyboard, joystick and mouse configuration common stuff (between Fred and FreeSpace)
18 * Revision 1.3 2002/06/09 04:41:15 relnev
19 * added copyright header
21 * Revision 1.2 2002/05/07 03:16:43 theoddone33
22 * The Great Newline Fix
24 * Revision 1.1.1.1 2002/05/03 03:28:08 root
28 * 14 11/01/99 3:36p Jefff
29 * had scan code texts for y and z in german swapped
31 * 13 11/01/99 2:16p Jefff
32 * minor key name change in german
34 * 12 10/29/99 6:10p Jefff
35 * squashed the damned y/z german issues once and for all
37 * 11 10/28/99 11:16p Jefff
38 * Changed some german key names. Made key translations always use the
41 * 10 10/28/99 2:05a Jefff
42 * revised some german key names. changed some y/z switch stuff.
44 * 9 10/25/99 5:39p Jefff
45 * swap init binding for y and z keys in German builds
47 * 8 9/01/99 2:56p Jefff
48 * a few control key description changes
50 * 7 8/22/99 5:53p Dave
51 * Scoring fixes. Added self destruct key. Put callsigns in the logfile
52 * instead of ship designations for multiplayer players.
54 * 6 8/19/99 10:59a Dave
55 * Packet loss detection.
57 * 5 8/01/99 12:39p Dave
58 * Added HUD contrast control key (for nebula).
60 * 4 7/23/99 2:57p Andsager
61 * fix translate_key_to_index to work with localization
63 * 3 11/05/98 4:18p Dave
64 * First run nebula support. Beefed up localization a bit. Removed all
65 * conditional compiles for foreign versions. Modified mission file
68 * 2 10/07/98 10:52a Dave
71 * 1 10/07/98 10:48a Dave
73 * 41 6/19/98 3:51p Lawrance
74 * localize control text
76 * 40 6/17/98 11:05a Lawrance
77 * localize the control config strings
79 * 39 5/24/98 2:28p Hoffoss
80 * Because we never really care about if the left or the right shift or
81 * alt key was used, but rather than either shift or alt was used, made
82 * both map to the left one. Solves some problems, causes none.
84 * 38 5/22/98 11:21a Hoffoss
85 * Added bank when pressed back in.
87 * 37 5/15/98 8:37p Lawrance
88 * Add 'equalize recharge rates' and 'target ship that sent last
89 * transmission' key bindings
91 * 36 5/13/98 7:15p Hoffoss
92 * Fixed remaining bugs with axis binding.
94 * 35 5/13/98 1:17a Hoffoss
95 * Added joystick axes configurability.
97 * 34 5/12/98 11:25a Hoffoss
98 * Disabled bank when pressed action.
100 * 33 5/09/98 10:48p Lawrance
101 * change text for view bindings
103 * 32 5/09/98 4:52p Lawrance
104 * Implement padlock view (up/rear/left/right)
106 * 31 4/30/98 9:43p Hoffoss
107 * Added new actions for free look movement which are default bounded to
110 * 30 4/25/98 1:25p Lawrance
111 * Add time compression keys to key config
113 * 29 4/25/98 12:43p Allender
114 * added new shortcut key for attack my subsystem
116 * 28 4/18/98 5:00p Dave
117 * Put in observer zoom key. Made mission sync screen more informative.
119 * 27 4/17/98 1:24a Lawrance
122 * 26 4/15/98 11:06a Lawrance
123 * fix bug with a multi key showing up in demo, remove obsolete bindings
124 * from demo and full version
126 * 25 4/10/98 12:47p Allender
127 * changed working on replay popup. Don't reference repair in comm menu.
128 * Added Shift-R for repair me
130 * 24 4/08/98 11:11a Hoffoss
131 * Fixed some bugs that showed up due to fixing other bugs the other day
134 * 23 4/07/98 4:06p Lawrance
135 * Change binding next for bomb targeting
137 * 22 4/07/98 1:52p Lawrance
138 * fix error in binding text for energy keys
140 * 21 4/06/98 11:17a Hoffoss
141 * Fixed num lock/pause interplay bug.
143 * 20 4/01/98 6:46p Lawrance
144 * change text for Alt+J
146 * 19 3/31/98 4:15p Hoffoss
147 * Disabled the show objectives action.
149 * 18 3/25/98 2:16p Dave
150 * Select random default image for newly created pilots. Fixed several
151 * multi-pause messaging bugs. Begin work on online help for multiplayer
154 * 17 3/19/98 5:04p Dave
155 * Put in support for targeted multiplayer text and voice messaging (all,
156 * friendly, hostile, individual).
158 * 16 3/17/98 11:25a Hoffoss
159 * Fixed some of the action's names.
161 * 15 3/17/98 10:48a Hoffoss
162 * Allowed a special hack for "bank while pressed" action to use alt and
163 * shift keys standalone.
165 * 14 2/28/98 9:47p Lawrance
166 * change some binding text
168 * 13 2/28/98 7:02p Lawrance
169 * overhaul on-line help
171 * 12 2/26/98 12:33a Lawrance
172 * Added back slew mode, lots of changes to external and chase views.
174 * 11 2/23/98 11:25a Sandeep
177 * 10 2/22/98 6:27p Lawrance
178 * External mode takes precedence over chase mode. Fix bug with repair
179 * ships docking in chase mode.
181 * 9 2/22/98 12:19p John
182 * Externalized some strings
184 * 8 2/02/98 6:59p Lawrance
185 * Adding new targeting keys (bomb, uninspected cargo, new ship, live
188 * 7 1/27/98 4:24p Allender
189 * moved hotkey selection to F3 instead of X. Made palette flash
190 * disappear in multiplayer pause menu
192 * 6 1/22/98 4:53p Hoffoss
193 * Made training messages/directives display a joystick button in place of
194 * a keypress if there is no keypress bound to the action.
196 * 5 1/22/98 4:15p Hoffoss
197 * Added code to allow popup to tell player he needs to bind a key for the
200 * 4 1/02/98 4:42p Allender
201 * removed unused key bindings from control config list
203 * 3 12/30/97 4:47p Allender
204 * work with ignore my target command. Added new keyboard hotkey. Made
207 * 2 12/24/97 3:37p Hoffoss
208 * Moved control config stuff to seperate library to Fred can access it as
211 * 1 12/24/97 3:27p Hoffoss
213 * 1 12/24/97 11:58a Hoffoss
215 * 98 12/22/97 2:15p Hoffoss
216 * Fixed bug where joystick axis lines weren't being displayed.
218 * 97 12/16/97 2:44p Hoffoss
219 * Added clear button to control config screen.
221 * 96 12/12/97 3:07p Hoffoss
222 * Changed how deleting bindings work. Each control of an action can be
223 * deleted independently or both at once.
225 * 95 12/07/97 2:36p John
226 * Made warp out be Alt+J instead of J
228 * 94 12/03/97 4:59p Hoffoss
229 * Added reset sound and change control config sounds around.
231 * 93 12/03/97 4:16p Hoffoss
232 * Changed sound stuff used in interface screens for interface purposes.
234 * 92 12/01/97 5:25p Hoffoss
235 * Routed interface sound playing through a special function that will
236 * only allow one instance of the sound to play at a time, avoiding
237 * over-mixing problems.
239 * 91 12/01/97 3:38p Hoffoss
240 * Changed placement of 'More' indicator.
242 * 90 11/25/97 3:49p Hoffoss
243 * Changed subhilighting to happen when mouse is over line, rather than
244 * mouse button down but not up again yet.
246 * 89 11/24/97 10:20p Lawrance
247 * Add key 'KEY_N' to target next ship on monitoring view
249 * 88 11/24/97 6:15p Lawrance
250 * fix button scroll problem
252 * 87 11/23/97 6:15p Hoffoss
253 * Make exiting the controls config screen save the pilot, so changes keep
254 * even if programs crashes or something.
256 * 86 11/21/97 5:57p Hoffoss
257 * Fixed bug where timef type controls weren't checking joystick buttons.
259 * 85 11/21/97 4:06p Hoffoss
260 * Fixed bug with enabling of axis are reversed.
262 * 84 11/20/97 4:47p Hoffoss
263 * Swapped throttle and rudder, which apparently were backwards.
265 * 83 11/20/97 4:00p Lawrance
266 * set z to a valid value
268 * 82 11/20/97 3:52p Hoffoss
269 * Made "None" appear if no control is bound to function.
271 * 81 11/20/97 2:10p Hoffoss
272 * Added defaults for joystick buttons 2 and 3.
274 * 80 11/20/97 1:08a Lawrance
275 * add support for 'R' key - target closest friendly repair ship
277 * 79 11/19/97 8:33p Hoffoss
278 * New controls config screen baby!
280 * 78 11/17/97 7:09p Hoffoss
281 * Made chase view control a trigger type.
283 * 77 11/17/97 6:40p Lawrance
284 * Changed 'I' key to toggle of extended target info, moved target closest
285 * locked missile to 'L'
287 * 76 11/17/97 3:26p Jasen
288 * Adjusted coordinates for the help button .ani location
290 * 75 11/16/97 3:51p Hoffoss
291 * Added more button to config screen when scrolling allowed.
293 * 74 11/16/97 3:20p Hoffoss
294 * Added various suggestions from the Todolist.
296 * 73 11/14/97 4:33p Mike
297 * Change Debug key to backquote (from F11).
298 * Balance a ton of subsystems in ships.tbl.
299 * Change "Heavy Laser" to "Disruptor".
301 * 72 11/12/97 2:54p Hoffoss
302 * Made modifiers non-stand alone, added support for red tabs on
305 * 71 10/30/97 6:01p Hoffoss
306 * Changed screen to utilize the new text color standards.
308 * 70 10/29/97 7:25p Hoffoss
309 * Added crude support for UI button double click checking.
311 * 69 10/29/97 6:32p Hoffoss
312 * Changed some interface apperances.
314 * 68 10/29/97 4:54p Hoffoss
315 * Changed scan_code_text element for Enter to 'Enter' instead of 'a' with
316 * a caret over it (what's that all about?)
318 * 67 10/28/97 10:42a Hoffoss
319 * Fixed handling of continuous controls that have modifiers to the key.
321 * 66 10/28/97 10:03a Hoffoss
322 * Fixed bug with continuous type controls not registering if pressed and
323 * released too quickly. Also some other little changes.
325 * 65 10/28/97 12:12a Lawrance
326 * remove unused keys (Alt-H and Alt-F)
328 * 64 10/27/97 12:23p Hoffoss
329 * Improved warning system and fixed coloring bug.
331 * 63 10/27/97 11:39a Hoffoss
332 * Added control conflicts checking.
334 * 62 10/26/97 3:20p Hoffoss
335 * Added many missing features to control config screen.
337 * 61 10/25/97 5:41p Hoffoss
338 * More functionality added to the controls config screen.
340 * 60 10/24/97 11:00p Hoffoss
341 * Controls config screen much improved.
343 * 59 10/22/97 4:50p Hoffoss
344 * Disabled throttle by default.
346 * 58 10/22/97 11:00a Hoffoss
347 * Changed VIEW_SLEW and VIEW_EXTERNAL to be continuous rather than
350 * 57 10/21/97 7:05p Hoffoss
351 * Overhauled the key/joystick control structure and usage throughout the
352 * entire FreeSpace code. The whole system is very different now.
354 * 56 10/18/97 7:19p Hoffoss
355 * Added timestamp recording when a key is pressed.
357 * 55 10/13/97 4:33p Hoffoss
358 * Made training messages go away after time.
360 * 54 10/13/97 3:24p Hoffoss
361 * Made it so training message text can be arbitrarily bolded.
363 * 53 9/24/97 4:52p Hoffoss
364 * Changed training message key token handling, and implemented a new
365 * training message system method to test out for a while.
367 * 52 9/14/97 10:24p Lawrance
368 * add damage screen popup window
370 * 51 9/10/97 6:02p Hoffoss
371 * Added code to check for key-pressed sexp operator in FreeSpace as part
372 * of training mission stuff.
374 * 50 9/09/97 3:39p Sandeep
375 * warning level 4 bugs
380 #include "controlsconfig.h"
383 #include "localize.h"
388 #define COMPUTER_TAB 3
390 int Failed_key_index;
392 // assume control keys are used as modifiers until we find out
393 int Shift_is_modifier;
394 int Ctrl_is_modifier;
397 int Axis_enabled[JOY_NUM_AXES] = { 1, 1, 1, 0, 0, 0 };
398 int Axis_enabled_defaults[JOY_NUM_AXES] = { 1, 1, 1, 0, 0, 0 };
399 int Invert_axis[JOY_NUM_AXES] = { 0, 0, 0, 0, 0, 0 };
400 int Invert_axis_defaults[JOY_NUM_AXES] = { 0, 0, 0, 0, 0, 0 };
402 // arrays which hold the key mappings. The array index represents a key-independent action.
405 config_item Control_config[CCFG_MAX + 1] = {
407 { KEY_T, -1, TARGET_TAB, "Target Next Ship" },
408 { KEY_SHIFTED | KEY_T, -1, TARGET_TAB, "Target Previous Ship" },
409 { KEY_H, 2, TARGET_TAB, "Target Next Closest Hostile Ship" },
410 { KEY_SHIFTED | KEY_H, -1, TARGET_TAB, "Target Previous Closest Hostile Ship" },
411 { KEY_ALTED | KEY_H, -1, TARGET_TAB, "Toggle Auto Targeting" },
412 { KEY_F, -1, TARGET_TAB, "Target Next Closest Friendly Ship" },
413 { KEY_SHIFTED | KEY_F, -1, TARGET_TAB, "Target Previous Closest Friendly Ship" },
414 { KEY_Y, 4, TARGET_TAB, "Target Ship in Reticle" },
415 { KEY_G, -1, TARGET_TAB, "Target Target's Nearest Attacker" },
416 { KEY_ALTED | KEY_Y, -1, TARGET_TAB, "Target Last Ship to Send Transmission" },
417 { KEY_ALTED | KEY_T, -1, TARGET_TAB, "Turn Off Auto-Targeting" },
419 // targeting a ship's subsystem
420 { KEY_V, -1, TARGET_TAB, "Target Subsystem in Reticle" },
421 { KEY_S, -1, TARGET_TAB, "Target Next Subsystem" },
422 { KEY_SHIFTED | KEY_S, -1, TARGET_TAB, "Target Previous Subsystem" },
423 { KEY_ALTED | KEY_S, -1, TARGET_TAB, "Turn Off Auto-Targeting of Subsystems" },
426 { KEY_M, -1, COMPUTER_TAB, "Match Target Speed" },
427 { KEY_ALTED | KEY_M, -1, COMPUTER_TAB, "Toggle Auto Speed Matching" },
430 { KEY_LCTRL, 0, WEAPON_TAB, "Fire Primary Weapon", CC_TYPE_CONTINUOUS },
431 { KEY_SPACEBAR, 1, WEAPON_TAB, "Fire Secondary Weapon", CC_TYPE_CONTINUOUS },
432 { KEY_PERIOD, -1, WEAPON_TAB, "Cycle Forward Primary Weapon" },
433 { KEY_COMMA, -1, WEAPON_TAB, "Cycle Backward Primary Weapon" },
434 { KEY_DIVIDE, -1, WEAPON_TAB, "Cycle Secondary Weapon Bank" },
435 { KEY_SHIFTED | KEY_DIVIDE, -1, WEAPON_TAB, "Cycle Secondary Weapon Firing Rate" },
436 { KEY_X, 3, WEAPON_TAB, "Launch Countermeasure" },
439 { KEY_A, -1, SHIP_TAB, "Forward Thrust", CC_TYPE_CONTINUOUS },
440 { KEY_Z, -1, SHIP_TAB, "Reverse Thrust", CC_TYPE_CONTINUOUS },
441 { KEY_PAD7, -1, SHIP_TAB, "Bank Left", CC_TYPE_CONTINUOUS },
442 { KEY_PAD9, -1, SHIP_TAB, "Bank Right", CC_TYPE_CONTINUOUS },
443 { KEY_PAD8, -1, SHIP_TAB, "Pitch Forward", CC_TYPE_CONTINUOUS },
444 { KEY_PAD2, -1, SHIP_TAB, "Pitch Backward", CC_TYPE_CONTINUOUS },
445 { KEY_PAD4, -1, SHIP_TAB, "Turn Left", CC_TYPE_CONTINUOUS },
446 { KEY_PAD6, -1, SHIP_TAB, "Turn Right", CC_TYPE_CONTINUOUS },
449 { KEY_BACKSP, -1, SHIP_TAB, "Set Throttle to Zero" },
450 { KEY_SLASH, -1, SHIP_TAB, "Set Throttle to Max" },
451 { KEY_LBRACKET, -1, SHIP_TAB, "Set Throttle to One-Third" },
452 { KEY_RBRACKET, -1, SHIP_TAB, "Set Throttle to Two-Thirds" },
453 { KEY_EQUAL, -1, SHIP_TAB, "Increase Throttle 5 Percent" },
454 { KEY_MINUS, -1, SHIP_TAB, "Decrease Throttle 5 Percent" },
456 // squadmate messaging
457 { KEY_SHIFTED | KEY_A, -1, COMPUTER_TAB, "Attack My Target" },
458 { KEY_SHIFTED | KEY_Z, -1, COMPUTER_TAB, "Disarm My Target" },
459 { KEY_SHIFTED | KEY_D, -1, COMPUTER_TAB, "Disable My Target" },
460 { KEY_SHIFTED | KEY_V, -1, COMPUTER_TAB, "Attack my Subsystem" },
461 { KEY_SHIFTED | KEY_X, -1, COMPUTER_TAB, "Capture My Target" },
462 { KEY_SHIFTED | KEY_E, -1, COMPUTER_TAB, "Engage Enemy" },
463 { KEY_SHIFTED | KEY_W, -1, COMPUTER_TAB, "Form on my Wing" },
464 { KEY_SHIFTED | KEY_I, -1, COMPUTER_TAB, "Ignore my Target" },
465 { KEY_SHIFTED | KEY_P, -1, COMPUTER_TAB, "Protect my Target" },
466 { KEY_SHIFTED | KEY_C, -1, COMPUTER_TAB, "Cover me" },
467 { KEY_SHIFTED | KEY_J, -1, COMPUTER_TAB, "Return to base" },
468 { KEY_SHIFTED | KEY_R, -1, COMPUTER_TAB, "Rearm me" },
470 { KEY_R, 6, TARGET_TAB, "Target Closest Attacking Ship" },
473 { KEY_PADMULTIPLY, -1, COMPUTER_TAB, "Chase View" },
474 { KEY_PADPERIOD, -1, COMPUTER_TAB, "External View"},
475 { KEY_PADENTER, -1, COMPUTER_TAB, "Toggle External Camera Lock"},
476 { KEY_PAD0, -1, COMPUTER_TAB, "Free Look View", CC_TYPE_CONTINUOUS },
477 { KEY_PADDIVIDE, -1, COMPUTER_TAB, "Current Target View" },
478 { KEY_PADPLUS, -1, COMPUTER_TAB, "Increase View Distance", CC_TYPE_CONTINUOUS },
479 { KEY_PADMINUS, -1, COMPUTER_TAB, "Decrease View Distance", CC_TYPE_CONTINUOUS },
480 { KEY_PAD5, -1, COMPUTER_TAB, "Center View", CC_TYPE_CONTINUOUS },
481 { -1, 33, COMPUTER_TAB, "View Up", CC_TYPE_CONTINUOUS },
482 { -1, 32, COMPUTER_TAB, "View Rear", CC_TYPE_CONTINUOUS },
483 { -1, 34, COMPUTER_TAB, "View Left", CC_TYPE_CONTINUOUS },
484 { -1, 35, COMPUTER_TAB, "View Right", CC_TYPE_CONTINUOUS },
486 { KEY_RAPOSTRO, -1, COMPUTER_TAB, "Cycle Radar Range" },
487 { KEY_C, -1, COMPUTER_TAB, "Communications Menu" },
488 { -1, -1, -1, "Show Objectives" },
489 { KEY_ALTED | KEY_J, -1, COMPUTER_TAB, "Enter Subspace (End Mission)" },
490 { KEY_J, -1, TARGET_TAB, "Target Target's Target" },
491 { KEY_TAB, 5, SHIP_TAB, "Afterburner", CC_TYPE_CONTINUOUS },
493 { KEY_INSERT, -1, COMPUTER_TAB, "Increase Weapon Energy" },
494 { KEY_DELETE, -1, COMPUTER_TAB, "Decrease Weapon Energy" },
495 { KEY_HOME, -1, COMPUTER_TAB, "Increase Shield Energy" },
496 { KEY_END, -1, COMPUTER_TAB, "Decrease Shield Energy" },
497 { KEY_PAGEUP, -1, COMPUTER_TAB, "Increase Engine Energy" },
498 { KEY_PAGEDOWN, -1, COMPUTER_TAB, "Decrease Engine Energy" },
499 { KEY_ALTED | KEY_D, -1, COMPUTER_TAB, "Equalize Energy Settings" },
501 { KEY_Q, 7, COMPUTER_TAB, "Equalize Shield" },
502 { KEY_UP, -1, COMPUTER_TAB, "Augment Forward Shield" },
503 { KEY_DOWN, -1, COMPUTER_TAB, "Augment Rear Shield" },
504 { KEY_LEFT, -1, COMPUTER_TAB, "Augment Left Shield" },
505 { KEY_RIGHT, -1, COMPUTER_TAB, "Augment Right Shield" },
506 { KEY_SCROLLOCK, -1, COMPUTER_TAB, "Transfer Energy Laser->Shield" },
507 { KEY_SHIFTED | KEY_SCROLLOCK, -1, COMPUTER_TAB, "Transfer Energy Shield->Laser" },
508 { -1, -1, -1, "Show Damage Popup Window" },
510 { -1, -1, SHIP_TAB, "Bank When Pressed", CC_TYPE_CONTINUOUS },
511 { -1, -1, -1, "Show NavMap" },
512 { KEY_ALTED | KEY_E, -1, COMPUTER_TAB, "Add or Remove Escort" },
513 { KEY_ALTED | KEY_SHIFTED | KEY_E, -1, COMPUTER_TAB, "Clear Escort List" },
514 { KEY_E, -1, TARGET_TAB, "Target Next Escort Ship" },
515 { KEY_ALTED | KEY_R, -1, TARGET_TAB, "Target Closest Repair Ship" },
517 { KEY_U, -1, TARGET_TAB, "Target Next Uninspected Cargo" },
518 { KEY_SHIFTED | KEY_U, -1, TARGET_TAB, "Target Previous Uninspected Cargo" },
519 { KEY_N, -1, TARGET_TAB, "Target Newest Ship In Area" },
520 { KEY_K, -1, TARGET_TAB, "Target Next Live Turret" },
521 { KEY_SHIFTED | KEY_K, -1, TARGET_TAB, "Target Previous Live Turret" },
523 { KEY_B, -1, TARGET_TAB, "Target Next Hostile Bomb or Bomber" },
524 { KEY_SHIFTED | KEY_B, -1, TARGET_TAB, "Target Previous Hostile Bomb or Bomber" },
526 // multiplayer messaging keys
527 { KEY_1, -1, COMPUTER_TAB, "(Multiplayer) Message All", CC_TYPE_CONTINUOUS },
528 { KEY_2, -1, COMPUTER_TAB, "(Multiplayer) Message Friendly", CC_TYPE_CONTINUOUS },
529 { KEY_3, -1, COMPUTER_TAB, "(Multiplayer) Message Hostile", CC_TYPE_CONTINUOUS },
530 { KEY_4, -1, COMPUTER_TAB, "(Multiplayer) Message Target", CC_TYPE_CONTINUOUS },
531 { KEY_ALTED | KEY_X, -1, COMPUTER_TAB, "(Multiplayer) Observer zoom to target"},
533 { KEY_SHIFTED | KEY_PERIOD, -1, COMPUTER_TAB, "Increase time compression" },
534 { KEY_SHIFTED | KEY_COMMA, -1, COMPUTER_TAB, "Decrease time compression" },
536 { KEY_L, -1, COMPUTER_TAB, "Toggle high HUD contrast" },
538 { KEY_SHIFTED | KEY_N, -1, COMPUTER_TAB, "(Multiplayer) Toggle network info"},
539 { KEY_SHIFTED | KEY_END, -1, COMPUTER_TAB, "(Multiplayer) Self destruct"},
544 char *Scan_code_text_german[] = {
545 "", "Esc", "1", "2", "3", "4", "5", "6",
546 "7", "8", "9", "0", "Akzent '", "\xE1", "R\x81""cktaste", "Tab",
547 "Q", "W", "E", "R", "T", "Z", "U", "I",
548 "O", "P", "\x9A", "+", "Eingabe", "Strg Links", "A", "S",
550 "D", "F", "G", "H", "J", "K", "L", "\x99",
551 "\xAE", "`", "Shift", "#", "Y", "X", "C", "V",
552 "B", "N", "M", ",", ".", "-", "Shift", "Num *",
553 "Alt", "Leertaste", "Hochstell", "F1", "F2", "F3", "F4", "F5",
555 "F6", "F7", "F8", "F9", "F10", "Pause", "Rollen", "Num 7",
556 "Num 8", "Num 9", "Num -", "Num 4", "Num 5", "Num 6", "Num +", "Num 1",
557 "Num 2", "Num 3", "Num 0", "Num ,", "", "", "", "F11",
558 "F12", "", "", "", "", "", "", "",
560 "", "", "", "", "", "", "", "",
561 "", "", "", "", "", "", "", "",
562 "", "", "", "", "", "", "", "",
563 "", "", "", "", "", "", "", "",
565 "", "", "", "", "", "", "", "",
566 "", "", "", "", "", "", "", "",
567 "", "", "", "", "", "", "", "",
568 "", "", "", "", "Num Eingabe", "Strg Rechts", "", "",
570 "", "", "", "", "", "", "", "",
571 "", "", "", "", "", "", "", "",
572 "", "", "", "", "", "Num /", "", "Druck",
573 "Alt", "", "", "", "", "", "", "",
575 "", "", "", "", "", "Num Lock", "", "Pos 1",
576 "Pfeil Hoch", "Bild Hoch", "", "Pfeil Links", "", "Pfeil Rechts", "", "Ende",
577 "Pfeil Runter", "Bild Runter", "Einfg", "Entf", "", "", "", "",
578 "", "", "", "", "", "", "", "",
580 "", "", "", "", "", "", "", "",
581 "", "", "", "", "", "", "", "",
582 "", "", "", "", "", "", "", "",
583 "", "", "", "", "", "", "", "",
586 char *Joy_button_text_german[] = {
587 "Knopf 1", "Knopf 2", "Knopf 3", "Knopf 4", "Knopf 5", "Knopf 6",
588 "Knopf 7", "Knopf 8", "Knopf 9", "Knopf 10", "Knopf 11", "Knopf 12",
589 "Knopf 13", "Knopf 14", "Knopf 15", "Knopf 16", "Knopf 17", "Knopf 18",
590 "Knopf 19", "Knopf 20", "Knopf 21", "Knopf 22", "Knopf 23", "Knopf 24",
591 "Knopf 25", "Knopf 26", "Knopf 27", "Knopf 28", "Knopf 29", "Knopf 30",
592 "Knopf 31", "Knopf 32", "Hut Hinten", "Hut Vorne", "Hut Links", "Hut Rechts"
595 char *Scan_code_text_french[] = {
596 "", "\x90""chap", "1", "2", "3", "4", "5", "6",
597 "7", "8", "9", "0", "-", "=", "Fl\x82""che Ret.", "Tab",
598 "Q", "W", "E", "R", "T", "Y", "U", "I",
599 "O", "P", "[", "]", "Entr\x82""e", "Ctrl Gauche", "A", "S",
601 "D", "F", "G", "H", "J", "K", "L", ";",
602 "'", "`", "Maj.", "\\", "Z", "X", "C", "V",
603 "B", "N", "M", ",", ".", "/", "Maj.", "Pav\x82 *",
604 "Alt", "Espace", "Verr. Maj.", "F1", "F2", "F3", "F4", "F5",
606 "F6", "F7", "F8", "F9", "F10", "Pause", "Arret defil", "Pav\x82 7",
607 "Pav\x82 8", "Pav\x82 9", "Pav\x82 -", "Pav\x82 4", "Pav\x82 5", "Pav\x82 6", "Pav\x82 +", "Pav\x82 1",
608 "Pav\x82 2", "Pav\x82 3", "Pav\x82 0", "Pav\x82 .", "", "", "", "F11",
609 "F12", "", "", "", "", "", "", "",
611 "", "", "", "", "", "", "", "",
612 "", "", "", "", "", "", "", "",
613 "", "", "", "", "", "", "", "",
614 "", "", "", "", "", "", "", "",
616 "", "", "", "", "", "", "", "",
617 "", "", "", "", "", "", "", "",
618 "", "", "", "", "", "", "", "",
619 "", "", "", "", "Pav\x82 Entr", "Ctrl Droite", "", "",
621 "", "", "", "", "", "", "", "",
622 "", "", "", "", "", "", "", "",
623 "", "", "", "", "", "Pav\x82 /", "", "Impr \x82""cran",
624 "Alt", "", "", "", "", "", "", "",
626 "", "", "", "", "", "Verr num", "", "Orig.",
627 "Fl\x82""che Haut", "Page Haut", "", "Fl\x82""che Gauche", "", "Fl\x82""che Droite", "", "Fin",
628 "Fl\x82""che Bas", "Page Bas", "Inser", "Suppr", "", "", "", "",
629 "", "", "", "", "", "", "", "",
631 "", "", "", "", "", "", "", "",
632 "", "", "", "", "", "", "", "",
633 "", "", "", "", "", "", "", "",
634 "", "", "", "", "", "", "", "",
637 char *Joy_button_text_french[] = {
638 "Bouton 1", "Bouton 2", "Bouton 3", "Bouton 4", "Bouton 5", "Bouton 6",
639 "Bouton 7", "Bouton 8", "Bouton 9", "Bouton 10", "Bouton 11", "Bouton 12",
640 "Bouton 13", "Bouton 14", "Bouton 15", "Bouton 16", "Bouton 17", "Bouton 18",
641 "Bouton 19", "Bouton 20", "Bouton 21", "Bouton 22", "Bouton 23", "Bouton 24",
642 "Bouton 25", "Bouton 26", "Bouton 27", "Bouton 28", "Bouton 29", "Bouton 30",
643 "Bouton 31", "Bouton 32", "Chapeau Arrière", "Chapeau Avant", "Chapeau Gauche", "Chapeau Droite"
646 // This is the text that is displayed on the screen for the keys a player selects
647 char *Scan_code_text_english[] = {
648 "", "Esc", "1", "2", "3", "4", "5", "6",
649 "7", "8", "9", "0", "-", "=", "Backspace", "Tab",
650 "Q", "W", "E", "R", "T", "Y", "U", "I",
651 "O", "P", "[", "]", "Enter", "Left Ctrl", "A", "S",
653 "D", "F", "G", "H", "J", "K", "L", ";",
654 "'", "`", "Shift", "\\", "Z", "X", "C", "V",
655 "B", "N", "M", ",", ".", "/", "Shift", "Pad *",
656 "Alt", "Spacebar", "Caps Lock", "F1", "F2", "F3", "F4", "F5",
658 "F6", "F7", "F8", "F9", "F10", "Pause", "Scroll Lock", "Pad 7",
659 "Pad 8", "Pad 9", "Pad -", "Pad 4", "Pad 5", "Pad 6", "Pad +", "Pad 1",
660 "Pad 2", "Pad 3", "Pad 0", "Pad .", "", "", "", "F11",
661 "F12", "", "", "", "", "", "", "",
663 "", "", "", "", "", "", "", "",
664 "", "", "", "", "", "", "", "",
665 "", "", "", "", "", "", "", "",
666 "", "", "", "", "", "", "", "",
668 "", "", "", "", "", "", "", "",
669 "", "", "", "", "", "", "", "",
670 "", "", "", "", "", "", "", "",
671 "", "", "", "", "Pad Enter", "Right Ctrl", "", "",
673 "", "", "", "", "", "", "", "",
674 "", "", "", "", "", "", "", "",
675 "", "", "", "", "", "Pad /", "", "Print Scrn",
676 "Alt", "", "", "", "", "", "", "",
678 "", "", "", "", "", "Num Lock", "", "Home",
679 "Up Arrow", "Page Up", "", "Left Arrow", "", "Right Arrow", "", "End",
680 "Down Arrow", "Page Down", "Insert", "Delete", "", "", "", "",
681 "", "", "", "", "", "", "", "",
683 "", "", "", "", "", "", "", "",
684 "", "", "", "", "", "", "", "",
685 "", "", "", "", "", "", "", "",
686 "", "", "", "", "", "", "", "",
689 char *Joy_button_text_english[] = {
690 "Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6",
691 "Button 7", "Button 8", "Button 9", "Button 10", "Button 11", "Button 12",
692 "Button 13", "Button 14", "Button 15", "Button 16", "Button 17", "Button 18",
693 "Button 19", "Button 20", "Button 21", "Button 22", "Button 23", "Button 24",
694 "Button 25", "Button 26", "Button 27", "Button 28", "Button 29", "Button 30",
695 "Button 31", "Button 32", "Hat Back", "Hat Forward", "Hat Left", "Hat Right"
698 char **Scan_code_text = Scan_code_text_english;
699 char **Joy_button_text = Joy_button_text_english;
701 void set_modifier_status()
706 Shift_is_modifier = 0;
707 Ctrl_is_modifier = 0;
709 for (i=0; i<CCFG_MAX; i++) {
710 if (Control_config[i].key_id < 0)
713 if (Control_config[i].key_id & KEY_ALTED)
716 if (Control_config[i].key_id & KEY_SHIFTED)
717 Shift_is_modifier = 1;
719 if (Control_config[i].key_id & KEY_CTRLED) {
720 Assert(0); // get Alan
721 Ctrl_is_modifier = 1;
726 int translate_key_to_index(char *key)
728 int i, index = -1, alt = 0, shift = 0, max_scan_codes;
731 max_scan_codes = sizeof(Scan_code_text_german) / sizeof(char *);
733 max_scan_codes = sizeof(Scan_code_text_french) / sizeof(char *);
735 max_scan_codes = sizeof(Scan_code_text_english) / sizeof(char *);
738 // look for modifiers
740 if (!strnicmp(key, "Alt", 3)) {
747 char *translated_shift;
750 translated_shift = "Shift";
752 translated_shift = "Maj.";
754 translated_shift = "Shift";
757 if (!strnicmp(key, translated_shift, 5)) {
764 // look up index for default key
766 for (i=0; i<max_scan_codes; i++)
767 if (!stricmp(key, Scan_code_text_english[i])) {
772 if (i == max_scan_codes)
776 index |= KEY_SHIFTED;
780 // convert scancode to Control_config index
781 for (i=0; i<CCFG_MAX; i++) {
782 if (Control_config[i].key_default == index) {
797 // Given the system default key 'key', return the current key that is bound to the function
798 // Both are 'key' and the return value are descriptive strings that can be displayed
799 // directly to the user. If 'key' isn't a real key or not normally bound to anything,
800 // or there is no key current bound to the function, NULL is returned.
801 char *translate_key(char *key)
803 int index = -1, code = -1;
805 index = translate_key_to_index(key);
809 code = Control_config[index].key_id;
810 Failed_key_index = index;
812 code = Control_config[index].joy_id;
814 return Joy_button_text[code];
817 return textify_scancode(code);
820 char *textify_scancode(int code)
822 static char text[40];
828 if (code & KEY_ALTED) {
830 strcat(text, "Alt-");
832 strcat(text, "Alt-");
834 strcat(text, "Alt-");
838 if (code & KEY_SHIFTED) {
840 strcat(text, "Shift-");
842 strcat(text, "Maj.-");
844 strcat(text, "Shift-");
848 strcat(text, Scan_code_text[code & KEY_MASK]);
853 // initialize common control config stuff - call at game startup after localization has been initialized
854 void control_config_common_init()
857 Scan_code_text = Scan_code_text_german;
858 Joy_button_text = Joy_button_text_german;
860 // swap init bindings for y and z keys
861 Control_config[TARGET_SHIP_IN_RETICLE].key_default = KEY_Z;
862 Control_config[TARGET_LAST_TRANMISSION_SENDER].key_default = KEY_ALTED | KEY_Z;
863 Control_config[REVERSE_THRUST].key_default = KEY_Y;
864 Control_config[DISARM_MESSAGE].key_default = KEY_SHIFTED | KEY_Y;
866 Scan_code_text = Scan_code_text_french;
867 Joy_button_text = Joy_button_text_french;
869 Scan_code_text = Scan_code_text_english;
870 Joy_button_text = Joy_button_text_english;