From dfe0f8a599dc1005fe8d9a3a88eb39d405f8476b Mon Sep 17 00:00:00 2001 From: mcmartin Date: Sat, 5 Jul 2003 23:15:18 +0000 Subject: [PATCH] Added several keys to the new input system This allows the player to use "down" keys for selecting ships in melee, even though there is no "down" in battle. Infrastructure for several later enhancements is also in this patch. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1024 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/content/starcon.key | 4 +++- sc2/src/sc2code/controls.h | 8 +++++--- sc2/src/sc2code/gameinp.c | 13 ++++++++++++- sc2/src/sc2code/libs/graphics/sdl/sdl_common.c | 5 +++++ sc2/src/sc2code/libs/input/sdl/input.c | 6 +++++- sc2/src/sc2code/pickmele.c | 2 +- 6 files changed, 31 insertions(+), 7 deletions(-) diff --git a/sc2/content/starcon.key b/sc2/content/starcon.key index 946ca6d9c..03c9319c6 100644 --- a/sc2/content/starcon.key +++ b/sc2/content/starcon.key @@ -69,10 +69,12 @@ Lander-Right: key Keypad-6 Lander-Weapon: key RightShift Lander-Escape: key Escape -# Player 2's flight controls. +# Player 2's flight controls. We add the key 'd' to let him +# move down in the super-melee ship selection. Player-2-Thrust: key e Player-2-Left: key s Player-2-Right: key f +Player-2-Down: key d Player-2-Weapon: key q Player-2-Special: key a diff --git a/sc2/src/sc2code/controls.h b/sc2/src/sc2code/controls.h index 047952ac8..9727cfb63 100644 --- a/sc2/src/sc2code/controls.h +++ b/sc2/src/sc2code/controls.h @@ -25,15 +25,16 @@ // This struct controls the various controls available to the player. typedef struct _controller_input_state { - int p1_thrust, p1_left, p1_right, p1_weapon, p1_special, p1_escape; - int p2_thrust, p2_left, p2_right, p2_weapon, p2_special; + int p1_thrust, p1_left, p1_right, p1_down, p1_weapon, p1_special, p1_escape; + int p2_thrust, p2_left, p2_right, p2_down, p2_weapon, p2_special; int lander_thrust, lander_left, lander_right, lander_weapon, lander_escape; - int pause, exit, abort; + int pause, exit, abort, debug; } CONTROLLER_INPUT_STATE; typedef struct _menu_input_state { int up, down, left, right, select, cancel, special; int page_up, page_down, zoom_in, zoom_out; + int del; } MENU_INPUT_STATE; typedef UBYTE BATTLE_INPUT_STATE; @@ -43,6 +44,7 @@ typedef UBYTE BATTLE_INPUT_STATE; #define BATTLE_WEAPON ((BATTLE_INPUT_STATE)(1 << 3)) #define BATTLE_SPECIAL ((BATTLE_INPUT_STATE)(1 << 4)) #define BATTLE_ESCAPE ((BATTLE_INPUT_STATE)(1 << 5)) +#define BATTLE_DOWN ((BATTLE_INPUT_STATE)(1 << 6)) typedef BATTLE_INPUT_STATE (*battle_summary_func) (void); extern battle_summary_func ComputerInput, HumanInput[NUM_PLAYERS]; diff --git a/sc2/src/sc2code/gameinp.c b/sc2/src/sc2code/gameinp.c index 54e90280b..527c4c726 100644 --- a/sc2/src/sc2code/gameinp.c +++ b/sc2/src/sc2code/gameinp.c @@ -36,7 +36,7 @@ typedef INPUT_STATE_DESC *PINPUT_STATE_DESC; typedef struct { DWORD up, down, left, right, select, cancel, special; - DWORD page_up, page_down, zoom_in, zoom_out; + DWORD page_up, page_down, zoom_in, zoom_out, del; } MENU_ANNOTATIONS; @@ -67,6 +67,7 @@ _clear_menu_state (void) CurrentMenuState.page_down = 0; CurrentMenuState.zoom_in = 0; CurrentMenuState.zoom_out = 0; + CurrentMenuState.del = 0; CachedMenuState.up = 0; CachedMenuState.down = 0; CachedMenuState.left = 0; @@ -78,6 +79,7 @@ _clear_menu_state (void) CachedMenuState.page_down = 0; CachedMenuState.zoom_in = 0; CachedMenuState.zoom_out = 0; + CachedMenuState.del = 0; CachedGestalt = FALSE; } @@ -96,6 +98,7 @@ ResetKeyRepeat (void) RepeatDelays.page_down = _max_accel; RepeatDelays.zoom_in = _max_accel; RepeatDelays.zoom_out = _max_accel; + RepeatDelays.del = _max_accel; GestaltRepeatDelay = _max_accel; Times.up = initTime; Times.down = initTime; @@ -108,6 +111,7 @@ ResetKeyRepeat (void) Times.page_down = initTime; Times.zoom_in = initTime; Times.zoom_out = initTime; + Times.del = initTime; GestaltTime = initTime; } @@ -217,6 +221,7 @@ UpdateInputState (void) _check_for_pulse(&CurrentMenuState.page_down, &CachedMenuState.page_down, &OldMenuState.page_down, &RepeatDelays.page_down, &NewTime, &Times.page_down); _check_for_pulse(&CurrentMenuState.zoom_in, &CachedMenuState.zoom_in, &OldMenuState.zoom_in, &RepeatDelays.zoom_in, &NewTime, &Times.zoom_in); _check_for_pulse(&CurrentMenuState.zoom_out, &CachedMenuState.zoom_out, &OldMenuState.zoom_out, &RepeatDelays.zoom_out, &NewTime, &Times.zoom_out); + _check_for_pulse(&CurrentMenuState.del, &CachedMenuState.del, &OldMenuState.del, &RepeatDelays.del, &NewTime, &Times.del); if (CurrentInputState.pause) GamePaused = TRUE; @@ -328,6 +333,8 @@ p1_combat_summary (void) InputState |= BATTLE_SPECIAL; if (CurrentInputState.p1_escape) InputState |= BATTLE_ESCAPE; + if (CurrentInputState.p1_down) + InputState |= BATTLE_DOWN; return InputState; } @@ -345,6 +352,8 @@ p2_combat_summary (void) InputState |= BATTLE_WEAPON; if (CurrentInputState.p2_special) InputState |= BATTLE_SPECIAL; + if (CurrentInputState.p2_down) + InputState |= BATTLE_DOWN; return InputState; } @@ -356,12 +365,14 @@ AnyButtonPress (BOOLEAN CheckSpecial) return CurrentInputState.p1_thrust ||CurrentInputState.p1_left ||CurrentInputState.p1_right + ||CurrentInputState.p1_down ||CurrentInputState.p1_weapon ||CurrentInputState.p1_special ||CurrentInputState.p1_escape ||CurrentInputState.p2_thrust ||CurrentInputState.p2_left ||CurrentInputState.p2_right + ||CurrentInputState.p2_down ||CurrentInputState.p2_weapon ||CurrentInputState.p2_special ||CurrentInputState.lander_thrust diff --git a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c index 3c926dc25..889e748ef 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c +++ b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c @@ -125,6 +125,11 @@ TFB_ProcessEvents () } if (ImmediateInputState.abort) exit (0); + if (ImmediateInputState.debug) + { + FlushInput (); + fprintf (stderr, "This would enter debug mode if we had one yet, but we don't.\n"); + } } void diff --git a/sc2/src/sc2code/libs/input/sdl/input.c b/sc2/src/sc2code/libs/input/sdl/input.c index ae94a567b..593e2f535 100644 --- a/sc2/src/sc2code/libs/input/sdl/input.c +++ b/sc2/src/sc2code/libs/input/sdl/input.c @@ -49,15 +49,18 @@ static VControl_NameBinding control_names[] = { { "Menu-Page-Down", (int *)&ImmediateMenuState.page_down }, { "Menu-Zoom-In", (int *)&ImmediateMenuState.zoom_in }, { "Menu-Zoom-Out", (int *)&ImmediateMenuState.zoom_out }, + { "Menu-Delete", (int *)&ImmediateMenuState.del }, { "Player-1-Thrust", (int *)&ImmediateInputState.p1_thrust }, { "Player-1-Left", (int *)&ImmediateInputState.p1_left }, { "Player-1-Right", (int *)&ImmediateInputState.p1_right }, + { "Player-1-Down", (int *)&ImmediateInputState.p1_down }, { "Player-1-Weapon", (int *)&ImmediateInputState.p1_weapon }, { "Player-1-Special", (int *)&ImmediateInputState.p1_special }, { "Player-1-Escape", (int *)&ImmediateInputState.p1_escape }, { "Player-2-Thrust", (int *)&ImmediateInputState.p2_thrust }, { "Player-2-Left", (int *)&ImmediateInputState.p2_left }, { "Player-2-Right", (int *)&ImmediateInputState.p2_right }, + { "Player-2-Down", (int *)&ImmediateInputState.p2_down }, { "Player-2-Weapon", (int *)&ImmediateInputState.p2_weapon }, { "Player-2-Special", (int *)&ImmediateInputState.p2_special }, { "Lander-Thrust", (int *)&ImmediateInputState.lander_thrust }, @@ -67,7 +70,8 @@ static VControl_NameBinding control_names[] = { { "Lander-Escape", (int *)&ImmediateInputState.lander_escape }, { "Pause", (int *)&ImmediateInputState.pause }, { "Exit", (int *)&ImmediateInputState.exit }, - { "Abort", (int *)&ImmediateInputState.abort }}; + { "Abort", (int *)&ImmediateInputState.abort }, + { "Debug", (int *)&ImmediateInputState.debug }}; static void diff --git a/sc2/src/sc2code/pickmele.c b/sc2/src/sc2code/pickmele.c index 1d0548048..cc5ed5c63 100644 --- a/sc2/src/sc2code/pickmele.c +++ b/sc2/src/sc2code/pickmele.c @@ -230,7 +230,7 @@ GetMeleeStarShip (STARSHIPPTR LastStarShipPtr, COUNT which_player) if (new_row-- == 0) new_row = NUM_MELEE_ROWS - 1; } - else if (CurrentMenuState.down) + else if ((InputState & BATTLE_DOWN) || CurrentMenuState.down) { if (++new_row == NUM_MELEE_ROWS) new_row = 0;