From 4bf24a955ee822024c17f276a08c2da07f765469 Mon Sep 17 00:00:00 2001 From: Perry Hugh Date: Tue, 4 Aug 2020 06:04:59 +0000 Subject: [PATCH] Restore Gamepad Zooming --- apps/openmw/mwbase/world.hpp | 1 + apps/openmw/mwinput/actionmanager.cpp | 5 +++++ apps/openmw/mwinput/actionmanager.hpp | 2 +- apps/openmw/mwinput/controllermanager.cpp | 4 ++-- apps/openmw/mwworld/worldimp.cpp | 5 +++++ apps/openmw/mwworld/worldimp.hpp | 1 + 6 files changed, 15 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 17e233053..9709df362 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -416,6 +416,7 @@ namespace MWBase virtual void togglePOV(bool force = false) = 0; virtual bool isFirstPerson() const = 0; + virtual bool isPreviewModeEnabled() const = 0; virtual void togglePreviewMode(bool enable) = 0; virtual bool toggleVanityMode(bool enable) = 0; virtual void allowVanityMode(bool allow) = 0; diff --git a/apps/openmw/mwinput/actionmanager.cpp b/apps/openmw/mwinput/actionmanager.cpp index ec6c5cf7f..adb5a1c8a 100644 --- a/apps/openmw/mwinput/actionmanager.cpp +++ b/apps/openmw/mwinput/actionmanager.cpp @@ -167,6 +167,11 @@ namespace MWInput mAttemptJump = false; } + + bool ActionManager::isPreviewModeEnabled() + { + return MWBase::Environment::get().getWorld()->isPreviewModeEnabled(); + } void ActionManager::resetIdleTime() { diff --git a/apps/openmw/mwinput/actionmanager.hpp b/apps/openmw/mwinput/actionmanager.hpp index 7aa73f520..eceac2e94 100644 --- a/apps/openmw/mwinput/actionmanager.hpp +++ b/apps/openmw/mwinput/actionmanager.hpp @@ -54,7 +54,7 @@ namespace MWInput void setAttemptJump(bool enabled) { mAttemptJump = enabled; } - float getPreviewDelay() const { return mPreviewPOVDelay; }; + bool isPreviewModeEnabled(); private: void handleGuiArrowKey(int action); diff --git a/apps/openmw/mwinput/controllermanager.cpp b/apps/openmw/mwinput/controllermanager.cpp index b0e769cc6..c9941c836 100644 --- a/apps/openmw/mwinput/controllermanager.cpp +++ b/apps/openmw/mwinput/controllermanager.cpp @@ -89,7 +89,7 @@ namespace MWInput bool ControllerManager::update(float dt) { - mGamepadPreviewMode = mActionManager->getPreviewDelay() == 1.f; + mGamepadPreviewMode = mActionManager->isPreviewModeEnabled(); if (mGuiCursorEnabled && !(mJoystickLastUsed && !mGamepadGuiCursorEnabled)) { @@ -287,7 +287,7 @@ namespace MWInput } else { - if (mGamepadPreviewMode && arg.value) // Preview Mode Gamepad Zooming + if (mGamepadPreviewMode) // Preview Mode Gamepad Zooming { if (arg.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT) { diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 84f50cdef..2eec9bf0e 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2394,6 +2394,11 @@ namespace MWWorld { return mRendering->getCamera()->isFirstPerson(); } + + bool World::isPreviewModeEnabled() const + { + return mRendering->getCamera()->getMode() == MWRender::Camera::Mode::Preview; + } void World::togglePreviewMode(bool enable) { diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index c08206600..5eae9608e 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -524,6 +524,7 @@ namespace MWWorld void togglePOV(bool force = false) override; bool isFirstPerson() const override; + bool isPreviewModeEnabled() const override; void togglePreviewMode(bool enable) override;