From 7b2d5a642777b43ddad84aca1764e7a1104c7aca Mon Sep 17 00:00:00 2001 From: mcmartin Date: Thu, 15 Jan 2004 07:52:45 +0000 Subject: [PATCH] Input refactoring, phase 1 Instead of two structs with many members, these structs are now an array indexed by an enum. This makes it easier to take actions on the entirety of the input state. The input core itself (input/ and gameinp.c) look a lot messier at the moment; phase 2 will be to clean them up. This phase is mostly to get "typographical" changes across the code out of the way first to minimize update disruption. This refactoring has the eventual goal of eliminating the special purpose input code scattered throught battles, SuperMelee's menus, and IP exploration. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1312 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 2 + sc2/src/sc2code/comm.c | 22 +- sc2/src/sc2code/confirm.c | 6 +- sc2/src/sc2code/controls.h | 54 +++- sc2/src/sc2code/encount.c | 8 +- sc2/src/sc2code/gameinp.c | 271 +++++++++--------- sc2/src/sc2code/gameopt.c | 30 +- sc2/src/sc2code/getchar.c | 12 +- .../sc2code/libs/graphics/sdl/sdl_common.c | 4 +- sc2/src/sc2code/libs/input/sdl/input.c | 68 ++--- sc2/src/sc2code/libs/video/vidplayer.c | 12 +- sc2/src/sc2code/melee.c | 56 ++-- sc2/src/sc2code/menu.c | 6 +- sc2/src/sc2code/outfit.c | 26 +- sc2/src/sc2code/pickmele.c | 10 +- sc2/src/sc2code/pickship.c | 10 +- sc2/src/sc2code/planets/cargo.c | 8 +- sc2/src/sc2code/planets/devices.c | 8 +- sc2/src/sc2code/planets/lander.c | 12 +- sc2/src/sc2code/planets/pstarmap.c | 18 +- sc2/src/sc2code/planets/roster.c | 10 +- sc2/src/sc2code/planets/scan.c | 16 +- sc2/src/sc2code/planets/solarsys.c | 10 +- sc2/src/sc2code/restart.c | 12 +- sc2/src/sc2code/save.c | 2 +- sc2/src/sc2code/ships/sis_ship/sis_ship.c | 2 +- sc2/src/sc2code/shipyard.c | 18 +- sc2/src/sc2code/starbase.c | 6 +- sc2/src/sc2code/util.c | 6 +- 29 files changed, 375 insertions(+), 350 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 0da4a5b6d..d7d8ea2e5 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,6 @@ Changes towards version 0.4: +- Input code refactoring, phase 1: Replaced messy structs with an + array indexed by an enum. -Michael - Thread code refactoring: only the main thread will actually spawn threads, and thread IDs are properly recycled with SDL_WaitThead () once they're done. (With luck, this will fix bug #561) -Michael diff --git a/sc2/src/sc2code/comm.c b/sc2/src/sc2code/comm.c index 044fddc72..3bfdbdefa 100644 --- a/sc2/src/sc2code/comm.c +++ b/sc2/src/sc2code/comm.c @@ -1355,7 +1355,7 @@ SpewPhrases (COUNT wait_track) #endif LockMutex (GraphicsLock); - if (CurrentMenuState.cancel) + if (PulsedInputState.key[KEY_MENU_CANCEL]) { SetSliderImage (SetAbsFrameIndex (ActivityFrame, 8)); JumpTrack (); @@ -1369,13 +1369,13 @@ SpewPhrases (COUNT wait_track) BOOLEAN left=FALSE, right=FALSE; if (optSmoothScroll == OPT_PC) { - left = CurrentMenuState.left; - right = CurrentMenuState.right; + left = PulsedInputState.key[KEY_MENU_LEFT]; + right = PulsedInputState.key[KEY_MENU_RIGHT]; } else if (optSmoothScroll == OPT_3DO) { - left = ImmediateMenuState.left; - right = ImmediateMenuState.right; + left = ImmediateInputState.key[KEY_MENU_LEFT]; + right = ImmediateInputState.key[KEY_MENU_RIGHT]; } if (right) { @@ -1578,7 +1578,7 @@ DoCommunication (PENCOUNTER_STATE pES) TimeIn = GetTimeCounter (); // Warning! This used to re-gather input data to check for rewind. UpdateInputState (); - if (CurrentMenuState.left) + if (PulsedInputState.key[KEY_MENU_LEFT]) { FadeMusic (BACKGROUND_VOL, ONE_SECOND); LockMutex (GraphicsLock); @@ -1639,7 +1639,7 @@ DoCommunication (PENCOUNTER_STATE pES) UnlockMutex (GraphicsLock); } - if (CurrentMenuState.select) + if (PulsedInputState.key[KEY_MENU_SELECT]) { pES->phrase_buf_index = pES->response_list[pES->cur_response].response_text.CharCount; @@ -1661,7 +1661,7 @@ DoCommunication (PENCOUNTER_STATE pES) (*pES->response_list[pES->cur_response].response_func) (pES->response_list[pES->cur_response].response_ref); } - else if (CurrentMenuState.cancel && + else if (PulsedInputState.key[KEY_MENU_CANCEL] && LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE) { TFB_SoundChain *curr; @@ -1809,7 +1809,7 @@ DoCommunication (PENCOUNTER_STATE pES) else { response = pES->cur_response; - if (CurrentMenuState.left) + if (PulsedInputState.key[KEY_MENU_LEFT]) { FadeMusic (BACKGROUND_VOL, ONE_SECOND); LockMutex (GraphicsLock); @@ -1857,10 +1857,10 @@ DoCommunication (PENCOUNTER_STATE pES) TaskSwitch (); while (CommData.AlienTalkDesc.AnimFlags & PAUSE_TALKING); } - else if (CurrentMenuState.up) + else if (PulsedInputState.key[KEY_MENU_UP]) response = (BYTE)((response + (BYTE)(pES->num_responses - 1)) % pES->num_responses); - else if (CurrentMenuState.down) + else if (PulsedInputState.key[KEY_MENU_DOWN]) response = (BYTE)((BYTE)(response + 1) % pES->num_responses); diff --git a/sc2/src/sc2code/confirm.c b/sc2/src/sc2code/confirm.c index 0b72f3ea9..1a007bbe1 100644 --- a/sc2/src/sc2code/confirm.c +++ b/sc2/src/sc2code/confirm.c @@ -147,18 +147,18 @@ DoConfirmExit (void) ExitRequested = FALSE; GamePaused = FALSE; UpdateInputState (); - if (CurrentMenuState.select) + if (PulsedInputState.key[KEY_MENU_SELECT]) { done = TRUE; PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 1), 0, NotPositional (), NULL, GAME_SOUND_PRIORITY); } - else if (CurrentMenuState.cancel) + else if (PulsedInputState.key[KEY_MENU_CANCEL]) { done = TRUE; response = FALSE; } - else if (CurrentMenuState.left || CurrentMenuState.right) + else if (PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_RIGHT]) { response = !response; DrawConfirmationWindow (response); diff --git a/sc2/src/sc2code/controls.h b/sc2/src/sc2code/controls.h index 81f8ec97c..6c4f77659 100644 --- a/sc2/src/sc2code/controls.h +++ b/sc2/src/sc2code/controls.h @@ -22,21 +22,49 @@ #include "starcon.h" #include "compiler.h" -// This struct controls the various controls available to the player. +// Enumerated type for controls +enum { + KEY_P1_THRUST, + KEY_P1_LEFT, + KEY_P1_RIGHT, + KEY_P1_DOWN, + KEY_P1_WEAPON, + KEY_P1_SPECIAL, + KEY_P1_ESCAPE, + KEY_P2_THRUST, + KEY_P2_LEFT, + KEY_P2_RIGHT, + KEY_P2_DOWN, + KEY_P2_WEAPON, + KEY_P2_SPECIAL, + KEY_LANDER_THRUST, + KEY_LANDER_LEFT, + KEY_LANDER_RIGHT, + KEY_LANDER_WEAPON, + KEY_LANDER_ESCAPE, + KEY_PAUSE, + KEY_EXIT, + KEY_ABORT, + KEY_DEBUG, + KEY_MENU_UP, + KEY_MENU_DOWN, + KEY_MENU_LEFT, + KEY_MENU_RIGHT, + KEY_MENU_SELECT, + KEY_MENU_CANCEL, + KEY_MENU_SPECIAL, + KEY_MENU_PAGE_UP, + KEY_MENU_PAGE_DOWN, + KEY_MENU_ZOOM_IN, + KEY_MENU_ZOOM_OUT, + KEY_MENU_DELETE, + NUM_KEYS +}; typedef struct _controller_input_state { - 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, debug; + int key[NUM_KEYS]; } 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; #define BATTLE_LEFT ((BATTLE_INPUT_STATE)(1 << 0)) #define BATTLE_RIGHT ((BATTLE_INPUT_STATE)(1 << 1)) @@ -50,10 +78,8 @@ typedef BATTLE_INPUT_STATE (*battle_summary_func) (void); extern battle_summary_func ComputerInput, HumanInput[NUM_PLAYERS]; extern battle_summary_func PlayerInput[NUM_PLAYERS]; -extern CONTROLLER_INPUT_STATE CurrentInputState; -extern MENU_INPUT_STATE CurrentMenuState; +extern CONTROLLER_INPUT_STATE CurrentInputState, PulsedInputState; extern volatile CONTROLLER_INPUT_STATE ImmediateInputState; -extern volatile MENU_INPUT_STATE ImmediateMenuState; void UpdateInputState (void); void FlushInputState (void); diff --git a/sc2/src/sc2code/encount.c b/sc2/src/sc2code/encount.c index 532474e3f..aefdcb119 100644 --- a/sc2/src/sc2code/encount.c +++ b/sc2/src/sc2code/encount.c @@ -34,7 +34,7 @@ DoSelectAction (PMENU_STATE pMS) pMS->Initialized = TRUE; pMS->InputFunc = DoSelectAction; } - else if (CurrentMenuState.select) + else if (PulsedInputState.key[KEY_MENU_SELECT]) { switch (pMS->CurState) { @@ -642,10 +642,10 @@ UninitEncounter (void) while (!(AnyButtonPress (TRUE)) && GetTimeCounter () < Time) TaskSwitch (); LockMutex (GraphicsLock); - if (!CurrentInputState.p1_escape) + if (!CurrentInputState.key[KEY_P1_ESCAPE]) { DrawFadeText (str1, str2, FALSE, &scavenge_r); - if (!CurrentInputState.p1_escape) + if (!CurrentInputState.key[KEY_P1_ESCAPE]) { SetContextForeGroundColor (BLACK_COLOR); r.corner.x = scavenge_r.corner.x + 10; @@ -674,7 +674,7 @@ UninitEncounter (void) && GetTimeCounter () < Time) TaskSwitch (); LockMutex (GraphicsLock); - if (!CurrentInputState.p1_escape) + if (!CurrentInputState.key[KEY_P1_ESCAPE]) DrawFadeText (str1, str2, FALSE, &scavenge_r); } } diff --git a/sc2/src/sc2code/gameinp.c b/sc2/src/sc2code/gameinp.c index d09dfad9e..2348390eb 100644 --- a/sc2/src/sc2code/gameinp.c +++ b/sc2/src/sc2code/gameinp.c @@ -35,14 +35,12 @@ 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, del; + DWORD key [NUM_KEYS]; } MENU_ANNOTATIONS; -CONTROLLER_INPUT_STATE CurrentInputState; -MENU_INPUT_STATE CurrentMenuState; -static MENU_INPUT_STATE CachedMenuState, OldMenuState; +CONTROLLER_INPUT_STATE CurrentInputState, PulsedInputState; +static CONTROLLER_INPUT_STATE CachedInputState, OldInputState; static MENU_ANNOTATIONS RepeatDelays, Times; static DWORD GestaltRepeatDelay, GestaltTime; static BOOLEAN OldGestalt, CachedGestalt; @@ -53,35 +51,34 @@ int ExitState; static MENU_SOUND_FLAGS sound_0, sound_1; volatile CONTROLLER_INPUT_STATE ImmediateInputState; -volatile MENU_INPUT_STATE ImmediateMenuState; static void _clear_menu_state (void) { - CurrentMenuState.up = 0; - CurrentMenuState.down = 0; - CurrentMenuState.left = 0; - CurrentMenuState.right = 0; - CurrentMenuState.select = 0; - CurrentMenuState.cancel = 0; - CurrentMenuState.special = 0; - CurrentMenuState.page_up = 0; - CurrentMenuState.page_down = 0; - CurrentMenuState.zoom_in = 0; - CurrentMenuState.zoom_out = 0; - CurrentMenuState.del = 0; - CachedMenuState.up = 0; - CachedMenuState.down = 0; - CachedMenuState.left = 0; - CachedMenuState.right = 0; - CachedMenuState.select = 0; - CachedMenuState.cancel = 0; - CachedMenuState.special = 0; - CachedMenuState.page_up = 0; - CachedMenuState.page_down = 0; - CachedMenuState.zoom_in = 0; - CachedMenuState.zoom_out = 0; - CachedMenuState.del = 0; + PulsedInputState.key[KEY_MENU_UP] = 0; + PulsedInputState.key[KEY_MENU_DOWN] = 0; + PulsedInputState.key[KEY_MENU_LEFT] = 0; + PulsedInputState.key[KEY_MENU_RIGHT] = 0; + PulsedInputState.key[KEY_MENU_SELECT] = 0; + PulsedInputState.key[KEY_MENU_CANCEL] = 0; + PulsedInputState.key[KEY_MENU_SPECIAL] = 0; + PulsedInputState.key[KEY_MENU_PAGE_UP] = 0; + PulsedInputState.key[KEY_MENU_PAGE_DOWN] = 0; + PulsedInputState.key[KEY_MENU_ZOOM_IN] = 0; + PulsedInputState.key[KEY_MENU_ZOOM_OUT] = 0; + PulsedInputState.key[KEY_MENU_DELETE] = 0; + CachedInputState.key[KEY_MENU_UP] = 0; + CachedInputState.key[KEY_MENU_DOWN] = 0; + CachedInputState.key[KEY_MENU_LEFT] = 0; + CachedInputState.key[KEY_MENU_RIGHT] = 0; + CachedInputState.key[KEY_MENU_SELECT] = 0; + CachedInputState.key[KEY_MENU_CANCEL] = 0; + CachedInputState.key[KEY_MENU_SPECIAL] = 0; + CachedInputState.key[KEY_MENU_PAGE_UP] = 0; + CachedInputState.key[KEY_MENU_PAGE_DOWN] = 0; + CachedInputState.key[KEY_MENU_ZOOM_IN] = 0; + CachedInputState.key[KEY_MENU_ZOOM_OUT] = 0; + CachedInputState.key[KEY_MENU_DELETE] = 0; CachedGestalt = FALSE; } @@ -89,31 +86,31 @@ void ResetKeyRepeat (void) { DWORD initTime = GetTimeCounter (); - RepeatDelays.up = _max_accel; - RepeatDelays.down = _max_accel; - RepeatDelays.left = _max_accel; - RepeatDelays.right = _max_accel; - RepeatDelays.select = _max_accel; - RepeatDelays.cancel = _max_accel; - RepeatDelays.special = _max_accel; - RepeatDelays.page_up = _max_accel; - RepeatDelays.page_down = _max_accel; - RepeatDelays.zoom_in = _max_accel; - RepeatDelays.zoom_out = _max_accel; - RepeatDelays.del = _max_accel; + RepeatDelays.key[KEY_MENU_UP] = _max_accel; + RepeatDelays.key[KEY_MENU_DOWN] = _max_accel; + RepeatDelays.key[KEY_MENU_LEFT] = _max_accel; + RepeatDelays.key[KEY_MENU_RIGHT] = _max_accel; + RepeatDelays.key[KEY_MENU_SELECT] = _max_accel; + RepeatDelays.key[KEY_MENU_CANCEL] = _max_accel; + RepeatDelays.key[KEY_MENU_SPECIAL] = _max_accel; + RepeatDelays.key[KEY_MENU_PAGE_UP] = _max_accel; + RepeatDelays.key[KEY_MENU_PAGE_DOWN] = _max_accel; + RepeatDelays.key[KEY_MENU_ZOOM_IN] = _max_accel; + RepeatDelays.key[KEY_MENU_ZOOM_OUT] = _max_accel; + RepeatDelays.key[KEY_MENU_DELETE] = _max_accel; GestaltRepeatDelay = _max_accel; - Times.up = initTime; - Times.down = initTime; - Times.left = initTime; - Times.right = initTime; - Times.select = initTime; - Times.cancel = initTime; - Times.special = initTime; - Times.page_up = initTime; - Times.page_down = initTime; - Times.zoom_in = initTime; - Times.zoom_out = initTime; - Times.del = initTime; + Times.key[KEY_MENU_UP] = initTime; + Times.key[KEY_MENU_DOWN] = initTime; + Times.key[KEY_MENU_LEFT] = initTime; + Times.key[KEY_MENU_RIGHT] = initTime; + Times.key[KEY_MENU_SELECT] = initTime; + Times.key[KEY_MENU_CANCEL] = initTime; + Times.key[KEY_MENU_SPECIAL] = initTime; + Times.key[KEY_MENU_PAGE_UP] = initTime; + Times.key[KEY_MENU_PAGE_DOWN] = initTime; + Times.key[KEY_MENU_ZOOM_IN] = initTime; + Times.key[KEY_MENU_ZOOM_OUT] = initTime; + Times.key[KEY_MENU_DELETE] = initTime; GestaltTime = initTime; } @@ -149,23 +146,23 @@ _check_gestalt (DWORD NewTime) { BOOLEAN CurrentGestalt; OldGestalt = CachedGestalt; - CachedGestalt = ImmediateMenuState.up || ImmediateMenuState.down || ImmediateMenuState.left || ImmediateMenuState.right; - CurrentGestalt = CurrentMenuState.up || CurrentMenuState.down || CurrentMenuState.left || CurrentMenuState.right; + CachedGestalt = ImmediateInputState.key[KEY_MENU_UP] || ImmediateInputState.key[KEY_MENU_DOWN] || ImmediateInputState.key[KEY_MENU_LEFT] || ImmediateInputState.key[KEY_MENU_RIGHT]; + CurrentGestalt = PulsedInputState.key[KEY_MENU_UP] || PulsedInputState.key[KEY_MENU_DOWN] || PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_RIGHT]; if (OldGestalt && CachedGestalt) { if (NewTime - GestaltTime < GestaltRepeatDelay) { - CurrentMenuState.up = 0; - CurrentMenuState.down = 0; - CurrentMenuState.left = 0; - CurrentMenuState.right = 0; + PulsedInputState.key[KEY_MENU_UP] = 0; + PulsedInputState.key[KEY_MENU_DOWN] = 0; + PulsedInputState.key[KEY_MENU_LEFT] = 0; + PulsedInputState.key[KEY_MENU_RIGHT] = 0; } else { - CurrentMenuState.up = CachedMenuState.up; - CurrentMenuState.down = CachedMenuState.down; - CurrentMenuState.left = CachedMenuState.left; - CurrentMenuState.right = CachedMenuState.right; + PulsedInputState.key[KEY_MENU_UP] = CachedInputState.key[KEY_MENU_UP]; + PulsedInputState.key[KEY_MENU_DOWN] = CachedInputState.key[KEY_MENU_DOWN]; + PulsedInputState.key[KEY_MENU_LEFT] = CachedInputState.key[KEY_MENU_LEFT]; + PulsedInputState.key[KEY_MENU_RIGHT] = CachedInputState.key[KEY_MENU_RIGHT]; if (GestaltRepeatDelay > _min_accel) GestaltRepeatDelay -= _step_accel; if (GestaltRepeatDelay < _min_accel) @@ -175,10 +172,10 @@ _check_gestalt (DWORD NewTime) } else { - CurrentMenuState.up = CachedMenuState.up; - CurrentMenuState.down = CachedMenuState.down; - CurrentMenuState.left = CachedMenuState.left; - CurrentMenuState.right = CachedMenuState.right; + PulsedInputState.key[KEY_MENU_UP] = CachedInputState.key[KEY_MENU_UP]; + PulsedInputState.key[KEY_MENU_DOWN] = CachedInputState.key[KEY_MENU_DOWN]; + PulsedInputState.key[KEY_MENU_LEFT] = CachedInputState.key[KEY_MENU_LEFT]; + PulsedInputState.key[KEY_MENU_RIGHT] = CachedInputState.key[KEY_MENU_RIGHT]; GestaltTime = NewTime; GestaltRepeatDelay = _max_accel; } @@ -202,8 +199,8 @@ UpdateInputState (void) } CurrentInputState = ImmediateInputState; - OldMenuState = CachedMenuState; - CachedMenuState = ImmediateMenuState; + OldInputState = CachedInputState; + CachedInputState = ImmediateInputState; NewTime = GetTimeCounter (); if (_gestalt_keys) { @@ -211,24 +208,24 @@ UpdateInputState (void) } else { - _check_for_pulse(&CurrentMenuState.up, &CachedMenuState.up, &OldMenuState.up, &RepeatDelays.up, &NewTime, &Times.up); - _check_for_pulse(&CurrentMenuState.down, &CachedMenuState.down, &OldMenuState.down, &RepeatDelays.down, &NewTime, &Times.down); - _check_for_pulse(&CurrentMenuState.left, &CachedMenuState.left, &OldMenuState.left, &RepeatDelays.left, &NewTime, &Times.left); - _check_for_pulse(&CurrentMenuState.right, &CachedMenuState.right, &OldMenuState.right, &RepeatDelays.right, &NewTime, &Times.right); + _check_for_pulse(&PulsedInputState.key[KEY_MENU_UP], &CachedInputState.key[KEY_MENU_UP], &OldInputState.key[KEY_MENU_UP], &RepeatDelays.key[KEY_MENU_UP], &NewTime, &Times.key[KEY_MENU_UP]); + _check_for_pulse(&PulsedInputState.key[KEY_MENU_DOWN], &CachedInputState.key[KEY_MENU_DOWN], &OldInputState.key[KEY_MENU_DOWN], &RepeatDelays.key[KEY_MENU_DOWN], &NewTime, &Times.key[KEY_MENU_DOWN]); + _check_for_pulse(&PulsedInputState.key[KEY_MENU_LEFT], &CachedInputState.key[KEY_MENU_LEFT], &OldInputState.key[KEY_MENU_LEFT], &RepeatDelays.key[KEY_MENU_LEFT], &NewTime, &Times.key[KEY_MENU_LEFT]); + _check_for_pulse(&PulsedInputState.key[KEY_MENU_RIGHT], &CachedInputState.key[KEY_MENU_RIGHT], &OldInputState.key[KEY_MENU_RIGHT], &RepeatDelays.key[KEY_MENU_RIGHT], &NewTime, &Times.key[KEY_MENU_RIGHT]); } - _check_for_pulse(&CurrentMenuState.select, &CachedMenuState.select, &OldMenuState.select, &RepeatDelays.select, &NewTime, &Times.select); - _check_for_pulse(&CurrentMenuState.cancel, &CachedMenuState.cancel, &OldMenuState.cancel, &RepeatDelays.cancel, &NewTime, &Times.cancel); - _check_for_pulse(&CurrentMenuState.special, &CachedMenuState.special, &OldMenuState.special, &RepeatDelays.special, &NewTime, &Times.special); - _check_for_pulse(&CurrentMenuState.page_up, &CachedMenuState.page_up, &OldMenuState.page_up, &RepeatDelays.page_up, &NewTime, &Times.page_up); - _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); + _check_for_pulse(&PulsedInputState.key[KEY_MENU_SELECT], &CachedInputState.key[KEY_MENU_SELECT], &OldInputState.key[KEY_MENU_SELECT], &RepeatDelays.key[KEY_MENU_SELECT], &NewTime, &Times.key[KEY_MENU_SELECT]); + _check_for_pulse(&PulsedInputState.key[KEY_MENU_CANCEL], &CachedInputState.key[KEY_MENU_CANCEL], &OldInputState.key[KEY_MENU_CANCEL], &RepeatDelays.key[KEY_MENU_CANCEL], &NewTime, &Times.key[KEY_MENU_CANCEL]); + _check_for_pulse(&PulsedInputState.key[KEY_MENU_SPECIAL], &CachedInputState.key[KEY_MENU_SPECIAL], &OldInputState.key[KEY_MENU_SPECIAL], &RepeatDelays.key[KEY_MENU_SPECIAL], &NewTime, &Times.key[KEY_MENU_SPECIAL]); + _check_for_pulse(&PulsedInputState.key[KEY_MENU_PAGE_UP], &CachedInputState.key[KEY_MENU_PAGE_UP], &OldInputState.key[KEY_MENU_PAGE_UP], &RepeatDelays.key[KEY_MENU_PAGE_UP], &NewTime, &Times.key[KEY_MENU_PAGE_UP]); + _check_for_pulse(&PulsedInputState.key[KEY_MENU_PAGE_DOWN], &CachedInputState.key[KEY_MENU_PAGE_DOWN], &OldInputState.key[KEY_MENU_PAGE_DOWN], &RepeatDelays.key[KEY_MENU_PAGE_DOWN], &NewTime, &Times.key[KEY_MENU_PAGE_DOWN]); + _check_for_pulse(&PulsedInputState.key[KEY_MENU_ZOOM_IN], &CachedInputState.key[KEY_MENU_ZOOM_IN], &OldInputState.key[KEY_MENU_ZOOM_IN], &RepeatDelays.key[KEY_MENU_ZOOM_IN], &NewTime, &Times.key[KEY_MENU_ZOOM_IN]); + _check_for_pulse(&PulsedInputState.key[KEY_MENU_ZOOM_OUT], &CachedInputState.key[KEY_MENU_ZOOM_OUT], &OldInputState.key[KEY_MENU_ZOOM_OUT], &RepeatDelays.key[KEY_MENU_ZOOM_OUT], &NewTime, &Times.key[KEY_MENU_ZOOM_OUT]); + _check_for_pulse(&PulsedInputState.key[KEY_MENU_DELETE], &CachedInputState.key[KEY_MENU_DELETE], &OldInputState.key[KEY_MENU_DELETE], &RepeatDelays.key[KEY_MENU_DELETE], &NewTime, &Times.key[KEY_MENU_DELETE]); - if (CurrentInputState.pause) + if (CurrentInputState.key[KEY_PAUSE]) GamePaused = TRUE; - if (CurrentInputState.exit) + if (CurrentInputState.key[KEY_EXIT]) ExitRequested = TRUE; } @@ -285,20 +282,20 @@ DoInput (PVOID pInputState, BOOLEAN resetInput) #endif /* CREATE_JOURNAL */ } - if (CurrentInputState.exit) + if (CurrentInputState.key[KEY_EXIT]) ExitState = ConfirmExit (); input = MENU_SOUND_NONE; - if (CurrentMenuState.up) input |= MENU_SOUND_UP; - if (CurrentMenuState.down) input |= MENU_SOUND_DOWN; - if (CurrentMenuState.left) input |= MENU_SOUND_LEFT; - if (CurrentMenuState.right) input |= MENU_SOUND_RIGHT; - if (CurrentMenuState.select) input |= MENU_SOUND_SELECT; - if (CurrentMenuState.cancel) input |= MENU_SOUND_CANCEL; - if (CurrentMenuState.special) input |= MENU_SOUND_SPECIAL; - if (CurrentMenuState.page_up) input |= MENU_SOUND_PAGEUP; - if (CurrentMenuState.page_down) input |= MENU_SOUND_PAGEDOWN; - if (CurrentMenuState.del) input |= MENU_SOUND_DELETE; + if (PulsedInputState.key[KEY_MENU_UP]) input |= MENU_SOUND_UP; + if (PulsedInputState.key[KEY_MENU_DOWN]) input |= MENU_SOUND_DOWN; + if (PulsedInputState.key[KEY_MENU_LEFT]) input |= MENU_SOUND_LEFT; + if (PulsedInputState.key[KEY_MENU_RIGHT]) input |= MENU_SOUND_RIGHT; + if (PulsedInputState.key[KEY_MENU_SELECT]) input |= MENU_SOUND_SELECT; + if (PulsedInputState.key[KEY_MENU_CANCEL]) input |= MENU_SOUND_CANCEL; + if (PulsedInputState.key[KEY_MENU_SPECIAL]) input |= MENU_SOUND_SPECIAL; + if (PulsedInputState.key[KEY_MENU_PAGE_UP]) input |= MENU_SOUND_PAGEUP; + if (PulsedInputState.key[KEY_MENU_PAGE_DOWN]) input |= MENU_SOUND_PAGEDOWN; + if (PulsedInputState.key[KEY_MENU_DELETE]) input |= MENU_SOUND_DELETE; if (MenuSounds && (pSolarSysState == 0 @@ -347,19 +344,19 @@ BATTLE_INPUT_STATE p1_combat_summary (void) { BATTLE_INPUT_STATE InputState = 0; - if (CurrentInputState.p1_thrust) + if (CurrentInputState.key[KEY_P1_THRUST]) InputState |= BATTLE_THRUST; - if (CurrentInputState.p1_left) + if (CurrentInputState.key[KEY_P1_LEFT]) InputState |= BATTLE_LEFT; - if (CurrentInputState.p1_right) + if (CurrentInputState.key[KEY_P1_RIGHT]) InputState |= BATTLE_RIGHT; - if (CurrentInputState.p1_weapon) + if (CurrentInputState.key[KEY_P1_WEAPON]) InputState |= BATTLE_WEAPON; - if (CurrentInputState.p1_special) + if (CurrentInputState.key[KEY_P1_SPECIAL]) InputState |= BATTLE_SPECIAL; - if (CurrentInputState.p1_escape) + if (CurrentInputState.key[KEY_P1_ESCAPE]) InputState |= BATTLE_ESCAPE; - if (CurrentInputState.p1_down) + if (CurrentInputState.key[KEY_P1_DOWN]) InputState |= BATTLE_DOWN; return InputState; } @@ -368,17 +365,17 @@ BATTLE_INPUT_STATE p2_combat_summary (void) { BATTLE_INPUT_STATE InputState = 0; - if (CurrentInputState.p2_thrust) + if (CurrentInputState.key[KEY_P2_THRUST]) InputState |= BATTLE_THRUST; - if (CurrentInputState.p2_left) + if (CurrentInputState.key[KEY_P2_LEFT]) InputState |= BATTLE_LEFT; - if (CurrentInputState.p2_right) + if (CurrentInputState.key[KEY_P2_RIGHT]) InputState |= BATTLE_RIGHT; - if (CurrentInputState.p2_weapon) + if (CurrentInputState.key[KEY_P2_WEAPON]) InputState |= BATTLE_WEAPON; - if (CurrentInputState.p2_special) + if (CurrentInputState.key[KEY_P2_SPECIAL]) InputState |= BATTLE_SPECIAL; - if (CurrentInputState.p2_down) + if (CurrentInputState.key[KEY_P2_DOWN]) InputState |= BATTLE_DOWN; return InputState; } @@ -388,35 +385,35 @@ AnyButtonPress (BOOLEAN CheckSpecial) { (void) CheckSpecial; // Ignored UpdateInputState (); - 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 - ||CurrentInputState.lander_left - ||CurrentInputState.lander_right - ||CurrentInputState.lander_weapon - ||CurrentInputState.lander_escape - ||CurrentMenuState.up - ||CurrentMenuState.down - ||CurrentMenuState.left - ||CurrentMenuState.right - ||CurrentMenuState.page_up - ||CurrentMenuState.page_down - ||CurrentMenuState.zoom_in - ||CurrentMenuState.zoom_out - ||CurrentMenuState.select - ||CurrentMenuState.cancel - ||CurrentMenuState.special; + return CurrentInputState.key[KEY_P1_THRUST] + ||CurrentInputState.key[KEY_P1_LEFT] + ||CurrentInputState.key[KEY_P1_RIGHT] + ||CurrentInputState.key[KEY_P1_DOWN] + ||CurrentInputState.key[KEY_P1_WEAPON] + ||CurrentInputState.key[KEY_P1_SPECIAL] + ||CurrentInputState.key[KEY_P1_ESCAPE] + ||CurrentInputState.key[KEY_P2_THRUST] + ||CurrentInputState.key[KEY_P2_LEFT] + ||CurrentInputState.key[KEY_P2_RIGHT] + ||CurrentInputState.key[KEY_P2_DOWN] + ||CurrentInputState.key[KEY_P2_WEAPON] + ||CurrentInputState.key[KEY_P2_SPECIAL] + ||CurrentInputState.key[KEY_LANDER_THRUST] + ||CurrentInputState.key[KEY_LANDER_LEFT] + ||CurrentInputState.key[KEY_LANDER_RIGHT] + ||CurrentInputState.key[KEY_LANDER_WEAPON] + ||CurrentInputState.key[KEY_LANDER_ESCAPE] + ||PulsedInputState.key[KEY_MENU_UP] + ||PulsedInputState.key[KEY_MENU_DOWN] + ||PulsedInputState.key[KEY_MENU_LEFT] + ||PulsedInputState.key[KEY_MENU_RIGHT] + ||PulsedInputState.key[KEY_MENU_PAGE_UP] + ||PulsedInputState.key[KEY_MENU_PAGE_DOWN] + ||PulsedInputState.key[KEY_MENU_ZOOM_IN] + ||PulsedInputState.key[KEY_MENU_ZOOM_OUT] + ||PulsedInputState.key[KEY_MENU_SELECT] + ||PulsedInputState.key[KEY_MENU_CANCEL] + ||PulsedInputState.key[KEY_MENU_SPECIAL]; } BOOLEAN diff --git a/sc2/src/sc2code/gameopt.c b/sc2/src/sc2code/gameopt.c index be30fbfb3..3f3a72b0e 100644 --- a/sc2/src/sc2code/gameopt.c +++ b/sc2/src/sc2code/gameopt.c @@ -512,8 +512,8 @@ DoSettings (PMENU_STATE pMS) pMS->Initialized = TRUE; pMS->InputFunc = DoSettings; } - else if (CurrentMenuState.cancel - || (CurrentMenuState.select + else if (PulsedInputState.key[KEY_MENU_CANCEL] + || (PulsedInputState.key[KEY_MENU_SELECT] && pMS->CurState == EXIT_MENU_SETTING)) { LockMutex (GraphicsLock); @@ -524,7 +524,7 @@ DoSettings (PMENU_STATE pMS) pMS->InputFunc = DoGameOptions; pMS->Initialized = 0; } - else if (CurrentMenuState.select) + else if (PulsedInputState.key[KEY_MENU_SELECT]) { switch (pMS->CurState) { @@ -583,8 +583,8 @@ DoQuitMenu (PMENU_STATE pMS) pMS->Initialized = TRUE; pMS->InputFunc = DoQuitMenu; } - else if (CurrentMenuState.cancel - || (CurrentMenuState.select + else if (PulsedInputState.key[KEY_MENU_CANCEL] + || (PulsedInputState.key[KEY_MENU_SELECT] && pMS->CurState == NO_QUIT_MENU)) { LockMutex (GraphicsLock); @@ -595,7 +595,7 @@ DoQuitMenu (PMENU_STATE pMS) pMS->InputFunc = DoGameOptions; pMS->Initialized = 0; } - else if (CurrentMenuState.select) + else if (PulsedInputState.key[KEY_MENU_SELECT]) { switch (pMS->CurState) { @@ -1018,7 +1018,7 @@ Restart: pMS->Initialized = TRUE; goto ChangeGameSelection; } - else if (CurrentMenuState.cancel) + else if (PulsedInputState.key[KEY_MENU_CANCEL]) { LockMutex (GraphicsLock); SetFlashRect ((PRECT)~0L, (FRAME)0); @@ -1039,7 +1039,7 @@ Restart: } return (FALSE); } - else if (CurrentMenuState.select) + else if (PulsedInputState.key[KEY_MENU_SELECT]) { pSD = &((SUMMARY_DESC *)pMS->CurString)[pMS->CurState]; prev_save = pMS->CurState; @@ -1106,7 +1106,7 @@ Restart: else { NewState = pMS->CurState; - if (CurrentMenuState.left || CurrentMenuState.page_up) + if (PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_PAGE_UP]) { if (NewState == 0) NewState = MAX_SAVED_GAMES - 1; @@ -1115,7 +1115,7 @@ Restart: else NewState = 0; } - else if (CurrentMenuState.right || CurrentMenuState.page_down) + else if (PulsedInputState.key[KEY_MENU_RIGHT] || PulsedInputState.key[KEY_MENU_PAGE_DOWN]) { if (NewState == MAX_SAVED_GAMES - 1) NewState = 0; @@ -1124,14 +1124,14 @@ Restart: else NewState = MAX_SAVED_GAMES - 1; } - else if (CurrentMenuState.up) + else if (PulsedInputState.key[KEY_MENU_UP]) { if (NewState == 0) NewState = MAX_SAVED_GAMES - 1; else NewState--; } - else if (CurrentMenuState.down) + else if (PulsedInputState.key[KEY_MENU_DOWN]) { if (NewState == MAX_SAVED_GAMES - 1) NewState = 0; @@ -1373,14 +1373,14 @@ DoGameOptions (PMENU_STATE pMS) pMS->Initialized = 1; pMS->InputFunc = DoGameOptions; } - else if (CurrentMenuState.cancel - || (CurrentMenuState.select + else if (PulsedInputState.key[KEY_MENU_CANCEL] + || (PulsedInputState.key[KEY_MENU_SELECT] && pMS->CurState == SETTINGS + 1)) { pMS->CurState = SETTINGS + 1; return (FALSE); } - else if (CurrentMenuState.select || force_select) + else if (PulsedInputState.key[KEY_MENU_SELECT] || force_select) { switch (pMS->CurState) { diff --git a/sc2/src/sc2code/getchar.c b/sc2/src/sc2code/getchar.c index 598997a29..f68760be2 100644 --- a/sc2/src/sc2code/getchar.c +++ b/sc2/src/sc2code/getchar.c @@ -34,17 +34,17 @@ GetJoystickChar (void) int dy; UWORD old_char; - if (CurrentMenuState.select) + if (PulsedInputState.key[KEY_MENU_SELECT]) return ('\n'); - else if (CurrentMenuState.cancel) + else if (PulsedInputState.key[KEY_MENU_CANCEL]) return (0x1B); - else if (CurrentMenuState.special) + else if (PulsedInputState.key[KEY_MENU_SPECIAL]) return (0x7F); old_char = cur_char; dy = 0; - if (CurrentMenuState.up) dy = -1; - else if (CurrentMenuState.down) dy = 1; + if (PulsedInputState.key[KEY_MENU_UP]) dy = -1; + else if (PulsedInputState.key[KEY_MENU_DOWN]) dy = 1; if (dy) { if (cur_char == ' ') @@ -72,7 +72,7 @@ GetJoystickChar (void) } } - if ((CurrentMenuState.page_up || CurrentMenuState.page_down) && isalpha (cur_char)) + if ((PulsedInputState.key[KEY_MENU_PAGE_UP] || PulsedInputState.key[KEY_MENU_PAGE_DOWN]) && isalpha (cur_char)) { if (islower (cur_char)) cur_char = toupper (cur_char); diff --git a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c index b1cf59082..aec8dd98e 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c +++ b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c @@ -149,9 +149,9 @@ TFB_ProcessEvents () break; } } - if (ImmediateInputState.abort || abortFlag) + if (ImmediateInputState.key[KEY_ABORT] || abortFlag) exit (0); - if (ImmediateInputState.debug) + if (ImmediateInputState.key[KEY_DEBUG]) { FlushInput (); uio_debugInteractive(stdin, stdout, stderr); diff --git a/sc2/src/sc2code/libs/input/sdl/input.c b/sc2/src/sc2code/libs/input/sdl/input.c index 786608165..434e1550b 100644 --- a/sc2/src/sc2code/libs/input/sdl/input.c +++ b/sc2/src/sc2code/libs/input/sdl/input.c @@ -40,40 +40,40 @@ static BOOLEAN _in_character_mode = FALSE; #define VCONTROL_VERSION 1 static VControl_NameBinding control_names[] = { - { "Menu-Up", (int *)&ImmediateMenuState.up }, - { "Menu-Down", (int *)&ImmediateMenuState.down }, - { "Menu-Left", (int *)&ImmediateMenuState.left }, - { "Menu-Right", (int *)&ImmediateMenuState.right }, - { "Menu-Select", (int *)&ImmediateMenuState.select }, - { "Menu-Cancel", (int *)&ImmediateMenuState.cancel }, - { "Menu-Special", (int *)&ImmediateMenuState.special }, - { "Menu-Page-Up", (int *)&ImmediateMenuState.page_up }, - { "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 }, - { "Lander-Left", (int *)&ImmediateInputState.lander_left }, - { "Lander-Right", (int *)&ImmediateInputState.lander_right }, - { "Lander-Weapon", (int *)&ImmediateInputState.lander_weapon }, - { "Lander-Escape", (int *)&ImmediateInputState.lander_escape }, - { "Pause", (int *)&ImmediateInputState.pause }, - { "Exit", (int *)&ImmediateInputState.exit }, - { "Abort", (int *)&ImmediateInputState.abort }, - { "Debug", (int *)&ImmediateInputState.debug }, + { "Menu-Up", (int *)&ImmediateInputState.key[KEY_MENU_UP] }, + { "Menu-Down", (int *)&ImmediateInputState.key[KEY_MENU_DOWN] }, + { "Menu-Left", (int *)&ImmediateInputState.key[KEY_MENU_LEFT] }, + { "Menu-Right", (int *)&ImmediateInputState.key[KEY_MENU_RIGHT] }, + { "Menu-Select", (int *)&ImmediateInputState.key[KEY_MENU_SELECT] }, + { "Menu-Cancel", (int *)&ImmediateInputState.key[KEY_MENU_CANCEL] }, + { "Menu-Special", (int *)&ImmediateInputState.key[KEY_MENU_SPECIAL] }, + { "Menu-Page-Up", (int *)&ImmediateInputState.key[KEY_MENU_PAGE_UP] }, + { "Menu-Page-Down", (int *)&ImmediateInputState.key[KEY_MENU_PAGE_DOWN] }, + { "Menu-Zoom-In", (int *)&ImmediateInputState.key[KEY_MENU_ZOOM_IN] }, + { "Menu-Zoom-Out", (int *)&ImmediateInputState.key[KEY_MENU_ZOOM_OUT] }, + { "Menu-Delete", (int *)&ImmediateInputState.key[KEY_MENU_DELETE] }, + { "Player-1-Thrust", (int *)&ImmediateInputState.key[KEY_P1_THRUST] }, + { "Player-1-Left", (int *)&ImmediateInputState.key[KEY_P1_LEFT] }, + { "Player-1-Right", (int *)&ImmediateInputState.key[KEY_P1_RIGHT] }, + { "Player-1-Down", (int *)&ImmediateInputState.key[KEY_P1_DOWN] }, + { "Player-1-Weapon", (int *)&ImmediateInputState.key[KEY_P1_WEAPON] }, + { "Player-1-Special", (int *)&ImmediateInputState.key[KEY_P1_SPECIAL] }, + { "Player-1-Escape", (int *)&ImmediateInputState.key[KEY_P1_ESCAPE] }, + { "Player-2-Thrust", (int *)&ImmediateInputState.key[KEY_P2_THRUST] }, + { "Player-2-Left", (int *)&ImmediateInputState.key[KEY_P2_LEFT] }, + { "Player-2-Right", (int *)&ImmediateInputState.key[KEY_P2_RIGHT] }, + { "Player-2-Down", (int *)&ImmediateInputState.key[KEY_P2_DOWN] }, + { "Player-2-Weapon", (int *)&ImmediateInputState.key[KEY_P2_WEAPON] }, + { "Player-2-Special", (int *)&ImmediateInputState.key[KEY_P2_SPECIAL] }, + { "Lander-Thrust", (int *)&ImmediateInputState.key[KEY_LANDER_THRUST] }, + { "Lander-Left", (int *)&ImmediateInputState.key[KEY_LANDER_LEFT] }, + { "Lander-Right", (int *)&ImmediateInputState.key[KEY_LANDER_RIGHT] }, + { "Lander-Weapon", (int *)&ImmediateInputState.key[KEY_LANDER_WEAPON] }, + { "Lander-Escape", (int *)&ImmediateInputState.key[KEY_LANDER_ESCAPE] }, + { "Pause", (int *)&ImmediateInputState.key[KEY_PAUSE] }, + { "Exit", (int *)&ImmediateInputState.key[KEY_EXIT] }, + { "Abort", (int *)&ImmediateInputState.key[KEY_ABORT] }, + { "Debug", (int *)&ImmediateInputState.key[KEY_DEBUG] }, { "Illegal", NULL}}; diff --git a/sc2/src/sc2code/libs/video/vidplayer.c b/sc2/src/sc2code/libs/video/vidplayer.c index ba1a6f398..965996d2d 100644 --- a/sc2/src/sc2code/libs/video/vidplayer.c +++ b/sc2/src/sc2code/libs/video/vidplayer.c @@ -400,14 +400,14 @@ TFB_DoVideoInput (PVOID pIS) if (!pVIS->CurVideo || !TFB_VideoPlaying (pVIS->CurVideo)) return FALSE; - if (CurrentMenuState.select - || CurrentMenuState.cancel - || CurrentMenuState.special) + if (PulsedInputState.key[KEY_MENU_SELECT] + || PulsedInputState.key[KEY_MENU_CANCEL] + || PulsedInputState.key[KEY_MENU_SPECIAL]) { // abort movie TFB_StopVideo (pVIS->CurVideo); return FALSE; } - else if (CurrentMenuState.left || CurrentMenuState.right) + else if (PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_RIGHT]) { if (vid->decoder->audio_synced) { @@ -417,9 +417,9 @@ TFB_DoVideoInput (PVOID pIS) newpos = vid->decoder->pos; UnlockMutex (vid->guard); - if (CurrentMenuState.left) + if (PulsedInputState.key[KEY_MENU_LEFT]) newpos -= 2; - else if (CurrentMenuState.right) + else if (PulsedInputState.key[KEY_MENU_RIGHT]) newpos += 1; if (newpos < 0) newpos = 0; diff --git a/sc2/src/sc2code/melee.c b/sc2/src/sc2code/melee.c index 3892ed4c3..72bccb6bc 100644 --- a/sc2/src/sc2code/melee.c +++ b/sc2/src/sc2code/melee.c @@ -862,9 +862,9 @@ DoLoadTeam (PMELEE_STATE pMS) pMS->InputFunc = DoLoadTeam; UnlockMutex (GraphicsLock); } - else if (CurrentMenuState.select | CurrentMenuState.cancel) + else if (PulsedInputState.key[KEY_MENU_SELECT] | PulsedInputState.key[KEY_MENU_CANCEL]) { - if (!CurrentMenuState.cancel) + if (!PulsedInputState.key[KEY_MENU_CANCEL]) { pMS->TeamImage[pMS->side] = pMS->FileList[ pMS->CurIndex - pMS->TopTeamIndex @@ -890,7 +890,7 @@ DoLoadTeam (PMELEE_STATE pMS) NewTop = pMS->TopTeamIndex; index = old_index = pMS->CurIndex; - if (CurrentMenuState.up) + if (PulsedInputState.key[KEY_MENU_UP]) { if (index-- == 0) index = 0; @@ -898,7 +898,7 @@ DoLoadTeam (PMELEE_STATE pMS) if (index < NewTop && (NewTop -= MAX_VIS_TEAMS) < 0) NewTop = 0; } - else if (CurrentMenuState.down) + else if (PulsedInputState.key[KEY_MENU_DOWN]) { if ((int)index < (int)GetDirEntryTableCount (pMS->TeamDE) + NUM_PREBUILT - 1) ++index; @@ -906,7 +906,7 @@ DoLoadTeam (PMELEE_STATE pMS) if ((int)index > (int)pMS->BotTeamIndex) NewTop = index; } - else if (CurrentMenuState.page_up) + else if (PulsedInputState.key[KEY_MENU_PAGE_UP]) { if ((index -= MAX_VIS_TEAMS) < 0) index = NewTop = 0; @@ -916,7 +916,7 @@ DoLoadTeam (PMELEE_STATE pMS) NewTop = 0; } } - else if (CurrentMenuState.page_down) + else if (PulsedInputState.key[KEY_MENU_PAGE_DOWN]) { if ((int)(index += MAX_VIS_TEAMS) < (int)(GetDirEntryTableCount (pMS->TeamDE) + NUM_PREBUILT)) @@ -1176,8 +1176,8 @@ DoEdit (PMELEE_STATE pMS) pMS->InputFunc = DoEdit; } else if ((pMS->row < NUM_MELEE_ROWS || pMS->CurIndex == (BYTE)~0) - && (CurrentMenuState.cancel - || (CurrentMenuState.right + && (PulsedInputState.key[KEY_MENU_CANCEL] + || (PulsedInputState.key[KEY_MENU_RIGHT] && (pMS->col == NUM_MELEE_COLUMNS - 1 || pMS->row == NUM_MELEE_ROWS)))) { LockMutex (GraphicsLock); @@ -1189,16 +1189,16 @@ DoEdit (PMELEE_STATE pMS) InTime = GetTimeCounter (); } else if (pMS->row < NUM_MELEE_ROWS - && (CurrentMenuState.select || CurrentMenuState.special)) + && (PulsedInputState.key[KEY_MENU_SELECT] || PulsedInputState.key[KEY_MENU_SPECIAL])) { - if (CurrentMenuState.select) + if (PulsedInputState.key[KEY_MENU_SELECT]) pMS->Initialized = 0; else pMS->Initialized = -1; TFB_ResetControls (); DoPickShip (pMS); } - else if (pMS->row < NUM_MELEE_ROWS && CurrentMenuState.del) + else if (pMS->row < NUM_MELEE_ROWS && PulsedInputState.key[KEY_MENU_DELETE]) { DeleteCurrentShip (pMS); AdvanceCursor (pMS); @@ -1232,7 +1232,7 @@ DoEdit (PMELEE_STATE pMS) UnlockMutex (GraphicsLock); return (TRUE); } - else if (CurrentMenuState.select) + else if (PulsedInputState.key[KEY_MENU_SELECT]) { pMS->CurIndex = 0; LockMutex (GraphicsLock); @@ -1244,18 +1244,18 @@ DoEdit (PMELEE_STATE pMS) } { - if (CurrentMenuState.left) + if (PulsedInputState.key[KEY_MENU_LEFT]) { if (col-- == 0) col = 0; } - else if (CurrentMenuState.right) + else if (PulsedInputState.key[KEY_MENU_RIGHT]) { if (++col == NUM_MELEE_COLUMNS) col = NUM_MELEE_COLUMNS - 1; } - if (CurrentMenuState.up) + if (PulsedInputState.key[KEY_MENU_UP]) { if (row-- == 0) { @@ -1268,7 +1268,7 @@ DoEdit (PMELEE_STATE pMS) } } } - else if (CurrentMenuState.down) + else if (PulsedInputState.key[KEY_MENU_DOWN]) { if (row++ == NUM_MELEE_ROWS) { @@ -1343,11 +1343,11 @@ DoPickShip (PMELEE_STATE pMS) DrawMeleeShipStrings (pMS, (BYTE)(pMS->CurIndex)); } } - else if (CurrentMenuState.select || CurrentMenuState.cancel) + else if (PulsedInputState.key[KEY_MENU_SELECT] || PulsedInputState.key[KEY_MENU_CANCEL]) { pMS->InputFunc = 0; /* disable ship flashing */ - if (!CurrentMenuState.cancel) + if (!PulsedInputState.key[KEY_MENU_CANCEL]) { HSTARSHIP hStarShip; @@ -1381,7 +1381,7 @@ DoPickShip (PMELEE_STATE pMS) return (TRUE); } - else if (CurrentMenuState.special) + else if (PulsedInputState.key[KEY_MENU_SPECIAL]) { DoShipSpin (pMS->CurIndex, (MUSIC_REF)0); @@ -1393,25 +1393,25 @@ DoPickShip (PMELEE_STATE pMS) NewStarShip = pMS->CurIndex; - if (CurrentMenuState.left) + if (PulsedInputState.key[KEY_MENU_LEFT]) { if (NewStarShip-- % NUM_PICK_COLS == 0) NewStarShip += NUM_PICK_COLS; } - else if (CurrentMenuState.right) + else if (PulsedInputState.key[KEY_MENU_RIGHT]) { if (++NewStarShip % NUM_PICK_COLS == 0) NewStarShip -= NUM_PICK_COLS; } - if (CurrentMenuState.up) + if (PulsedInputState.key[KEY_MENU_UP]) { if (NewStarShip >= NUM_PICK_COLS) NewStarShip -= NUM_PICK_COLS; else NewStarShip += NUM_PICK_COLS * (NUM_PICK_ROWS - 1); } - else if (CurrentMenuState.down) + else if (PulsedInputState.key[KEY_MENU_DOWN]) { if (NewStarShip < NUM_PICK_COLS * (NUM_PICK_ROWS - 1)) NewStarShip += NUM_PICK_COLS; @@ -1605,7 +1605,7 @@ DoMelee (PMELEE_STATE pMS) } InTime = GetTimeCounter (); } - else if (CurrentMenuState.cancel || CurrentMenuState.left) + else if (PulsedInputState.key[KEY_MENU_CANCEL] || PulsedInputState.key[KEY_MENU_LEFT]) { LockMutex (GraphicsLock); InTime = GetTimeCounter (); @@ -1613,7 +1613,7 @@ DoMelee (PMELEE_STATE pMS) UnlockMutex (GraphicsLock); pMS->MeleeOption = EDIT_MELEE; pMS->Initialized = FALSE; - if (CurrentMenuState.cancel) + if (PulsedInputState.key[KEY_MENU_CANCEL]) pMS->side = pMS->row = pMS->col = 0; else pMS->side = 0, @@ -1626,13 +1626,13 @@ DoMelee (PMELEE_STATE pMS) MELEE_OPTIONS NewMeleeOption; NewMeleeOption = pMS->MeleeOption; - if (CurrentMenuState.up) + if (PulsedInputState.key[KEY_MENU_UP]) { InTime = GetTimeCounter (); if (NewMeleeOption-- == CONTROLS_TOP) NewMeleeOption = CONTROLS_TOP; } - else if (CurrentMenuState.down) + else if (PulsedInputState.key[KEY_MENU_DOWN]) { InTime = GetTimeCounter (); if (NewMeleeOption++ == CONTROLS_BOT) @@ -1655,7 +1655,7 @@ DoMelee (PMELEE_STATE pMS) UnlockMutex (GraphicsLock); } - if (CurrentMenuState.select || force_select) + if (PulsedInputState.key[KEY_MENU_SELECT] || force_select) { switch (pMS->MeleeOption) { diff --git a/sc2/src/sc2code/menu.c b/sc2/src/sc2code/menu.c index c224827d1..d36b1717b 100644 --- a/sc2/src/sc2code/menu.c +++ b/sc2/src/sc2code/menu.c @@ -451,11 +451,11 @@ DoMenuChooser (PMENU_STATE pMS, BYTE BaseState) BOOLEAN useAltMenu = FALSE; if (optWhichMenu == OPT_PC) useAltMenu = GetAlternateMenu (&BaseState, &NewState); - if (CurrentMenuState.left || CurrentMenuState.up) + if (PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_UP]) NewState = PreviousMenuState (BaseState, NewState); - else if (CurrentMenuState.right || CurrentMenuState.down) + else if (PulsedInputState.key[KEY_MENU_RIGHT] || PulsedInputState.key[KEY_MENU_DOWN]) NewState = NextMenuState (BaseState, NewState); - else if (useAltMenu && CurrentMenuState.select) + else if (useAltMenu && PulsedInputState.key[KEY_MENU_SELECT]) { NewState = ConvertAlternateMenu (BaseState, NewState); if (NewState == ALT_MANIFEST) diff --git a/sc2/src/sc2code/outfit.c b/sc2/src/sc2code/outfit.c index 6567a6f41..2da655db7 100644 --- a/sc2/src/sc2code/outfit.c +++ b/sc2/src/sc2code/outfit.c @@ -177,9 +177,9 @@ DoInstallModule (PMENU_STATE pMS) return (TRUE); } - select = CurrentMenuState.select; - cancel = CurrentMenuState.cancel; - motion = CurrentMenuState.left || CurrentMenuState.right || CurrentMenuState.up || CurrentMenuState.down; + select = PulsedInputState.key[KEY_MENU_SELECT]; + cancel = PulsedInputState.key[KEY_MENU_CANCEL]; + motion = PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_RIGHT] || PulsedInputState.key[KEY_MENU_UP] || PulsedInputState.key[KEY_MENU_DOWN]; SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); @@ -373,9 +373,9 @@ DoInstallModule (PMENU_STATE pMS) NewItem = NewState < EMPTY_SLOT ? pMS->CurState : pMS->delta_item; do { - if (NewState >= EMPTY_SLOT && (CurrentMenuState.up || CurrentMenuState.down)) + if (NewState >= EMPTY_SLOT && (PulsedInputState.key[KEY_MENU_UP] || PulsedInputState.key[KEY_MENU_DOWN])) { - if (CurrentMenuState.up) + if (PulsedInputState.key[KEY_MENU_UP]) { if (NewState-- == EMPTY_SLOT) NewState = EMPTY_SLOT + 3; @@ -389,18 +389,18 @@ DoInstallModule (PMENU_STATE pMS) if (GET_GAME_STATE (CHMMR_BOMB_STATE) == 3) { if (NewState == EMPTY_SLOT + 3) - NewState = CurrentMenuState.up ? EMPTY_SLOT + 2 : EMPTY_SLOT; + NewState = PulsedInputState.key[KEY_MENU_UP] ? EMPTY_SLOT + 2 : EMPTY_SLOT; if (NewState == EMPTY_SLOT + 2) NewItem = NUM_BOMB_MODULES; } pMS->delta_item = NewItem; } - else if (CurrentMenuState.left || CurrentMenuState.up) + else if (PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_UP]) { if (NewItem-- == FirstItem) NewItem = LastItem; } - else if (CurrentMenuState.right || CurrentMenuState.down) + else if (PulsedInputState.key[KEY_MENU_RIGHT] || PulsedInputState.key[KEY_MENU_DOWN]) { if (NewItem++ == LastItem) NewItem = FirstItem; @@ -519,7 +519,7 @@ ChangeFuelQuantity () r.extent.height = 1; - if (CurrentMenuState.up) + if (PulsedInputState.key[KEY_MENU_UP]) { LockMutex (GraphicsLock); SetContext (SpaceContext); @@ -545,7 +545,7 @@ ChangeFuelQuantity () } UnlockMutex (GraphicsLock); } - else if (CurrentMenuState.down) + else if (PulsedInputState.key[KEY_MENU_DOWN]) { LockMutex (GraphicsLock); SetContext (SpaceContext); @@ -690,8 +690,8 @@ DoOutfit (PMENU_STATE pMS) SetContext (StatusContext); } - else if (CurrentMenuState.cancel - || (CurrentMenuState.select + else if (PulsedInputState.key[KEY_MENU_CANCEL] + || (PulsedInputState.key[KEY_MENU_SELECT] && pMS->CurState == OUTFIT_EXIT)) { if (pMS->CurState == OUTFIT_DOFUEL) @@ -712,7 +712,7 @@ ExitOutfit: return (FALSE); } } - else if (CurrentMenuState.select) + else if (PulsedInputState.key[KEY_MENU_SELECT]) { switch (pMS->CurState) { diff --git a/sc2/src/sc2code/pickmele.c b/sc2/src/sc2code/pickmele.c index 72a7b9b87..61353b05e 100644 --- a/sc2/src/sc2code/pickmele.c +++ b/sc2/src/sc2code/pickmele.c @@ -200,7 +200,7 @@ GetMeleeStarShip (STARSHIPPTR LastStarShipPtr, COUNT which_player) OldTime = NewTime; } - if (InputState & BATTLE_WEAPON || CurrentMenuState.select) + if (InputState & BATTLE_WEAPON || PulsedInputState.key[KEY_MENU_SELECT]) { if (hBattleShip || (col == NUM_MELEE_COLS_ORIG && ConfirmExit ())) { @@ -214,22 +214,22 @@ GetMeleeStarShip (STARSHIPPTR LastStarShipPtr, COUNT which_player) new_row = row; new_col = col; - if ((InputState & BATTLE_LEFT) || CurrentMenuState.left) + if ((InputState & BATTLE_LEFT) || PulsedInputState.key[KEY_MENU_LEFT]) { if (new_col-- == 0) new_col = NUM_MELEE_COLS_ORIG; } - else if ((InputState & BATTLE_RIGHT) || CurrentMenuState.right) + else if ((InputState & BATTLE_RIGHT) || PulsedInputState.key[KEY_MENU_RIGHT]) { if (new_col++ == NUM_MELEE_COLS_ORIG) new_col = 0; } - if ((InputState & BATTLE_THRUST) || CurrentMenuState.up) + if ((InputState & BATTLE_THRUST) || PulsedInputState.key[KEY_MENU_UP]) { if (new_row-- == 0) new_row = NUM_MELEE_ROWS - 1; } - else if ((InputState & BATTLE_DOWN) || CurrentMenuState.down) + else if ((InputState & BATTLE_DOWN) || PulsedInputState.key[KEY_MENU_DOWN]) { if (++new_row == NUM_MELEE_ROWS) new_row = 0; diff --git a/sc2/src/sc2code/pickship.c b/sc2/src/sc2code/pickship.c index 33cf59112..e8aeafbc2 100644 --- a/sc2/src/sc2code/pickship.c +++ b/sc2/src/sc2code/pickship.c @@ -48,7 +48,7 @@ DoPickBattleShip (PMENU_STATE pMS) goto ChangeSelection; } - else if (CurrentMenuState.select) + else if (PulsedInputState.key[KEY_MENU_SELECT]) { if ((HSTARSHIP)pMS->CurFrame) return (FALSE); @@ -57,10 +57,10 @@ DoPickBattleShip (PMENU_STATE pMS) { COORD new_row, new_col; int dx = 0, dy = 0; - if (CurrentMenuState.right) dx = 1; - if (CurrentMenuState.left) dx = -1; - if (CurrentMenuState.up) dy = -1; - if (CurrentMenuState.down) dy = 1; + if (PulsedInputState.key[KEY_MENU_RIGHT]) dx = 1; + if (PulsedInputState.key[KEY_MENU_LEFT]) dx = -1; + if (PulsedInputState.key[KEY_MENU_UP]) dy = -1; + if (PulsedInputState.key[KEY_MENU_DOWN]) dy = 1; new_col = pMS->first_item.x + dx; new_row = pMS->first_item.y + dy; diff --git a/sc2/src/sc2code/planets/cargo.c b/sc2/src/sc2code/planets/cargo.c index 892a553b0..f9324190c 100644 --- a/sc2/src/sc2code/planets/cargo.c +++ b/sc2/src/sc2code/planets/cargo.c @@ -280,10 +280,10 @@ DoDiscardCargo (PMENU_STATE pMS) { BYTE NewState; BOOLEAN select, cancel, back, forward; - select = CurrentMenuState.select; - cancel = CurrentMenuState.cancel; - back = CurrentMenuState.up || CurrentMenuState.left; - forward = CurrentMenuState.down || CurrentMenuState.right; + select = PulsedInputState.key[KEY_MENU_SELECT]; + cancel = PulsedInputState.key[KEY_MENU_CANCEL]; + back = PulsedInputState.key[KEY_MENU_UP] || PulsedInputState.key[KEY_MENU_LEFT]; + forward = PulsedInputState.key[KEY_MENU_DOWN] || PulsedInputState.key[KEY_MENU_RIGHT]; if (GLOBAL (CurrentActivity) & CHECK_ABORT) return (FALSE); diff --git a/sc2/src/sc2code/planets/devices.c b/sc2/src/sc2code/planets/devices.c index 22b76afee..f6a3d62fe 100644 --- a/sc2/src/sc2code/planets/devices.c +++ b/sc2/src/sc2code/planets/devices.c @@ -425,10 +425,10 @@ DoManipulateDevices (PMENU_STATE pMS) { BYTE NewState; BOOLEAN select, cancel, back, forward; - select = CurrentMenuState.select; - cancel = CurrentMenuState.cancel; - back = CurrentMenuState.up || CurrentMenuState.left; - forward = CurrentMenuState.down || CurrentMenuState.right; + select = PulsedInputState.key[KEY_MENU_SELECT]; + cancel = PulsedInputState.key[KEY_MENU_CANCEL]; + back = PulsedInputState.key[KEY_MENU_UP] || PulsedInputState.key[KEY_MENU_LEFT]; + forward = PulsedInputState.key[KEY_MENU_DOWN] || PulsedInputState.key[KEY_MENU_RIGHT]; if (GLOBAL (CurrentActivity) & CHECK_ABORT) return (FALSE); diff --git a/sc2/src/sc2code/planets/lander.c b/sc2/src/sc2code/planets/lander.c index 072a59a7d..f3bc1eef6 100644 --- a/sc2/src/sc2code/planets/lander.c +++ b/sc2/src/sc2code/planets/lander.c @@ -1592,7 +1592,7 @@ SetVelocityComponents ( } else if (pMS->delta_item == 0 || (HIBYTE (pMS->delta_item) - && (CurrentInputState.lander_escape + && (CurrentInputState.key[KEY_LANDER_ESCAPE] || ((PPLANETSIDE_DESC)pMenuState->ModuleFrame)->InTransit))) { if (pMS->delta_item || pMS->CurState > EXPLOSION_LIFE + 60) @@ -1653,9 +1653,9 @@ SetVelocityComponents ( index = GetFrameIndex (LanderFrame[0]); if (LONIBBLE (pMS->CurState)) pMS->CurState -= MAKE_BYTE (1, 0); - else if (CurrentInputState.lander_left || CurrentInputState.lander_right) + else if (CurrentInputState.key[KEY_LANDER_LEFT] || CurrentInputState.key[KEY_LANDER_RIGHT]) { - if (CurrentInputState.lander_left) + if (CurrentInputState.key[KEY_LANDER_LEFT]) { dx = -1; --index; @@ -1695,7 +1695,7 @@ SetVelocityComponents ( ); } - if (!CurrentInputState.lander_thrust) + if (!CurrentInputState.key[KEY_LANDER_THRUST]) dx = dy = 0; else GetNextVelocityComponents ( @@ -1704,7 +1704,7 @@ SetVelocityComponents ( if (HINIBBLE (pMS->CurState)) pMS->CurState -= MAKE_BYTE (0, 1); - else if (CurrentInputState.lander_weapon) + else if (CurrentInputState.key[KEY_LANDER_WEAPON]) { HELEMENT hWeaponElement; @@ -1733,7 +1733,7 @@ SetVelocityComponents ( index + ANGLE_TO_FACING (FULL_CIRCLE) ); - if (!CurrentInputState.lander_thrust) + if (!CurrentInputState.key[KEY_LANDER_THRUST]) wdx = wdy = 0; else GetCurrentVelocityComponents ( diff --git a/sc2/src/sc2code/planets/pstarmap.c b/sc2/src/sc2code/planets/pstarmap.c index e8f9d7e41..6c81f055f 100644 --- a/sc2/src/sc2code/planets/pstarmap.c +++ b/sc2/src/sc2code/planets/pstarmap.c @@ -628,7 +628,7 @@ DoMoveCursor (PMENU_STATE pMS) buf[0] = '\0'; goto UpdateCursorInfo; } - else if (CurrentMenuState.cancel) + else if (PulsedInputState.key[KEY_MENU_CANCEL]) { if (pMS->flash_task) { @@ -638,7 +638,7 @@ DoMoveCursor (PMENU_STATE pMS) return (FALSE); } - else if (CurrentMenuState.select) + else if (PulsedInputState.key[KEY_MENU_SELECT]) { GLOBAL (autopilot) = pMS->first_item; @@ -651,18 +651,18 @@ DoMoveCursor (PMENU_STATE pMS) SIZE ZoomIn, ZoomOut; ZoomIn = ZoomOut = 0; - if (CurrentMenuState.zoom_in) + if (PulsedInputState.key[KEY_MENU_ZOOM_IN]) ZoomIn = 1; - else if (CurrentMenuState.zoom_out) + else if (PulsedInputState.key[KEY_MENU_ZOOM_OUT]) ZoomOut = 1; ZoomStarMap (ZoomIn - ZoomOut); sx = sy = 0; - if (CurrentMenuState.left) sx = -1; - if (CurrentMenuState.right) sx = 1; - if (CurrentMenuState.up) sy = -1; - if (CurrentMenuState.down) sy = 1; + if (PulsedInputState.key[KEY_MENU_LEFT]) sx = -1; + if (PulsedInputState.key[KEY_MENU_RIGHT]) sx = 1; + if (PulsedInputState.key[KEY_MENU_UP]) sy = -1; + if (PulsedInputState.key[KEY_MENU_DOWN]) sy = 1; if (sx == 0 && sy == 0) { @@ -1162,7 +1162,7 @@ DoFlagshipCommands (PMENU_STATE pMS) } else { - BOOLEAN select = CurrentMenuState.select; + BOOLEAN select = PulsedInputState.key[KEY_MENU_SELECT]; LockMutex (GraphicsLock); while (*(volatile BYTE *)&pMS->CurState == 0 && (*(volatile SIZE *)&pMS->Initialized & 1) diff --git a/sc2/src/sc2code/planets/roster.c b/sc2/src/sc2code/planets/roster.c index faf4beffa..e0b826836 100644 --- a/sc2/src/sc2code/planets/roster.c +++ b/sc2/src/sc2code/planets/roster.c @@ -219,11 +219,11 @@ DoModifyRoster (PMENU_STATE pMS) return (FALSE); } - select = CurrentMenuState.select; - cancel = CurrentMenuState.cancel; - up = CurrentMenuState.up; - down = CurrentMenuState.down; - horiz = CurrentMenuState.left || CurrentMenuState.right; + select = PulsedInputState.key[KEY_MENU_SELECT]; + cancel = PulsedInputState.key[KEY_MENU_CANCEL]; + up = PulsedInputState.key[KEY_MENU_UP]; + down = PulsedInputState.key[KEY_MENU_DOWN]; + horiz = PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_RIGHT]; if (pMS->Initialized && (pMS->CurState & SHIP_TOGGLE)) { diff --git a/sc2/src/sc2code/planets/scan.c b/sc2/src/sc2code/planets/scan.c index ee88fba8e..51bac8f0e 100644 --- a/sc2/src/sc2code/planets/scan.c +++ b/sc2/src/sc2code/planets/scan.c @@ -653,8 +653,8 @@ static BOOLEAN PickPlanetSide (PMENU_STATE pMS) { BOOLEAN select, cancel; - select = CurrentMenuState.select; - cancel = CurrentMenuState.cancel; + select = PulsedInputState.key[KEY_MENU_SELECT]; + cancel = PulsedInputState.key[KEY_MENU_CANCEL]; if (GLOBAL (CurrentActivity) & CHECK_ABORT) { if (pMenuState->flash_task) @@ -809,10 +809,10 @@ ExitPlanetSide: new_pt = pSolarSysState->MenuState.first_item; - if (CurrentMenuState.left) dx = -1; - if (CurrentMenuState.right) dx = 1; - if (CurrentMenuState.up) dy = -1; - if (CurrentMenuState.down) dy = 1; + if (PulsedInputState.key[KEY_MENU_LEFT]) dx = -1; + if (PulsedInputState.key[KEY_MENU_RIGHT]) dx = 1; + if (PulsedInputState.key[KEY_MENU_UP]) dy = -1; + if (PulsedInputState.key[KEY_MENU_DOWN]) dy = 1; dx = dx << MAG_SHIFT; if (dx) @@ -941,8 +941,8 @@ DoScan (PMENU_STATE pMS) { DWORD TimeIn, WaitTime; BOOLEAN select, cancel; - select = CurrentMenuState.select; - cancel = CurrentMenuState.cancel; + select = PulsedInputState.key[KEY_MENU_SELECT]; + cancel = PulsedInputState.key[KEY_MENU_CANCEL]; if (GLOBAL (CurrentActivity) & CHECK_ABORT) return (FALSE); diff --git a/sc2/src/sc2code/planets/solarsys.c b/sc2/src/sc2code/planets/solarsys.c index e54fdf618..779d99b69 100644 --- a/sc2/src/sc2code/planets/solarsys.c +++ b/sc2/src/sc2code/planets/solarsys.c @@ -777,15 +777,15 @@ UndrawShip (void) DrawIPRadar (FALSE); #endif /* SHOW_RADAR */ - if (CurrentInputState.p1_thrust) + if (CurrentInputState.key[KEY_P1_THRUST]) delta_y = -1; else delta_y = 0; delta_x = 0; - if (CurrentInputState.p1_left) + if (CurrentInputState.key[KEY_P1_LEFT]) delta_x -= 1; - if (CurrentInputState.p1_right) + if (CurrentInputState.key[KEY_P1_RIGHT]) delta_x += 1; if (delta_x || delta_y < 0) @@ -1180,8 +1180,8 @@ TheMess: else { UpdateInputState (); - cancel = ImmediateMenuState.cancel; - select = ImmediateMenuState.select; + cancel = ImmediateInputState.key[KEY_MENU_CANCEL]; + select = ImmediateInputState.key[KEY_MENU_SELECT]; } // JournalInput (InputState); } diff --git a/sc2/src/sc2code/restart.c b/sc2/src/sc2code/restart.c index 43e8d7fa5..10cfaac8a 100644 --- a/sc2/src/sc2code/restart.c +++ b/sc2/src/sc2code/restart.c @@ -111,9 +111,9 @@ else if (InputState & DEVICE_EXIT) return (FALSE); { return (FALSE); } - else if (!(CurrentMenuState.up || CurrentMenuState.down || - CurrentMenuState.left || CurrentMenuState.right || - CurrentMenuState.select)) + else if (!(PulsedInputState.key[KEY_MENU_UP] || PulsedInputState.key[KEY_MENU_DOWN] || + PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_RIGHT] || + PulsedInputState.key[KEY_MENU_SELECT])) { if (GetTimeCounter () - InTime < ONE_SECOND * 15) @@ -122,7 +122,7 @@ else if (InputState & DEVICE_EXIT) return (FALSE); GLOBAL (CurrentActivity) = (ACTIVITY)~0; return (FALSE); } - else if (CurrentMenuState.select) + else if (PulsedInputState.key[KEY_MENU_SELECT]) { BYTE fade_buf[1]; @@ -166,12 +166,12 @@ else if (InputState & DEVICE_EXIT) return (FALSE); BYTE NewState; NewState = pMS->CurState; - if (CurrentMenuState.up) + if (PulsedInputState.key[KEY_MENU_UP]) { if (NewState-- == START_NEW_GAME) NewState = QUIT_GAME; } - else if (CurrentMenuState.down) + else if (PulsedInputState.key[KEY_MENU_DOWN]) { if (NewState++ == QUIT_GAME) NewState = START_NEW_GAME; diff --git a/sc2/src/sc2code/save.c b/sc2/src/sc2code/save.c index fe2dca6b8..a8ab700d0 100644 --- a/sc2/src/sc2code/save.c +++ b/sc2/src/sc2code/save.c @@ -220,7 +220,7 @@ SaveProblem (void) { TaskSwitch (); UpdateInputState (); - } while (!(CurrentMenuState.select || CurrentMenuState.special || + } while (!(PulsedInputState.key[KEY_MENU_SELECT] || PulsedInputState.key[KEY_MENU_SPECIAL] || (GLOBAL (CurrentActivity) & CHECK_ABORT))); LockMutex (GraphicsLock); diff --git a/sc2/src/sc2code/ships/sis_ship/sis_ship.c b/sc2/src/sc2code/ships/sis_ship/sis_ship.c index fdf9c7695..0a7a69286 100644 --- a/sc2/src/sc2code/ships/sis_ship/sis_ship.c +++ b/sc2/src/sc2code/ships/sis_ship/sis_ship.c @@ -276,7 +276,7 @@ sis_hyper_postprocess (PELEMENT ElementPtr) GLOBAL (velocity) = ElementPtr->velocity; GetElementStarShip (ElementPtr, &StarShipPtr); - if (((StarShipPtr->cur_status_flags & WEAPON) || CurrentMenuState.cancel) + if (((StarShipPtr->cur_status_flags & WEAPON) || PulsedInputState.key[KEY_MENU_CANCEL]) && StarShipPtr->special_counter == 0) { #define MENU_DELAY 10 diff --git a/sc2/src/sc2code/shipyard.c b/sc2/src/sc2code/shipyard.c index 56173fec9..9a296c6c8 100644 --- a/sc2/src/sc2code/shipyard.c +++ b/sc2/src/sc2code/shipyard.c @@ -605,10 +605,10 @@ DoModifyShips (PMENU_STATE pMS) #ifdef WANT_SHIP_SPINS BOOLEAN special; - special = CurrentMenuState.special; + special = PulsedInputState.key[KEY_MENU_SPECIAL]; #endif /* WANT_SHIP_SPINS */ - select = CurrentMenuState.select; - cancel = CurrentMenuState.cancel; + select = PulsedInputState.key[KEY_MENU_SELECT]; + cancel = PulsedInputState.key[KEY_MENU_CANCEL]; if (GLOBAL (CurrentActivity) & CHECK_ABORT) { @@ -637,10 +637,10 @@ DoModifyShips (PMENU_STATE pMS) SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); } - if (CurrentMenuState.right) dx = 1; - if (CurrentMenuState.left) dx = -1; - if (CurrentMenuState.up) dy = -1; - if (CurrentMenuState.down) dy = 1; + if (PulsedInputState.key[KEY_MENU_RIGHT]) dx = 1; + if (PulsedInputState.key[KEY_MENU_LEFT]) dx = -1; + if (PulsedInputState.key[KEY_MENU_UP]) dy = -1; + if (PulsedInputState.key[KEY_MENU_DOWN]) dy = 1; NewState = pMS->CurState; if (pMS->delta_item & MODIFY_CREW_FLAG) { @@ -1207,8 +1207,8 @@ DoShipyard (PMENU_STATE pMS) if (GLOBAL (CurrentActivity) & CHECK_ABORT) goto ExitShipyard; - select = CurrentMenuState.select; - cancel = CurrentMenuState.cancel; + select = PulsedInputState.key[KEY_MENU_SELECT]; + cancel = PulsedInputState.key[KEY_MENU_CANCEL]; SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); if (!pMS->Initialized) diff --git a/sc2/src/sc2code/starbase.c b/sc2/src/sc2code/starbase.c index 825745b07..80a29c502 100644 --- a/sc2/src/sc2code/starbase.c +++ b/sc2/src/sc2code/starbase.c @@ -337,7 +337,7 @@ s.origin.x = SAFE_X, s.origin.y = SAFE_Y + 4; "rotate starbase"); UnlockMutex (GraphicsLock); } - else if (CurrentMenuState.select + else if (PulsedInputState.key[KEY_MENU_SELECT] || GET_GAME_STATE (MOONBASE_ON_SHIP) || GET_GAME_STATE (CHMMR_BOMB_STATE) == 2) { @@ -399,12 +399,12 @@ ExitStarBase: STARBASE_STATE NewState; NewState = pMS->CurState; - if (CurrentMenuState.left || CurrentMenuState.up) + if (PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_UP]) { if (NewState-- == TALK_COMMANDER) NewState = DEPART_BASE; } - else if (CurrentMenuState.right || CurrentMenuState.down) + else if (PulsedInputState.key[KEY_MENU_RIGHT] || PulsedInputState.key[KEY_MENU_DOWN]) { if (NewState++ == DEPART_BASE) NewState = TALK_COMMANDER; diff --git a/sc2/src/sc2code/util.c b/sc2/src/sc2code/util.c index b6937c02b..40f580902 100644 --- a/sc2/src/sc2code/util.c +++ b/sc2/src/sc2code/util.c @@ -178,13 +178,13 @@ PauseGame (void) FlushGraphics (); //LockMutex (GraphicsLock); - while (ImmediateInputState.pause) + while (ImmediateInputState.key[KEY_PAUSE]) TaskSwitch (); - while (!ImmediateInputState.pause) + while (!ImmediateInputState.key[KEY_PAUSE]) TaskSwitch (); - while (ImmediateInputState.pause) + while (ImmediateInputState.key[KEY_PAUSE]) TaskSwitch (); GamePaused = FALSE;