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.5 2003/06/03 04:00:39 taylor
19 * Polish language support (Janusz Dziemidowicz)
21 * Revision 1.4 2003/05/25 02:30:42 taylor
24 * Revision 1.3 2002/06/09 04:41:15 relnev
25 * added copyright header
27 * Revision 1.2 2002/05/07 03:16:43 theoddone33
28 * The Great Newline Fix
30 * Revision 1.1.1.1 2002/05/03 03:28:08 root
34 * 14 11/01/99 3:36p Jefff
35 * had scan code texts for y and z in german swapped
37 * 13 11/01/99 2:16p Jefff
38 * minor key name change in german
40 * 12 10/29/99 6:10p Jefff
41 * squashed the damned y/z german issues once and for all
43 * 11 10/28/99 11:16p Jefff
44 * Changed some german key names. Made key translations always use the
47 * 10 10/28/99 2:05a Jefff
48 * revised some german key names. changed some y/z switch stuff.
50 * 9 10/25/99 5:39p Jefff
51 * swap init binding for y and z keys in German builds
53 * 8 9/01/99 2:56p Jefff
54 * a few control key description changes
56 * 7 8/22/99 5:53p Dave
57 * Scoring fixes. Added self destruct key. Put callsigns in the logfile
58 * instead of ship designations for multiplayer players.
60 * 6 8/19/99 10:59a Dave
61 * Packet loss detection.
63 * 5 8/01/99 12:39p Dave
64 * Added HUD contrast control key (for nebula).
66 * 4 7/23/99 2:57p Andsager
67 * fix translate_key_to_index to work with localization
69 * 3 11/05/98 4:18p Dave
70 * First run nebula support. Beefed up localization a bit. Removed all
71 * conditional compiles for foreign versions. Modified mission file
74 * 2 10/07/98 10:52a Dave
77 * 1 10/07/98 10:48a Dave
79 * 41 6/19/98 3:51p Lawrance
80 * localize control text
82 * 40 6/17/98 11:05a Lawrance
83 * localize the control config strings
85 * 39 5/24/98 2:28p Hoffoss
86 * Because we never really care about if the left or the right shift or
87 * alt key was used, but rather than either shift or alt was used, made
88 * both map to the left one. Solves some problems, causes none.
90 * 38 5/22/98 11:21a Hoffoss
91 * Added bank when pressed back in.
93 * 37 5/15/98 8:37p Lawrance
94 * Add 'equalize recharge rates' and 'target ship that sent last
95 * transmission' key bindings
97 * 36 5/13/98 7:15p Hoffoss
98 * Fixed remaining bugs with axis binding.
100 * 35 5/13/98 1:17a Hoffoss
101 * Added joystick axes configurability.
103 * 34 5/12/98 11:25a Hoffoss
104 * Disabled bank when pressed action.
106 * 33 5/09/98 10:48p Lawrance
107 * change text for view bindings
109 * 32 5/09/98 4:52p Lawrance
110 * Implement padlock view (up/rear/left/right)
112 * 31 4/30/98 9:43p Hoffoss
113 * Added new actions for free look movement which are default bounded to
116 * 30 4/25/98 1:25p Lawrance
117 * Add time compression keys to key config
119 * 29 4/25/98 12:43p Allender
120 * added new shortcut key for attack my subsystem
122 * 28 4/18/98 5:00p Dave
123 * Put in observer zoom key. Made mission sync screen more informative.
125 * 27 4/17/98 1:24a Lawrance
128 * 26 4/15/98 11:06a Lawrance
129 * fix bug with a multi key showing up in demo, remove obsolete bindings
130 * from demo and full version
132 * 25 4/10/98 12:47p Allender
133 * changed working on replay popup. Don't reference repair in comm menu.
134 * Added Shift-R for repair me
136 * 24 4/08/98 11:11a Hoffoss
137 * Fixed some bugs that showed up due to fixing other bugs the other day
140 * 23 4/07/98 4:06p Lawrance
141 * Change binding next for bomb targeting
143 * 22 4/07/98 1:52p Lawrance
144 * fix error in binding text for energy keys
146 * 21 4/06/98 11:17a Hoffoss
147 * Fixed num lock/pause interplay bug.
149 * 20 4/01/98 6:46p Lawrance
150 * change text for Alt+J
152 * 19 3/31/98 4:15p Hoffoss
153 * Disabled the show objectives action.
155 * 18 3/25/98 2:16p Dave
156 * Select random default image for newly created pilots. Fixed several
157 * multi-pause messaging bugs. Begin work on online help for multiplayer
160 * 17 3/19/98 5:04p Dave
161 * Put in support for targeted multiplayer text and voice messaging (all,
162 * friendly, hostile, individual).
164 * 16 3/17/98 11:25a Hoffoss
165 * Fixed some of the action's names.
167 * 15 3/17/98 10:48a Hoffoss
168 * Allowed a special hack for "bank while pressed" action to use alt and
169 * shift keys standalone.
171 * 14 2/28/98 9:47p Lawrance
172 * change some binding text
174 * 13 2/28/98 7:02p Lawrance
175 * overhaul on-line help
177 * 12 2/26/98 12:33a Lawrance
178 * Added back slew mode, lots of changes to external and chase views.
180 * 11 2/23/98 11:25a Sandeep
183 * 10 2/22/98 6:27p Lawrance
184 * External mode takes precedence over chase mode. Fix bug with repair
185 * ships docking in chase mode.
187 * 9 2/22/98 12:19p John
188 * Externalized some strings
190 * 8 2/02/98 6:59p Lawrance
191 * Adding new targeting keys (bomb, uninspected cargo, new ship, live
194 * 7 1/27/98 4:24p Allender
195 * moved hotkey selection to F3 instead of X. Made palette flash
196 * disappear in multiplayer pause menu
198 * 6 1/22/98 4:53p Hoffoss
199 * Made training messages/directives display a joystick button in place of
200 * a keypress if there is no keypress bound to the action.
202 * 5 1/22/98 4:15p Hoffoss
203 * Added code to allow popup to tell player he needs to bind a key for the
206 * 4 1/02/98 4:42p Allender
207 * removed unused key bindings from control config list
209 * 3 12/30/97 4:47p Allender
210 * work with ignore my target command. Added new keyboard hotkey. Made
213 * 2 12/24/97 3:37p Hoffoss
214 * Moved control config stuff to seperate library to Fred can access it as
217 * 1 12/24/97 3:27p Hoffoss
219 * 1 12/24/97 11:58a Hoffoss
221 * 98 12/22/97 2:15p Hoffoss
222 * Fixed bug where joystick axis lines weren't being displayed.
224 * 97 12/16/97 2:44p Hoffoss
225 * Added clear button to control config screen.
227 * 96 12/12/97 3:07p Hoffoss
228 * Changed how deleting bindings work. Each control of an action can be
229 * deleted independently or both at once.
231 * 95 12/07/97 2:36p John
232 * Made warp out be Alt+J instead of J
234 * 94 12/03/97 4:59p Hoffoss
235 * Added reset sound and change control config sounds around.
237 * 93 12/03/97 4:16p Hoffoss
238 * Changed sound stuff used in interface screens for interface purposes.
240 * 92 12/01/97 5:25p Hoffoss
241 * Routed interface sound playing through a special function that will
242 * only allow one instance of the sound to play at a time, avoiding
243 * over-mixing problems.
245 * 91 12/01/97 3:38p Hoffoss
246 * Changed placement of 'More' indicator.
248 * 90 11/25/97 3:49p Hoffoss
249 * Changed subhilighting to happen when mouse is over line, rather than
250 * mouse button down but not up again yet.
252 * 89 11/24/97 10:20p Lawrance
253 * Add key 'KEY_N' to target next ship on monitoring view
255 * 88 11/24/97 6:15p Lawrance
256 * fix button scroll problem
258 * 87 11/23/97 6:15p Hoffoss
259 * Make exiting the controls config screen save the pilot, so changes keep
260 * even if programs crashes or something.
262 * 86 11/21/97 5:57p Hoffoss
263 * Fixed bug where timef type controls weren't checking joystick buttons.
265 * 85 11/21/97 4:06p Hoffoss
266 * Fixed bug with enabling of axis are reversed.
268 * 84 11/20/97 4:47p Hoffoss
269 * Swapped throttle and rudder, which apparently were backwards.
271 * 83 11/20/97 4:00p Lawrance
272 * set z to a valid value
274 * 82 11/20/97 3:52p Hoffoss
275 * Made "None" appear if no control is bound to function.
277 * 81 11/20/97 2:10p Hoffoss
278 * Added defaults for joystick buttons 2 and 3.
280 * 80 11/20/97 1:08a Lawrance
281 * add support for 'R' key - target closest friendly repair ship
283 * 79 11/19/97 8:33p Hoffoss
284 * New controls config screen baby!
286 * 78 11/17/97 7:09p Hoffoss
287 * Made chase view control a trigger type.
289 * 77 11/17/97 6:40p Lawrance
290 * Changed 'I' key to toggle of extended target info, moved target closest
291 * locked missile to 'L'
293 * 76 11/17/97 3:26p Jasen
294 * Adjusted coordinates for the help button .ani location
296 * 75 11/16/97 3:51p Hoffoss
297 * Added more button to config screen when scrolling allowed.
299 * 74 11/16/97 3:20p Hoffoss
300 * Added various suggestions from the Todolist.
302 * 73 11/14/97 4:33p Mike
303 * Change Debug key to backquote (from F11).
304 * Balance a ton of subsystems in ships.tbl.
305 * Change "Heavy Laser" to "Disruptor".
307 * 72 11/12/97 2:54p Hoffoss
308 * Made modifiers non-stand alone, added support for red tabs on
311 * 71 10/30/97 6:01p Hoffoss
312 * Changed screen to utilize the new text color standards.
314 * 70 10/29/97 7:25p Hoffoss
315 * Added crude support for UI button double click checking.
317 * 69 10/29/97 6:32p Hoffoss
318 * Changed some interface apperances.
320 * 68 10/29/97 4:54p Hoffoss
321 * Changed scan_code_text element for Enter to 'Enter' instead of 'a' with
322 * a caret over it (what's that all about?)
324 * 67 10/28/97 10:42a Hoffoss
325 * Fixed handling of continuous controls that have modifiers to the key.
327 * 66 10/28/97 10:03a Hoffoss
328 * Fixed bug with continuous type controls not registering if pressed and
329 * released too quickly. Also some other little changes.
331 * 65 10/28/97 12:12a Lawrance
332 * remove unused keys (Alt-H and Alt-F)
334 * 64 10/27/97 12:23p Hoffoss
335 * Improved warning system and fixed coloring bug.
337 * 63 10/27/97 11:39a Hoffoss
338 * Added control conflicts checking.
340 * 62 10/26/97 3:20p Hoffoss
341 * Added many missing features to control config screen.
343 * 61 10/25/97 5:41p Hoffoss
344 * More functionality added to the controls config screen.
346 * 60 10/24/97 11:00p Hoffoss
347 * Controls config screen much improved.
349 * 59 10/22/97 4:50p Hoffoss
350 * Disabled throttle by default.
352 * 58 10/22/97 11:00a Hoffoss
353 * Changed VIEW_SLEW and VIEW_EXTERNAL to be continuous rather than
356 * 57 10/21/97 7:05p Hoffoss
357 * Overhauled the key/joystick control structure and usage throughout the
358 * entire FreeSpace code. The whole system is very different now.
360 * 56 10/18/97 7:19p Hoffoss
361 * Added timestamp recording when a key is pressed.
363 * 55 10/13/97 4:33p Hoffoss
364 * Made training messages go away after time.
366 * 54 10/13/97 3:24p Hoffoss
367 * Made it so training message text can be arbitrarily bolded.
369 * 53 9/24/97 4:52p Hoffoss
370 * Changed training message key token handling, and implemented a new
371 * training message system method to test out for a while.
373 * 52 9/14/97 10:24p Lawrance
374 * add damage screen popup window
376 * 51 9/10/97 6:02p Hoffoss
377 * Added code to check for key-pressed sexp operator in FreeSpace as part
378 * of training mission stuff.
380 * 50 9/09/97 3:39p Sandeep
381 * warning level 4 bugs
386 #include "controlsconfig.h"
389 #include "localize.h"
394 #define COMPUTER_TAB 3
396 int Failed_key_index;
398 // assume control keys are used as modifiers until we find out
399 int Shift_is_modifier;
400 int Ctrl_is_modifier;
403 int Axis_enabled[JOY_NUM_AXES] = { 1, 1, 1, 0, 0, 0 };
404 int Axis_enabled_defaults[JOY_NUM_AXES] = { 1, 1, 1, 0, 0, 0 };
405 int Invert_axis[JOY_NUM_AXES] = { 0, 0, 0, 0, 0, 0 };
406 int Invert_axis_defaults[JOY_NUM_AXES] = { 0, 0, 0, 0, 0, 0 };
408 // arrays which hold the key mappings. The array index represents a key-independent action.
411 config_item Control_config[CCFG_MAX + 1] = {
413 { KEY_T, -1, TARGET_TAB, "Target Next Ship" },
414 { KEY_SHIFTED | KEY_T, -1, TARGET_TAB, "Target Previous Ship" },
415 { KEY_H, 2, TARGET_TAB, "Target Next Closest Hostile Ship" },
416 { KEY_SHIFTED | KEY_H, -1, TARGET_TAB, "Target Previous Closest Hostile Ship" },
417 { KEY_ALTED | KEY_H, -1, TARGET_TAB, "Toggle Auto Targeting" },
418 { KEY_F, -1, TARGET_TAB, "Target Next Closest Friendly Ship" },
419 { KEY_SHIFTED | KEY_F, -1, TARGET_TAB, "Target Previous Closest Friendly Ship" },
420 { KEY_Y, 4, TARGET_TAB, "Target Ship in Reticle" },
421 { KEY_G, -1, TARGET_TAB, "Target Target's Nearest Attacker" },
422 { KEY_ALTED | KEY_Y, -1, TARGET_TAB, "Target Last Ship to Send Transmission" },
423 { KEY_ALTED | KEY_T, -1, TARGET_TAB, "Turn Off Auto-Targeting" },
425 // targeting a ship's subsystem
426 { KEY_V, -1, TARGET_TAB, "Target Subsystem in Reticle" },
427 { KEY_S, -1, TARGET_TAB, "Target Next Subsystem" },
428 { KEY_SHIFTED | KEY_S, -1, TARGET_TAB, "Target Previous Subsystem" },
429 { KEY_ALTED | KEY_S, -1, TARGET_TAB, "Turn Off Auto-Targeting of Subsystems" },
432 { KEY_M, -1, COMPUTER_TAB, "Match Target Speed" },
433 { KEY_ALTED | KEY_M, -1, COMPUTER_TAB, "Toggle Auto Speed Matching" },
436 { KEY_LCTRL, 0, WEAPON_TAB, "Fire Primary Weapon", CC_TYPE_CONTINUOUS },
437 { KEY_SPACEBAR, 1, WEAPON_TAB, "Fire Secondary Weapon", CC_TYPE_CONTINUOUS },
438 { KEY_PERIOD, -1, WEAPON_TAB, "Cycle Forward Primary Weapon" },
439 { KEY_COMMA, -1, WEAPON_TAB, "Cycle Backward Primary Weapon" },
440 { KEY_DIVIDE, -1, WEAPON_TAB, "Cycle Secondary Weapon Bank" },
441 { KEY_SHIFTED | KEY_DIVIDE, -1, WEAPON_TAB, "Cycle Secondary Weapon Firing Rate" },
442 { KEY_X, 3, WEAPON_TAB, "Launch Countermeasure" },
445 { KEY_A, -1, SHIP_TAB, "Forward Thrust", CC_TYPE_CONTINUOUS },
446 { KEY_Z, -1, SHIP_TAB, "Reverse Thrust", CC_TYPE_CONTINUOUS },
447 { KEY_PAD7, -1, SHIP_TAB, "Bank Left", CC_TYPE_CONTINUOUS },
448 { KEY_PAD9, -1, SHIP_TAB, "Bank Right", CC_TYPE_CONTINUOUS },
449 { KEY_PAD8, -1, SHIP_TAB, "Pitch Forward", CC_TYPE_CONTINUOUS },
450 { KEY_PAD2, -1, SHIP_TAB, "Pitch Backward", CC_TYPE_CONTINUOUS },
451 { KEY_PAD4, -1, SHIP_TAB, "Turn Left", CC_TYPE_CONTINUOUS },
452 { KEY_PAD6, -1, SHIP_TAB, "Turn Right", CC_TYPE_CONTINUOUS },
455 { KEY_BACKSP, -1, SHIP_TAB, "Set Throttle to Zero" },
456 { KEY_SLASH, -1, SHIP_TAB, "Set Throttle to Max" },
457 { KEY_LBRACKET, -1, SHIP_TAB, "Set Throttle to One-Third" },
458 { KEY_RBRACKET, -1, SHIP_TAB, "Set Throttle to Two-Thirds" },
459 { KEY_EQUAL, -1, SHIP_TAB, "Increase Throttle 5 Percent" },
460 { KEY_MINUS, -1, SHIP_TAB, "Decrease Throttle 5 Percent" },
462 // squadmate messaging
463 { KEY_SHIFTED | KEY_A, -1, COMPUTER_TAB, "Attack My Target" },
464 { KEY_SHIFTED | KEY_Z, -1, COMPUTER_TAB, "Disarm My Target" },
465 { KEY_SHIFTED | KEY_D, -1, COMPUTER_TAB, "Disable My Target" },
466 { KEY_SHIFTED | KEY_V, -1, COMPUTER_TAB, "Attack my Subsystem" },
467 { KEY_SHIFTED | KEY_X, -1, COMPUTER_TAB, "Capture My Target" },
468 { KEY_SHIFTED | KEY_E, -1, COMPUTER_TAB, "Engage Enemy" },
469 { KEY_SHIFTED | KEY_W, -1, COMPUTER_TAB, "Form on my Wing" },
470 { KEY_SHIFTED | KEY_I, -1, COMPUTER_TAB, "Ignore my Target" },
471 { KEY_SHIFTED | KEY_P, -1, COMPUTER_TAB, "Protect my Target" },
472 { KEY_SHIFTED | KEY_C, -1, COMPUTER_TAB, "Cover me" },
473 { KEY_SHIFTED | KEY_J, -1, COMPUTER_TAB, "Return to base" },
474 { KEY_SHIFTED | KEY_R, -1, COMPUTER_TAB, "Rearm me" },
476 { KEY_R, 6, TARGET_TAB, "Target Closest Attacking Ship" },
479 { KEY_PADMULTIPLY, -1, COMPUTER_TAB, "Chase View" },
480 { KEY_PADPERIOD, -1, COMPUTER_TAB, "External View"},
481 { KEY_PADENTER, -1, COMPUTER_TAB, "Toggle External Camera Lock"},
482 { KEY_PAD0, -1, COMPUTER_TAB, "Free Look View", CC_TYPE_CONTINUOUS },
483 { KEY_PADDIVIDE, -1, COMPUTER_TAB, "Current Target View" },
484 { KEY_PADPLUS, -1, COMPUTER_TAB, "Increase View Distance", CC_TYPE_CONTINUOUS },
485 { KEY_PADMINUS, -1, COMPUTER_TAB, "Decrease View Distance", CC_TYPE_CONTINUOUS },
486 { KEY_PAD5, -1, COMPUTER_TAB, "Center View", CC_TYPE_CONTINUOUS },
487 { -1, 33, COMPUTER_TAB, "View Up", CC_TYPE_CONTINUOUS },
488 { -1, 32, COMPUTER_TAB, "View Rear", CC_TYPE_CONTINUOUS },
489 { -1, 34, COMPUTER_TAB, "View Left", CC_TYPE_CONTINUOUS },
490 { -1, 35, COMPUTER_TAB, "View Right", CC_TYPE_CONTINUOUS },
492 { KEY_RAPOSTRO, -1, COMPUTER_TAB, "Cycle Radar Range" },
493 { KEY_C, -1, COMPUTER_TAB, "Communications Menu" },
494 { -1, -1, -1, "Show Objectives" },
495 { KEY_ALTED | KEY_J, -1, COMPUTER_TAB, "Enter Subspace (End Mission)" },
496 { KEY_J, -1, TARGET_TAB, "Target Target's Target" },
497 { KEY_TAB, 5, SHIP_TAB, "Afterburner", CC_TYPE_CONTINUOUS },
499 { KEY_INSERT, -1, COMPUTER_TAB, "Increase Weapon Energy" },
500 { KEY_DELETE, -1, COMPUTER_TAB, "Decrease Weapon Energy" },
501 { KEY_HOME, -1, COMPUTER_TAB, "Increase Shield Energy" },
502 { KEY_END, -1, COMPUTER_TAB, "Decrease Shield Energy" },
503 { KEY_PAGEUP, -1, COMPUTER_TAB, "Increase Engine Energy" },
504 { KEY_PAGEDOWN, -1, COMPUTER_TAB, "Decrease Engine Energy" },
505 { KEY_ALTED | KEY_D, -1, COMPUTER_TAB, "Equalize Energy Settings" },
507 { KEY_Q, 7, COMPUTER_TAB, "Equalize Shield" },
508 { KEY_UP, -1, COMPUTER_TAB, "Augment Forward Shield" },
509 { KEY_DOWN, -1, COMPUTER_TAB, "Augment Rear Shield" },
510 { KEY_LEFT, -1, COMPUTER_TAB, "Augment Left Shield" },
511 { KEY_RIGHT, -1, COMPUTER_TAB, "Augment Right Shield" },
512 { KEY_SCROLLOCK, -1, COMPUTER_TAB, "Transfer Energy Laser->Shield" },
513 { KEY_SHIFTED | KEY_SCROLLOCK, -1, COMPUTER_TAB, "Transfer Energy Shield->Laser" },
514 { -1, -1, -1, "Show Damage Popup Window" },
516 { -1, -1, SHIP_TAB, "Bank When Pressed", CC_TYPE_CONTINUOUS },
517 { -1, -1, -1, "Show NavMap" },
518 { KEY_ALTED | KEY_E, -1, COMPUTER_TAB, "Add or Remove Escort" },
519 { KEY_ALTED | KEY_SHIFTED | KEY_E, -1, COMPUTER_TAB, "Clear Escort List" },
520 { KEY_E, -1, TARGET_TAB, "Target Next Escort Ship" },
521 { KEY_ALTED | KEY_R, -1, TARGET_TAB, "Target Closest Repair Ship" },
523 { KEY_U, -1, TARGET_TAB, "Target Next Uninspected Cargo" },
524 { KEY_SHIFTED | KEY_U, -1, TARGET_TAB, "Target Previous Uninspected Cargo" },
525 { KEY_N, -1, TARGET_TAB, "Target Newest Ship In Area" },
526 { KEY_K, -1, TARGET_TAB, "Target Next Live Turret" },
527 { KEY_SHIFTED | KEY_K, -1, TARGET_TAB, "Target Previous Live Turret" },
529 { KEY_B, -1, TARGET_TAB, "Target Next Hostile Bomb or Bomber" },
530 { KEY_SHIFTED | KEY_B, -1, TARGET_TAB, "Target Previous Hostile Bomb or Bomber" },
532 // multiplayer messaging keys
533 { KEY_1, -1, COMPUTER_TAB, "(Multiplayer) Message All", CC_TYPE_CONTINUOUS },
534 { KEY_2, -1, COMPUTER_TAB, "(Multiplayer) Message Friendly", CC_TYPE_CONTINUOUS },
535 { KEY_3, -1, COMPUTER_TAB, "(Multiplayer) Message Hostile", CC_TYPE_CONTINUOUS },
536 { KEY_4, -1, COMPUTER_TAB, "(Multiplayer) Message Target", CC_TYPE_CONTINUOUS },
537 { KEY_ALTED | KEY_X, -1, COMPUTER_TAB, "(Multiplayer) Observer zoom to target"},
539 { KEY_SHIFTED | KEY_PERIOD, -1, COMPUTER_TAB, "Increase time compression" },
540 { KEY_SHIFTED | KEY_COMMA, -1, COMPUTER_TAB, "Decrease time compression" },
542 { KEY_L, -1, COMPUTER_TAB, "Toggle high HUD contrast" },
544 { KEY_SHIFTED | KEY_N, -1, COMPUTER_TAB, "(Multiplayer) Toggle network info"},
545 { KEY_SHIFTED | KEY_END, -1, COMPUTER_TAB, "(Multiplayer) Self destruct"},
550 char *Scan_code_text_german[] = {
551 "", "Esc", "1", "2", "3", "4", "5", "6",
553 "7", "8", "9", "0", "Akzent '", "\xE1", "R\x81""cktaste", "Tab",
555 "7", "8", "9", "0", "?", "Akzent '", "R\x81""cktaste", "Tab",
557 "Q", "W", "E", "R", "T", "Z", "U", "I",
558 "O", "P", "\x9A", "+", "Eingabe", "Strg Links", "A", "S",
560 "D", "F", "G", "H", "J", "K", "L", "\x99",
562 "\xAE", "`", "Shift", "#", "Y", "X", "C", "V",
564 "\x8E", "`", "Shift", "#", "Y", "X", "C", "V",
566 "B", "N", "M", ",", ".", "-", "Shift", "Num *",
567 "Alt", "Leertaste", "Hochstell", "F1", "F2", "F3", "F4", "F5",
569 "F6", "F7", "F8", "F9", "F10", "Pause", "Rollen", "Num 7",
570 "Num 8", "Num 9", "Num -", "Num 4", "Num 5", "Num 6", "Num +", "Num 1",
571 "Num 2", "Num 3", "Num 0", "Num ,", "", "", "", "F11",
572 "F12", "", "", "", "", "", "", "",
574 "", "", "", "", "", "", "", "",
575 "", "", "", "", "", "", "", "",
576 "", "", "", "", "", "", "", "",
577 "", "", "", "", "", "", "", "",
579 "", "", "", "", "", "", "", "",
580 "", "", "", "", "", "", "", "",
581 "", "", "", "", "", "", "", "",
582 "", "", "", "", "Num Eingabe", "Strg Rechts", "", "",
584 "", "", "", "", "", "", "", "",
585 "", "", "", "", "", "", "", "",
586 "", "", "", "", "", "Num /", "", "Druck",
587 "Alt", "", "", "", "", "", "", "",
589 "", "", "", "", "", "Num Lock", "", "Pos 1",
590 "Pfeil Hoch", "Bild Hoch", "", "Pfeil Links", "", "Pfeil Rechts", "", "Ende",
591 "Pfeil Runter", "Bild Runter", "Einfg", "Entf", "", "", "", "",
592 "", "", "", "", "", "", "", "",
594 "", "", "", "", "", "", "", "",
595 "", "", "", "", "", "", "", "",
596 "", "", "", "", "", "", "", "",
597 "", "", "", "", "", "", "", "",
600 char *Joy_button_text_german[] = {
601 "Knopf 1", "Knopf 2", "Knopf 3", "Knopf 4", "Knopf 5", "Knopf 6",
602 "Knopf 7", "Knopf 8", "Knopf 9", "Knopf 10", "Knopf 11", "Knopf 12",
603 "Knopf 13", "Knopf 14", "Knopf 15", "Knopf 16", "Knopf 17", "Knopf 18",
604 "Knopf 19", "Knopf 20", "Knopf 21", "Knopf 22", "Knopf 23", "Knopf 24",
605 "Knopf 25", "Knopf 26", "Knopf 27", "Knopf 28", "Knopf 29", "Knopf 30",
606 "Knopf 31", "Knopf 32", "Hut Hinten", "Hut Vorne", "Hut Links", "Hut Rechts"
609 char *Scan_code_text_french[] = {
610 "", "\x90""chap", "1", "2", "3", "4", "5", "6",
611 "7", "8", "9", "0", "-", "=", "Fl\x82""che Ret.", "Tab",
612 "Q", "W", "E", "R", "T", "Y", "U", "I",
613 "O", "P", "[", "]", "Entr\x82""e", "Ctrl Gauche", "A", "S",
615 "D", "F", "G", "H", "J", "K", "L", ";",
616 "'", "`", "Maj.", "\\", "Z", "X", "C", "V",
617 "B", "N", "M", ",", ".", "/", "Maj.", "Pav\x82 *",
618 "Alt", "Espace", "Verr. Maj.", "F1", "F2", "F3", "F4", "F5",
620 "F6", "F7", "F8", "F9", "F10", "Pause", "Arret defil", "Pav\x82 7",
621 "Pav\x82 8", "Pav\x82 9", "Pav\x82 -", "Pav\x82 4", "Pav\x82 5", "Pav\x82 6", "Pav\x82 +", "Pav\x82 1",
622 "Pav\x82 2", "Pav\x82 3", "Pav\x82 0", "Pav\x82 .", "", "", "", "F11",
623 "F12", "", "", "", "", "", "", "",
625 "", "", "", "", "", "", "", "",
626 "", "", "", "", "", "", "", "",
627 "", "", "", "", "", "", "", "",
628 "", "", "", "", "", "", "", "",
630 "", "", "", "", "", "", "", "",
631 "", "", "", "", "", "", "", "",
632 "", "", "", "", "", "", "", "",
633 "", "", "", "", "Pav\x82 Entr", "Ctrl Droite", "", "",
635 "", "", "", "", "", "", "", "",
636 "", "", "", "", "", "", "", "",
637 "", "", "", "", "", "Pav\x82 /", "", "Impr \x82""cran",
638 "Alt", "", "", "", "", "", "", "",
640 "", "", "", "", "", "Verr num", "", "Orig.",
641 "Fl\x82""che Haut", "Page Haut", "", "Fl\x82""che Gauche", "", "Fl\x82""che Droite", "", "Fin",
642 "Fl\x82""che Bas", "Page Bas", "Inser", "Suppr", "", "", "", "",
643 "", "", "", "", "", "", "", "",
645 "", "", "", "", "", "", "", "",
646 "", "", "", "", "", "", "", "",
647 "", "", "", "", "", "", "", "",
648 "", "", "", "", "", "", "", "",
651 char *Joy_button_text_french[] = {
652 "Bouton 1", "Bouton 2", "Bouton 3", "Bouton 4", "Bouton 5", "Bouton 6",
653 "Bouton 7", "Bouton 8", "Bouton 9", "Bouton 10", "Bouton 11", "Bouton 12",
654 "Bouton 13", "Bouton 14", "Bouton 15", "Bouton 16", "Bouton 17", "Bouton 18",
655 "Bouton 19", "Bouton 20", "Bouton 21", "Bouton 22", "Bouton 23", "Bouton 24",
656 "Bouton 25", "Bouton 26", "Bouton 27", "Bouton 28", "Bouton 29", "Bouton 30",
657 "Bouton 31", "Bouton 32", "Chapeau Arrière", "Chapeau Avant", "Chapeau Gauche", "Chapeau Droite"
660 // This is the text that is displayed on the screen for the keys a player selects
661 char *Scan_code_text_english[] = {
662 "", "Esc", "1", "2", "3", "4", "5", "6",
663 "7", "8", "9", "0", "-", "=", "Backspace", "Tab",
664 "Q", "W", "E", "R", "T", "Y", "U", "I",
665 "O", "P", "[", "]", "Enter", "Left Ctrl", "A", "S",
667 "D", "F", "G", "H", "J", "K", "L", ";",
668 "'", "`", "Shift", "\\", "Z", "X", "C", "V",
669 "B", "N", "M", ",", ".", "/", "Shift", "Pad *",
670 "Alt", "Spacebar", "Caps Lock", "F1", "F2", "F3", "F4", "F5",
672 "F6", "F7", "F8", "F9", "F10", "Pause", "Scroll Lock", "Pad 7",
673 "Pad 8", "Pad 9", "Pad -", "Pad 4", "Pad 5", "Pad 6", "Pad +", "Pad 1",
674 "Pad 2", "Pad 3", "Pad 0", "Pad .", "", "", "", "F11",
675 "F12", "", "", "", "", "", "", "",
677 "", "", "", "", "", "", "", "",
678 "", "", "", "", "", "", "", "",
679 "", "", "", "", "", "", "", "",
680 "", "", "", "", "", "", "", "",
682 "", "", "", "", "", "", "", "",
683 "", "", "", "", "", "", "", "",
684 "", "", "", "", "", "", "", "",
685 "", "", "", "", "Pad Enter", "Right Ctrl", "", "",
687 "", "", "", "", "", "", "", "",
688 "", "", "", "", "", "", "", "",
689 "", "", "", "", "", "Pad /", "", "Print Scrn",
690 "Alt", "", "", "", "", "", "", "",
692 "", "", "", "", "", "Num Lock", "", "Home",
693 "Up Arrow", "Page Up", "", "Left Arrow", "", "Right Arrow", "", "End",
694 "Down Arrow", "Page Down", "Insert", "Delete", "", "", "", "",
695 "", "", "", "", "", "", "", "",
697 "", "", "", "", "", "", "", "",
698 "", "", "", "", "", "", "", "",
699 "", "", "", "", "", "", "", "",
700 "", "", "", "", "", "", "", "",
703 char *Joy_button_text_english[] = {
704 "Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6",
705 "Button 7", "Button 8", "Button 9", "Button 10", "Button 11", "Button 12",
706 "Button 13", "Button 14", "Button 15", "Button 16", "Button 17", "Button 18",
707 "Button 19", "Button 20", "Button 21", "Button 22", "Button 23", "Button 24",
708 "Button 25", "Button 26", "Button 27", "Button 28", "Button 29", "Button 30",
709 "Button 31", "Button 32", "Hat Back", "Hat Forward", "Hat Left", "Hat Right"
712 char *Scan_code_text_polish[] = {
713 "", "Esc", "1", "2", "3", "4", "5", "6",
714 "7", "8", "9", "0", "-", "=", "Backspace", "Tab",
715 "Q", "W", "E", "R", "T", "Y", "U", "I",
716 "O", "P", "[", "]", "Enter", "Lewy Ctrl", "A", "S",
718 "D", "F", "G", "H", "J", "K", "L", ";",
719 "'", "`", "LShift", "\\", "Z", "X", "C", "V",
720 "B", "N", "M", ",", ".", "/", "PShift", "Num *",
721 "Alt", "Spacja", "CapsLock", "F1", "F2", "F3", "F4", "F5",
723 "F6", "F7", "F8", "F9", "F10", "Pause", "Scrlock", "Num 7",
724 "Num 8", "Num 9", "Num -", "Num 4", "Num 5", "Num 6", "Num +", "Num 1",
725 "Num 2", "Num 3", "Num 0", "Num .", "", "", "", "F11",
726 "F12", "", "", "", "", "", "", "",
728 "", "", "", "", "", "", "", "",
729 "", "", "", "", "", "", "", "",
730 "", "", "", "", "", "", "", "",
731 "", "", "", "", "", "", "", "",
733 "", "", "", "", "", "", "", "",
734 "", "", "", "", "", "", "", "",
735 "", "", "", "", "", "", "", "",
736 "", "", "", "", "Num Enter", "Prawy Ctrl", "", "",
738 "", "", "", "", "", "", "", "",
739 "", "", "", "", "", "", "", "",
740 "", "", "", "", "", "Num /", "", "PrntScr",
741 "Alt", "", "", "", "", "", "", "",
743 "", "", "", "", "", "Num Lock", "", "Home",
744 "Kursor G\xF3ra", "Page Up", "", "Kursor Lewo", "", "Kursor Prawo", "", "End",
745 "Kursor D\xF3\xB3", "Page Down", "Insert", "Delete", "", "", "", "",
746 "", "", "", "", "", "", "", "",
748 "", "", "", "", "", "", "", "",
749 "", "", "", "", "", "", "", "",
750 "", "", "", "", "", "", "", "",
751 "", "", "", "", "", "", "", "",
754 char *Joy_button_text_polish[] = {
755 "Przyc.1", "Przyc.2", "Przyc.3", "Przyc.4", "Przyc.5", "Przyc.6",
756 "Przyc.7", "Przyc.8", "Przyc.9", "Przyc.10", "Przyc.11", "Przyc.12",
757 "Przyc.13", "Przyc.14", "Przyc.15", "Przyc.16", "Przyc.17", "Przyc.18",
758 "Przyc.19", "Przyc.20", "Przyc.21", "Przyc.22", "Przyc.23", "Przyc.24",
759 "Przyc.25", "Przyc.26", "Przyc.27", "Przyc.28", "Przyc.29", "Przyc.30",
760 "Przyc.31", "Przyc.32", "Hat Ty\xB3", "Hat Prz\xF3\x64", "Hat Lewo", "Hat Prawo"
763 char **Scan_code_text = Scan_code_text_english;
764 char **Joy_button_text = Joy_button_text_english;
766 void set_modifier_status()
771 Shift_is_modifier = 0;
772 Ctrl_is_modifier = 0;
774 for (i=0; i<CCFG_MAX; i++) {
775 if (Control_config[i].key_id < 0)
778 if (Control_config[i].key_id & KEY_ALTED)
781 if (Control_config[i].key_id & KEY_SHIFTED)
782 Shift_is_modifier = 1;
784 if (Control_config[i].key_id & KEY_CTRLED) {
785 Assert(0); // get Alan
786 Ctrl_is_modifier = 1;
791 int translate_key_to_index(char *key)
793 int i, index = -1, alt = 0, shift = 0, max_scan_codes;
796 max_scan_codes = sizeof(Scan_code_text_german) / sizeof(char *);
798 max_scan_codes = sizeof(Scan_code_text_french) / sizeof(char *);
800 max_scan_codes = sizeof(Scan_code_text_polish) / sizeof(char *);
802 max_scan_codes = sizeof(Scan_code_text_english) / sizeof(char *);
805 // look for modifiers
807 if (!strnicmp(key, "Alt", 3)) {
814 char *translated_shift;
817 translated_shift = "Shift";
819 translated_shift = "Maj.";
821 translated_shift = "Shift";
824 if (!strnicmp(key, translated_shift, 5)) {
832 // fix for German training mission key check
833 if (Lcl_gr && !strcmp(key, "Links Ctrl")) {
834 strncpy(key, "Left Ctrl", 10);
838 // look up index for default key
840 for (i=0; i<max_scan_codes; i++)
841 if (!stricmp(key, Scan_code_text_english[i])) {
846 if (i == max_scan_codes)
850 index |= KEY_SHIFTED;
854 // convert scancode to Control_config index
855 for (i=0; i<CCFG_MAX; i++) {
856 if (Control_config[i].key_default == index) {
871 // Given the system default key 'key', return the current key that is bound to the function
872 // Both are 'key' and the return value are descriptive strings that can be displayed
873 // directly to the user. If 'key' isn't a real key or not normally bound to anything,
874 // or there is no key current bound to the function, NULL is returned.
875 char *translate_key(char *key)
877 int index = -1, code = -1;
879 index = translate_key_to_index(key);
883 code = Control_config[index].key_id;
884 Failed_key_index = index;
886 code = Control_config[index].joy_id;
888 return Joy_button_text[code];
891 return textify_scancode(code);
894 char *textify_scancode(int code)
896 static char text[40];
902 if (code & KEY_ALTED) {
904 strcat(text, "Alt-");
906 strcat(text, "Alt-");
908 strcat(text, "Alt-");
912 if (code & KEY_SHIFTED) {
914 strcat(text, "Shift-");
916 strcat(text, "Maj.-");
918 strcat(text, "Shift-");
922 strcat(text, Scan_code_text[code & KEY_MASK]);
927 // initialize common control config stuff - call at game startup after localization has been initialized
928 void control_config_common_init()
931 Scan_code_text = Scan_code_text_german;
932 Joy_button_text = Joy_button_text_german;
934 // swap init bindings for y and z keys
935 Control_config[TARGET_SHIP_IN_RETICLE].key_default = KEY_Z;
936 Control_config[TARGET_LAST_TRANMISSION_SENDER].key_default = KEY_ALTED | KEY_Z;
937 Control_config[REVERSE_THRUST].key_default = KEY_Y;
938 Control_config[DISARM_MESSAGE].key_default = KEY_SHIFTED | KEY_Y;
940 Scan_code_text = Scan_code_text_french;
941 Joy_button_text = Joy_button_text_french;
943 Scan_code_text = Scan_code_text_polish;
944 Joy_button_text = Joy_button_text_polish;
946 Scan_code_text = Scan_code_text_english;
947 Joy_button_text = Joy_button_text_english;