From 2f9570ec2450c7bec0beb8eda15c3d1957b3962f Mon Sep 17 00:00:00 2001 From: gugueU Date: Tue, 15 Nov 2022 21:54:51 +0100 Subject: [PATCH] feat(frontend): add shortcut to lock/unlock menus --- .../es-app/src/views/GameClipView.cpp | 2 +- .../frontend/es-app/src/views/SystemView.cpp | 37 ++++++++++++++++--- .../frontend/es-app/src/views/SystemView.h | 1 + .../views/gamelist/ISimpleGameListView.cpp | 13 ++++--- .../frontend/es-core/src/WindowManager.cpp | 4 +- projects/frontend/es-core/src/WindowManager.h | 2 + .../es-core/src/input/InputCompactEvent.h | 2 + 7 files changed, 48 insertions(+), 13 deletions(-) diff --git a/projects/frontend/es-app/src/views/GameClipView.cpp b/projects/frontend/es-app/src/views/GameClipView.cpp index 5beef02bcc..3b3b0d08a7 100644 --- a/projects/frontend/es-app/src/views/GameClipView.cpp +++ b/projects/frontend/es-app/src/views/GameClipView.cpp @@ -217,7 +217,7 @@ bool GameClipView::ProcessInput(const InputCompactEvent& event) } // TOGGLE FAVORITES - Y - if (event.YPressed()) + if (event.YPressed() && RecalboxConf::Instance().AsString("emulationstation.menu") != "none") { if (mGame->IsGame() && mGame->System().HasFavoritesInTheme()) { diff --git a/projects/frontend/es-app/src/views/SystemView.cpp b/projects/frontend/es-app/src/views/SystemView.cpp index 2fcf2d4790..cd7f9210ea 100755 --- a/projects/frontend/es-app/src/views/SystemView.cpp +++ b/projects/frontend/es-app/src/views/SystemView.cpp @@ -217,6 +217,14 @@ void SystemView::goToSystem(SystemData* system, bool animate) bool SystemView::ProcessInput(const InputCompactEvent& event) { + if (event.IsNotPressedAndReleased()) + return true; + + if (event.HotkeyPressed() && !mHotKeyAlreadyPressed) mHotKeyAlreadyPressed = true; + + else mHotKeyAlreadyPressed = false; + + if (event.AnythingPressed()) { switch (mCarousel.type) @@ -466,6 +474,22 @@ void SystemView::onCursorChanged(const CursorState& state) void SystemView::Render(const Transform4x4f& parentTrans) { + if (mHotKeyAlreadyPressed && mWindow.GetTimeSinceLastInput() >= 5000) + { + if(RecalboxConf::Instance().AsString("emulationstation.menu") != "none") + mWindow.pushGui((new GuiMsgBox(mWindow, "VERROUILLER LES MENUS ?\n(Pour déverrouiller maintenez HOTKEY pendant 10sec.)", _("OK"), [this] + { + RecalboxConf::Instance().SetString("emulationstation.menu", "none"); + }, _("CANCEL"), nullptr))->SetDefaultButton(1)); + else + mWindow.pushGui(new GuiMsgBox(mWindow, _("Déverrouller les menus ?"), _("OK"), [this] + { + RecalboxConf::Instance().SetString("emulationstation.menu", ""); + }, _("CANCEL"), nullptr)); + + mHotKeyAlreadyPressed = false; + } + if(size() == 0) return; // nothing to render @@ -504,13 +528,14 @@ bool SystemView::getHelpPrompts(Help& help) else if (RecalboxConf::Instance().GetNetplayEnabled()) help.Set(HelpType::X, _("NETPLAY")); - help.Set(HelpType::Select, _("QUIT")) - .Set(HelpType::Start, _("MENU")) - .Set(HelpType::R, _("SEARCH")); - - if(GameClipView::IsGameClipEnabled()) + if(RecalboxConf::Instance().AsString("emulationstation.menu") != "none") { - help.Set(HelpType::Y, _("gameclip")); + help.Set(HelpType::Select, _("QUIT")).Set(HelpType::Start, _("MENU")).Set(HelpType::R, _("SEARCH")); + + if (GameClipView::IsGameClipEnabled()) + { + help.Set(HelpType::Y, _("gameclip")); + } } return true; diff --git a/projects/frontend/es-app/src/views/SystemView.h b/projects/frontend/es-app/src/views/SystemView.h index a7f0d72cd1..4ce9f5567f 100755 --- a/projects/frontend/es-app/src/views/SystemView.h +++ b/projects/frontend/es-app/src/views/SystemView.h @@ -112,4 +112,5 @@ private: bool mViewNeedsReload; bool mShowing; bool launchKodi; + bool mHotKeyAlreadyPressed = false; }; diff --git a/projects/frontend/es-app/src/views/gamelist/ISimpleGameListView.cpp b/projects/frontend/es-app/src/views/gamelist/ISimpleGameListView.cpp index 529dea3fcc..a4b754c624 100755 --- a/projects/frontend/es-app/src/views/gamelist/ISimpleGameListView.cpp +++ b/projects/frontend/es-app/src/views/gamelist/ISimpleGameListView.cpp @@ -183,7 +183,7 @@ bool ISimpleGameListView::ProcessInput(const InputCompactEvent& event) } // TOGGLE FAVORITES - if (event.YPressed() && !cursor->TopAncestor().PreInstalled()) + if (RecalboxConf::Instance().AsString("emulationstation.menu") != "none" && event.YPressed() && !cursor->TopAncestor().PreInstalled()) { if (cursor->IsGame() && cursor->System().HasFavoritesInTheme()) @@ -300,7 +300,7 @@ bool ISimpleGameListView::ProcessInput(const InputCompactEvent& event) return true; } - if (event.StartPressed()) + if (event.StartPressed() && RecalboxConf::Instance().AsString("emulationstation.menu") != "none") { clean(); mWindow.pushGui(new GuiMenuGamelistOptions(mWindow, mSystem, mSystemManager)); @@ -329,8 +329,6 @@ bool ISimpleGameListView::getHelpPrompts(Help& help) help.Set(HelpType::X, _("P2K CONTROLS")); } FileData* fd = getCursor(); - if (!fd->TopAncestor().PreInstalled()) - help.Set(HelpType::Y, IsFavoriteSystem() ? _("Remove from favorite") : _("Favorite")); if (!hideSystemView) help.Set(Help::Cancel(), _("BACK")); @@ -340,7 +338,12 @@ bool ISimpleGameListView::getHelpPrompts(Help& help) if (RecalboxConf::Instance().GetQuickSystemSelect() && !hideSystemView) help.Set(HelpType::LeftRight, _("SYSTEM")); - help.Set(HelpType::Start, _("OPTIONS")); + if(RecalboxConf::Instance().AsString("emulationstation.menu") != "none") + { + help.Set(HelpType::Start, _("OPTIONS")); + if (!fd->TopAncestor().PreInstalled()) + help.Set(HelpType::Y, IsFavoriteSystem() ? _("Remove from favorite") : _("Favorite")); + } return true; } diff --git a/projects/frontend/es-core/src/WindowManager.cpp b/projects/frontend/es-core/src/WindowManager.cpp index 5c97bb2f71..53856bb693 100644 --- a/projects/frontend/es-core/src/WindowManager.cpp +++ b/projects/frontend/es-core/src/WindowManager.cpp @@ -176,7 +176,9 @@ bool WindowManager::ProcessInput(const InputCompactEvent& event) return true; } - mTimeSinceLastInput = 0; + if(!event.IsNotPressedAndReleased()) + mTimeSinceLastInput = 0; + if (peekGui() != nullptr) { peekGui()->ProcessInput(event); diff --git a/projects/frontend/es-core/src/WindowManager.h b/projects/frontend/es-core/src/WindowManager.h index d16430e213..503cac139a 100644 --- a/projects/frontend/es-core/src/WindowManager.h +++ b/projects/frontend/es-core/src/WindowManager.h @@ -61,6 +61,8 @@ class WindowManager void DoWake(); + unsigned int GetTimeSinceLastInput() const { return mTimeSinceLastInput; } + /*! * @brief Add new popup to dysplay list * @param infoPopup Popup to add to display list diff --git a/projects/frontend/es-core/src/input/InputCompactEvent.h b/projects/frontend/es-core/src/input/InputCompactEvent.h index 4217d8834b..47833e7e8c 100644 --- a/projects/frontend/es-core/src/input/InputCompactEvent.h +++ b/projects/frontend/es-core/src/input/InputCompactEvent.h @@ -217,6 +217,8 @@ class InputCompactEvent bool CancelPressed() const { return RecalboxConf::Instance().GetSwapValidateAndCancel() ? BPressed() : APressed(); } bool CancelReleased() const { return RecalboxConf::Instance().GetSwapValidateAndCancel() ? BReleased() : AReleased(); } + bool IsNotPressedAndReleased() const { return !mActivatedEntryFlags && !mDeactivatedEntryFlags; } + /* * Debug */ -- GitLab