Browse Source

Fix stand ground for gamepad controls

pull/5945/head
staphen 3 years ago committed by Anders Jenbo
parent
commit
d2bc7c10ba
  1. 37
      Source/controls/plrctrls.cpp
  2. 4
      Source/diablo.cpp

37
Source/controls/plrctrls.cpp

@ -482,27 +482,30 @@ void FindTrigger()
CheckRportal(); 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) { if (ControlMode == ControlTypes::Gamepad) {
ControllerButtonCombo standGroundCombo = sgOptions.Padmapper.ButtonComboForAction("StandGround"); ControllerButtonCombo standGroundCombo = sgOptions.Padmapper.ButtonComboForAction("StandGround");
stand = IsControllerButtonComboPressed(standGroundCombo); return StandToggle || IsControllerButtonComboPressed(standGroundCombo);
} }
#ifndef USE_SDL1
if (ControlMode == ControlTypes::VirtualGamepad) { if (ControlMode == ControlTypes::VirtualGamepad) {
stand = VirtualGamepadState.standButton.isHeld; return VirtualGamepadState.standButton.isHeld;
} }
#endif #endif
return false;
}
void Interact()
{
if (leveltype == DTYPE_TOWN && pcursmonst != -1) {
NetSendCmdLocParam1(true, CMD_TALKXY, Towners[pcursmonst].position, pcursmonst);
return;
}
Player &myPlayer = *MyPlayer; Player &myPlayer = *MyPlayer;
if (leveltype != DTYPE_TOWN && stand) { if (leveltype != DTYPE_TOWN && IsStandingGround()) {
Direction pdir = myPlayer._pdir; Direction pdir = myPlayer._pdir;
AxisDirection moveDir = GetMoveDirection(); AxisDirection moveDir = GetMoveDirection();
bool motion = moveDir.x != AxisDirectionX_NONE || moveDir.y != AxisDirectionY_NONE; 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()) if (!player.isWalking() && player.CanChangeAction())
player._pdir = pdir; player._pdir = pdir;
#ifndef USE_SDL1 if (IsStandingGround()) {
if (ControlMode == ControlTypes::VirtualGamepad) { if (player._pmode == PM_STAND)
if (VirtualGamepadState.standButton.isHeld) { StartStand(player, pdir);
if (player._pmode == PM_STAND) return;
StartStand(player, pdir);
return;
}
} }
#endif
if (PosOkPlayer(player, delta) && IsPathBlocked(player.position.future, pdir)) { if (PosOkPlayer(player, delta) && IsPathBlocked(player.position.future, pdir)) {
if (player._pmode == PM_STAND) if (player._pmode == PM_STAND)

4
Source/diablo.cpp

@ -1989,8 +1989,8 @@ void InitPadmapActions()
N_("Toggle stand ground"), N_("Toggle stand ground"),
N_("Toggle whether the player moves."), N_("Toggle whether the player moves."),
ControllerButton_NONE, ControllerButton_NONE,
[] { StandToggle = true; }, [] { StandToggle = !StandToggle; },
[] { StandToggle = false; }, nullptr,
CanPlayerTakeAction); CanPlayerTakeAction);
sgOptions.Padmapper.AddAction( sgOptions.Padmapper.AddAction(
"UseHealthPotion", "UseHealthPotion",

Loading…
Cancel
Save