diff --git a/Common/UI/Root.cpp b/Common/UI/Root.cpp index dfb775eb95..564381e87c 100644 --- a/Common/UI/Root.cpp +++ b/Common/UI/Root.cpp @@ -124,6 +124,8 @@ void EnableFocusMovement(bool enable) { focusMoves.clear(); heldKeys.clear(); focusedView = nullptr; + } else { + enable = enable; } } @@ -361,7 +363,7 @@ restart: } } -DialogResult UpdateViewHierarchy(ViewGroup *root) { +DialogResult UpdateViewHierarchy(ViewGroup *root, bool canEnableFocusMovement) { ProcessHeldKeys(root); frameCount++; @@ -370,7 +372,7 @@ DialogResult UpdateViewHierarchy(ViewGroup *root) { return DR_NONE; } - if (focusMoves.size()) { + if (focusMoves.size() && canEnableFocusMovement) { EnableFocusMovement(true); if (!GetFocusedView()) { // Find a view to focus. @@ -397,8 +399,8 @@ DialogResult UpdateViewHierarchy(ViewGroup *root) { } } } - focusMoves.clear(); } + focusMoves.clear(); root->Update(); return DispatchEvents(); diff --git a/Common/UI/Root.h b/Common/UI/Root.h index 861941f6b7..e5d341503a 100644 --- a/Common/UI/Root.h +++ b/Common/UI/Root.h @@ -26,7 +26,7 @@ DialogResult DispatchEvents(); class ViewGroup; void LayoutViewHierarchy(const UIContext &dc, const UI::Margins &rootMargins, UI::ViewGroup *root, ViewLayoutMode layoutMode, bool immersiveMode); -DialogResult UpdateViewHierarchy(ViewGroup *root); +DialogResult UpdateViewHierarchy(ViewGroup *root, bool canEnableFocusMovement = true); enum class KeyEventResult { IGNORE_KEY, // Don't let it be processed. diff --git a/Common/UI/UIScreen.cpp b/Common/UI/UIScreen.cpp index ed723aba67..97d3b26d7c 100644 --- a/Common/UI/UIScreen.cpp +++ b/Common/UI/UIScreen.cpp @@ -104,7 +104,7 @@ void UIScreen::update() { DoRecreateViews(); if (root_) { - DialogResult result = UpdateViewHierarchy(root_); + DialogResult result = UpdateViewHierarchy(root_, AllowFocusMovement()); if (result != DR_NONE) { TriggerFinish(result); } diff --git a/Common/UI/UIScreen.h b/Common/UI/UIScreen.h index 7202455124..149b05068c 100644 --- a/Common/UI/UIScreen.h +++ b/Common/UI/UIScreen.h @@ -50,6 +50,7 @@ public: protected: virtual void CreateViews() = 0; + virtual bool AllowFocusMovement() const { return true; } Bounds GetLayoutBounds(UIContext &dc) const; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index e1639f4d1f..004a858d3d 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1738,6 +1738,14 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) { return screenRenderFlags; } +bool EmuScreen::AllowFocusMovement() const { + if (chatMenu_ && chatMenu_->GetVisibility() == UI::V_VISIBLE) { + return true; + } + // We have just a game controller and possibly a chat and debug button. Don't allow focus movement. + return false; +} + ScreenRenderFlags EmuScreen::RunEmulation(bool skipBufferEffects) { using namespace Draw; ScreenRenderFlags flags = ScreenRenderFlags::NONE; diff --git a/UI/EmuScreen.h b/UI/EmuScreen.h index 68fb0b13eb..8ca0a385ac 100644 --- a/UI/EmuScreen.h +++ b/UI/EmuScreen.h @@ -77,6 +77,8 @@ protected: void SetPSPAnalog(int rotation, int stick, float x, float y) override; ViewLayoutMode LayoutMode() const override; + bool AllowFocusMovement() const override; + private: void CreateViews() override; ScreenRenderFlags RunEmulation(bool skipBufferEffects);