From 53fc6bf10766fe9773556d5e4acd84f3df6af451 Mon Sep 17 00:00:00 2001 From: Zephyron Date: Wed, 28 Jan 2026 16:41:21 +1000 Subject: [PATCH] feat(hle/am): add event handling for state controllers - Implement GetGpuErrorDetectedSystemEvent (cmd 1020) - Implement GetFriendInvitationStorageChannelEvent (cmd 1030) - Implement GetNotificationStorageChannelEvent (cmd 1040) - Implement GetHealthWarningDisappearedSystemEvent (cmd 1050) - Implement GetAccumulatedSuspendedTickChangedEvent (cmd 63) --- .../am/service/common_state_getter.cpp | 38 ++++++++++++++++--- .../service/am/service/common_state_getter.h | 4 ++ .../am/service/global_state_controller.cpp | 14 +++++-- .../am/service/global_state_controller.h | 4 +- 4 files changed, 51 insertions(+), 9 deletions(-) diff --git a/src/core/hle/service/am/service/common_state_getter.cpp b/src/core/hle/service/am/service/common_state_getter.cpp index c8efa6bf8..f48692bad 100644 --- a/src/core/hle/service/am/service/common_state_getter.cpp +++ b/src/core/hle/service/am/service/common_state_getter.cpp @@ -1,5 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include "common/settings.h" @@ -82,13 +82,13 @@ ICommonStateGetter::ICommonStateGetter(Core::System& system_, std::shared_ptr, "GetGpuErrorDetectedSystemEvent"}, {1021, nullptr, "SetDelayTimeToAbortOnGpuError"}, - {1030, nullptr, "GetFriendInvitationStorageChannelEvent"}, + {1030, D<&ICommonStateGetter::GetFriendInvitationStorageChannelEvent>, "GetFriendInvitationStorageChannelEvent"}, {1031, nullptr, "TryPopFromFriendInvitationStorageChannel"}, - {1040, nullptr, "GetNotificationStorageChannelEvent"}, + {1040, D<&ICommonStateGetter::GetNotificationStorageChannelEvent>, "GetNotificationStorageChannelEvent"}, {1041, nullptr, "TryPopFromNotificationStorageChannel"}, - {1050, nullptr, "GetHealthWarningDisappearedSystemEvent"}, + {1050, D<&ICommonStateGetter::GetHealthWarningDisappearedSystemEvent>, "GetHealthWarningDisappearedSystemEvent"}, {1060, nullptr, "SetHdcpAuthenticationActivated"}, {1061, nullptr, "GetLastForegroundCaptureImageEx"}, {1062, nullptr, "GetLastApplicationCaptureImageEx"}, @@ -297,4 +297,32 @@ Result ICommonStateGetter::SetRequestExitToLibraryAppletAtExecuteNextProgramEnab R_SUCCEED(); } +Result ICommonStateGetter::GetGpuErrorDetectedSystemEvent( + OutCopyHandle out_event) { + LOG_DEBUG(Service_AM, "called"); + *out_event = m_applet->gpu_error_detected_event.GetHandle(); + R_SUCCEED(); +} + +Result ICommonStateGetter::GetFriendInvitationStorageChannelEvent( + OutCopyHandle out_event) { + LOG_DEBUG(Service_AM, "called"); + *out_event = m_applet->friend_invitation_storage_channel_event.GetHandle(); + R_SUCCEED(); +} + +Result ICommonStateGetter::GetNotificationStorageChannelEvent( + OutCopyHandle out_event) { + LOG_DEBUG(Service_AM, "called"); + *out_event = m_applet->notification_storage_channel_event.GetHandle(); + R_SUCCEED(); +} + +Result ICommonStateGetter::GetHealthWarningDisappearedSystemEvent( + OutCopyHandle out_event) { + LOG_DEBUG(Service_AM, "called"); + *out_event = m_applet->health_warning_disappeared_system_event.GetHandle(); + R_SUCCEED(); +} + } // namespace Service::AM diff --git a/src/core/hle/service/am/service/common_state_getter.h b/src/core/hle/service/am/service/common_state_getter.h index 59a46fa94..255884c3a 100644 --- a/src/core/hle/service/am/service/common_state_getter.h +++ b/src/core/hle/service/am/service/common_state_getter.h @@ -53,6 +53,10 @@ private: OutArray out_applet_ids); Result GetSettingsPlatformRegion(Out out_settings_platform_region); Result SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled(); + Result GetGpuErrorDetectedSystemEvent(OutCopyHandle out_event); + Result GetFriendInvitationStorageChannelEvent(OutCopyHandle out_event); + Result GetNotificationStorageChannelEvent(OutCopyHandle out_event); + Result GetHealthWarningDisappearedSystemEvent(OutCopyHandle out_event); void SetCpuBoostMode(HLERequestContext& ctx); 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 1894aa6d0..98c012146 100644 --- a/src/core/hle/service/am/service/global_state_controller.cpp +++ b/src/core/hle/service/am/service/global_state_controller.cpp @@ -1,5 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include "core/hle/service/am/service/cradle_firmware_updater.h" @@ -10,7 +10,8 @@ namespace Service::AM { IGlobalStateController::IGlobalStateController(Core::System& system_) : ServiceFramework{system_, "IGlobalStateController"}, - m_context{system_, "IGlobalStateController"}, m_hdcp_authentication_failed_event{m_context} { + m_context{system_, "IGlobalStateController"}, m_hdcp_authentication_failed_event{m_context}, + m_accumulated_suspended_tick_changed_event{m_context} { // clang-format off static const FunctionInfo functions[] = { {0, D<&IGlobalStateController::RequestToEnterSleep>, "RequestToEnterSleep"}, @@ -35,7 +36,7 @@ IGlobalStateController::IGlobalStateController(Core::System& system_) {60, nullptr, "SetWirelessPriorityMode"}, {61, nullptr, "GetWirelessPriorityMode"}, {62, nullptr, "GetAccumulatedSuspendedTickValue"}, - {63, nullptr, "GetAccumulatedSuspendedTickChangedEvent"}, + {63, D<&IGlobalStateController::GetAccumulatedSuspendedTickChangedEvent>, "GetAccumulatedSuspendedTickChangedEvent"}, {64, nullptr, "SetAlarmTimeChangeEvent"}, {65, nullptr, "GetWakeupCount"}, {66, nullptr, "GetHomeButtonInputProtectionStartTime"}, @@ -130,4 +131,11 @@ Result IGlobalStateController::UpdateDefaultDisplayResolution() { R_SUCCEED(); } +Result IGlobalStateController::GetAccumulatedSuspendedTickChangedEvent( + OutCopyHandle out_event) { + LOG_DEBUG(Service_AM, "called"); + *out_event = m_accumulated_suspended_tick_changed_event.GetHandle(); + R_SUCCEED(); +} + } // namespace Service::AM 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 49891cc36..f11dc9ce3 100644 --- a/src/core/hle/service/am/service/global_state_controller.h +++ b/src/core/hle/service/am/service/global_state_controller.h @@ -1,5 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once @@ -33,9 +33,11 @@ private: Result GetHdcpAuthenticationFailedEvent(OutCopyHandle out_event); Result OpenCradleFirmwareUpdater( Out> out_cradle_firmware_updater); + Result GetAccumulatedSuspendedTickChangedEvent(OutCopyHandle out_event); KernelHelpers::ServiceContext m_context; Event m_hdcp_authentication_failed_event; + Event m_accumulated_suspended_tick_changed_event; }; } // namespace Service::AM