2 * $Logfile: /Freespace2/code/ControlConfig/ControlsConfigCommon.cpp $
7 * C module for keyboard, joystick and mouse configuration common stuff (between Fred and FreeSpace)
10 * Revision 1.2 2002/05/07 03:16:43 theoddone33
11 * The Great Newline Fix
13 * Revision 1.1.1.1 2002/05/03 03:28:08 root
17 * 14 11/01/99 3:36p Jefff
18 * had scan code texts for y and z in german swapped
20 * 13 11/01/99 2:16p Jefff
21 * minor key name change in german
23 * 12 10/29/99 6:10p Jefff
24 * squashed the damned y/z german issues once and for all
26 * 11 10/28/99 11:16p Jefff
27 * Changed some german key names. Made key translations always use the
30 * 10 10/28/99 2:05a Jefff
31 * revised some german key names. changed some y/z switch stuff.
33 * 9 10/25/99 5:39p Jefff
34 * swap init binding for y and z keys in German builds
36 * 8 9/01/99 2:56p Jefff
37 * a few control key description changes
39 * 7 8/22/99 5:53p Dave
40 * Scoring fixes. Added self destruct key. Put callsigns in the logfile
41 * instead of ship designations for multiplayer players.
43 * 6 8/19/99 10:59a Dave
44 * Packet loss detection.
46 * 5 8/01/99 12:39p Dave
47 * Added HUD contrast control key (for nebula).
49 * 4 7/23/99 2:57p Andsager
50 * fix translate_key_to_index to work with localization
52 * 3 11/05/98 4:18p Dave
53 * First run nebula support. Beefed up localization a bit. Removed all
54 * conditional compiles for foreign versions. Modified mission file
57 * 2 10/07/98 10:52a Dave
60 * 1 10/07/98 10:48a Dave
62 * 41 6/19/98 3:51p Lawrance
63 * localize control text
65 * 40 6/17/98 11:05a Lawrance
66 * localize the control config strings
68 * 39 5/24/98 2:28p Hoffoss
69 * Because we never really care about if the left or the right shift or
70 * alt key was used, but rather than either shift or alt was used, made
71 * both map to the left one. Solves some problems, causes none.
73 * 38 5/22/98 11:21a Hoffoss
74 * Added bank when pressed back in.
76 * 37 5/15/98 8:37p Lawrance
77 * Add 'equalize recharge rates' and 'target ship that sent last
78 * transmission' key bindings
80 * 36 5/13/98 7:15p Hoffoss
81 * Fixed remaining bugs with axis binding.
83 * 35 5/13/98 1:17a Hoffoss
84 * Added joystick axes configurability.
86 * 34 5/12/98 11:25a Hoffoss
87 * Disabled bank when pressed action.
89 * 33 5/09/98 10:48p Lawrance
90 * change text for view bindings
92 * 32 5/09/98 4:52p Lawrance
93 * Implement padlock view (up/rear/left/right)
95 * 31 4/30/98 9:43p Hoffoss
96 * Added new actions for free look movement which are default bounded to
99 * 30 4/25/98 1:25p Lawrance
100 * Add time compression keys to key config
102 * 29 4/25/98 12:43p Allender
103 * added new shortcut key for attack my subsystem
105 * 28 4/18/98 5:00p Dave
106 * Put in observer zoom key. Made mission sync screen more informative.
108 * 27 4/17/98 1:24a Lawrance
111 * 26 4/15/98 11:06a Lawrance
112 * fix bug with a multi key showing up in demo, remove obsolete bindings
113 * from demo and full version
115 * 25 4/10/98 12:47p Allender
116 * changed working on replay popup. Don't reference repair in comm menu.
117 * Added Shift-R for repair me
119 * 24 4/08/98 11:11a Hoffoss
120 * Fixed some bugs that showed up due to fixing other bugs the other day
123 * 23 4/07/98 4:06p Lawrance
124 * Change binding next for bomb targeting
126 * 22 4/07/98 1:52p Lawrance
127 * fix error in binding text for energy keys
129 * 21 4/06/98 11:17a Hoffoss
130 * Fixed num lock/pause interplay bug.
132 * 20 4/01/98 6:46p Lawrance
133 * change text for Alt+J
135 * 19 3/31/98 4:15p Hoffoss
136 * Disabled the show objectives action.
138 * 18 3/25/98 2:16p Dave
139 * Select random default image for newly created pilots. Fixed several
140 * multi-pause messaging bugs. Begin work on online help for multiplayer
143 * 17 3/19/98 5:04p Dave
144 * Put in support for targeted multiplayer text and voice messaging (all,
145 * friendly, hostile, individual).
147 * 16 3/17/98 11:25a Hoffoss
148 * Fixed some of the action's names.
150 * 15 3/17/98 10:48a Hoffoss
151 * Allowed a special hack for "bank while pressed" action to use alt and
152 * shift keys standalone.
154 * 14 2/28/98 9:47p Lawrance
155 * change some binding text
157 * 13 2/28/98 7:02p Lawrance
158 * overhaul on-line help
160 * 12 2/26/98 12:33a Lawrance
161 * Added back slew mode, lots of changes to external and chase views.
163 * 11 2/23/98 11:25a Sandeep
166 * 10 2/22/98 6:27p Lawrance
167 * External mode takes precedence over chase mode. Fix bug with repair
168 * ships docking in chase mode.
170 * 9 2/22/98 12:19p John
171 * Externalized some strings
173 * 8 2/02/98 6:59p Lawrance
174 * Adding new targeting keys (bomb, uninspected cargo, new ship, live
177 * 7 1/27/98 4:24p Allender
178 * moved hotkey selection to F3 instead of X. Made palette flash
179 * disappear in multiplayer pause menu
181 * 6 1/22/98 4:53p Hoffoss
182 * Made training messages/directives display a joystick button in place of
183 * a keypress if there is no keypress bound to the action.
185 * 5 1/22/98 4:15p Hoffoss
186 * Added code to allow popup to tell player he needs to bind a key for the
189 * 4 1/02/98 4:42p Allender
190 * removed unused key bindings from control config list
192 * 3 12/30/97 4:47p Allender
193 * work with ignore my target command. Added new keyboard hotkey. Made
196 * 2 12/24/97 3:37p Hoffoss
197 * Moved control config stuff to seperate library to Fred can access it as
200 * 1 12/24/97 3:27p Hoffoss
202 * 1 12/24/97 11:58a Hoffoss
204 * 98 12/22/97 2:15p Hoffoss
205 * Fixed bug where joystick axis lines weren't being displayed.
207 * 97 12/16/97 2:44p Hoffoss
208 * Added clear button to control config screen.
210 * 96 12/12/97 3:07p Hoffoss
211 * Changed how deleting bindings work. Each control of an action can be
212 * deleted independently or both at once.
214 * 95 12/07/97 2:36p John
215 * Made warp out be Alt+J instead of J
217 * 94 12/03/97 4:59p Hoffoss
218 * Added reset sound and change control config sounds around.
220 * 93 12/03/97 4:16p Hoffoss
221 * Changed sound stuff used in interface screens for interface purposes.
223 * 92 12/01/97 5:25p Hoffoss
224 * Routed interface sound playing through a special function that will
225 * only allow one instance of the sound to play at a time, avoiding
226 * over-mixing problems.
228 * 91 12/01/97 3:38p Hoffoss
229 * Changed placement of 'More' indicator.
231 * 90 11/25/97 3:49p Hoffoss
232 * Changed subhilighting to happen when mouse is over line, rather than
233 * mouse button down but not up again yet.
235 * 89 11/24/97 10:20p Lawrance
236 * Add key 'KEY_N' to target next ship on monitoring view
238 * 88 11/24/97 6:15p Lawrance
239 * fix button scroll problem
241 * 87 11/23/97 6:15p Hoffoss
242 * Make exiting the controls config screen save the pilot, so changes keep
243 * even if programs crashes or something.
245 * 86 11/21/97 5:57p Hoffoss
246 * Fixed bug where timef type controls weren't checking joystick buttons.
248 * 85 11/21/97 4:06p Hoffoss
249 * Fixed bug with enabling of axis are reversed.
251 * 84 11/20/97 4:47p Hoffoss
252 * Swapped throttle and rudder, which apparently were backwards.
254 * 83 11/20/97 4:00p Lawrance
255 * set z to a valid value
257 * 82 11/20/97 3:52p Hoffoss
258 * Made "None" appear if no control is bound to function.
260 * 81 11/20/97 2:10p Hoffoss
261 * Added defaults for joystick buttons 2 and 3.
263 * 80 11/20/97 1:08a Lawrance
264 * add support for 'R' key - target closest friendly repair ship
266 * 79 11/19/97 8:33p Hoffoss
267 * New controls config screen baby!
269 * 78 11/17/97 7:09p Hoffoss
270 * Made chase view control a trigger type.
272 * 77 11/17/97 6:40p Lawrance
273 * Changed 'I' key to toggle of extended target info, moved target closest
274 * locked missile to 'L'
276 * 76 11/17/97 3:26p Jasen
277 * Adjusted coordinates for the help button .ani location
279 * 75 11/16/97 3:51p Hoffoss
280 * Added more button to config screen when scrolling allowed.
282 * 74 11/16/97 3:20p Hoffoss
283 * Added various suggestions from the Todolist.
285 * 73 11/14/97 4:33p Mike
286 * Change Debug key to backquote (from F11).
287 * Balance a ton of subsystems in ships.tbl.
288 * Change "Heavy Laser" to "Disruptor".
290 * 72 11/12/97 2:54p Hoffoss
291 * Made modifiers non-stand alone, added support for red tabs on
294 * 71 10/30/97 6:01p Hoffoss
295 * Changed screen to utilize the new text color standards.
297 * 70 10/29/97 7:25p Hoffoss
298 * Added crude support for UI button double click checking.
300 * 69 10/29/97 6:32p Hoffoss
301 * Changed some interface apperances.
303 * 68 10/29/97 4:54p Hoffoss
304 * Changed scan_code_text element for Enter to 'Enter' instead of 'a' with
305 * a caret over it (what's that all about?)
307 * 67 10/28/97 10:42a Hoffoss
308 * Fixed handling of continuous controls that have modifiers to the key.
310 * 66 10/28/97 10:03a Hoffoss
311 * Fixed bug with continuous type controls not registering if pressed and
312 * released too quickly. Also some other little changes.
314 * 65 10/28/97 12:12a Lawrance
315 * remove unused keys (Alt-H and Alt-F)
317 * 64 10/27/97 12:23p Hoffoss
318 * Improved warning system and fixed coloring bug.
320 * 63 10/27/97 11:39a Hoffoss
321 * Added control conflicts checking.
323 * 62 10/26/97 3:20p Hoffoss
324 * Added many missing features to control config screen.
326 * 61 10/25/97 5:41p Hoffoss
327 * More functionality added to the controls config screen.
329 * 60 10/24/97 11:00p Hoffoss
330 * Controls config screen much improved.
332 * 59 10/22/97 4:50p Hoffoss
333 * Disabled throttle by default.
335 * 58 10/22/97 11:00a Hoffoss
336 * Changed VIEW_SLEW and VIEW_EXTERNAL to be continuous rather than
339 * 57 10/21/97 7:05p Hoffoss
340 * Overhauled the key/joystick control structure and usage throughout the
341 * entire FreeSpace code. The whole system is very different now.
343 * 56 10/18/97 7:19p Hoffoss
344 * Added timestamp recording when a key is pressed.
346 * 55 10/13/97 4:33p Hoffoss
347 * Made training messages go away after time.
349 * 54 10/13/97 3:24p Hoffoss
350 * Made it so training message text can be arbitrarily bolded.
352 * 53 9/24/97 4:52p Hoffoss
353 * Changed training message key token handling, and implemented a new
354 * training message system method to test out for a while.
356 * 52 9/14/97 10:24p Lawrance
357 * add damage screen popup window
359 * 51 9/10/97 6:02p Hoffoss
360 * Added code to check for key-pressed sexp operator in FreeSpace as part
361 * of training mission stuff.
363 * 50 9/09/97 3:39p Sandeep
364 * warning level 4 bugs
369 #include "controlsconfig.h"
372 #include "localize.h"
377 #define COMPUTER_TAB 3
379 int Failed_key_index;
381 // assume control keys are used as modifiers until we find out
382 int Shift_is_modifier;
383 int Ctrl_is_modifier;
386 int Axis_enabled[JOY_NUM_AXES] = { 1, 1, 1, 0, 0, 0 };
387 int Axis_enabled_defaults[JOY_NUM_AXES] = { 1, 1, 1, 0, 0, 0 };
388 int Invert_axis[JOY_NUM_AXES] = { 0, 0, 0, 0, 0, 0 };
389 int Invert_axis_defaults[JOY_NUM_AXES] = { 0, 0, 0, 0, 0, 0 };
391 // arrays which hold the key mappings. The array index represents a key-independent action.
394 config_item Control_config[CCFG_MAX + 1] = {
396 { KEY_T, -1, TARGET_TAB, "Target Next Ship" },
397 { KEY_SHIFTED | KEY_T, -1, TARGET_TAB, "Target Previous Ship" },
398 { KEY_H, 2, TARGET_TAB, "Target Next Closest Hostile Ship" },
399 { KEY_SHIFTED | KEY_H, -1, TARGET_TAB, "Target Previous Closest Hostile Ship" },
400 { KEY_ALTED | KEY_H, -1, TARGET_TAB, "Toggle Auto Targeting" },
401 { KEY_F, -1, TARGET_TAB, "Target Next Closest Friendly Ship" },
402 { KEY_SHIFTED | KEY_F, -1, TARGET_TAB, "Target Previous Closest Friendly Ship" },
403 { KEY_Y, 4, TARGET_TAB, "Target Ship in Reticle" },
404 { KEY_G, -1, TARGET_TAB, "Target Target's Nearest Attacker" },
405 { KEY_ALTED | KEY_Y, -1, TARGET_TAB, "Target Last Ship to Send Transmission" },
406 { KEY_ALTED | KEY_T, -1, TARGET_TAB, "Turn Off Auto-Targeting" },
408 // targeting a ship's subsystem
409 { KEY_V, -1, TARGET_TAB, "Target Subsystem in Reticle" },
410 { KEY_S, -1, TARGET_TAB, "Target Next Subsystem" },
411 { KEY_SHIFTED | KEY_S, -1, TARGET_TAB, "Target Previous Subsystem" },
412 { KEY_ALTED | KEY_S, -1, TARGET_TAB, "Turn Off Auto-Targeting of Subsystems" },
415 { KEY_M, -1, COMPUTER_TAB, "Match Target Speed" },
416 { KEY_ALTED | KEY_M, -1, COMPUTER_TAB, "Toggle Auto Speed Matching" },
419 { KEY_LCTRL, 0, WEAPON_TAB, "Fire Primary Weapon", CC_TYPE_CONTINUOUS },
420 { KEY_SPACEBAR, 1, WEAPON_TAB, "Fire Secondary Weapon", CC_TYPE_CONTINUOUS },
421 { KEY_PERIOD, -1, WEAPON_TAB, "Cycle Forward Primary Weapon" },
422 { KEY_COMMA, -1, WEAPON_TAB, "Cycle Backward Primary Weapon" },
423 { KEY_DIVIDE, -1, WEAPON_TAB, "Cycle Secondary Weapon Bank" },
424 { KEY_SHIFTED | KEY_DIVIDE, -1, WEAPON_TAB, "Cycle Secondary Weapon Firing Rate" },
425 { KEY_X, 3, WEAPON_TAB, "Launch Countermeasure" },
428 { KEY_A, -1, SHIP_TAB, "Forward Thrust", CC_TYPE_CONTINUOUS },
429 { KEY_Z, -1, SHIP_TAB, "Reverse Thrust", CC_TYPE_CONTINUOUS },
430 { KEY_PAD7, -1, SHIP_TAB, "Bank Left", CC_TYPE_CONTINUOUS },
431 { KEY_PAD9, -1, SHIP_TAB, "Bank Right", CC_TYPE_CONTINUOUS },
432 { KEY_PAD8, -1, SHIP_TAB, "Pitch Forward", CC_TYPE_CONTINUOUS },
433 { KEY_PAD2, -1, SHIP_TAB, "Pitch Backward", CC_TYPE_CONTINUOUS },
434 { KEY_PAD4, -1, SHIP_TAB, "Turn Left", CC_TYPE_CONTINUOUS },
435 { KEY_PAD6, -1, SHIP_TAB, "Turn Right", CC_TYPE_CONTINUOUS },
438 { KEY_BACKSP, -1, SHIP_TAB, "Set Throttle to Zero" },
439 { KEY_SLASH, -1, SHIP_TAB, "Set Throttle to Max" },
440 { KEY_LBRACKET, -1, SHIP_TAB, "Set Throttle to One-Third" },
441 { KEY_RBRACKET, -1, SHIP_TAB, "Set Throttle to Two-Thirds" },
442 { KEY_EQUAL, -1, SHIP_TAB, "Increase Throttle 5 Percent" },
443 { KEY_MINUS, -1, SHIP_TAB, "Decrease Throttle 5 Percent" },
445 // squadmate messaging
446 { KEY_SHIFTED | KEY_A, -1, COMPUTER_TAB, "Attack My Target" },
447 { KEY_SHIFTED | KEY_Z, -1, COMPUTER_TAB, "Disarm My Target" },
448 { KEY_SHIFTED | KEY_D, -1, COMPUTER_TAB, "Disable My Target" },
449 { KEY_SHIFTED | KEY_V, -1, COMPUTER_TAB, "Attack my Subsystem" },
450 { KEY_SHIFTED | KEY_X, -1, COMPUTER_TAB, "Capture My Target" },
451 { KEY_SHIFTED | KEY_E, -1, COMPUTER_TAB, "Engage Enemy" },
452 { KEY_SHIFTED | KEY_W, -1, COMPUTER_TAB, "Form on my Wing" },
453 { KEY_SHIFTED | KEY_I, -1, COMPUTER_TAB, "Ignore my Target" },
454 { KEY_SHIFTED | KEY_P, -1, COMPUTER_TAB, "Protect my Target" },
455 { KEY_SHIFTED | KEY_C, -1, COMPUTER_TAB, "Cover me" },
456 { KEY_SHIFTED | KEY_J, -1, COMPUTER_TAB, "Return to base" },
457 { KEY_SHIFTED | KEY_R, -1, COMPUTER_TAB, "Rearm me" },
459 { KEY_R, 6, TARGET_TAB, "Target Closest Attacking Ship" },
462 { KEY_PADMULTIPLY, -1, COMPUTER_TAB, "Chase View" },
463 { KEY_PADPERIOD, -1, COMPUTER_TAB, "External View"},
464 { KEY_PADENTER, -1, COMPUTER_TAB, "Toggle External Camera Lock"},
465 { KEY_PAD0, -1, COMPUTER_TAB, "Free Look View", CC_TYPE_CONTINUOUS },
466 { KEY_PADDIVIDE, -1, COMPUTER_TAB, "Current Target View" },
467 { KEY_PADPLUS, -1, COMPUTER_TAB, "Increase View Distance", CC_TYPE_CONTINUOUS },
468 { KEY_PADMINUS, -1, COMPUTER_TAB, "Decrease View Distance", CC_TYPE_CONTINUOUS },
469 { KEY_PAD5, -1, COMPUTER_TAB, "Center View", CC_TYPE_CONTINUOUS },
470 { -1, 33, COMPUTER_TAB, "View Up", CC_TYPE_CONTINUOUS },
471 { -1, 32, COMPUTER_TAB, "View Rear", CC_TYPE_CONTINUOUS },
472 { -1, 34, COMPUTER_TAB, "View Left", CC_TYPE_CONTINUOUS },
473 { -1, 35, COMPUTER_TAB, "View Right", CC_TYPE_CONTINUOUS },
475 { KEY_RAPOSTRO, -1, COMPUTER_TAB, "Cycle Radar Range" },
476 { KEY_C, -1, COMPUTER_TAB, "Communications Menu" },
477 { -1, -1, -1, "Show Objectives" },
478 { KEY_ALTED | KEY_J, -1, COMPUTER_TAB, "Enter Subspace (End Mission)" },
479 { KEY_J, -1, TARGET_TAB, "Target Target's Target" },
480 { KEY_TAB, 5, SHIP_TAB, "Afterburner", CC_TYPE_CONTINUOUS },
482 { KEY_INSERT, -1, COMPUTER_TAB, "Increase Weapon Energy" },
483 { KEY_DELETE, -1, COMPUTER_TAB, "Decrease Weapon Energy" },
484 { KEY_HOME, -1, COMPUTER_TAB, "Increase Shield Energy" },
485 { KEY_END, -1, COMPUTER_TAB, "Decrease Shield Energy" },
486 { KEY_PAGEUP, -1, COMPUTER_TAB, "Increase Engine Energy" },
487 { KEY_PAGEDOWN, -1, COMPUTER_TAB, "Decrease Engine Energy" },
488 { KEY_ALTED | KEY_D, -1, COMPUTER_TAB, "Equalize Energy Settings" },
490 { KEY_Q, 7, COMPUTER_TAB, "Equalize Shield" },
491 { KEY_UP, -1, COMPUTER_TAB, "Augment Forward Shield" },
492 { KEY_DOWN, -1, COMPUTER_TAB, "Augment Rear Shield" },
493 { KEY_LEFT, -1, COMPUTER_TAB, "Augment Left Shield" },
494 { KEY_RIGHT, -1, COMPUTER_TAB, "Augment Right Shield" },
495 { KEY_SCROLLOCK, -1, COMPUTER_TAB, "Transfer Energy Laser->Shield" },
496 { KEY_SHIFTED | KEY_SCROLLOCK, -1, COMPUTER_TAB, "Transfer Energy Shield->Laser" },
497 { -1, -1, -1, "Show Damage Popup Window" },
499 { -1, -1, SHIP_TAB, "Bank When Pressed", CC_TYPE_CONTINUOUS },
500 { -1, -1, -1, "Show NavMap" },
501 { KEY_ALTED | KEY_E, -1, COMPUTER_TAB, "Add or Remove Escort" },
502 { KEY_ALTED | KEY_SHIFTED | KEY_E, -1, COMPUTER_TAB, "Clear Escort List" },
503 { KEY_E, -1, TARGET_TAB, "Target Next Escort Ship" },
504 { KEY_ALTED | KEY_R, -1, TARGET_TAB, "Target Closest Repair Ship" },
506 { KEY_U, -1, TARGET_TAB, "Target Next Uninspected Cargo" },
507 { KEY_SHIFTED | KEY_U, -1, TARGET_TAB, "Target Previous Uninspected Cargo" },
508 { KEY_N, -1, TARGET_TAB, "Target Newest Ship In Area" },
509 { KEY_K, -1, TARGET_TAB, "Target Next Live Turret" },
510 { KEY_SHIFTED | KEY_K, -1, TARGET_TAB, "Target Previous Live Turret" },
512 { KEY_B, -1, TARGET_TAB, "Target Next Hostile Bomb or Bomber" },
513 { KEY_SHIFTED | KEY_B, -1, TARGET_TAB, "Target Previous Hostile Bomb or Bomber" },
515 // multiplayer messaging keys
516 { KEY_1, -1, COMPUTER_TAB, "(Multiplayer) Message All", CC_TYPE_CONTINUOUS },
517 { KEY_2, -1, COMPUTER_TAB, "(Multiplayer) Message Friendly", CC_TYPE_CONTINUOUS },
518 { KEY_3, -1, COMPUTER_TAB, "(Multiplayer) Message Hostile", CC_TYPE_CONTINUOUS },
519 { KEY_4, -1, COMPUTER_TAB, "(Multiplayer) Message Target", CC_TYPE_CONTINUOUS },
520 { KEY_ALTED | KEY_X, -1, COMPUTER_TAB, "(Multiplayer) Observer zoom to target"},
522 { KEY_SHIFTED | KEY_PERIOD, -1, COMPUTER_TAB, "Increase time compression" },
523 { KEY_SHIFTED | KEY_COMMA, -1, COMPUTER_TAB, "Decrease time compression" },
525 { KEY_L, -1, COMPUTER_TAB, "Toggle high HUD contrast" },
527 { KEY_SHIFTED | KEY_N, -1, COMPUTER_TAB, "(Multiplayer) Toggle network info"},
528 { KEY_SHIFTED | KEY_END, -1, COMPUTER_TAB, "(Multiplayer) Self destruct"},
533 char *Scan_code_text_german[] = {
534 "", "Esc", "1", "2", "3", "4", "5", "6",
535 "7", "8", "9", "0", "Akzent '", "\xE1", "R\x81""cktaste", "Tab",
536 "Q", "W", "E", "R", "T", "Z", "U", "I",
537 "O", "P", "\x9A", "+", "Eingabe", "Strg Links", "A", "S",
539 "D", "F", "G", "H", "J", "K", "L", "\x99",
540 "\xAE", "`", "Shift", "#", "Y", "X", "C", "V",
541 "B", "N", "M", ",", ".", "-", "Shift", "Num *",
542 "Alt", "Leertaste", "Hochstell", "F1", "F2", "F3", "F4", "F5",
544 "F6", "F7", "F8", "F9", "F10", "Pause", "Rollen", "Num 7",
545 "Num 8", "Num 9", "Num -", "Num 4", "Num 5", "Num 6", "Num +", "Num 1",
546 "Num 2", "Num 3", "Num 0", "Num ,", "", "", "", "F11",
547 "F12", "", "", "", "", "", "", "",
549 "", "", "", "", "", "", "", "",
550 "", "", "", "", "", "", "", "",
551 "", "", "", "", "", "", "", "",
552 "", "", "", "", "", "", "", "",
554 "", "", "", "", "", "", "", "",
555 "", "", "", "", "", "", "", "",
556 "", "", "", "", "", "", "", "",
557 "", "", "", "", "Num Eingabe", "Strg Rechts", "", "",
559 "", "", "", "", "", "", "", "",
560 "", "", "", "", "", "", "", "",
561 "", "", "", "", "", "Num /", "", "Druck",
562 "Alt", "", "", "", "", "", "", "",
564 "", "", "", "", "", "Num Lock", "", "Pos 1",
565 "Pfeil Hoch", "Bild Hoch", "", "Pfeil Links", "", "Pfeil Rechts", "", "Ende",
566 "Pfeil Runter", "Bild Runter", "Einfg", "Entf", "", "", "", "",
567 "", "", "", "", "", "", "", "",
569 "", "", "", "", "", "", "", "",
570 "", "", "", "", "", "", "", "",
571 "", "", "", "", "", "", "", "",
572 "", "", "", "", "", "", "", "",
575 char *Joy_button_text_german[] = {
576 "Knopf 1", "Knopf 2", "Knopf 3", "Knopf 4", "Knopf 5", "Knopf 6",
577 "Knopf 7", "Knopf 8", "Knopf 9", "Knopf 10", "Knopf 11", "Knopf 12",
578 "Knopf 13", "Knopf 14", "Knopf 15", "Knopf 16", "Knopf 17", "Knopf 18",
579 "Knopf 19", "Knopf 20", "Knopf 21", "Knopf 22", "Knopf 23", "Knopf 24",
580 "Knopf 25", "Knopf 26", "Knopf 27", "Knopf 28", "Knopf 29", "Knopf 30",
581 "Knopf 31", "Knopf 32", "Hut Hinten", "Hut Vorne", "Hut Links", "Hut Rechts"
584 char *Scan_code_text_french[] = {
585 "", "\x90""chap", "1", "2", "3", "4", "5", "6",
586 "7", "8", "9", "0", "-", "=", "Fl\x82""che Ret.", "Tab",
587 "Q", "W", "E", "R", "T", "Y", "U", "I",
588 "O", "P", "[", "]", "Entr\x82""e", "Ctrl Gauche", "A", "S",
590 "D", "F", "G", "H", "J", "K", "L", ";",
591 "'", "`", "Maj.", "\\", "Z", "X", "C", "V",
592 "B", "N", "M", ",", ".", "/", "Maj.", "Pav\x82 *",
593 "Alt", "Espace", "Verr. Maj.", "F1", "F2", "F3", "F4", "F5",
595 "F6", "F7", "F8", "F9", "F10", "Pause", "Arret defil", "Pav\x82 7",
596 "Pav\x82 8", "Pav\x82 9", "Pav\x82 -", "Pav\x82 4", "Pav\x82 5", "Pav\x82 6", "Pav\x82 +", "Pav\x82 1",
597 "Pav\x82 2", "Pav\x82 3", "Pav\x82 0", "Pav\x82 .", "", "", "", "F11",
598 "F12", "", "", "", "", "", "", "",
600 "", "", "", "", "", "", "", "",
601 "", "", "", "", "", "", "", "",
602 "", "", "", "", "", "", "", "",
603 "", "", "", "", "", "", "", "",
605 "", "", "", "", "", "", "", "",
606 "", "", "", "", "", "", "", "",
607 "", "", "", "", "", "", "", "",
608 "", "", "", "", "Pav\x82 Entr", "Ctrl Droite", "", "",
610 "", "", "", "", "", "", "", "",
611 "", "", "", "", "", "", "", "",
612 "", "", "", "", "", "Pav\x82 /", "", "Impr \x82""cran",
613 "Alt", "", "", "", "", "", "", "",
615 "", "", "", "", "", "Verr num", "", "Orig.",
616 "Fl\x82""che Haut", "Page Haut", "", "Fl\x82""che Gauche", "", "Fl\x82""che Droite", "", "Fin",
617 "Fl\x82""che Bas", "Page Bas", "Inser", "Suppr", "", "", "", "",
618 "", "", "", "", "", "", "", "",
620 "", "", "", "", "", "", "", "",
621 "", "", "", "", "", "", "", "",
622 "", "", "", "", "", "", "", "",
623 "", "", "", "", "", "", "", "",
626 char *Joy_button_text_french[] = {
627 "Bouton 1", "Bouton 2", "Bouton 3", "Bouton 4", "Bouton 5", "Bouton 6",
628 "Bouton 7", "Bouton 8", "Bouton 9", "Bouton 10", "Bouton 11", "Bouton 12",
629 "Bouton 13", "Bouton 14", "Bouton 15", "Bouton 16", "Bouton 17", "Bouton 18",
630 "Bouton 19", "Bouton 20", "Bouton 21", "Bouton 22", "Bouton 23", "Bouton 24",
631 "Bouton 25", "Bouton 26", "Bouton 27", "Bouton 28", "Bouton 29", "Bouton 30",
632 "Bouton 31", "Bouton 32", "Chapeau Arrière", "Chapeau Avant", "Chapeau Gauche", "Chapeau Droite"
635 // This is the text that is displayed on the screen for the keys a player selects
636 char *Scan_code_text_english[] = {
637 "", "Esc", "1", "2", "3", "4", "5", "6",
638 "7", "8", "9", "0", "-", "=", "Backspace", "Tab",
639 "Q", "W", "E", "R", "T", "Y", "U", "I",
640 "O", "P", "[", "]", "Enter", "Left Ctrl", "A", "S",
642 "D", "F", "G", "H", "J", "K", "L", ";",
643 "'", "`", "Shift", "\\", "Z", "X", "C", "V",
644 "B", "N", "M", ",", ".", "/", "Shift", "Pad *",
645 "Alt", "Spacebar", "Caps Lock", "F1", "F2", "F3", "F4", "F5",
647 "F6", "F7", "F8", "F9", "F10", "Pause", "Scroll Lock", "Pad 7",
648 "Pad 8", "Pad 9", "Pad -", "Pad 4", "Pad 5", "Pad 6", "Pad +", "Pad 1",
649 "Pad 2", "Pad 3", "Pad 0", "Pad .", "", "", "", "F11",
650 "F12", "", "", "", "", "", "", "",
652 "", "", "", "", "", "", "", "",
653 "", "", "", "", "", "", "", "",
654 "", "", "", "", "", "", "", "",
655 "", "", "", "", "", "", "", "",
657 "", "", "", "", "", "", "", "",
658 "", "", "", "", "", "", "", "",
659 "", "", "", "", "", "", "", "",
660 "", "", "", "", "Pad Enter", "Right Ctrl", "", "",
662 "", "", "", "", "", "", "", "",
663 "", "", "", "", "", "", "", "",
664 "", "", "", "", "", "Pad /", "", "Print Scrn",
665 "Alt", "", "", "", "", "", "", "",
667 "", "", "", "", "", "Num Lock", "", "Home",
668 "Up Arrow", "Page Up", "", "Left Arrow", "", "Right Arrow", "", "End",
669 "Down Arrow", "Page Down", "Insert", "Delete", "", "", "", "",
670 "", "", "", "", "", "", "", "",
672 "", "", "", "", "", "", "", "",
673 "", "", "", "", "", "", "", "",
674 "", "", "", "", "", "", "", "",
675 "", "", "", "", "", "", "", "",
678 char *Joy_button_text_english[] = {
679 "Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6",
680 "Button 7", "Button 8", "Button 9", "Button 10", "Button 11", "Button 12",
681 "Button 13", "Button 14", "Button 15", "Button 16", "Button 17", "Button 18",
682 "Button 19", "Button 20", "Button 21", "Button 22", "Button 23", "Button 24",
683 "Button 25", "Button 26", "Button 27", "Button 28", "Button 29", "Button 30",
684 "Button 31", "Button 32", "Hat Back", "Hat Forward", "Hat Left", "Hat Right"
687 char **Scan_code_text = Scan_code_text_english;
688 char **Joy_button_text = Joy_button_text_english;
690 void set_modifier_status()
695 Shift_is_modifier = 0;
696 Ctrl_is_modifier = 0;
698 for (i=0; i<CCFG_MAX; i++) {
699 if (Control_config[i].key_id < 0)
702 if (Control_config[i].key_id & KEY_ALTED)
705 if (Control_config[i].key_id & KEY_SHIFTED)
706 Shift_is_modifier = 1;
708 if (Control_config[i].key_id & KEY_CTRLED) {
709 Assert(0); // get Alan
710 Ctrl_is_modifier = 1;
715 int translate_key_to_index(char *key)
717 int i, index = -1, alt = 0, shift = 0, max_scan_codes;
720 max_scan_codes = sizeof(Scan_code_text_german) / sizeof(char *);
722 max_scan_codes = sizeof(Scan_code_text_french) / sizeof(char *);
724 max_scan_codes = sizeof(Scan_code_text_english) / sizeof(char *);
727 // look for modifiers
729 if (!strnicmp(key, "Alt", 3)) {
736 char *translated_shift;
739 translated_shift = "Shift";
741 translated_shift = "Maj.";
743 translated_shift = "Shift";
746 if (!strnicmp(key, translated_shift, 5)) {
753 // look up index for default key
755 for (i=0; i<max_scan_codes; i++)
756 if (!stricmp(key, Scan_code_text_english[i])) {
761 if (i == max_scan_codes)
765 index |= KEY_SHIFTED;
769 // convert scancode to Control_config index
770 for (i=0; i<CCFG_MAX; i++) {
771 if (Control_config[i].key_default == index) {
786 // Given the system default key 'key', return the current key that is bound to the function
787 // Both are 'key' and the return value are descriptive strings that can be displayed
788 // directly to the user. If 'key' isn't a real key or not normally bound to anything,
789 // or there is no key current bound to the function, NULL is returned.
790 char *translate_key(char *key)
792 int index = -1, code = -1;
794 index = translate_key_to_index(key);
798 code = Control_config[index].key_id;
799 Failed_key_index = index;
801 code = Control_config[index].joy_id;
803 return Joy_button_text[code];
806 return textify_scancode(code);
809 char *textify_scancode(int code)
811 static char text[40];
817 if (code & KEY_ALTED) {
819 strcat(text, "Alt-");
821 strcat(text, "Alt-");
823 strcat(text, "Alt-");
827 if (code & KEY_SHIFTED) {
829 strcat(text, "Shift-");
831 strcat(text, "Maj.-");
833 strcat(text, "Shift-");
837 strcat(text, Scan_code_text[code & KEY_MASK]);
842 // initialize common control config stuff - call at game startup after localization has been initialized
843 void control_config_common_init()
846 Scan_code_text = Scan_code_text_german;
847 Joy_button_text = Joy_button_text_german;
849 // swap init bindings for y and z keys
850 Control_config[TARGET_SHIP_IN_RETICLE].key_default = KEY_Z;
851 Control_config[TARGET_LAST_TRANMISSION_SENDER].key_default = KEY_ALTED | KEY_Z;
852 Control_config[REVERSE_THRUST].key_default = KEY_Y;
853 Control_config[DISARM_MESSAGE].key_default = KEY_SHIFTED | KEY_Y;
855 Scan_code_text = Scan_code_text_french;
856 Joy_button_text = Joy_button_text_french;
858 Scan_code_text = Scan_code_text_english;
859 Joy_button_text = Joy_button_text_english;