1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-25 12:41:01 +00:00

Enable toggling sneak via gamepad.

This commit is contained in:
Perry Hugh 2019-02-27 14:03:16 -08:00
parent 3ce261ddd4
commit 3ac5481ab4
No known key found for this signature in database
GPG Key ID: 080C82631635F396
2 changed files with 33 additions and 1 deletions

View File

@ -71,6 +71,8 @@ namespace MWInput
, mUserFileExists(userFileExists) , mUserFileExists(userFileExists)
, mAlwaysRunActive(Settings::Manager::getBool("always run", "Input")) , mAlwaysRunActive(Settings::Manager::getBool("always run", "Input"))
, mSneakToggles(Settings::Manager::getBool("toggle sneak", "Input")) , mSneakToggles(Settings::Manager::getBool("toggle sneak", "Input"))
, mSneakToggleShortcutTimer(0.f)
, mSneakGamepadShortcut(false)
, mSneaking(false) , mSneaking(false)
, mAttemptJump(false) , mAttemptJump(false)
, mInvUiScalingFactor(1.f) , mInvUiScalingFactor(1.f)
@ -579,7 +581,35 @@ namespace MWInput
if (!mSneakToggles) if (!mSneakToggles)
{ {
mPlayer->setSneak(actionIsActive(A_Sneak)); if(mJoystickLastUsed)
{
if(actionIsActive(A_Sneak))
{
if(mSneakToggleShortcutTimer) // New Sneak Button Press
{
if(mSneakToggleShortcutTimer <= 0.3f)
{
mSneakGamepadShortcut = true;
toggleSneaking();
}
else
mSneakGamepadShortcut = false;
}
if(!mSneaking)
toggleSneaking();
mSneakToggleShortcutTimer = 0.f;
}
else
{
if(!mSneakGamepadShortcut && mSneaking)
toggleSneaking();
if(mSneakToggleShortcutTimer <= 0.3f)
mSneakToggleShortcutTimer += dt;
}
}
else
mPlayer->setSneak(actionIsActive(A_Sneak));
} }
if (mAttemptJump && mControlSwitch["playerjumping"]) if (mAttemptJump && mControlSwitch["playerjumping"])

View File

@ -200,6 +200,8 @@ namespace MWInput
bool mUserFileExists; bool mUserFileExists;
bool mAlwaysRunActive; bool mAlwaysRunActive;
bool mSneakToggles; bool mSneakToggles;
float mSneakToggleShortcutTimer;
bool mSneakGamepadShortcut;
bool mSneaking; bool mSneaking;
bool mAttemptJump; bool mAttemptJump;