From 0abf9fa1fa391f710b6e2e0982242c00dd96f851 Mon Sep 17 00:00:00 2001 From: XorTroll Date: Fri, 29 Nov 2019 18:53:01 +0100 Subject: [PATCH] Some input changes, check for lack of controllers on menus --- Common/Source/am/am_QCommunications.cpp | 1 - .../Include/ui/ui_QMenuApplication.hpp | 7 +++ .../Include/ui/ui_QuickMenu.hpp | 1 + LibraryAppletQMenu/RomFs/LangDefault.json | 4 +- .../Source/ui/ui_LanguagesMenuLayout.cpp | 2 + .../Source/ui/ui_MenuLayout.cpp | 3 + LibraryAppletQMenu/Source/ui/ui_QuickMenu.cpp | 59 ++++++++----------- .../Source/ui/ui_SettingsMenuLayout.cpp | 2 + .../Source/ui/ui_StartupLayout.cpp | 2 + SystemAppletQDaemon/Source/Main.cpp | 4 +- 10 files changed, 43 insertions(+), 42 deletions(-) diff --git a/Common/Source/am/am_QCommunications.cpp b/Common/Source/am/am_QCommunications.cpp index 0342d64..a34f746 100644 --- a/Common/Source/am/am_QCommunications.cpp +++ b/Common/Source/am/am_QCommunications.cpp @@ -121,7 +121,6 @@ namespace am Result QDaemon_QMenuWriteImpl(void *data, size_t size, bool wait) Q_AM_WAIT(LibraryAppletSend(data, size)) - Result QDaemon_QMenuReadImpl(void *data, size_t size, bool wait) Q_AM_WAIT(LibraryAppletRead(data, size)) diff --git a/LibraryAppletQMenu/Include/ui/ui_QMenuApplication.hpp b/LibraryAppletQMenu/Include/ui/ui_QMenuApplication.hpp index 44968ad..054c384 100644 --- a/LibraryAppletQMenu/Include/ui/ui_QMenuApplication.hpp +++ b/LibraryAppletQMenu/Include/ui/ui_QMenuApplication.hpp @@ -78,6 +78,8 @@ namespace ui void SetSelectedUser(u128 user_id); u128 GetSelectedUser(); + + void CommonMenuOnLoop(); private: am::QMenuStartMode stmode; StartupLayout::Ref startupLayout; @@ -94,4 +96,9 @@ namespace ui u32 bgm_fade_out_ms; pu::audio::Music bgm; }; + + inline void QMenuApplication::CommonMenuOnLoop() // Stuff all menus should handle (currently just connected controllers) + { + if(!hidIsControllerConnected(CONTROLLER_HANDHELD) && !hidIsControllerConnected(CONTROLLER_PLAYER_1)) this->menuLayout->HandleControllerAppletOpen(); + } } \ No newline at end of file diff --git a/LibraryAppletQMenu/Include/ui/ui_QuickMenu.hpp b/LibraryAppletQMenu/Include/ui/ui_QuickMenu.hpp index fb0ad2e..0e1f1bd 100644 --- a/LibraryAppletQMenu/Include/ui/ui_QuickMenu.hpp +++ b/LibraryAppletQMenu/Include/ui/ui_QuickMenu.hpp @@ -46,6 +46,7 @@ namespace ui s32 GetWidth(); s32 GetHeight(); + void Toggle(); // Off if on, on if off (just change to the opposite state) bool IsOn(); void OnRender(pu::ui::render::Renderer::Ref &Drawer, s32 X, s32 Y); diff --git a/LibraryAppletQMenu/RomFs/LangDefault.json b/LibraryAppletQMenu/RomFs/LangDefault.json index 4d10839..4752ecf 100644 --- a/LibraryAppletQMenu/RomFs/LangDefault.json +++ b/LibraryAppletQMenu/RomFs/LangDefault.json @@ -94,7 +94,7 @@ "set_viewer_info": "You must enable this if you want to use the PC screen viewer (uViewer). It is not necessary otherwise.", "set_flog_info": "This must be enabled to be able to launch homebrew directly as applications. Note that this might involve BAN RISK.", "startup_welcome_info": "Welcome! Please select an account to use.", - "startup_control_info": "Hold the L or R-stick in order to open menus easily from main menu.", + "startup_control_info": "Hold the L / R-stick or Z / R / ZL / ZR in order to open menus easily from main menu.", "startup_login_error": "Invalid password. Please try again.", "startup_password": "(password)", "startup_new_user": "Create new user", @@ -117,7 +117,7 @@ "help_title": "uLaunch help", "help_launch": "Press A to launch the selected entry, or to return to it if suspended.", "help_close": "Press X to close the currently opened title.", - "help_quick": "Hold a stick (L or R-stick) and move it while being held to select an option in the quick menu, then release it to open it.", + "help_quick": "Press L / R-stick or L / R / ZL / ZR to open the quick menu. There press A having an option focused to select it or press B to cancel.", "help_multiselect": "Press Y to open the multiselect mode\n(with this mode open, press Y to select/deselect any title, Y to confirm the selection or B to cancel)", "help_back": "Press B or HOME on any menu (except the startup menu) to return to the main menu.", "help_minus": "Press Minus (-) on the main menu to swap between the normal menu and the homebrew menu\n(the first swap will take longer due to homebrew scanning!)", diff --git a/LibraryAppletQMenu/Source/ui/ui_LanguagesMenuLayout.cpp b/LibraryAppletQMenu/Source/ui/ui_LanguagesMenuLayout.cpp index fd4d040..5fcdca6 100644 --- a/LibraryAppletQMenu/Source/ui/ui_LanguagesMenuLayout.cpp +++ b/LibraryAppletQMenu/Source/ui/ui_LanguagesMenuLayout.cpp @@ -128,6 +128,8 @@ namespace ui void LanguagesMenuLayout::OnInput(u64 down, u64 up, u64 held, pu::ui::Touch pos) { + qapp->CommonMenuOnLoop(); + bool ret = am::QMenuIsHomePressed(); if(down & KEY_B) { diff --git a/LibraryAppletQMenu/Source/ui/ui_MenuLayout.cpp b/LibraryAppletQMenu/Source/ui/ui_MenuLayout.cpp index 8f5fd25..ffa33d5 100644 --- a/LibraryAppletQMenu/Source/ui/ui_MenuLayout.cpp +++ b/LibraryAppletQMenu/Source/ui/ui_MenuLayout.cpp @@ -604,6 +604,8 @@ namespace ui void MenuLayout::OnInput(u64 down, u64 up, u64 held, pu::ui::Touch pos) { + qapp->CommonMenuOnLoop(); + auto quickon = this->quickMenu->IsOn(); this->itemsMenu->SetEnabled(!quickon); if(quickon) return; @@ -723,6 +725,7 @@ namespace ui } else if(down & KEY_PLUS) this->logo_Click(); else if(down & KEY_MINUS) this->menuToggle_Click(); + else if((down & KEY_L) || (down & KEY_R) || (down & KEY_ZL) || (down & KEY_ZR) || (down & KEY_LSTICK) || (down & KEY_RSTICK)) this->quickMenu->Toggle(); } void MenuLayout::SetUser(u128 user) diff --git a/LibraryAppletQMenu/Source/ui/ui_QuickMenu.cpp b/LibraryAppletQMenu/Source/ui/ui_QuickMenu.cpp index 56fb0ef..ca17775 100644 --- a/LibraryAppletQMenu/Source/ui/ui_QuickMenu.cpp +++ b/LibraryAppletQMenu/Source/ui/ui_QuickMenu.cpp @@ -48,6 +48,11 @@ namespace ui { return 720; } + + void QuickMenu::Toggle() + { + this->on = !this->on; + } bool QuickMenu::IsOn() { @@ -130,12 +135,14 @@ namespace ui } else { - auto prevon = this->on; - this->on = false; - if(Held & KEY_LSTICK) this->on = true; - if(Held & KEY_RSTICK) this->on = true; - - if(prevon && !this->on) this->off_wait = prevheld; + if(Down & KEY_A) this->Toggle(); + else if(Down & KEY_B) + { + prevheld = 0; + this->Toggle(); + } + + if(!this->on && (this->bgalpha > 0) && (this->fgalpha > 0)) this->off_wait = prevheld; } } @@ -143,40 +150,20 @@ namespace ui { QuickMenuDirection dir = QuickMenuDirection::None; - if(this->lastheld & KEY_RSTICK) + if(this->lastheld & KEY_UP) { - if(this->lastheld & KEY_RSTICK_UP) - { - dir = QuickMenuDirection::Up; - if(this->lastheld & KEY_RSTICK_LEFT) dir = QuickMenuDirection::UpLeft; - else if(this->lastheld & KEY_RSTICK_RIGHT) dir = QuickMenuDirection::UpRight; - } - else if(this->lastheld & KEY_RSTICK_DOWN) - { - dir = QuickMenuDirection::Down; - if(this->lastheld & KEY_RSTICK_LEFT) dir = QuickMenuDirection::DownLeft; - else if(this->lastheld & KEY_RSTICK_RIGHT) dir = QuickMenuDirection::DownRight; - } - else if(this->lastheld & KEY_RSTICK_LEFT) dir = QuickMenuDirection::Left; - else if(this->lastheld & KEY_RSTICK_RIGHT) dir = QuickMenuDirection::Right; + dir = QuickMenuDirection::Up; + if(this->lastheld & KEY_LEFT) dir = QuickMenuDirection::UpLeft; + else if(this->lastheld & KEY_RIGHT) dir = QuickMenuDirection::UpRight; } - else if(this->lastheld & KEY_LSTICK) + else if(this->lastheld & KEY_DOWN) { - if(this->lastheld & KEY_LSTICK_UP) - { - dir = QuickMenuDirection::Up; - if(this->lastheld & KEY_LSTICK_LEFT) dir = QuickMenuDirection::UpLeft; - else if(this->lastheld & KEY_LSTICK_RIGHT) dir = QuickMenuDirection::UpRight; - } - else if(this->lastheld & KEY_LSTICK_DOWN) - { - dir = QuickMenuDirection::Down; - if(this->lastheld & KEY_LSTICK_LEFT) dir = QuickMenuDirection::DownLeft; - else if(this->lastheld & KEY_LSTICK_RIGHT) dir = QuickMenuDirection::DownRight; - } - else if(this->lastheld & KEY_LSTICK_LEFT) dir = QuickMenuDirection::Left; - else if(this->lastheld & KEY_LSTICK_RIGHT) dir = QuickMenuDirection::Right; + dir = QuickMenuDirection::Down; + if(this->lastheld & KEY_LEFT) dir = QuickMenuDirection::DownLeft; + else if(this->lastheld & KEY_RIGHT) dir = QuickMenuDirection::DownRight; } + else if(this->lastheld & KEY_LEFT) dir = QuickMenuDirection::Left; + else if(this->lastheld & KEY_RIGHT) dir = QuickMenuDirection::Right; return dir; } diff --git a/LibraryAppletQMenu/Source/ui/ui_SettingsMenuLayout.cpp b/LibraryAppletQMenu/Source/ui/ui_SettingsMenuLayout.cpp index f4bd5d6..3c3631b 100644 --- a/LibraryAppletQMenu/Source/ui/ui_SettingsMenuLayout.cpp +++ b/LibraryAppletQMenu/Source/ui/ui_SettingsMenuLayout.cpp @@ -268,6 +268,8 @@ namespace ui void SettingsMenuLayout::OnInput(u64 down, u64 up, u64 held, pu::ui::Touch pos) { + qapp->CommonMenuOnLoop(); + bool ret = am::QMenuIsHomePressed(); if(down & KEY_B) ret = true; if(ret) diff --git a/LibraryAppletQMenu/Source/ui/ui_StartupLayout.cpp b/LibraryAppletQMenu/Source/ui/ui_StartupLayout.cpp index 9e616a8..9c9c732 100644 --- a/LibraryAppletQMenu/Source/ui/ui_StartupLayout.cpp +++ b/LibraryAppletQMenu/Source/ui/ui_StartupLayout.cpp @@ -34,6 +34,8 @@ namespace ui void StartupLayout::OnInput(u64 down, u64 up, u64 held, pu::ui::Touch pos) { + qapp->CommonMenuOnLoop(); + if(this->loadmenu) { this->loadmenu = false; diff --git a/SystemAppletQDaemon/Source/Main.cpp b/SystemAppletQDaemon/Source/Main.cpp index c29c4cd..7a43d92 100644 --- a/SystemAppletQDaemon/Source/Main.cpp +++ b/SystemAppletQDaemon/Source/Main.cpp @@ -126,7 +126,7 @@ void HandleGeneralChannel() } } } - svcSleepThread(100000000L); + svcSleepThread(100'000'000L); } void HandleAppletMessage() @@ -434,8 +434,6 @@ namespace qdaemon svcSleepThread(10'000'000); } #endif - - svcSleepThread(100'000'000); // Wait for proper moment } void Exit()