diff --git a/Source/controls/plrctrls.cpp b/Source/controls/plrctrls.cpp index e79f24959..c32d53b7a 100644 --- a/Source/controls/plrctrls.cpp +++ b/Source/controls/plrctrls.cpp @@ -482,27 +482,30 @@ void FindTrigger() CheckRportal(); } -void Interact() +bool IsStandingGround() { - if (leveltype == DTYPE_TOWN && pcursmonst != -1) { - NetSendCmdLocParam1(true, CMD_TALKXY, Towners[pcursmonst].position, pcursmonst); - return; - } - - bool stand = StandToggle; -#ifndef USE_SDL1 if (ControlMode == ControlTypes::Gamepad) { ControllerButtonCombo standGroundCombo = sgOptions.Padmapper.ButtonComboForAction("StandGround"); - stand = IsControllerButtonComboPressed(standGroundCombo); + return StandToggle || IsControllerButtonComboPressed(standGroundCombo); } +#ifndef USE_SDL1 if (ControlMode == ControlTypes::VirtualGamepad) { - stand = VirtualGamepadState.standButton.isHeld; + return VirtualGamepadState.standButton.isHeld; } #endif + return false; +} + +void Interact() +{ + if (leveltype == DTYPE_TOWN && pcursmonst != -1) { + NetSendCmdLocParam1(true, CMD_TALKXY, Towners[pcursmonst].position, pcursmonst); + return; + } Player &myPlayer = *MyPlayer; - if (leveltype != DTYPE_TOWN && stand) { + if (leveltype != DTYPE_TOWN && IsStandingGround()) { Direction pdir = myPlayer._pdir; AxisDirection moveDir = GetMoveDirection(); bool motion = moveDir.x != AxisDirectionX_NONE || moveDir.y != AxisDirectionY_NONE; @@ -1303,15 +1306,11 @@ void WalkInDir(size_t playerId, AxisDirection dir) if (!player.isWalking() && player.CanChangeAction()) player._pdir = pdir; -#ifndef USE_SDL1 - if (ControlMode == ControlTypes::VirtualGamepad) { - if (VirtualGamepadState.standButton.isHeld) { - if (player._pmode == PM_STAND) - StartStand(player, pdir); - return; - } + if (IsStandingGround()) { + if (player._pmode == PM_STAND) + StartStand(player, pdir); + return; } -#endif if (PosOkPlayer(player, delta) && IsPathBlocked(player.position.future, pdir)) { if (player._pmode == PM_STAND) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index a314cb8e6..dc32551f5 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1989,8 +1989,8 @@ void InitPadmapActions() N_("Toggle stand ground"), N_("Toggle whether the player moves."), ControllerButton_NONE, - [] { StandToggle = true; }, - [] { StandToggle = false; }, + [] { StandToggle = !StandToggle; }, + nullptr, CanPlayerTakeAction); sgOptions.Padmapper.AddAction( "UseHealthPotion",