VERY experimental Nintendo Switch 2 emulator
C++
am: rewrite IHomeMenuFunctions
Liam409155d98f56
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txtindex 724ed989d4..ae2fe0b680 100644--- a/src/core/CMakeLists.txt+++ b/src/core/CMakeLists.txt@@ -427,8 +427,6 @@ add_library(core STATIChle/service/am/application_creator.hhle/service/am/hid_registration.cpphle/service/am/hid_registration.h- hle/service/am/home_menu_functions.cpp- hle/service/am/home_menu_functions.hhle/service/am/idle.cpphle/service/am/idle.hhle/service/am/library_applet_accessor.cpp@@ -473,6 +471,8 @@ add_library(core STATIChle/service/am/service/display_controller.hhle/service/am/service/global_state_controller.cpphle/service/am/service/global_state_controller.h+ hle/service/am/service/home_menu_functions.cpp+ hle/service/am/service/home_menu_functions.hhle/service/am/service/library_applet_proxy.cpphle/service/am/service/library_applet_proxy.hhle/service/am/service/system_applet_proxy.cppdiff --git a/src/core/hle/service/am/home_menu_functions.cpp b/src/core/hle/service/am/home_menu_functions.cppdeleted file mode 100644index 640e9fbb73..0000000000--- a/src/core/hle/service/am/home_menu_functions.cpp+++ /dev/null@@ -1,57 +0,0 @@-// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project-// SPDX-License-Identifier: GPL-2.0-or-later--#include "core/hle/service/am/home_menu_functions.h"-#include "core/hle/service/ipc_helpers.h"--namespace Service::AM {--IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_)- : ServiceFramework{system_, "IHomeMenuFunctions"}, service_context{system,- "IHomeMenuFunctions"} {- // clang-format off- static const FunctionInfo functions[] = {- {10, &IHomeMenuFunctions::RequestToGetForeground, "RequestToGetForeground"},- {11, nullptr, "LockForeground"},- {12, nullptr, "UnlockForeground"},- {20, nullptr, "PopFromGeneralChannel"},- {21, &IHomeMenuFunctions::GetPopFromGeneralChannelEvent, "GetPopFromGeneralChannelEvent"},- {30, nullptr, "GetHomeButtonWriterLockAccessor"},- {31, nullptr, "GetWriterLockAccessorEx"},- {40, nullptr, "IsSleepEnabled"},- {41, nullptr, "IsRebootEnabled"},- {50, nullptr, "LaunchSystemApplet"},- {51, nullptr, "LaunchStarter"},- {100, nullptr, "PopRequestLaunchApplicationForDebug"},- {110, nullptr, "IsForceTerminateApplicationDisabledForDebug"},- {200, nullptr, "LaunchDevMenu"},- {1000, nullptr, "SetLastApplicationExitReason"},- };- // clang-format on-- RegisterHandlers(functions);-- pop_from_general_channel_event =- service_context.CreateEvent("IHomeMenuFunctions:PopFromGeneralChannelEvent");-}--IHomeMenuFunctions::~IHomeMenuFunctions() {- service_context.CloseEvent(pop_from_general_channel_event);-}--void IHomeMenuFunctions::RequestToGetForeground(HLERequestContext& ctx) {- LOG_WARNING(Service_AM, "(STUBBED) called");-- IPC::ResponseBuilder rb{ctx, 2};- rb.Push(ResultSuccess);-}--void IHomeMenuFunctions::GetPopFromGeneralChannelEvent(HLERequestContext& ctx) {- LOG_WARNING(Service_AM, "(STUBBED) called");-- IPC::ResponseBuilder rb{ctx, 2, 1};- rb.Push(ResultSuccess);- rb.PushCopyObjects(pop_from_general_channel_event->GetReadableEvent());-}--} // namespace Service::AMdiff --git a/src/core/hle/service/am/home_menu_functions.h b/src/core/hle/service/am/home_menu_functions.hdeleted file mode 100644index e082d5d73e..0000000000--- a/src/core/hle/service/am/home_menu_functions.h+++ /dev/null@@ -1,25 +0,0 @@-// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project-// SPDX-License-Identifier: GPL-2.0-or-later--#pragma once--#include "core/hle/service/kernel_helpers.h"-#include "core/hle/service/service.h"--namespace Service::AM {--class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> {-public:- explicit IHomeMenuFunctions(Core::System& system_);- ~IHomeMenuFunctions() override;--private:- void RequestToGetForeground(HLERequestContext& ctx);- void GetPopFromGeneralChannelEvent(HLERequestContext& ctx);-- KernelHelpers::ServiceContext service_context;-- Kernel::KEvent* pop_from_general_channel_event;-};--} // namespace Service::AMdiff --git a/src/core/hle/service/am/service/home_menu_functions.cpp b/src/core/hle/service/am/service/home_menu_functions.cppnew file mode 100644index 0000000000..0c4d24b58b--- /dev/null+++ b/src/core/hle/service/am/service/home_menu_functions.cpp@@ -0,0 +1,74 @@+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#include "core/hle/result.h"+#include "core/hle/service/am/applet_manager.h"+#include "core/hle/service/am/service/home_menu_functions.h"+#include "core/hle/service/cmif_serialization.h"++namespace Service::AM {++IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_, std::shared_ptr<Applet> applet)+ : ServiceFramework{system_, "IHomeMenuFunctions"}, m_applet{std::move(applet)},+ m_context{system, "IHomeMenuFunctions"}, m_pop_from_general_channel_event{m_context} {+ // clang-format off+ static const FunctionInfo functions[] = {+ {10, D<&IHomeMenuFunctions::RequestToGetForeground>, "RequestToGetForeground"},+ {11, D<&IHomeMenuFunctions::LockForeground>, "LockForeground"},+ {12, D<&IHomeMenuFunctions::UnlockForeground>, "UnlockForeground"},+ {20, nullptr, "PopFromGeneralChannel"},+ {21, D<&IHomeMenuFunctions::GetPopFromGeneralChannelEvent>, "GetPopFromGeneralChannelEvent"},+ {30, nullptr, "GetHomeButtonWriterLockAccessor"},+ {31, nullptr, "GetWriterLockAccessorEx"},+ {40, nullptr, "IsSleepEnabled"},+ {41, D<&IHomeMenuFunctions::IsRebootEnabled>, "IsRebootEnabled"},+ {50, nullptr, "LaunchSystemApplet"},+ {51, nullptr, "LaunchStarter"},+ {100, nullptr, "PopRequestLaunchApplicationForDebug"},+ {110, D<&IHomeMenuFunctions::IsForceTerminateApplicationDisabledForDebug>, "IsForceTerminateApplicationDisabledForDebug"},+ {200, nullptr, "LaunchDevMenu"},+ {1000, nullptr, "SetLastApplicationExitReason"},+ };+ // clang-format on++ RegisterHandlers(functions);+}++IHomeMenuFunctions::~IHomeMenuFunctions() = default;++Result IHomeMenuFunctions::RequestToGetForeground() {+ LOG_WARNING(Service_AM, "(STUBBED) called");+ R_SUCCEED();+}++Result IHomeMenuFunctions::LockForeground() {+ LOG_WARNING(Service_AM, "(STUBBED) called");+ R_SUCCEED();+}++Result IHomeMenuFunctions::UnlockForeground() {+ LOG_WARNING(Service_AM, "(STUBBED) called");+ R_SUCCEED();+}++Result IHomeMenuFunctions::GetPopFromGeneralChannelEvent(+ OutCopyHandle<Kernel::KReadableEvent> out_event) {+ LOG_INFO(Service_AM, "called");+ *out_event = m_pop_from_general_channel_event.GetHandle();+ R_SUCCEED();+}++Result IHomeMenuFunctions::IsRebootEnabled(Out<bool> out_is_reboot_enbaled) {+ LOG_INFO(Service_AM, "called");+ *out_is_reboot_enbaled = true;+ R_SUCCEED();+}++Result IHomeMenuFunctions::IsForceTerminateApplicationDisabledForDebug(+ Out<bool> out_is_force_terminate_application_disabled_for_debug) {+ LOG_INFO(Service_AM, "called");+ *out_is_force_terminate_application_disabled_for_debug = false;+ R_SUCCEED();+}++} // namespace Service::AMdiff --git a/src/core/hle/service/am/service/home_menu_functions.h b/src/core/hle/service/am/service/home_menu_functions.hnew file mode 100644index 0000000000..caf6fbaabb--- /dev/null+++ b/src/core/hle/service/am/service/home_menu_functions.h@@ -0,0 +1,34 @@+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#pragma once++#include "core/hle/service/cmif_types.h"+#include "core/hle/service/kernel_helpers.h"+#include "core/hle/service/os/event.h"+#include "core/hle/service/service.h"++namespace Service::AM {++struct Applet;++class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> {+public:+ explicit IHomeMenuFunctions(Core::System& system_, std::shared_ptr<Applet> applet);+ ~IHomeMenuFunctions() override;++private:+ Result RequestToGetForeground();+ Result LockForeground();+ Result UnlockForeground();+ Result GetPopFromGeneralChannelEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);+ Result IsRebootEnabled(Out<bool> out_is_reboot_enbaled);+ Result IsForceTerminateApplicationDisabledForDebug(+ Out<bool> out_is_force_terminate_application_disabled_for_debug);++ const std::shared_ptr<Applet> m_applet;+ KernelHelpers::ServiceContext m_context;+ Event m_pop_from_general_channel_event;+};++} // namespace Service::AMdiff --git a/src/core/hle/service/am/service/library_applet_proxy.cpp b/src/core/hle/service/am/service/library_applet_proxy.cppindex 7b5e9717d6..cf1a34db21 100644--- a/src/core/hle/service/am/service/library_applet_proxy.cpp+++ b/src/core/hle/service/am/service/library_applet_proxy.cpp@@ -1,7 +1,6 @@// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project// SPDX-License-Identifier: GPL-2.0-or-later-#include "core/hle/service/am/home_menu_functions.h"#include "core/hle/service/am/library_applet_creator.h"#include "core/hle/service/am/library_applet_self_accessor.h"#include "core/hle/service/am/process_winding_controller.h"@@ -12,6 +11,7 @@#include "core/hle/service/am/service/debug_functions.h"#include "core/hle/service/am/service/display_controller.h"#include "core/hle/service/am/service/global_state_controller.h"+#include "core/hle/service/am/service/home_menu_functions.h"#include "core/hle/service/am/service/library_applet_proxy.h"#include "core/hle/service/am/window_controller.h"#include "core/hle/service/cmif_serialization.h"@@ -119,7 +119,7 @@ Result ILibraryAppletProxy::GetAppletCommonFunctions(Result ILibraryAppletProxy::GetHomeMenuFunctions(Out<SharedPointer<IHomeMenuFunctions>> out_home_menu_functions) {LOG_DEBUG(Service_AM, "called");- *out_home_menu_functions = std::make_shared<IHomeMenuFunctions>(system);+ *out_home_menu_functions = std::make_shared<IHomeMenuFunctions>(system, m_applet);R_SUCCEED();}diff --git a/src/core/hle/service/am/service/system_applet_proxy.cpp b/src/core/hle/service/am/service/system_applet_proxy.cppindex 077f6eea76..8fa852cfae 100644--- a/src/core/hle/service/am/service/system_applet_proxy.cpp+++ b/src/core/hle/service/am/service/system_applet_proxy.cpp@@ -2,7 +2,6 @@// SPDX-License-Identifier: GPL-2.0-or-later#include "core/hle/service/am/application_creator.h"-#include "core/hle/service/am/home_menu_functions.h"#include "core/hle/service/am/library_applet_creator.h"#include "core/hle/service/am/library_applet_self_accessor.h"#include "core/hle/service/am/process_winding_controller.h"@@ -13,6 +12,7 @@#include "core/hle/service/am/service/debug_functions.h"#include "core/hle/service/am/service/display_controller.h"#include "core/hle/service/am/service/global_state_controller.h"+#include "core/hle/service/am/service/home_menu_functions.h"#include "core/hle/service/am/service/system_applet_proxy.h"#include "core/hle/service/am/window_controller.h"#include "core/hle/service/cmif_serialization.h"@@ -118,7 +118,7 @@ Result ISystemAppletProxy::GetAppletCommonFunctions(Result ISystemAppletProxy::GetHomeMenuFunctions(Out<SharedPointer<IHomeMenuFunctions>> out_home_menu_functions) {LOG_DEBUG(Service_AM, "called");- *out_home_menu_functions = std::make_shared<IHomeMenuFunctions>(system);+ *out_home_menu_functions = std::make_shared<IHomeMenuFunctions>(system, m_applet);R_SUCCEED();}