Added "gestalt mode" for key-acceleration; fixes #381
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@985 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
Changes towards version 0.3:
|
Changes towards version 0.3:
|
||||||
|
- Added "gestalt mode" for acceleration cancels; fixes #381 - Michael
|
||||||
- Fixed some "false key cancels" in the input system, addressing bugs
|
- Fixed some "false key cancels" in the input system, addressing bugs
|
||||||
#378 and #379 -Michael
|
#378 and #379 -Michael
|
||||||
- Completely reworked the input system
|
- Completely reworked the input system
|
||||||
|
|||||||
@@ -55,8 +55,9 @@ extern volatile MENU_INPUT_STATE ImmediateMenuState;
|
|||||||
|
|
||||||
void UpdateInputState (void);
|
void UpdateInputState (void);
|
||||||
void TFB_ResetControls (void);
|
void TFB_ResetControls (void);
|
||||||
void SetMenuRepeatDelay (DWORD min, DWORD max, DWORD step);
|
void SetMenuRepeatDelay (DWORD min, DWORD max, DWORD step, BOOLEAN gestalt);
|
||||||
void SetDefaultMenuRepeatDelay (void);
|
void SetDefaultMenuRepeatDelay (void);
|
||||||
|
void ResetKeyRepeat (void);
|
||||||
|
|
||||||
BATTLE_INPUT_STATE p1_combat_summary (void);
|
BATTLE_INPUT_STATE p1_combat_summary (void);
|
||||||
BATTLE_INPUT_STATE p2_combat_summary (void);
|
BATTLE_INPUT_STATE p2_combat_summary (void);
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ MENU_INPUT_STATE CurrentMenuState;
|
|||||||
static MENU_INPUT_STATE CachedMenuState, OldMenuState;
|
static MENU_INPUT_STATE CachedMenuState, OldMenuState;
|
||||||
static MENU_ANNOTATIONS RepeatDelays, Times;
|
static MENU_ANNOTATIONS RepeatDelays, Times;
|
||||||
static DWORD _max_accel, _min_accel, _step_accel;
|
static DWORD _max_accel, _min_accel, _step_accel;
|
||||||
|
static BOOLEAN _gestalt_keys;
|
||||||
int ExitState;
|
int ExitState;
|
||||||
|
|
||||||
volatile CONTROLLER_INPUT_STATE ImmediateInputState;
|
volatile CONTROLLER_INPUT_STATE ImmediateInputState;
|
||||||
@@ -53,7 +54,6 @@ volatile MENU_INPUT_STATE ImmediateMenuState;
|
|||||||
static void
|
static void
|
||||||
_clear_menu_state (void)
|
_clear_menu_state (void)
|
||||||
{
|
{
|
||||||
DWORD initTime = GetTimeCounter ();
|
|
||||||
CurrentMenuState.up = 0;
|
CurrentMenuState.up = 0;
|
||||||
CurrentMenuState.down = 0;
|
CurrentMenuState.down = 0;
|
||||||
CurrentMenuState.left = 0;
|
CurrentMenuState.left = 0;
|
||||||
@@ -76,6 +76,12 @@ _clear_menu_state (void)
|
|||||||
CachedMenuState.page_down = 0;
|
CachedMenuState.page_down = 0;
|
||||||
CachedMenuState.zoom_in = 0;
|
CachedMenuState.zoom_in = 0;
|
||||||
CachedMenuState.zoom_out = 0;
|
CachedMenuState.zoom_out = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ResetKeyRepeat (void)
|
||||||
|
{
|
||||||
|
DWORD initTime = GetTimeCounter ();
|
||||||
RepeatDelays.up = _max_accel;
|
RepeatDelays.up = _max_accel;
|
||||||
RepeatDelays.down = _max_accel;
|
RepeatDelays.down = _max_accel;
|
||||||
RepeatDelays.left = _max_accel;
|
RepeatDelays.left = _max_accel;
|
||||||
@@ -100,6 +106,27 @@ _clear_menu_state (void)
|
|||||||
Times.zoom_out = initTime;
|
Times.zoom_out = initTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_gestalt (void)
|
||||||
|
{
|
||||||
|
BOOLEAN reset = FALSE;
|
||||||
|
if (OldMenuState.up != CachedMenuState.up) reset = TRUE;
|
||||||
|
if (OldMenuState.down != CachedMenuState.down) reset = TRUE;
|
||||||
|
if (OldMenuState.left != CachedMenuState.left) reset = TRUE;
|
||||||
|
if (OldMenuState.right != CachedMenuState.right) reset = TRUE;
|
||||||
|
if (OldMenuState.select != CachedMenuState.select) reset = TRUE;
|
||||||
|
if (OldMenuState.cancel != CachedMenuState.cancel) reset = TRUE;
|
||||||
|
if (OldMenuState.special != CachedMenuState.special) reset = TRUE;
|
||||||
|
if (OldMenuState.page_up != CachedMenuState.page_up) reset = TRUE;
|
||||||
|
if (OldMenuState.page_down != CachedMenuState.page_down) reset = TRUE;
|
||||||
|
if (OldMenuState.zoom_in != CachedMenuState.zoom_in) reset = TRUE;
|
||||||
|
if (OldMenuState.zoom_out != CachedMenuState.zoom_out) reset = TRUE;
|
||||||
|
if (reset)
|
||||||
|
{
|
||||||
|
ResetKeyRepeat ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_check_for_pulse (int *current, int *cached, int *old, DWORD *accel, DWORD *newtime, DWORD *oldtime)
|
_check_for_pulse (int *current, int *cached, int *old, DWORD *accel, DWORD *newtime, DWORD *oldtime)
|
||||||
{
|
{
|
||||||
@@ -147,6 +174,10 @@ UpdateInputState (void)
|
|||||||
CurrentInputState = ImmediateInputState;
|
CurrentInputState = ImmediateInputState;
|
||||||
OldMenuState = CachedMenuState;
|
OldMenuState = CachedMenuState;
|
||||||
CachedMenuState = ImmediateMenuState;
|
CachedMenuState = ImmediateMenuState;
|
||||||
|
if (_gestalt_keys)
|
||||||
|
{
|
||||||
|
_check_gestalt ();
|
||||||
|
}
|
||||||
NewTime = GetTimeCounter ();
|
NewTime = GetTimeCounter ();
|
||||||
_check_for_pulse(&CurrentMenuState.up, &CachedMenuState.up, &OldMenuState.up, &RepeatDelays.up, &NewTime, &Times.up);
|
_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.down, &CachedMenuState.down, &OldMenuState.down, &RepeatDelays.down, &NewTime, &Times.down);
|
||||||
@@ -169,12 +200,14 @@ UpdateInputState (void)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SetMenuRepeatDelay (DWORD min, DWORD max, DWORD step)
|
SetMenuRepeatDelay (DWORD min, DWORD max, DWORD step, BOOLEAN gestalt)
|
||||||
{
|
{
|
||||||
_min_accel = min;
|
_min_accel = min;
|
||||||
_max_accel = max;
|
_max_accel = max;
|
||||||
_step_accel = step;
|
_step_accel = step;
|
||||||
|
_gestalt_keys = gestalt;
|
||||||
_clear_menu_state ();
|
_clear_menu_state ();
|
||||||
|
ResetKeyRepeat ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -183,13 +216,15 @@ SetDefaultMenuRepeatDelay ()
|
|||||||
_min_accel = ACCELERATION_INCREMENT;
|
_min_accel = ACCELERATION_INCREMENT;
|
||||||
_max_accel = MENU_REPEAT_DELAY;
|
_max_accel = MENU_REPEAT_DELAY;
|
||||||
_step_accel = ACCELERATION_INCREMENT;
|
_step_accel = ACCELERATION_INCREMENT;
|
||||||
|
_gestalt_keys = FALSE;
|
||||||
_clear_menu_state ();
|
_clear_menu_state ();
|
||||||
|
ResetKeyRepeat ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DoInput (PVOID pInputState, BOOLEAN resetInput)
|
DoInput (PVOID pInputState, BOOLEAN resetInput)
|
||||||
{
|
{
|
||||||
SetMenuRepeatDelay (ACCELERATION_INCREMENT, MENU_REPEAT_DELAY, ACCELERATION_INCREMENT);
|
SetMenuRepeatDelay (ACCELERATION_INCREMENT, MENU_REPEAT_DELAY, ACCELERATION_INCREMENT, FALSE);
|
||||||
if (resetInput)
|
if (resetInput)
|
||||||
{
|
{
|
||||||
TFB_ResetControls ();
|
TFB_ResetControls ();
|
||||||
|
|||||||
@@ -607,6 +607,7 @@ DoMoveCursor (PMENU_STATE pMS)
|
|||||||
STAMP s;
|
STAMP s;
|
||||||
UNICODE buf[30];
|
UNICODE buf[30];
|
||||||
static UNICODE last_buf;
|
static UNICODE last_buf;
|
||||||
|
static int last_dx = 0, last_dy = 0;
|
||||||
|
|
||||||
pMS->MenuRepeatDelay = (COUNT)pMS->CurState;
|
pMS->MenuRepeatDelay = (COUNT)pMS->CurState;
|
||||||
if (!pMS->Initialized)
|
if (!pMS->Initialized)
|
||||||
@@ -617,7 +618,7 @@ DoMoveCursor (PMENU_STATE pMS)
|
|||||||
);
|
);
|
||||||
pMS->InputFunc = DoMoveCursor;
|
pMS->InputFunc = DoMoveCursor;
|
||||||
|
|
||||||
SetMenuRepeatDelay (MIN_ACCEL_DELAY, MAX_ACCEL_DELAY, STEP_ACCEL_DELAY);
|
SetMenuRepeatDelay (MIN_ACCEL_DELAY, MAX_ACCEL_DELAY, STEP_ACCEL_DELAY, TRUE);
|
||||||
|
|
||||||
pMS->flash_task = AssignTask (flash_cursor_func, 2048,
|
pMS->flash_task = AssignTask (flash_cursor_func, 2048,
|
||||||
"flash location on star map");
|
"flash location on star map");
|
||||||
@@ -626,6 +627,7 @@ DoMoveCursor (PMENU_STATE pMS)
|
|||||||
|
|
||||||
last_buf = ~0;
|
last_buf = ~0;
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
|
last_dx = last_dy = 0;
|
||||||
goto UpdateCursorInfo;
|
goto UpdateCursorInfo;
|
||||||
}
|
}
|
||||||
else if (CurrentMenuState.cancel)
|
else if (CurrentMenuState.cancel)
|
||||||
@@ -659,10 +661,10 @@ DoMoveCursor (PMENU_STATE pMS)
|
|||||||
ZoomStarMap (ZoomOut - ZoomIn);
|
ZoomStarMap (ZoomOut - ZoomIn);
|
||||||
|
|
||||||
sx = sy = 0;
|
sx = sy = 0;
|
||||||
if (CurrentMenuState.left) sx = -1;
|
if (CurrentMenuState.left) sx = -1;
|
||||||
if (CurrentMenuState.right) sx = 1;
|
if (CurrentMenuState.right) sx = 1;
|
||||||
if (CurrentMenuState.up) sy = -1;
|
if (CurrentMenuState.up) sy = -1;
|
||||||
if (CurrentMenuState.down) sy = 1;
|
if (CurrentMenuState.down) sy = 1;
|
||||||
|
|
||||||
if (sx == 0 && sy == 0)
|
if (sx == 0 && sy == 0)
|
||||||
{
|
{
|
||||||
@@ -1100,7 +1102,7 @@ DoStarMap (void)
|
|||||||
|
|
||||||
MenuState.InputFunc = DoMoveCursor;
|
MenuState.InputFunc = DoMoveCursor;
|
||||||
MenuState.Initialized = FALSE;
|
MenuState.Initialized = FALSE;
|
||||||
SetMenuRepeatDelay (MIN_ACCEL_DELAY, MAX_ACCEL_DELAY, STEP_ACCEL_DELAY);
|
SetMenuRepeatDelay (MIN_ACCEL_DELAY, MAX_ACCEL_DELAY, STEP_ACCEL_DELAY, TRUE);
|
||||||
|
|
||||||
transition_pending = TRUE;
|
transition_pending = TRUE;
|
||||||
if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1)
|
if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1)
|
||||||
|
|||||||
@@ -668,7 +668,7 @@ PickPlanetSide (PMENU_STATE pMS)
|
|||||||
if (!pMS->Initialized)
|
if (!pMS->Initialized)
|
||||||
{
|
{
|
||||||
pMS->InputFunc = PickPlanetSide;
|
pMS->InputFunc = PickPlanetSide;
|
||||||
SetMenuRepeatDelay (0, 0, 0);
|
SetMenuRepeatDelay (0, 0, 0, FALSE);
|
||||||
if (pMS->CurFrame == 0)
|
if (pMS->CurFrame == 0)
|
||||||
{
|
{
|
||||||
pMS->CurFrame = (FRAME)MenuSounds;
|
pMS->CurFrame = (FRAME)MenuSounds;
|
||||||
|
|||||||
Reference in New Issue
Block a user