Fully softcoded the key defaults.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@980 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
mcmartin
2003-06-16 02:53:58 +00:00
parent 1fd2db3614
commit 6c8922b4df
3 changed files with 99 additions and 154 deletions
+68 -45
View File
@@ -1,62 +1,85 @@
# Sample UQM input configuration file. This file may replace the # Default UQM input configuration file.
# automatically generated keys.cfg if you wish; there is no difference
# in behavior. This one just has more comments in it.
# This is the actual key configuration. Most keys can be described in # Keyboard control definitions follow this point. Most keys can be
# a straightforward manner; consult the name table in # described in a straightforward manner; consult the name table in
# src/sc2code/libs/input/sdl/keynames.c for the names of unusual keys. # src/sc2code/libs/input/sdl/keynames.c for the names of unusual keys.
# Most keys can be named by just the symbol they produce. # Most keys can be named by just the symbol they produce.
Menu-Select: key Return # Menu controls. Both sets of arrow keys, basically. Paging controls
Player-1-Thrust: key Return # moving quickly through the file lists in Super Melee. Zooming
Lander-Thrust: key Return # controls zoom controls in the starmap. "Cancel" is also used to get
Player-1-Escape: key Escape # you into menu mode to begin with. There is a "Menu-Special" command
Lander-Escape: key Escape # currently unused by the game. It seems to have been originally used
Menu-Cancel: key Space # to call up details on starships in the Super Melee selection screen.
Player-1-Weapon: key Space
Lander-Weapon: key Space # Arrow key controls...
Player-2-Left: key a
Player-2-Right: key d
Player-2-Weapon: key t
Player-2-Thrust: key w
Player-2-Special: key y
Menu-Down: key Keypad-2
Menu-Page-Down: key Keypad-3
Menu-Left: key Keypad-4
Player-1-Left: key Keypad-4
Lander-Left: key Keypad-4
Menu-Right: key Keypad-6
Player-1-Right: key Keypad-6
Lander-Right: key Keypad-6
Menu-Up: key Keypad-8
Player-1-Thrust: key Keypad-8
Lander-Thrust: key Keypad-8
Menu-Page-Up: key Keypad-9
Menu-Zoom-Out: key Keypad--
Menu-Zoom-In: key Keypad-+
Menu-Select: key Keypad-Enter
Player-1-Thrust: key Keypad-Enter
Lander-Thrust: key Keypad-Enter
Menu-Up: key Up Menu-Up: key Up
Player-1-Thrust: key Up
Lander-Thrust: key Up
Menu-Down: key Down Menu-Down: key Down
Menu-Right: key Right Menu-Right: key Right
Player-1-Right: key Right
Lander-Right: key Right
Menu-Left: key Left Menu-Left: key Left
Player-1-Left: key Left
Lander-Left: key Left
Menu-Page-Up: key PageUp Menu-Page-Up: key PageUp
Menu-Zoom-In: key PageUp
Menu-Page-Down: key PageDown Menu-Page-Down: key PageDown
Menu-Zoom-In: key PageUp
Menu-Zoom-Out: key PageDown Menu-Zoom-Out: key PageDown
Menu-Select: key Return
Menu-Cancel: key Space
# ... and the number pad. Note that zoom controls on the starmap are
# different from the paging controls in Super Melee.
Menu-Up: key Keypad-8
Menu-Down: key Keypad-2
Menu-Left: key Keypad-4
Menu-Right: key Keypad-6
Menu-Page-Up: key Keypad-9
Menu-Page-Down: key Keypad-3
Menu-Zoom-In: key Keypad-+
Menu-Zoom-Out: key Keypad--
Menu-Select: key Keypad-Enter
Menu-Cancel: key Keypad-0
# Player 1's flight controls. This is the bottom player in Super
# Melee and the player in the full game. Again, the player has the
# option of using either the number pad or the arrow keys.
Player-1-Thrust: key Return
Player-1-Thrust: key Up
Player-1-Left: key Left
Player-1-Right: key Right
Player-1-Weapon: key RightShift
Player-1-Special: key RightControl
Player-1-Escape: key Escape
Player-1-Thrust: key Keypad-Enter
Player-1-Thrust: key Keypad-8
Player-1-Left: key Keypad-4
Player-1-Right: key Keypad-6
# Lander controls. These map mostly to Player 1's controls.
Lander-Thrust: key Return
Lander-Thrust: key Up
Lander-Left: key Left
Lander-Right: key Right
Lander-Thrust: key Keypad-Enter
Lander-Thrust: key Keypad-8
Lander-Left: key Keypad-4
Lander-Right: key Keypad-6
Lander-Weapon: key RightShift
Lander-Escape: key Escape
# Player 2's flight controls.
Player-2-Thrust: key e
Player-2-Left: key s
Player-2-Right: key f
Player-2-Weapon: key q
Player-2-Special: key a
# System utility keys.
Pause: key F1 Pause: key F1
Exit: key F10 Exit: key F10
Abort: key F12 Abort: key F12
Player-1-Weapon: key RightShift
Lander-Weapon: key RightShift
Player-1-Special: key RightControl
# This is a sample joystick configuration. This is intended to work # This is a sample joystick configuration. This is intended to work
# primarily under WinXP with a USB analag/digital gamepad. The # primarily under WinXP with a USB analag/digital gamepad. The
@@ -30,6 +30,5 @@ enum
int TFB_InitInput (int driver, int flags); int TFB_InitInput (int driver, int flags);
void TFB_UninitInput (void); void TFB_UninitInput (void);
void TFB_CreateDefaultConfig (void);
#endif #endif
+16 -93
View File
@@ -74,18 +74,28 @@ static void
initKeyConfig(void) { initKeyConfig(void) {
char userFile[PATH_MAX]; /* System-wide key config */ char userFile[PATH_MAX]; /* System-wide key config */
int cb; int cb;
FILE *fp;
int errors;
cb = snprintf (userFile, PATH_MAX, "%skeys.cfg", configDir); cb = snprintf (userFile, PATH_MAX, "%skeys.cfg", configDir);
assert (cb != -1); assert (cb != -1);
// Verified before: strlen (configDir) <= PATH_MAX - 13 // Verified before: strlen (configDir) <= PATH_MAX - 13
if (fileExists (userFile)) { if (fileExists (userFile)) {
FILE *fp;
int errors;
/* Should this really be an OpenResFile? The user
* won't be putting his configuration data in a .zip,
* will he? */
fp = res_OpenResFile (userFile, "rt"); fp = res_OpenResFile (userFile, "rt");
} else {
if (copyFile ("starcon.key", userFile) == -1)
{
fprintf(stderr, "Warning: Could not copy default key config "
"to %s: %s.\n", userFile, strerror (errno));
}
else
{
fprintf(stderr, "Copying default key config file to %s.\n",
userFile);
}
fp = res_OpenResFile ("starcon.key", "rt");
}
errors = VControl_ReadConfiguration (fp); errors = VControl_ReadConfiguration (fp);
res_CloseResFile (fp); res_CloseResFile (fp);
if (errors) if (errors)
@@ -98,6 +108,7 @@ initKeyConfig(void) {
if (errors > 5) if (errors > 5)
{ {
fprintf (stderr, "Hey! you haven't updated your keys.cfg to use the new system, have you?\nDelete %s and try again.\n", userFile); fprintf (stderr, "Hey! you haven't updated your keys.cfg to use the new system, have you?\nDelete %s and try again.\n", userFile);
fprintf (stderr, "If you've done that and it STILL doesn't work, make sure your content/starcon.key is up to date.\n");
} }
else else
{ {
@@ -106,23 +117,7 @@ initKeyConfig(void) {
exit (1); exit (1);
} }
} else {
FILE *fp = fopen (userFile, "wt");
TFB_CreateDefaultConfig ();
if (fp == NULL)
{
fprintf(stderr, "Warning: Could not copy default key config "
"to %s: %s.\n", userFile, strerror (errno));
}
else
{
fprintf(stderr, "Copying default key config file to %s.\n",
userFile);
VControl_Dump (fp);
fclose (fp);
}
}
} }
int int
@@ -178,78 +173,6 @@ TFB_UninitInput (void)
VControl_Uninit (); VControl_Uninit ();
} }
void
TFB_CreateDefaultConfig (void)
{
/* Generate the default control structures. Arrow keys have
* the expected effect. ENTER is menu select, SPACE is menu
* cancel. In combat or on planet surfaces, move with the
* arrow keys, or thrust with ENTER, fire with SPACE or right
* SHIFT, and do your special with right CTRL. Escaping is
* handled by the ESCAPE key. Player 2 flies with W-A-D,
* fires with T, and does his special with Y. Pause is F1,
* Exit is F10, and Abort is F12. Zooming may be done with
* Page Up or Page Down, or with the + and - keys on the
* numeric keypad.
*
* All references to "the arrow keys" or "ENTER" may use the
* numeric keypad. */
VControl_AddKeyBinding (SDLK_UP, (int *)&ImmediateMenuState.up);
VControl_AddKeyBinding (SDLK_DOWN, (int *)&ImmediateMenuState.down);
VControl_AddKeyBinding (SDLK_LEFT, (int *)&ImmediateMenuState.left);
VControl_AddKeyBinding (SDLK_RIGHT, (int *)&ImmediateMenuState.right);
VControl_AddKeyBinding (SDLK_RETURN, (int *)&ImmediateMenuState.select);
VControl_AddKeyBinding (SDLK_KP8, (int *)&ImmediateMenuState.up);
VControl_AddKeyBinding (SDLK_KP2, (int *)&ImmediateMenuState.down);
VControl_AddKeyBinding (SDLK_KP4, (int *)&ImmediateMenuState.left);
VControl_AddKeyBinding (SDLK_KP6, (int *)&ImmediateMenuState.right);
VControl_AddKeyBinding (SDLK_KP_ENTER, (int *)&ImmediateMenuState.select);
VControl_AddKeyBinding (SDLK_SPACE, (int *)&ImmediateMenuState.cancel);
VControl_AddKeyBinding (SDLK_PAGEUP, (int *)&ImmediateMenuState.page_up);
VControl_AddKeyBinding (SDLK_PAGEDOWN, (int *)&ImmediateMenuState.page_down);
VControl_AddKeyBinding (SDLK_KP9, (int *)&ImmediateMenuState.page_up);
VControl_AddKeyBinding (SDLK_KP3, (int *)&ImmediateMenuState.page_down);
VControl_AddKeyBinding (SDLK_PAGEUP, (int *)&ImmediateMenuState.zoom_in);
VControl_AddKeyBinding (SDLK_PAGEDOWN, (int *)&ImmediateMenuState.zoom_out);
VControl_AddKeyBinding (SDLK_KP_PLUS, (int *)&ImmediateMenuState.zoom_in);
VControl_AddKeyBinding (SDLK_KP_MINUS, (int *)&ImmediateMenuState.zoom_out);
VControl_AddKeyBinding (SDLK_KP8, (int *)&ImmediateInputState.p1_thrust);
VControl_AddKeyBinding (SDLK_UP, (int *)&ImmediateInputState.p1_thrust);
VControl_AddKeyBinding (SDLK_RETURN, (int *)&ImmediateInputState.p1_thrust);
VControl_AddKeyBinding (SDLK_KP_ENTER, (int *)&ImmediateInputState.p1_thrust);
VControl_AddKeyBinding (SDLK_KP4, (int *)&ImmediateInputState.p1_left);
VControl_AddKeyBinding (SDLK_LEFT, (int *)&ImmediateInputState.p1_left);
VControl_AddKeyBinding (SDLK_KP6, (int *)&ImmediateInputState.p1_right);
VControl_AddKeyBinding (SDLK_RIGHT, (int *)&ImmediateInputState.p1_right);
VControl_AddKeyBinding (SDLK_SPACE, (int *)&ImmediateInputState.p1_weapon);
VControl_AddKeyBinding (SDLK_RSHIFT, (int *)&ImmediateInputState.p1_weapon);
VControl_AddKeyBinding (SDLK_RCTRL, (int *)&ImmediateInputState.p1_special);
VControl_AddKeyBinding (SDLK_ESCAPE, (int *)&ImmediateInputState.p1_escape);
VControl_AddKeyBinding (SDLK_e, (int *)&ImmediateInputState.p2_thrust);
VControl_AddKeyBinding (SDLK_s, (int *)&ImmediateInputState.p2_left);
VControl_AddKeyBinding (SDLK_f, (int *)&ImmediateInputState.p2_right);
VControl_AddKeyBinding (SDLK_q, (int *)&ImmediateInputState.p2_weapon);
VControl_AddKeyBinding (SDLK_a, (int *)&ImmediateInputState.p2_special);
VControl_AddKeyBinding (SDLK_KP8, (int *)&ImmediateInputState.lander_thrust);
VControl_AddKeyBinding (SDLK_UP, (int *)&ImmediateInputState.lander_thrust);
VControl_AddKeyBinding (SDLK_RETURN, (int *)&ImmediateInputState.lander_thrust);
VControl_AddKeyBinding (SDLK_KP_ENTER, (int *)&ImmediateInputState.lander_thrust);
VControl_AddKeyBinding (SDLK_KP4, (int *)&ImmediateInputState.lander_left);
VControl_AddKeyBinding (SDLK_LEFT, (int *)&ImmediateInputState.lander_left);
VControl_AddKeyBinding (SDLK_KP6, (int *)&ImmediateInputState.lander_right);
VControl_AddKeyBinding (SDLK_RIGHT, (int *)&ImmediateInputState.lander_right);
VControl_AddKeyBinding (SDLK_SPACE, (int *)&ImmediateInputState.lander_weapon);
VControl_AddKeyBinding (SDLK_RSHIFT, (int *)&ImmediateInputState.lander_weapon);
VControl_AddKeyBinding (SDLK_ESCAPE, (int *)&ImmediateInputState.lander_escape);
VControl_AddKeyBinding (SDLK_F1, (int *)&ImmediateInputState.pause);
VControl_AddKeyBinding (SDLK_F10, (int *)&ImmediateInputState.exit);
VControl_AddKeyBinding (SDLK_F12, (int *)&ImmediateInputState.abort);
}
void void
EnableCharacterMode (void) EnableCharacterMode (void)
{ {