diff --git a/src/core/hle/service/am/service/global_state_controller.cpp b/src/core/hle/service/am/service/global_state_controller.cpp index dba5d36130..3e3b61b0a0 100644 --- a/src/core/hle/service/am/service/global_state_controller.cpp +++ b/src/core/hle/service/am/service/global_state_controller.cpp @@ -15,8 +15,8 @@ IGlobalStateController::IGlobalStateController(Core::System& system_) {0, nullptr, "RequestToEnterSleep"}, {1, nullptr, "EnterSleep"}, {2, nullptr, "StartSleepSequence"}, - {3, nullptr, "StartShutdownSequence"}, - {4, nullptr, "StartRebootSequence"}, + {3, D<&IGlobalStateController::StartShutdownSequence>, "StartShutdownSequence"}, + {4, D<&IGlobalStateController::StartRebootSequence>, "StartRebootSequence"}, {9, nullptr, "IsAutoPowerDownRequested"}, {10, D<&IGlobalStateController::LoadAndApplyIdlePolicySettings>, "LoadAndApplyIdlePolicySettings"}, {11, nullptr, "NotifyCecSettingsChanged"}, @@ -31,6 +31,18 @@ IGlobalStateController::IGlobalStateController(Core::System& system_) RegisterHandlers(functions); } +Result IGlobalStateController::StartShutdownSequence() { + LOG_INFO(Service_AM, "called"); + system.Exit(); + R_SUCCEED(); +} + +Result IGlobalStateController::StartRebootSequence() { + LOG_INFO(Service_AM, "called"); + system.Exit(); + R_SUCCEED(); +} + IGlobalStateController::~IGlobalStateController() = default; Result IGlobalStateController::LoadAndApplyIdlePolicySettings() { diff --git a/src/core/hle/service/am/service/global_state_controller.h b/src/core/hle/service/am/service/global_state_controller.h index 67c753513d..83efb57dfc 100644 --- a/src/core/hle/service/am/service/global_state_controller.h +++ b/src/core/hle/service/am/service/global_state_controller.h @@ -18,6 +18,8 @@ public: ~IGlobalStateController() override; private: + Result StartShutdownSequence(); + Result StartRebootSequence(); Result LoadAndApplyIdlePolicySettings(); Result ShouldSleepOnBoot(Out out_should_sleep_on_boot); Result GetHdcpAuthenticationFailedEvent(OutCopyHandle out_event); diff --git a/src/suyu/main.cpp b/src/suyu/main.cpp index e0ac838908..6421be422b 100644 --- a/src/suyu/main.cpp +++ b/src/suyu/main.cpp @@ -1577,6 +1577,7 @@ void GMainWindow::ConnectMenuEvents() { [this]() { OnCabinet(Service::NFP::CabinetMode::StartFormatter); }); connect_menu(ui->action_Load_Mii_Edit, &GMainWindow::OnMiiEdit); connect_menu(ui->action_Open_Controller_Menu, &GMainWindow::OnOpenControllerMenu); + connect_menu(ui->action_Load_Home_Menu, &GMainWindow::OnHomeMenu); connect_menu(ui->action_Capture_Screenshot, &GMainWindow::OnCaptureScreenshot); // TAS @@ -4291,6 +4292,29 @@ void GMainWindow::OnOpenControllerMenu() { LibraryAppletParameters(ControllerAppletId, Service::AM::AppletId::Controller)); } +void GMainWindow::OnHomeMenu() { + constexpr u64 QLaunchId = static_cast(Service::AM::AppletProgramId::QLaunch); + auto bis_system = system->GetFileSystemController().GetSystemNANDContents(); + if (!bis_system) { + QMessageBox::warning(this, tr("No firmware available"), + tr("Please install the firmware to use the Home Menu.")); + return; + } + + auto qlaunch_applet_nca = bis_system->GetEntry(QLaunchId, FileSys::ContentRecordType::Program); + if (!qlaunch_applet_nca) { + QMessageBox::warning(this, tr("Home Menu Applet"), + tr("Home Menu is not available. Please reinstall firmware.")); + return; + } + + system->GetFrontendAppletHolder().SetCurrentAppletId(Service::AM::AppletId::QLaunch); + + const auto filename = QString::fromStdString((qlaunch_applet_nca->GetFullPath())); + UISettings::values.roms_path = QFileInfo(filename).path().toStdString(); + BootGame(filename, LibraryAppletParameters(QLaunchId, Service::AM::AppletId::QLaunch)); +} + void GMainWindow::OnCaptureScreenshot() { if (emu_thread == nullptr || !emu_thread->IsRunning()) { return; diff --git a/src/suyu/main.h b/src/suyu/main.h index 42a0ab0c90..1705c491bf 100644 --- a/src/suyu/main.h +++ b/src/suyu/main.h @@ -399,6 +399,7 @@ private slots: void OnCabinet(Service::NFP::CabinetMode mode); void OnMiiEdit(); void OnOpenControllerMenu(); + void OnHomeMenu(); void OnCaptureScreenshot(); void OnCheckFirmwareDecryption(); void OnLanguageChanged(const QString& locale); diff --git a/src/suyu/main.ui b/src/suyu/main.ui index ec748b196a..439dc4ba36 100644 --- a/src/suyu/main.ui +++ b/src/suyu/main.ui @@ -173,6 +173,7 @@ + @@ -475,6 +476,11 @@ Install Decryption Keys + + + Open Home Menu + +