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();
}
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)

4
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",

Loading…
Cancel
Save