From af35057212949c4a1088157b4f2e6e592f23f5ee Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 11 Feb 2024 19:23:26 -0500 Subject: am: rewrite IAppletCommonFunctions --- .../hle/service/am/applet_common_functions.cpp | 63 ---------------------- src/core/hle/service/am/applet_common_functions.h | 24 --------- .../service/am/service/applet_common_functions.cpp | 63 ++++++++++++++++++++++ .../service/am/service/applet_common_functions.h | 26 +++++++++ .../hle/service/am/service/application_proxy.cpp | 2 +- .../service/am/service/library_applet_proxy.cpp | 2 +- .../hle/service/am/service/system_applet_proxy.cpp | 2 +- 7 files changed, 92 insertions(+), 90 deletions(-) delete mode 100644 src/core/hle/service/am/applet_common_functions.cpp delete mode 100644 src/core/hle/service/am/applet_common_functions.h create mode 100644 src/core/hle/service/am/service/applet_common_functions.cpp create mode 100644 src/core/hle/service/am/service/applet_common_functions.h (limited to 'src/core/hle/service/am') diff --git a/src/core/hle/service/am/applet_common_functions.cpp b/src/core/hle/service/am/applet_common_functions.cpp deleted file mode 100644 index 130614ae5..000000000 --- a/src/core/hle/service/am/applet_common_functions.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "core/hle/service/am/applet.h" -#include "core/hle/service/am/applet_common_functions.h" -#include "core/hle/service/ipc_helpers.h" - -namespace Service::AM { - -IAppletCommonFunctions::IAppletCommonFunctions(Core::System& system_, - std::shared_ptr applet_) - : ServiceFramework{system_, "IAppletCommonFunctions"}, applet{std::move(applet_)} { - // clang-format off - static const FunctionInfo functions[] = { - {0, nullptr, "SetTerminateResult"}, - {10, nullptr, "ReadThemeStorage"}, - {11, nullptr, "WriteThemeStorage"}, - {20, nullptr, "PushToAppletBoundChannel"}, - {21, nullptr, "TryPopFromAppletBoundChannel"}, - {40, nullptr, "GetDisplayLogicalResolution"}, - {42, nullptr, "SetDisplayMagnification"}, - {50, nullptr, "SetHomeButtonDoubleClickEnabled"}, - {51, nullptr, "GetHomeButtonDoubleClickEnabled"}, - {52, nullptr, "IsHomeButtonShortPressedBlocked"}, - {60, nullptr, "IsVrModeCurtainRequired"}, - {61, nullptr, "IsSleepRequiredByHighTemperature"}, - {62, nullptr, "IsSleepRequiredByLowBattery"}, - {70, &IAppletCommonFunctions::SetCpuBoostRequestPriority, "SetCpuBoostRequestPriority"}, - {80, nullptr, "SetHandlingCaptureButtonShortPressedMessageEnabledForApplet"}, - {81, nullptr, "SetHandlingCaptureButtonLongPressedMessageEnabledForApplet"}, - {90, nullptr, "OpenNamedChannelAsParent"}, - {91, nullptr, "OpenNamedChannelAsChild"}, - {100, nullptr, "SetApplicationCoreUsageMode"}, - {300, &IAppletCommonFunctions::GetCurrentApplicationId, "GetCurrentApplicationId"}, - }; - // clang-format on - - RegisterHandlers(functions); -} - -IAppletCommonFunctions::~IAppletCommonFunctions() = default; - -void IAppletCommonFunctions::SetCpuBoostRequestPriority(HLERequestContext& ctx) { - LOG_WARNING(Service_AM, "(STUBBED) called"); - - IPC::RequestParser rp{ctx}; - - std::scoped_lock lk{applet->lock}; - applet->cpu_boost_request_priority = rp.Pop(); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); -} - -void IAppletCommonFunctions::GetCurrentApplicationId(HLERequestContext& ctx) { - LOG_WARNING(Service_AM, "(STUBBED) called"); - - IPC::ResponseBuilder rb{ctx, 4}; - rb.Push(ResultSuccess); - rb.Push(system.GetApplicationProcessProgramID() & ~0xFFFULL); -} - -} // namespace Service::AM diff --git a/src/core/hle/service/am/applet_common_functions.h b/src/core/hle/service/am/applet_common_functions.h deleted file mode 100644 index b86adf5cb..000000000 --- a/src/core/hle/service/am/applet_common_functions.h +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "core/hle/service/service.h" - -namespace Service::AM { - -struct Applet; - -class IAppletCommonFunctions final : public ServiceFramework { -public: - explicit IAppletCommonFunctions(Core::System& system_, std::shared_ptr applet_); - ~IAppletCommonFunctions() override; - -private: - void SetCpuBoostRequestPriority(HLERequestContext& ctx); - void GetCurrentApplicationId(HLERequestContext& ctx); - - const std::shared_ptr applet; -}; - -} // namespace Service::AM diff --git a/src/core/hle/service/am/service/applet_common_functions.cpp b/src/core/hle/service/am/service/applet_common_functions.cpp new file mode 100644 index 000000000..0f29ab285 --- /dev/null +++ b/src/core/hle/service/am/service/applet_common_functions.cpp @@ -0,0 +1,63 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/am/applet.h" +#include "core/hle/service/am/service/applet_common_functions.h" +#include "core/hle/service/cmif_serialization.h" + +namespace Service::AM { + +IAppletCommonFunctions::IAppletCommonFunctions(Core::System& system_, + std::shared_ptr applet_) + : ServiceFramework{system_, "IAppletCommonFunctions"}, applet{std::move(applet_)} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "SetTerminateResult"}, + {10, nullptr, "ReadThemeStorage"}, + {11, nullptr, "WriteThemeStorage"}, + {20, nullptr, "PushToAppletBoundChannel"}, + {21, nullptr, "TryPopFromAppletBoundChannel"}, + {40, nullptr, "GetDisplayLogicalResolution"}, + {42, nullptr, "SetDisplayMagnification"}, + {50, nullptr, "SetHomeButtonDoubleClickEnabled"}, + {51, D<&IAppletCommonFunctions::GetHomeButtonDoubleClickEnabled>, "GetHomeButtonDoubleClickEnabled"}, + {52, nullptr, "IsHomeButtonShortPressedBlocked"}, + {60, nullptr, "IsVrModeCurtainRequired"}, + {61, nullptr, "IsSleepRequiredByHighTemperature"}, + {62, nullptr, "IsSleepRequiredByLowBattery"}, + {70, D<&IAppletCommonFunctions::SetCpuBoostRequestPriority>, "SetCpuBoostRequestPriority"}, + {80, nullptr, "SetHandlingCaptureButtonShortPressedMessageEnabledForApplet"}, + {81, nullptr, "SetHandlingCaptureButtonLongPressedMessageEnabledForApplet"}, + {90, nullptr, "OpenNamedChannelAsParent"}, + {91, nullptr, "OpenNamedChannelAsChild"}, + {100, nullptr, "SetApplicationCoreUsageMode"}, + {300, D<&IAppletCommonFunctions::GetCurrentApplicationId>, "GetCurrentApplicationId"}, + }; + // clang-format on + + RegisterHandlers(functions); +} + +IAppletCommonFunctions::~IAppletCommonFunctions() = default; + +Result IAppletCommonFunctions::GetHomeButtonDoubleClickEnabled( + Out out_home_button_double_click_enabled) { + LOG_WARNING(Service_AM, "(STUBBED) called"); + *out_home_button_double_click_enabled = false; + R_SUCCEED(); +} + +Result IAppletCommonFunctions::SetCpuBoostRequestPriority(s32 priority) { + LOG_WARNING(Service_AM, "(STUBBED) called"); + std::scoped_lock lk{applet->lock}; + applet->cpu_boost_request_priority = priority; + R_SUCCEED(); +} + +Result IAppletCommonFunctions::GetCurrentApplicationId(Out out_application_id) { + LOG_WARNING(Service_AM, "(STUBBED) called"); + *out_application_id = system.GetApplicationProcessProgramID() & ~0xFFFULL; + R_SUCCEED(); +} + +} // namespace Service::AM diff --git a/src/core/hle/service/am/service/applet_common_functions.h b/src/core/hle/service/am/service/applet_common_functions.h new file mode 100644 index 000000000..4424fc83d --- /dev/null +++ b/src/core/hle/service/am/service/applet_common_functions.h @@ -0,0 +1,26 @@ +// 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/service.h" + +namespace Service::AM { + +struct Applet; + +class IAppletCommonFunctions final : public ServiceFramework { +public: + explicit IAppletCommonFunctions(Core::System& system_, std::shared_ptr applet_); + ~IAppletCommonFunctions() override; + +private: + Result GetHomeButtonDoubleClickEnabled(Out out_home_button_double_click_enabled); + Result SetCpuBoostRequestPriority(s32 priority); + Result GetCurrentApplicationId(Out out_application_id); + + const std::shared_ptr applet; +}; + +} // namespace Service::AM diff --git a/src/core/hle/service/am/service/application_proxy.cpp b/src/core/hle/service/am/service/application_proxy.cpp index d28321a4a..b22960610 100644 --- a/src/core/hle/service/am/service/application_proxy.cpp +++ b/src/core/hle/service/am/service/application_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/applet_common_functions.h" #include "core/hle/service/am/application_functions.h" #include "core/hle/service/am/common_state_getter.h" #include "core/hle/service/am/debug_functions.h" @@ -10,6 +9,7 @@ #include "core/hle/service/am/library_applet_self_accessor.h" #include "core/hle/service/am/process_winding_controller.h" #include "core/hle/service/am/self_controller.h" +#include "core/hle/service/am/service/applet_common_functions.h" #include "core/hle/service/am/service/application_proxy.h" #include "core/hle/service/am/service/audio_controller.h" #include "core/hle/service/am/window_controller.h" diff --git a/src/core/hle/service/am/service/library_applet_proxy.cpp b/src/core/hle/service/am/service/library_applet_proxy.cpp index dd0f8ff11..c4ea9392a 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/applet_common_functions.h" #include "core/hle/service/am/common_state_getter.h" #include "core/hle/service/am/debug_functions.h" #include "core/hle/service/am/display_controller.h" @@ -11,6 +10,7 @@ #include "core/hle/service/am/library_applet_self_accessor.h" #include "core/hle/service/am/process_winding_controller.h" #include "core/hle/service/am/self_controller.h" +#include "core/hle/service/am/service/applet_common_functions.h" #include "core/hle/service/am/service/audio_controller.h" #include "core/hle/service/am/service/library_applet_proxy.h" #include "core/hle/service/am/window_controller.h" diff --git a/src/core/hle/service/am/service/system_applet_proxy.cpp b/src/core/hle/service/am/service/system_applet_proxy.cpp index cc1f83fef..c63b53ac8 100644 --- a/src/core/hle/service/am/service/system_applet_proxy.cpp +++ b/src/core/hle/service/am/service/system_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/applet_common_functions.h" #include "core/hle/service/am/application_creator.h" #include "core/hle/service/am/common_state_getter.h" #include "core/hle/service/am/debug_functions.h" @@ -12,6 +11,7 @@ #include "core/hle/service/am/library_applet_self_accessor.h" #include "core/hle/service/am/process_winding_controller.h" #include "core/hle/service/am/self_controller.h" +#include "core/hle/service/am/service/applet_common_functions.h" #include "core/hle/service/am/service/audio_controller.h" #include "core/hle/service/am/service/system_applet_proxy.h" #include "core/hle/service/am/window_controller.h" -- cgit v1.2.3