diff options
| author | 2024-02-11 19:38:23 -0500 | |
|---|---|---|
| committer | 2024-02-12 09:16:02 -0500 | |
| commit | 96fea99af952490bf8799f0775bfa307e82bbf0f (patch) | |
| tree | 74fcd45dc02c1463d3f4b0ff39262895a57a741b /src/core/hle/service/am | |
| parent | am: rewrite IApplicationFunctions (diff) | |
| download | yuzu-96fea99af952490bf8799f0775bfa307e82bbf0f.tar.gz yuzu-96fea99af952490bf8799f0775bfa307e82bbf0f.tar.xz yuzu-96fea99af952490bf8799f0775bfa307e82bbf0f.zip | |
am: rewrite ICommonStateGetter
Diffstat (limited to 'src/core/hle/service/am')
| -rw-r--r-- | src/core/hle/service/am/am_types.h | 34 | ||||
| -rw-r--r-- | src/core/hle/service/am/applet_manager.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/am/applet_message_queue.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/am/applet_message_queue.h | 35 | ||||
| -rw-r--r-- | src/core/hle/service/am/common_state_getter.cpp | 314 | ||||
| -rw-r--r-- | src/core/hle/service/am/common_state_getter.h | 77 | ||||
| -rw-r--r-- | src/core/hle/service/am/library_applet_creator.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/am/service/application_proxy.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/am/service/common_state_getter.cpp | 277 | ||||
| -rw-r--r-- | src/core/hle/service/am/service/common_state_getter.h | 61 | ||||
| -rw-r--r-- | src/core/hle/service/am/service/library_applet_proxy.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/am/service/system_applet_proxy.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/am/window_controller.cpp | 4 |
13 files changed, 383 insertions, 435 deletions
diff --git a/src/core/hle/service/am/am_types.h b/src/core/hle/service/am/am_types.h index bf2272c0e..093adcdea 100644 --- a/src/core/hle/service/am/am_types.h +++ b/src/core/hle/service/am/am_types.h | |||
| @@ -128,6 +128,40 @@ enum class AppletProgramId : u64 { | |||
| 128 | MaxProgramId = 0x0100000000001FFFull, | 128 | MaxProgramId = 0x0100000000001FFFull, |
| 129 | }; | 129 | }; |
| 130 | 130 | ||
| 131 | // This is nn::am::AppletMessage | ||
| 132 | enum class AppletMessage : u32 { | ||
| 133 | None = 0, | ||
| 134 | ChangeIntoForeground = 1, | ||
| 135 | ChangeIntoBackground = 2, | ||
| 136 | Exit = 4, | ||
| 137 | ApplicationExited = 6, | ||
| 138 | FocusStateChanged = 15, | ||
| 139 | Resume = 16, | ||
| 140 | DetectShortPressingHomeButton = 20, | ||
| 141 | DetectLongPressingHomeButton = 21, | ||
| 142 | DetectShortPressingPowerButton = 22, | ||
| 143 | DetectMiddlePressingPowerButton = 23, | ||
| 144 | DetectLongPressingPowerButton = 24, | ||
| 145 | RequestToPrepareSleep = 25, | ||
| 146 | FinishedSleepSequence = 26, | ||
| 147 | SleepRequiredByHighTemperature = 27, | ||
| 148 | SleepRequiredByLowBattery = 28, | ||
| 149 | AutoPowerDown = 29, | ||
| 150 | OperationModeChanged = 30, | ||
| 151 | PerformanceModeChanged = 31, | ||
| 152 | DetectReceivingCecSystemStandby = 32, | ||
| 153 | SdCardRemoved = 33, | ||
| 154 | LaunchApplicationRequested = 50, | ||
| 155 | RequestToDisplay = 51, | ||
| 156 | ShowApplicationLogo = 55, | ||
| 157 | HideApplicationLogo = 56, | ||
| 158 | ForceHideApplicationLogo = 57, | ||
| 159 | FloatingApplicationDetected = 60, | ||
| 160 | DetectShortPressingCaptureButton = 90, | ||
| 161 | AlbumScreenShotTaken = 92, | ||
| 162 | AlbumRecordingSaved = 93, | ||
| 163 | }; | ||
| 164 | |||
| 131 | enum class LibraryAppletMode : u32 { | 165 | enum class LibraryAppletMode : u32 { |
| 132 | AllForeground = 0, | 166 | AllForeground = 0, |
| 133 | PartialForeground = 1, | 167 | PartialForeground = 1, |
diff --git a/src/core/hle/service/am/applet_manager.cpp b/src/core/hle/service/am/applet_manager.cpp index 52200d5b2..b35d97bc7 100644 --- a/src/core/hle/service/am/applet_manager.cpp +++ b/src/core/hle/service/am/applet_manager.cpp | |||
| @@ -303,8 +303,8 @@ void AppletManager::CreateAndInsertByFrontendAppletParameters( | |||
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | // Applet was started by frontend, so it is foreground. | 305 | // Applet was started by frontend, so it is foreground. |
| 306 | applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::ChangeIntoForeground); | 306 | applet->message_queue.PushMessage(AppletMessage::ChangeIntoForeground); |
| 307 | applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged); | 307 | applet->message_queue.PushMessage(AppletMessage::FocusStateChanged); |
| 308 | applet->focus_state = FocusState::InFocus; | 308 | applet->focus_state = FocusState::InFocus; |
| 309 | 309 | ||
| 310 | this->InsertApplet(std::move(applet)); | 310 | this->InsertApplet(std::move(applet)); |
diff --git a/src/core/hle/service/am/applet_message_queue.cpp b/src/core/hle/service/am/applet_message_queue.cpp index 5ed996b70..83c3c5a55 100644 --- a/src/core/hle/service/am/applet_message_queue.cpp +++ b/src/core/hle/service/am/applet_message_queue.cpp | |||
| @@ -33,7 +33,7 @@ void AppletMessageQueue::PushMessage(AppletMessage msg) { | |||
| 33 | on_new_message->Signal(); | 33 | on_new_message->Signal(); |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | AppletMessageQueue::AppletMessage AppletMessageQueue::PopMessage() { | 36 | AppletMessage AppletMessageQueue::PopMessage() { |
| 37 | std::scoped_lock lk{lock}; | 37 | std::scoped_lock lk{lock}; |
| 38 | if (messages.empty()) { | 38 | if (messages.empty()) { |
| 39 | on_new_message->Clear(); | 39 | on_new_message->Clear(); |
diff --git a/src/core/hle/service/am/applet_message_queue.h b/src/core/hle/service/am/applet_message_queue.h index 5cb236d47..429b77d37 100644 --- a/src/core/hle/service/am/applet_message_queue.h +++ b/src/core/hle/service/am/applet_message_queue.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include <queue> | 6 | #include <queue> |
| 7 | 7 | ||
| 8 | #include "core/hle/service/am/am_types.h" | ||
| 8 | #include "core/hle/service/kernel_helpers.h" | 9 | #include "core/hle/service/kernel_helpers.h" |
| 9 | #include "core/hle/service/service.h" | 10 | #include "core/hle/service/service.h" |
| 10 | 11 | ||
| @@ -16,40 +17,6 @@ namespace Service::AM { | |||
| 16 | 17 | ||
| 17 | class AppletMessageQueue { | 18 | class AppletMessageQueue { |
| 18 | public: | 19 | public: |
| 19 | // This is nn::am::AppletMessage | ||
| 20 | enum class AppletMessage : u32 { | ||
| 21 | None = 0, | ||
| 22 | ChangeIntoForeground = 1, | ||
| 23 | ChangeIntoBackground = 2, | ||
| 24 | Exit = 4, | ||
| 25 | ApplicationExited = 6, | ||
| 26 | FocusStateChanged = 15, | ||
| 27 | Resume = 16, | ||
| 28 | DetectShortPressingHomeButton = 20, | ||
| 29 | DetectLongPressingHomeButton = 21, | ||
| 30 | DetectShortPressingPowerButton = 22, | ||
| 31 | DetectMiddlePressingPowerButton = 23, | ||
| 32 | DetectLongPressingPowerButton = 24, | ||
| 33 | RequestToPrepareSleep = 25, | ||
| 34 | FinishedSleepSequence = 26, | ||
| 35 | SleepRequiredByHighTemperature = 27, | ||
| 36 | SleepRequiredByLowBattery = 28, | ||
| 37 | AutoPowerDown = 29, | ||
| 38 | OperationModeChanged = 30, | ||
| 39 | PerformanceModeChanged = 31, | ||
| 40 | DetectReceivingCecSystemStandby = 32, | ||
| 41 | SdCardRemoved = 33, | ||
| 42 | LaunchApplicationRequested = 50, | ||
| 43 | RequestToDisplay = 51, | ||
| 44 | ShowApplicationLogo = 55, | ||
| 45 | HideApplicationLogo = 56, | ||
| 46 | ForceHideApplicationLogo = 57, | ||
| 47 | FloatingApplicationDetected = 60, | ||
| 48 | DetectShortPressingCaptureButton = 90, | ||
| 49 | AlbumScreenShotTaken = 92, | ||
| 50 | AlbumRecordingSaved = 93, | ||
| 51 | }; | ||
| 52 | |||
| 53 | explicit AppletMessageQueue(Core::System& system); | 20 | explicit AppletMessageQueue(Core::System& system); |
| 54 | ~AppletMessageQueue(); | 21 | ~AppletMessageQueue(); |
| 55 | 22 | ||
diff --git a/src/core/hle/service/am/common_state_getter.cpp b/src/core/hle/service/am/common_state_getter.cpp deleted file mode 100644 index 937ac0beb..000000000 --- a/src/core/hle/service/am/common_state_getter.cpp +++ /dev/null | |||
| @@ -1,314 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "common/settings.h" | ||
| 5 | #include "core/hle/service/am/am_results.h" | ||
| 6 | #include "core/hle/service/am/applet.h" | ||
| 7 | #include "core/hle/service/am/common_state_getter.h" | ||
| 8 | #include "core/hle/service/am/lock_accessor.h" | ||
| 9 | #include "core/hle/service/apm/apm_controller.h" | ||
| 10 | #include "core/hle/service/apm/apm_interface.h" | ||
| 11 | #include "core/hle/service/ipc_helpers.h" | ||
| 12 | #include "core/hle/service/pm/pm.h" | ||
| 13 | #include "core/hle/service/sm/sm.h" | ||
| 14 | #include "core/hle/service/vi/vi.h" | ||
| 15 | |||
| 16 | namespace Service::AM { | ||
| 17 | |||
| 18 | ICommonStateGetter::ICommonStateGetter(Core::System& system_, std::shared_ptr<Applet> applet_) | ||
| 19 | : ServiceFramework{system_, "ICommonStateGetter"}, applet{std::move(applet_)} { | ||
| 20 | // clang-format off | ||
| 21 | static const FunctionInfo functions[] = { | ||
| 22 | {0, &ICommonStateGetter::GetEventHandle, "GetEventHandle"}, | ||
| 23 | {1, &ICommonStateGetter::ReceiveMessage, "ReceiveMessage"}, | ||
| 24 | {2, nullptr, "GetThisAppletKind"}, | ||
| 25 | {3, nullptr, "AllowToEnterSleep"}, | ||
| 26 | {4, nullptr, "DisallowToEnterSleep"}, | ||
| 27 | {5, &ICommonStateGetter::GetOperationMode, "GetOperationMode"}, | ||
| 28 | {6, &ICommonStateGetter::GetPerformanceMode, "GetPerformanceMode"}, | ||
| 29 | {7, nullptr, "GetCradleStatus"}, | ||
| 30 | {8, &ICommonStateGetter::GetBootMode, "GetBootMode"}, | ||
| 31 | {9, &ICommonStateGetter::GetCurrentFocusState, "GetCurrentFocusState"}, | ||
| 32 | {10, &ICommonStateGetter::RequestToAcquireSleepLock, "RequestToAcquireSleepLock"}, | ||
| 33 | {11, nullptr, "ReleaseSleepLock"}, | ||
| 34 | {12, nullptr, "ReleaseSleepLockTransiently"}, | ||
| 35 | {13, &ICommonStateGetter::GetAcquiredSleepLockEvent, "GetAcquiredSleepLockEvent"}, | ||
| 36 | {14, nullptr, "GetWakeupCount"}, | ||
| 37 | {20, nullptr, "PushToGeneralChannel"}, | ||
| 38 | {30, nullptr, "GetHomeButtonReaderLockAccessor"}, | ||
| 39 | {31, &ICommonStateGetter::GetReaderLockAccessorEx, "GetReaderLockAccessorEx"}, | ||
| 40 | {32, nullptr, "GetWriterLockAccessorEx"}, | ||
| 41 | {40, nullptr, "GetCradleFwVersion"}, | ||
| 42 | {50, &ICommonStateGetter::IsVrModeEnabled, "IsVrModeEnabled"}, | ||
| 43 | {51, &ICommonStateGetter::SetVrModeEnabled, "SetVrModeEnabled"}, | ||
| 44 | {52, &ICommonStateGetter::SetLcdBacklighOffEnabled, "SetLcdBacklighOffEnabled"}, | ||
| 45 | {53, &ICommonStateGetter::BeginVrModeEx, "BeginVrModeEx"}, | ||
| 46 | {54, &ICommonStateGetter::EndVrModeEx, "EndVrModeEx"}, | ||
| 47 | {55, nullptr, "IsInControllerFirmwareUpdateSection"}, | ||
| 48 | {59, nullptr, "SetVrPositionForDebug"}, | ||
| 49 | {60, &ICommonStateGetter::GetDefaultDisplayResolution, "GetDefaultDisplayResolution"}, | ||
| 50 | {61, &ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent, "GetDefaultDisplayResolutionChangeEvent"}, | ||
| 51 | {62, nullptr, "GetHdcpAuthenticationState"}, | ||
| 52 | {63, nullptr, "GetHdcpAuthenticationStateChangeEvent"}, | ||
| 53 | {64, nullptr, "SetTvPowerStateMatchingMode"}, | ||
| 54 | {65, nullptr, "GetApplicationIdByContentActionName"}, | ||
| 55 | {66, &ICommonStateGetter::SetCpuBoostMode, "SetCpuBoostMode"}, | ||
| 56 | {67, nullptr, "CancelCpuBoostMode"}, | ||
| 57 | {68, &ICommonStateGetter::GetBuiltInDisplayType, "GetBuiltInDisplayType"}, | ||
| 58 | {80, &ICommonStateGetter::PerformSystemButtonPressingIfInFocus, "PerformSystemButtonPressingIfInFocus"}, | ||
| 59 | {90, nullptr, "SetPerformanceConfigurationChangedNotification"}, | ||
| 60 | {91, nullptr, "GetCurrentPerformanceConfiguration"}, | ||
| 61 | {100, nullptr, "SetHandlingHomeButtonShortPressedEnabled"}, | ||
| 62 | {110, nullptr, "OpenMyGpuErrorHandler"}, | ||
| 63 | {120, &ICommonStateGetter::GetAppletLaunchedHistory, "GetAppletLaunchedHistory"}, | ||
| 64 | {200, nullptr, "GetOperationModeSystemInfo"}, | ||
| 65 | {300, &ICommonStateGetter::GetSettingsPlatformRegion, "GetSettingsPlatformRegion"}, | ||
| 66 | {400, nullptr, "ActivateMigrationService"}, | ||
| 67 | {401, nullptr, "DeactivateMigrationService"}, | ||
| 68 | {500, nullptr, "DisableSleepTillShutdown"}, | ||
| 69 | {501, nullptr, "SuppressDisablingSleepTemporarily"}, | ||
| 70 | {502, nullptr, "IsSleepEnabled"}, | ||
| 71 | {503, nullptr, "IsDisablingSleepSuppressed"}, | ||
| 72 | {900, &ICommonStateGetter::SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled, "SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled"}, | ||
| 73 | }; | ||
| 74 | // clang-format on | ||
| 75 | |||
| 76 | RegisterHandlers(functions); | ||
| 77 | } | ||
| 78 | |||
| 79 | ICommonStateGetter::~ICommonStateGetter() = default; | ||
| 80 | |||
| 81 | void ICommonStateGetter::GetBootMode(HLERequestContext& ctx) { | ||
| 82 | LOG_DEBUG(Service_AM, "called"); | ||
| 83 | |||
| 84 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 85 | rb.Push(ResultSuccess); | ||
| 86 | rb.Push<u8>(static_cast<u8>(Service::PM::SystemBootMode::Normal)); // Normal boot mode | ||
| 87 | } | ||
| 88 | |||
| 89 | void ICommonStateGetter::GetEventHandle(HLERequestContext& ctx) { | ||
| 90 | LOG_DEBUG(Service_AM, "(STUBBED) called"); | ||
| 91 | |||
| 92 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 93 | rb.Push(ResultSuccess); | ||
| 94 | rb.PushCopyObjects(applet->message_queue.GetMessageReceiveEvent()); | ||
| 95 | } | ||
| 96 | |||
| 97 | void ICommonStateGetter::ReceiveMessage(HLERequestContext& ctx) { | ||
| 98 | LOG_DEBUG(Service_AM, "called"); | ||
| 99 | |||
| 100 | const auto message = applet->message_queue.PopMessage(); | ||
| 101 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 102 | |||
| 103 | if (message == AppletMessageQueue::AppletMessage::None) { | ||
| 104 | LOG_ERROR(Service_AM, "Message queue is empty"); | ||
| 105 | rb.Push(AM::ResultNoMessages); | ||
| 106 | rb.PushEnum<AppletMessageQueue::AppletMessage>(message); | ||
| 107 | return; | ||
| 108 | } | ||
| 109 | |||
| 110 | rb.Push(ResultSuccess); | ||
| 111 | rb.PushEnum<AppletMessageQueue::AppletMessage>(message); | ||
| 112 | } | ||
| 113 | |||
| 114 | void ICommonStateGetter::GetCurrentFocusState(HLERequestContext& ctx) { | ||
| 115 | LOG_DEBUG(Service_AM, "(STUBBED) called"); | ||
| 116 | |||
| 117 | std::scoped_lock lk{applet->lock}; | ||
| 118 | |||
| 119 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 120 | rb.Push(ResultSuccess); | ||
| 121 | rb.Push(static_cast<u8>(applet->focus_state)); | ||
| 122 | } | ||
| 123 | |||
| 124 | void ICommonStateGetter::GetOperationMode(HLERequestContext& ctx) { | ||
| 125 | const bool use_docked_mode{Settings::IsDockedMode()}; | ||
| 126 | LOG_DEBUG(Service_AM, "called, use_docked_mode={}", use_docked_mode); | ||
| 127 | |||
| 128 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 129 | rb.Push(ResultSuccess); | ||
| 130 | rb.Push(static_cast<u8>(use_docked_mode ? OperationMode::Docked : OperationMode::Handheld)); | ||
| 131 | } | ||
| 132 | |||
| 133 | void ICommonStateGetter::GetPerformanceMode(HLERequestContext& ctx) { | ||
| 134 | LOG_DEBUG(Service_AM, "called"); | ||
| 135 | |||
| 136 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 137 | rb.Push(ResultSuccess); | ||
| 138 | rb.PushEnum(system.GetAPMController().GetCurrentPerformanceMode()); | ||
| 139 | } | ||
| 140 | |||
| 141 | void ICommonStateGetter::RequestToAcquireSleepLock(HLERequestContext& ctx) { | ||
| 142 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 143 | |||
| 144 | // Sleep lock is acquired immediately. | ||
| 145 | applet->sleep_lock_event.Signal(); | ||
| 146 | |||
| 147 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 148 | rb.Push(ResultSuccess); | ||
| 149 | } | ||
| 150 | |||
| 151 | void ICommonStateGetter::GetReaderLockAccessorEx(HLERequestContext& ctx) { | ||
| 152 | IPC::RequestParser rp{ctx}; | ||
| 153 | const auto unknown = rp.Pop<u32>(); | ||
| 154 | |||
| 155 | LOG_INFO(Service_AM, "called, unknown={}", unknown); | ||
| 156 | |||
| 157 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | ||
| 158 | |||
| 159 | rb.Push(ResultSuccess); | ||
| 160 | rb.PushIpcInterface<ILockAccessor>(system); | ||
| 161 | } | ||
| 162 | |||
| 163 | void ICommonStateGetter::GetAcquiredSleepLockEvent(HLERequestContext& ctx) { | ||
| 164 | LOG_WARNING(Service_AM, "called"); | ||
| 165 | |||
| 166 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 167 | rb.Push(ResultSuccess); | ||
| 168 | rb.PushCopyObjects(applet->sleep_lock_event.GetHandle()); | ||
| 169 | } | ||
| 170 | |||
| 171 | void ICommonStateGetter::IsVrModeEnabled(HLERequestContext& ctx) { | ||
| 172 | LOG_DEBUG(Service_AM, "called"); | ||
| 173 | |||
| 174 | std::scoped_lock lk{applet->lock}; | ||
| 175 | |||
| 176 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 177 | rb.Push(ResultSuccess); | ||
| 178 | rb.Push(applet->vr_mode_enabled); | ||
| 179 | } | ||
| 180 | |||
| 181 | void ICommonStateGetter::SetVrModeEnabled(HLERequestContext& ctx) { | ||
| 182 | IPC::RequestParser rp{ctx}; | ||
| 183 | |||
| 184 | std::scoped_lock lk{applet->lock}; | ||
| 185 | applet->vr_mode_enabled = rp.Pop<bool>(); | ||
| 186 | LOG_WARNING(Service_AM, "VR Mode is {}", applet->vr_mode_enabled ? "on" : "off"); | ||
| 187 | |||
| 188 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 189 | rb.Push(ResultSuccess); | ||
| 190 | } | ||
| 191 | |||
| 192 | void ICommonStateGetter::SetLcdBacklighOffEnabled(HLERequestContext& ctx) { | ||
| 193 | IPC::RequestParser rp{ctx}; | ||
| 194 | const auto is_lcd_backlight_off_enabled = rp.Pop<bool>(); | ||
| 195 | |||
| 196 | LOG_WARNING(Service_AM, "(STUBBED) called. is_lcd_backlight_off_enabled={}", | ||
| 197 | is_lcd_backlight_off_enabled); | ||
| 198 | |||
| 199 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 200 | rb.Push(ResultSuccess); | ||
| 201 | } | ||
| 202 | |||
| 203 | void ICommonStateGetter::BeginVrModeEx(HLERequestContext& ctx) { | ||
| 204 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 205 | |||
| 206 | std::scoped_lock lk{applet->lock}; | ||
| 207 | applet->vr_mode_enabled = true; | ||
| 208 | |||
| 209 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 210 | rb.Push(ResultSuccess); | ||
| 211 | } | ||
| 212 | |||
| 213 | void ICommonStateGetter::EndVrModeEx(HLERequestContext& ctx) { | ||
| 214 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 215 | |||
| 216 | std::scoped_lock lk{applet->lock}; | ||
| 217 | applet->vr_mode_enabled = false; | ||
| 218 | |||
| 219 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 220 | rb.Push(ResultSuccess); | ||
| 221 | } | ||
| 222 | |||
| 223 | void ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent(HLERequestContext& ctx) { | ||
| 224 | LOG_DEBUG(Service_AM, "called"); | ||
| 225 | |||
| 226 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 227 | rb.Push(ResultSuccess); | ||
| 228 | rb.PushCopyObjects(applet->message_queue.GetOperationModeChangedEvent()); | ||
| 229 | } | ||
| 230 | |||
| 231 | void ICommonStateGetter::GetDefaultDisplayResolution(HLERequestContext& ctx) { | ||
| 232 | LOG_DEBUG(Service_AM, "called"); | ||
| 233 | |||
| 234 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 235 | rb.Push(ResultSuccess); | ||
| 236 | |||
| 237 | if (Settings::IsDockedMode()) { | ||
| 238 | rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedWidth)); | ||
| 239 | rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedHeight)); | ||
| 240 | } else { | ||
| 241 | rb.Push(static_cast<u32>(Service::VI::DisplayResolution::UndockedWidth)); | ||
| 242 | rb.Push(static_cast<u32>(Service::VI::DisplayResolution::UndockedHeight)); | ||
| 243 | } | ||
| 244 | } | ||
| 245 | |||
| 246 | void ICommonStateGetter::SetCpuBoostMode(HLERequestContext& ctx) { | ||
| 247 | LOG_DEBUG(Service_AM, "called, forwarding to APM:SYS"); | ||
| 248 | |||
| 249 | const auto& sm = system.ServiceManager(); | ||
| 250 | const auto apm_sys = sm.GetService<APM::APM_Sys>("apm:sys"); | ||
| 251 | ASSERT(apm_sys != nullptr); | ||
| 252 | |||
| 253 | apm_sys->SetCpuBoostMode(ctx); | ||
| 254 | } | ||
| 255 | |||
| 256 | void ICommonStateGetter::GetBuiltInDisplayType(HLERequestContext& ctx) { | ||
| 257 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 258 | |||
| 259 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 260 | rb.Push(ResultSuccess); | ||
| 261 | rb.Push(0); | ||
| 262 | } | ||
| 263 | |||
| 264 | void ICommonStateGetter::PerformSystemButtonPressingIfInFocus(HLERequestContext& ctx) { | ||
| 265 | IPC::RequestParser rp{ctx}; | ||
| 266 | const auto system_button{rp.PopEnum<SystemButtonType>()}; | ||
| 267 | |||
| 268 | LOG_WARNING(Service_AM, "(STUBBED) called, system_button={}", system_button); | ||
| 269 | |||
| 270 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 271 | rb.Push(ResultSuccess); | ||
| 272 | } | ||
| 273 | |||
| 274 | void ICommonStateGetter::GetAppletLaunchedHistory(HLERequestContext& ctx) { | ||
| 275 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 276 | |||
| 277 | std::shared_ptr<Applet> current_applet = applet; | ||
| 278 | std::vector<AppletId> result; | ||
| 279 | |||
| 280 | const size_t count = ctx.GetWriteBufferNumElements<AppletId>(); | ||
| 281 | size_t i; | ||
| 282 | |||
| 283 | for (i = 0; i < count && current_applet != nullptr; i++) { | ||
| 284 | result.push_back(current_applet->applet_id); | ||
| 285 | current_applet = current_applet->caller_applet.lock(); | ||
| 286 | } | ||
| 287 | |||
| 288 | ctx.WriteBuffer(result); | ||
| 289 | |||
| 290 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 291 | rb.Push(ResultSuccess); | ||
| 292 | rb.Push(static_cast<u32>(i)); | ||
| 293 | } | ||
| 294 | |||
| 295 | void ICommonStateGetter::GetSettingsPlatformRegion(HLERequestContext& ctx) { | ||
| 296 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 297 | |||
| 298 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 299 | rb.Push(ResultSuccess); | ||
| 300 | rb.PushEnum(SysPlatformRegion::Global); | ||
| 301 | } | ||
| 302 | |||
| 303 | void ICommonStateGetter::SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled( | ||
| 304 | HLERequestContext& ctx) { | ||
| 305 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 306 | |||
| 307 | std::scoped_lock lk{applet->lock}; | ||
| 308 | applet->request_exit_to_library_applet_at_execute_next_program_enabled = true; | ||
| 309 | |||
| 310 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 311 | rb.Push(ResultSuccess); | ||
| 312 | } | ||
| 313 | |||
| 314 | } // namespace Service::AM | ||
diff --git a/src/core/hle/service/am/common_state_getter.h b/src/core/hle/service/am/common_state_getter.h deleted file mode 100644 index bf652790c..000000000 --- a/src/core/hle/service/am/common_state_getter.h +++ /dev/null | |||
| @@ -1,77 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "core/hle/service/kernel_helpers.h" | ||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | #include "core/hle/service/am/applet_message_queue.h" | ||
| 10 | |||
| 11 | namespace Service::AM { | ||
| 12 | |||
| 13 | struct Applet; | ||
| 14 | |||
| 15 | class ICommonStateGetter final : public ServiceFramework<ICommonStateGetter> { | ||
| 16 | public: | ||
| 17 | explicit ICommonStateGetter(Core::System& system_, std::shared_ptr<Applet> applet_); | ||
| 18 | ~ICommonStateGetter() override; | ||
| 19 | |||
| 20 | private: | ||
| 21 | // This is nn::oe::FocusState | ||
| 22 | enum class FocusState : u8 { | ||
| 23 | InFocus = 1, | ||
| 24 | NotInFocus = 2, | ||
| 25 | Background = 3, | ||
| 26 | }; | ||
| 27 | |||
| 28 | // This is nn::oe::OperationMode | ||
| 29 | enum class OperationMode : u8 { | ||
| 30 | Handheld = 0, | ||
| 31 | Docked = 1, | ||
| 32 | }; | ||
| 33 | |||
| 34 | // This is nn::am::service::SystemButtonType | ||
| 35 | enum class SystemButtonType { | ||
| 36 | None, | ||
| 37 | HomeButtonShortPressing, | ||
| 38 | HomeButtonLongPressing, | ||
| 39 | PowerButtonShortPressing, | ||
| 40 | PowerButtonLongPressing, | ||
| 41 | ShutdownSystem, | ||
| 42 | CaptureButtonShortPressing, | ||
| 43 | CaptureButtonLongPressing, | ||
| 44 | }; | ||
| 45 | |||
| 46 | enum class SysPlatformRegion : s32 { | ||
| 47 | Global = 1, | ||
| 48 | Terra = 2, | ||
| 49 | }; | ||
| 50 | |||
| 51 | void GetEventHandle(HLERequestContext& ctx); | ||
| 52 | void ReceiveMessage(HLERequestContext& ctx); | ||
| 53 | void GetCurrentFocusState(HLERequestContext& ctx); | ||
| 54 | void RequestToAcquireSleepLock(HLERequestContext& ctx); | ||
| 55 | void GetAcquiredSleepLockEvent(HLERequestContext& ctx); | ||
| 56 | void GetReaderLockAccessorEx(HLERequestContext& ctx); | ||
| 57 | void GetDefaultDisplayResolutionChangeEvent(HLERequestContext& ctx); | ||
| 58 | void GetOperationMode(HLERequestContext& ctx); | ||
| 59 | void GetPerformanceMode(HLERequestContext& ctx); | ||
| 60 | void GetBootMode(HLERequestContext& ctx); | ||
| 61 | void IsVrModeEnabled(HLERequestContext& ctx); | ||
| 62 | void SetVrModeEnabled(HLERequestContext& ctx); | ||
| 63 | void SetLcdBacklighOffEnabled(HLERequestContext& ctx); | ||
| 64 | void BeginVrModeEx(HLERequestContext& ctx); | ||
| 65 | void EndVrModeEx(HLERequestContext& ctx); | ||
| 66 | void GetDefaultDisplayResolution(HLERequestContext& ctx); | ||
| 67 | void SetCpuBoostMode(HLERequestContext& ctx); | ||
| 68 | void GetBuiltInDisplayType(HLERequestContext& ctx); | ||
| 69 | void PerformSystemButtonPressingIfInFocus(HLERequestContext& ctx); | ||
| 70 | void GetAppletLaunchedHistory(HLERequestContext& ctx); | ||
| 71 | void GetSettingsPlatformRegion(HLERequestContext& ctx); | ||
| 72 | void SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled(HLERequestContext& ctx); | ||
| 73 | |||
| 74 | const std::shared_ptr<Applet> applet; | ||
| 75 | }; | ||
| 76 | |||
| 77 | } // namespace Service::AM | ||
diff --git a/src/core/hle/service/am/library_applet_creator.cpp b/src/core/hle/service/am/library_applet_creator.cpp index 00d5a0705..f7fdcb5db 100644 --- a/src/core/hle/service/am/library_applet_creator.cpp +++ b/src/core/hle/service/am/library_applet_creator.cpp | |||
| @@ -130,13 +130,13 @@ std::shared_ptr<ILibraryAppletAccessor> CreateGuestApplet(Core::System& system, | |||
| 130 | case LibraryAppletMode::PartialForegroundIndirectDisplay: | 130 | case LibraryAppletMode::PartialForegroundIndirectDisplay: |
| 131 | applet->hid_registration.EnableAppletToGetInput(true); | 131 | applet->hid_registration.EnableAppletToGetInput(true); |
| 132 | applet->focus_state = FocusState::InFocus; | 132 | applet->focus_state = FocusState::InFocus; |
| 133 | applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::ChangeIntoForeground); | 133 | applet->message_queue.PushMessage(AppletMessage::ChangeIntoForeground); |
| 134 | break; | 134 | break; |
| 135 | case LibraryAppletMode::AllForegroundInitiallyHidden: | 135 | case LibraryAppletMode::AllForegroundInitiallyHidden: |
| 136 | applet->hid_registration.EnableAppletToGetInput(false); | 136 | applet->hid_registration.EnableAppletToGetInput(false); |
| 137 | applet->focus_state = FocusState::NotInFocus; | 137 | applet->focus_state = FocusState::NotInFocus; |
| 138 | applet->system_buffer_manager.SetWindowVisibility(false); | 138 | applet->system_buffer_manager.SetWindowVisibility(false); |
| 139 | applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::ChangeIntoBackground); | 139 | applet->message_queue.PushMessage(AppletMessage::ChangeIntoBackground); |
| 140 | break; | 140 | break; |
| 141 | } | 141 | } |
| 142 | 142 | ||
diff --git a/src/core/hle/service/am/service/application_proxy.cpp b/src/core/hle/service/am/service/application_proxy.cpp index 55a4ea72f..2d46299e0 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 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/service/am/common_state_getter.h" | ||
| 5 | #include "core/hle/service/am/debug_functions.h" | 4 | #include "core/hle/service/am/debug_functions.h" |
| 6 | #include "core/hle/service/am/display_controller.h" | 5 | #include "core/hle/service/am/display_controller.h" |
| 7 | #include "core/hle/service/am/library_applet_creator.h" | 6 | #include "core/hle/service/am/library_applet_creator.h" |
| @@ -12,6 +11,7 @@ | |||
| 12 | #include "core/hle/service/am/service/application_functions.h" | 11 | #include "core/hle/service/am/service/application_functions.h" |
| 13 | #include "core/hle/service/am/service/application_proxy.h" | 12 | #include "core/hle/service/am/service/application_proxy.h" |
| 14 | #include "core/hle/service/am/service/audio_controller.h" | 13 | #include "core/hle/service/am/service/audio_controller.h" |
| 14 | #include "core/hle/service/am/service/common_state_getter.h" | ||
| 15 | #include "core/hle/service/am/window_controller.h" | 15 | #include "core/hle/service/am/window_controller.h" |
| 16 | #include "core/hle/service/cmif_serialization.h" | 16 | #include "core/hle/service/cmif_serialization.h" |
| 17 | 17 | ||
diff --git a/src/core/hle/service/am/service/common_state_getter.cpp b/src/core/hle/service/am/service/common_state_getter.cpp new file mode 100644 index 000000000..ac05b457b --- /dev/null +++ b/src/core/hle/service/am/service/common_state_getter.cpp | |||
| @@ -0,0 +1,277 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "common/settings.h" | ||
| 5 | #include "core/hle/service/am/am_results.h" | ||
| 6 | #include "core/hle/service/am/applet.h" | ||
| 7 | #include "core/hle/service/am/lock_accessor.h" | ||
| 8 | #include "core/hle/service/am/service/common_state_getter.h" | ||
| 9 | #include "core/hle/service/apm/apm_interface.h" | ||
| 10 | #include "core/hle/service/cmif_serialization.h" | ||
| 11 | #include "core/hle/service/pm/pm.h" | ||
| 12 | #include "core/hle/service/sm/sm.h" | ||
| 13 | #include "core/hle/service/vi/vi.h" | ||
| 14 | |||
| 15 | namespace Service::AM { | ||
| 16 | |||
| 17 | ICommonStateGetter::ICommonStateGetter(Core::System& system_, std::shared_ptr<Applet> applet) | ||
| 18 | : ServiceFramework{system_, "ICommonStateGetter"}, m_applet{std::move(applet)} { | ||
| 19 | // clang-format off | ||
| 20 | static const FunctionInfo functions[] = { | ||
| 21 | {0, D<&ICommonStateGetter::GetEventHandle>, "GetEventHandle"}, | ||
| 22 | {1, D<&ICommonStateGetter::ReceiveMessage>, "ReceiveMessage"}, | ||
| 23 | {2, nullptr, "GetThisAppletKind"}, | ||
| 24 | {3, nullptr, "AllowToEnterSleep"}, | ||
| 25 | {4, nullptr, "DisallowToEnterSleep"}, | ||
| 26 | {5, D<&ICommonStateGetter::GetOperationMode>, "GetOperationMode"}, | ||
| 27 | {6, D<&ICommonStateGetter::GetPerformanceMode>, "GetPerformanceMode"}, | ||
| 28 | {7, nullptr, "GetCradleStatus"}, | ||
| 29 | {8, D<&ICommonStateGetter::GetBootMode>, "GetBootMode"}, | ||
| 30 | {9, D<&ICommonStateGetter::GetCurrentFocusState>, "GetCurrentFocusState"}, | ||
| 31 | {10, D<&ICommonStateGetter::RequestToAcquireSleepLock>, "RequestToAcquireSleepLock"}, | ||
| 32 | {11, nullptr, "ReleaseSleepLock"}, | ||
| 33 | {12, nullptr, "ReleaseSleepLockTransiently"}, | ||
| 34 | {13, D<&ICommonStateGetter::GetAcquiredSleepLockEvent>, "GetAcquiredSleepLockEvent"}, | ||
| 35 | {14, nullptr, "GetWakeupCount"}, | ||
| 36 | {20, nullptr, "PushToGeneralChannel"}, | ||
| 37 | {30, nullptr, "GetHomeButtonReaderLockAccessor"}, | ||
| 38 | {31, D<&ICommonStateGetter::GetReaderLockAccessorEx>, "GetReaderLockAccessorEx"}, | ||
| 39 | {32, D<&ICommonStateGetter::GetWriterLockAccessorEx>, "GetWriterLockAccessorEx"}, | ||
| 40 | {40, nullptr, "GetCradleFwVersion"}, | ||
| 41 | {50, D<&ICommonStateGetter::IsVrModeEnabled>, "IsVrModeEnabled"}, | ||
| 42 | {51, D<&ICommonStateGetter::SetVrModeEnabled>, "SetVrModeEnabled"}, | ||
| 43 | {52, D<&ICommonStateGetter::SetLcdBacklighOffEnabled>, "SetLcdBacklighOffEnabled"}, | ||
| 44 | {53, D<&ICommonStateGetter::BeginVrModeEx>, "BeginVrModeEx"}, | ||
| 45 | {54, D<&ICommonStateGetter::EndVrModeEx>, "EndVrModeEx"}, | ||
| 46 | {55, D<&ICommonStateGetter::IsInControllerFirmwareUpdateSection>, "IsInControllerFirmwareUpdateSection"}, | ||
| 47 | {59, nullptr, "SetVrPositionForDebug"}, | ||
| 48 | {60, D<&ICommonStateGetter::GetDefaultDisplayResolution>, "GetDefaultDisplayResolution"}, | ||
| 49 | {61, D<&ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent>, "GetDefaultDisplayResolutionChangeEvent"}, | ||
| 50 | {62, nullptr, "GetHdcpAuthenticationState"}, | ||
| 51 | {63, nullptr, "GetHdcpAuthenticationStateChangeEvent"}, | ||
| 52 | {64, nullptr, "SetTvPowerStateMatchingMode"}, | ||
| 53 | {65, nullptr, "GetApplicationIdByContentActionName"}, | ||
| 54 | {66, &ICommonStateGetter::SetCpuBoostMode, "SetCpuBoostMode"}, | ||
| 55 | {67, nullptr, "CancelCpuBoostMode"}, | ||
| 56 | {68, D<&ICommonStateGetter::GetBuiltInDisplayType>, "GetBuiltInDisplayType"}, | ||
| 57 | {80, D<&ICommonStateGetter::PerformSystemButtonPressingIfInFocus>, "PerformSystemButtonPressingIfInFocus"}, | ||
| 58 | {90, nullptr, "SetPerformanceConfigurationChangedNotification"}, | ||
| 59 | {91, nullptr, "GetCurrentPerformanceConfiguration"}, | ||
| 60 | {100, nullptr, "SetHandlingHomeButtonShortPressedEnabled"}, | ||
| 61 | {110, nullptr, "OpenMyGpuErrorHandler"}, | ||
| 62 | {120, D<&ICommonStateGetter::GetAppletLaunchedHistory>, "GetAppletLaunchedHistory"}, | ||
| 63 | {200, D<&ICommonStateGetter::GetOperationModeSystemInfo>, "GetOperationModeSystemInfo"}, | ||
| 64 | {300, D<&ICommonStateGetter::GetSettingsPlatformRegion>, "GetSettingsPlatformRegion"}, | ||
| 65 | {400, nullptr, "ActivateMigrationService"}, | ||
| 66 | {401, nullptr, "DeactivateMigrationService"}, | ||
| 67 | {500, nullptr, "DisableSleepTillShutdown"}, | ||
| 68 | {501, nullptr, "SuppressDisablingSleepTemporarily"}, | ||
| 69 | {502, nullptr, "IsSleepEnabled"}, | ||
| 70 | {503, nullptr, "IsDisablingSleepSuppressed"}, | ||
| 71 | {900, D<&ICommonStateGetter::SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled>, "SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled"}, | ||
| 72 | }; | ||
| 73 | // clang-format on | ||
| 74 | |||
| 75 | RegisterHandlers(functions); | ||
| 76 | } | ||
| 77 | |||
| 78 | ICommonStateGetter::~ICommonStateGetter() = default; | ||
| 79 | |||
| 80 | Result ICommonStateGetter::GetEventHandle(OutCopyHandle<Kernel::KReadableEvent> out_event) { | ||
| 81 | LOG_DEBUG(Service_AM, "called"); | ||
| 82 | *out_event = &m_applet->message_queue.GetMessageReceiveEvent(); | ||
| 83 | R_SUCCEED(); | ||
| 84 | } | ||
| 85 | |||
| 86 | Result ICommonStateGetter::ReceiveMessage(Out<AppletMessage> out_applet_message) { | ||
| 87 | LOG_DEBUG(Service_AM, "called"); | ||
| 88 | |||
| 89 | *out_applet_message = m_applet->message_queue.PopMessage(); | ||
| 90 | if (*out_applet_message == AppletMessage::None) { | ||
| 91 | LOG_ERROR(Service_AM, "Tried to pop message but none was available!"); | ||
| 92 | R_THROW(AM::ResultNoMessages); | ||
| 93 | } | ||
| 94 | |||
| 95 | R_SUCCEED(); | ||
| 96 | } | ||
| 97 | |||
| 98 | Result ICommonStateGetter::GetCurrentFocusState(Out<FocusState> out_focus_state) { | ||
| 99 | LOG_DEBUG(Service_AM, "called"); | ||
| 100 | |||
| 101 | std::scoped_lock lk{m_applet->lock}; | ||
| 102 | *out_focus_state = m_applet->focus_state; | ||
| 103 | |||
| 104 | R_SUCCEED(); | ||
| 105 | } | ||
| 106 | |||
| 107 | Result ICommonStateGetter::RequestToAcquireSleepLock() { | ||
| 108 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 109 | |||
| 110 | // Sleep lock is acquired immediately. | ||
| 111 | m_applet->sleep_lock_event.Signal(); | ||
| 112 | R_SUCCEED(); | ||
| 113 | } | ||
| 114 | |||
| 115 | Result ICommonStateGetter::GetAcquiredSleepLockEvent( | ||
| 116 | OutCopyHandle<Kernel::KReadableEvent> out_event) { | ||
| 117 | LOG_WARNING(Service_AM, "called"); | ||
| 118 | *out_event = m_applet->sleep_lock_event.GetHandle(); | ||
| 119 | R_SUCCEED(); | ||
| 120 | } | ||
| 121 | |||
| 122 | Result ICommonStateGetter::GetReaderLockAccessorEx( | ||
| 123 | Out<SharedPointer<ILockAccessor>> out_lock_accessor, u32 button_type) { | ||
| 124 | LOG_INFO(Service_AM, "called, button_type={}", button_type); | ||
| 125 | *out_lock_accessor = std::make_shared<ILockAccessor>(system); | ||
| 126 | R_SUCCEED(); | ||
| 127 | } | ||
| 128 | |||
| 129 | Result ICommonStateGetter::GetWriterLockAccessorEx( | ||
| 130 | Out<SharedPointer<ILockAccessor>> out_lock_accessor, u32 button_type) { | ||
| 131 | LOG_INFO(Service_AM, "called, button_type={}", button_type); | ||
| 132 | *out_lock_accessor = std::make_shared<ILockAccessor>(system); | ||
| 133 | R_SUCCEED(); | ||
| 134 | } | ||
| 135 | |||
| 136 | Result ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent( | ||
| 137 | OutCopyHandle<Kernel::KReadableEvent> out_event) { | ||
| 138 | LOG_DEBUG(Service_AM, "called"); | ||
| 139 | *out_event = &m_applet->message_queue.GetOperationModeChangedEvent(); | ||
| 140 | R_SUCCEED(); | ||
| 141 | } | ||
| 142 | |||
| 143 | Result ICommonStateGetter::GetOperationMode(Out<OperationMode> out_operation_mode) { | ||
| 144 | const bool use_docked_mode{Settings::IsDockedMode()}; | ||
| 145 | LOG_DEBUG(Service_AM, "called, use_docked_mode={}", use_docked_mode); | ||
| 146 | *out_operation_mode = use_docked_mode ? OperationMode::Docked : OperationMode::Handheld; | ||
| 147 | R_SUCCEED(); | ||
| 148 | } | ||
| 149 | |||
| 150 | Result ICommonStateGetter::GetPerformanceMode(Out<APM::PerformanceMode> out_performance_mode) { | ||
| 151 | LOG_DEBUG(Service_AM, "called"); | ||
| 152 | *out_performance_mode = system.GetAPMController().GetCurrentPerformanceMode(); | ||
| 153 | R_SUCCEED(); | ||
| 154 | } | ||
| 155 | |||
| 156 | Result ICommonStateGetter::GetBootMode(Out<PM::SystemBootMode> out_boot_mode) { | ||
| 157 | LOG_DEBUG(Service_AM, "called"); | ||
| 158 | *out_boot_mode = Service::PM::SystemBootMode::Normal; | ||
| 159 | R_SUCCEED(); | ||
| 160 | } | ||
| 161 | |||
| 162 | Result ICommonStateGetter::IsVrModeEnabled(Out<bool> out_is_vr_mode_enabled) { | ||
| 163 | LOG_DEBUG(Service_AM, "called"); | ||
| 164 | |||
| 165 | std::scoped_lock lk{m_applet->lock}; | ||
| 166 | *out_is_vr_mode_enabled = m_applet->vr_mode_enabled; | ||
| 167 | R_SUCCEED(); | ||
| 168 | } | ||
| 169 | |||
| 170 | Result ICommonStateGetter::SetVrModeEnabled(bool is_vr_mode_enabled) { | ||
| 171 | std::scoped_lock lk{m_applet->lock}; | ||
| 172 | m_applet->vr_mode_enabled = is_vr_mode_enabled; | ||
| 173 | LOG_WARNING(Service_AM, "VR Mode is {}", m_applet->vr_mode_enabled ? "on" : "off"); | ||
| 174 | R_SUCCEED(); | ||
| 175 | } | ||
| 176 | |||
| 177 | Result ICommonStateGetter::SetLcdBacklighOffEnabled(bool is_lcd_backlight_off_enabled) { | ||
| 178 | LOG_WARNING(Service_AM, "(STUBBED) called. is_lcd_backlight_off_enabled={}", | ||
| 179 | is_lcd_backlight_off_enabled); | ||
| 180 | R_SUCCEED(); | ||
| 181 | } | ||
| 182 | |||
| 183 | Result ICommonStateGetter::BeginVrModeEx() { | ||
| 184 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 185 | std::scoped_lock lk{m_applet->lock}; | ||
| 186 | m_applet->vr_mode_enabled = true; | ||
| 187 | R_SUCCEED(); | ||
| 188 | } | ||
| 189 | |||
| 190 | Result ICommonStateGetter::EndVrModeEx() { | ||
| 191 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 192 | std::scoped_lock lk{m_applet->lock}; | ||
| 193 | m_applet->vr_mode_enabled = false; | ||
| 194 | R_SUCCEED(); | ||
| 195 | } | ||
| 196 | |||
| 197 | Result ICommonStateGetter::IsInControllerFirmwareUpdateSection( | ||
| 198 | Out<bool> out_is_in_controller_firmware_update_section) { | ||
| 199 | LOG_INFO(Service_AM, "called"); | ||
| 200 | *out_is_in_controller_firmware_update_section = false; | ||
| 201 | R_SUCCEED(); | ||
| 202 | } | ||
| 203 | |||
| 204 | Result ICommonStateGetter::GetDefaultDisplayResolution(Out<s32> out_width, Out<s32> out_height) { | ||
| 205 | LOG_DEBUG(Service_AM, "called"); | ||
| 206 | |||
| 207 | if (Settings::IsDockedMode()) { | ||
| 208 | *out_width = static_cast<u32>(Service::VI::DisplayResolution::DockedWidth); | ||
| 209 | *out_height = static_cast<u32>(Service::VI::DisplayResolution::DockedHeight); | ||
| 210 | } else { | ||
| 211 | *out_width = static_cast<u32>(Service::VI::DisplayResolution::UndockedWidth); | ||
| 212 | *out_height = static_cast<u32>(Service::VI::DisplayResolution::UndockedHeight); | ||
| 213 | } | ||
| 214 | |||
| 215 | R_SUCCEED(); | ||
| 216 | } | ||
| 217 | |||
| 218 | void ICommonStateGetter::SetCpuBoostMode(HLERequestContext& ctx) { | ||
| 219 | LOG_DEBUG(Service_AM, "called, forwarding to APM:SYS"); | ||
| 220 | |||
| 221 | const auto& sm = system.ServiceManager(); | ||
| 222 | const auto apm_sys = sm.GetService<APM::APM_Sys>("apm:sys"); | ||
| 223 | ASSERT(apm_sys != nullptr); | ||
| 224 | |||
| 225 | apm_sys->SetCpuBoostMode(ctx); | ||
| 226 | } | ||
| 227 | |||
| 228 | Result ICommonStateGetter::GetBuiltInDisplayType(Out<s32> out_display_type) { | ||
| 229 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 230 | *out_display_type = 0; | ||
| 231 | R_SUCCEED(); | ||
| 232 | } | ||
| 233 | |||
| 234 | Result ICommonStateGetter::PerformSystemButtonPressingIfInFocus(SystemButtonType type) { | ||
| 235 | LOG_WARNING(Service_AM, "(STUBBED) called, type={}", type); | ||
| 236 | R_SUCCEED(); | ||
| 237 | } | ||
| 238 | |||
| 239 | Result ICommonStateGetter::GetOperationModeSystemInfo(Out<u32> out_operation_mode_system_info) { | ||
| 240 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 241 | *out_operation_mode_system_info = 0; | ||
| 242 | R_SUCCEED(); | ||
| 243 | } | ||
| 244 | |||
| 245 | Result ICommonStateGetter::GetAppletLaunchedHistory( | ||
| 246 | Out<s32> out_count, OutArray<AppletId, BufferAttr_HipcMapAlias> out_applet_ids) { | ||
| 247 | LOG_INFO(Service_AM, "called"); | ||
| 248 | |||
| 249 | std::shared_ptr<Applet> current_applet = m_applet; | ||
| 250 | |||
| 251 | for (*out_count = 0; | ||
| 252 | *out_count < static_cast<s32>(out_applet_ids.size()) && current_applet != nullptr; | ||
| 253 | /* ... */) { | ||
| 254 | out_applet_ids[(*out_count)++] = current_applet->applet_id; | ||
| 255 | current_applet = current_applet->caller_applet.lock(); | ||
| 256 | } | ||
| 257 | |||
| 258 | R_SUCCEED(); | ||
| 259 | } | ||
| 260 | |||
| 261 | Result ICommonStateGetter::GetSettingsPlatformRegion( | ||
| 262 | Out<SysPlatformRegion> out_settings_platform_region) { | ||
| 263 | LOG_INFO(Service_AM, "called"); | ||
| 264 | *out_settings_platform_region = SysPlatformRegion::Global; | ||
| 265 | R_SUCCEED(); | ||
| 266 | } | ||
| 267 | |||
| 268 | Result ICommonStateGetter::SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled() { | ||
| 269 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 270 | |||
| 271 | std::scoped_lock lk{m_applet->lock}; | ||
| 272 | m_applet->request_exit_to_library_applet_at_execute_next_program_enabled = true; | ||
| 273 | |||
| 274 | R_SUCCEED(); | ||
| 275 | } | ||
| 276 | |||
| 277 | } // 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 new file mode 100644 index 000000000..5a8dca3d6 --- /dev/null +++ b/src/core/hle/service/am/service/common_state_getter.h | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "core/hle/service/am/am_types.h" | ||
| 7 | #include "core/hle/service/apm/apm_controller.h" | ||
| 8 | #include "core/hle/service/cmif_types.h" | ||
| 9 | #include "core/hle/service/pm/pm.h" | ||
| 10 | #include "core/hle/service/service.h" | ||
| 11 | |||
| 12 | namespace Kernel { | ||
| 13 | class KReadableEvent; | ||
| 14 | } | ||
| 15 | |||
| 16 | namespace Service::AM { | ||
| 17 | |||
| 18 | struct Applet; | ||
| 19 | class ILockAccessor; | ||
| 20 | |||
| 21 | class ICommonStateGetter final : public ServiceFramework<ICommonStateGetter> { | ||
| 22 | public: | ||
| 23 | explicit ICommonStateGetter(Core::System& system_, std::shared_ptr<Applet> applet_); | ||
| 24 | ~ICommonStateGetter() override; | ||
| 25 | |||
| 26 | private: | ||
| 27 | Result GetEventHandle(OutCopyHandle<Kernel::KReadableEvent> out_event); | ||
| 28 | Result ReceiveMessage(Out<AppletMessage> out_applet_message); | ||
| 29 | Result GetCurrentFocusState(Out<FocusState> out_focus_state); | ||
| 30 | Result RequestToAcquireSleepLock(); | ||
| 31 | Result GetAcquiredSleepLockEvent(OutCopyHandle<Kernel::KReadableEvent> out_event); | ||
| 32 | Result GetReaderLockAccessorEx(Out<SharedPointer<ILockAccessor>> out_lock_accessor, | ||
| 33 | u32 button_type); | ||
| 34 | Result GetWriterLockAccessorEx(Out<SharedPointer<ILockAccessor>> out_lock_accessor, | ||
| 35 | u32 button_type); | ||
| 36 | Result GetDefaultDisplayResolutionChangeEvent(OutCopyHandle<Kernel::KReadableEvent> out_event); | ||
| 37 | Result GetOperationMode(Out<OperationMode> out_operation_mode); | ||
| 38 | Result GetPerformanceMode(Out<APM::PerformanceMode> out_performance_mode); | ||
| 39 | Result GetBootMode(Out<PM::SystemBootMode> out_boot_mode); | ||
| 40 | Result IsVrModeEnabled(Out<bool> out_is_vr_mode_enabled); | ||
| 41 | Result SetVrModeEnabled(bool is_vr_mode_enabled); | ||
| 42 | Result SetLcdBacklighOffEnabled(bool is_lcd_backlight_off_enabled); | ||
| 43 | Result BeginVrModeEx(); | ||
| 44 | Result EndVrModeEx(); | ||
| 45 | Result IsInControllerFirmwareUpdateSection( | ||
| 46 | Out<bool> out_is_in_controller_firmware_update_section); | ||
| 47 | Result GetDefaultDisplayResolution(Out<s32> out_width, Out<s32> out_height); | ||
| 48 | Result GetBuiltInDisplayType(Out<s32> out_display_type); | ||
| 49 | Result PerformSystemButtonPressingIfInFocus(SystemButtonType type); | ||
| 50 | Result GetOperationModeSystemInfo(Out<u32> out_operation_mode_system_info); | ||
| 51 | Result GetAppletLaunchedHistory(Out<s32> out_count, | ||
| 52 | OutArray<AppletId, BufferAttr_HipcMapAlias> out_applet_ids); | ||
| 53 | Result GetSettingsPlatformRegion(Out<SysPlatformRegion> out_settings_platform_region); | ||
| 54 | Result SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled(); | ||
| 55 | |||
| 56 | void SetCpuBoostMode(HLERequestContext& ctx); | ||
| 57 | |||
| 58 | const std::shared_ptr<Applet> m_applet; | ||
| 59 | }; | ||
| 60 | |||
| 61 | } // namespace Service::AM | ||
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 c4ea9392a..28886b0c3 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 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/service/am/common_state_getter.h" | ||
| 5 | #include "core/hle/service/am/debug_functions.h" | 4 | #include "core/hle/service/am/debug_functions.h" |
| 6 | #include "core/hle/service/am/display_controller.h" | 5 | #include "core/hle/service/am/display_controller.h" |
| 7 | #include "core/hle/service/am/global_state_controller.h" | 6 | #include "core/hle/service/am/global_state_controller.h" |
| @@ -12,6 +11,7 @@ | |||
| 12 | #include "core/hle/service/am/self_controller.h" | 11 | #include "core/hle/service/am/self_controller.h" |
| 13 | #include "core/hle/service/am/service/applet_common_functions.h" | 12 | #include "core/hle/service/am/service/applet_common_functions.h" |
| 14 | #include "core/hle/service/am/service/audio_controller.h" | 13 | #include "core/hle/service/am/service/audio_controller.h" |
| 14 | #include "core/hle/service/am/service/common_state_getter.h" | ||
| 15 | #include "core/hle/service/am/service/library_applet_proxy.h" | 15 | #include "core/hle/service/am/service/library_applet_proxy.h" |
| 16 | #include "core/hle/service/am/window_controller.h" | 16 | #include "core/hle/service/am/window_controller.h" |
| 17 | #include "core/hle/service/cmif_serialization.h" | 17 | #include "core/hle/service/cmif_serialization.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 c63b53ac8..ea23bef94 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 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/service/am/application_creator.h" | 4 | #include "core/hle/service/am/application_creator.h" |
| 5 | #include "core/hle/service/am/common_state_getter.h" | ||
| 6 | #include "core/hle/service/am/debug_functions.h" | 5 | #include "core/hle/service/am/debug_functions.h" |
| 7 | #include "core/hle/service/am/display_controller.h" | 6 | #include "core/hle/service/am/display_controller.h" |
| 8 | #include "core/hle/service/am/global_state_controller.h" | 7 | #include "core/hle/service/am/global_state_controller.h" |
| @@ -13,6 +12,7 @@ | |||
| 13 | #include "core/hle/service/am/self_controller.h" | 12 | #include "core/hle/service/am/self_controller.h" |
| 14 | #include "core/hle/service/am/service/applet_common_functions.h" | 13 | #include "core/hle/service/am/service/applet_common_functions.h" |
| 15 | #include "core/hle/service/am/service/audio_controller.h" | 14 | #include "core/hle/service/am/service/audio_controller.h" |
| 15 | #include "core/hle/service/am/service/common_state_getter.h" | ||
| 16 | #include "core/hle/service/am/service/system_applet_proxy.h" | 16 | #include "core/hle/service/am/service/system_applet_proxy.h" |
| 17 | #include "core/hle/service/am/window_controller.h" | 17 | #include "core/hle/service/am/window_controller.h" |
| 18 | #include "core/hle/service/cmif_serialization.h" | 18 | #include "core/hle/service/cmif_serialization.h" |
diff --git a/src/core/hle/service/am/window_controller.cpp b/src/core/hle/service/am/window_controller.cpp index c07ef228b..7347fe9d9 100644 --- a/src/core/hle/service/am/window_controller.cpp +++ b/src/core/hle/service/am/window_controller.cpp | |||
| @@ -63,10 +63,10 @@ void IWindowController::SetAppletWindowVisibility(HLERequestContext& ctx) { | |||
| 63 | 63 | ||
| 64 | if (visible) { | 64 | if (visible) { |
| 65 | applet->focus_state = FocusState::InFocus; | 65 | applet->focus_state = FocusState::InFocus; |
| 66 | applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::ChangeIntoForeground); | 66 | applet->message_queue.PushMessage(AppletMessage::ChangeIntoForeground); |
| 67 | } else { | 67 | } else { |
| 68 | applet->focus_state = FocusState::NotInFocus; | 68 | applet->focus_state = FocusState::NotInFocus; |
| 69 | applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::ChangeIntoBackground); | 69 | applet->message_queue.PushMessage(AppletMessage::ChangeIntoBackground); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | IPC::ResponseBuilder rb{ctx, 2}; | 72 | IPC::ResponseBuilder rb{ctx, 2}; |