1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-17 10:21:11 +00:00

Merge pull request #2397 from Capostrophic/gamepad

Analogue movement fixes
This commit is contained in:
Andrei Kortunov 2019-05-28 22:45:42 +04:00 committed by GitHub
commit f9143decc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -703,7 +703,7 @@ namespace MWInput
mOverencumberedMessageDelay = 0.f; mOverencumberedMessageDelay = 0.f;
} }
if (mAlwaysRunActive || isRunning) if ((mAlwaysRunActive && !mJoystickLastUsed) || isRunning)
mPlayer->setRunState(!actionIsActive(A_Run)); mPlayer->setRunState(!actionIsActive(A_Run));
else else
mPlayer->setRunState(actionIsActive(A_Run)); mPlayer->setRunState(actionIsActive(A_Run));

View File

@ -1979,24 +1979,24 @@ void CharacterController::update(float duration, bool animationOnly)
osg::Vec3f rot = cls.getRotationVector(mPtr); osg::Vec3f rot = cls.getRotationVector(mPtr);
speed = cls.getSpeed(mPtr); speed = cls.getSpeed(mPtr);
float analogueMult = 1.f;
if(isPlayer) if(isPlayer)
{ {
// Joystick anologue movement. // Joystick analogue movement.
float xAxis = std::abs(cls.getMovementSettings(mPtr).mPosition[0]); float xAxis = std::abs(cls.getMovementSettings(mPtr).mPosition[0]);
float yAxis = std::abs(cls.getMovementSettings(mPtr).mPosition[1]); float yAxis = std::abs(cls.getMovementSettings(mPtr).mPosition[1]);
float analogueMovement = ((xAxis > yAxis) ? xAxis : yAxis); analogueMult = ((xAxis > yAxis) ? xAxis : yAxis);
// If Strafing, our max speed is slower so multiply by X axis instead. // If Strafing, our max speed is slower so multiply by X axis instead.
if(std::abs(vec.x()/2.0f) > std::abs(vec.y())) if(std::abs(vec.x()/2.0f) > std::abs(vec.y()))
analogueMovement = xAxis; analogueMult = xAxis;
// Due to the half way split between walking/running, we multiply speed by 2 while walking, unless a keyboard was used. // Due to the half way split between walking/running, we multiply speed by 2 while walking, unless a keyboard was used.
if(!isrunning && !sneak && !flying && analogueMovement <= 0.5f) if(!isrunning && !sneak && !flying && analogueMult <= 0.5f)
speed *= 2; analogueMult *= 2.f;
speed *= (analogueMovement);
} }
speed *= analogueMult;
vec.x() *= speed; vec.x() *= speed;
vec.y() *= speed; vec.y() *= speed;
@ -2063,6 +2063,7 @@ void CharacterController::update(float duration, bool animationOnly)
} }
} }
fatigueLoss *= duration; fatigueLoss *= duration;
fatigueLoss *= analogueMult;
DynamicStat<float> fatigue = cls.getCreatureStats(mPtr).getFatigue(); DynamicStat<float> fatigue = cls.getCreatureStats(mPtr).getFatigue();
if (!godmode) if (!godmode)