diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 2d5490968..c2882784a 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -439,6 +439,8 @@ add_library(core STATIC hle/service/am/audio_controller.h hle/service/am/common_state_getter.cpp hle/service/am/common_state_getter.h + hle/service/am/cradle_firmware_updater.cpp + hle/service/am/cradle_firmware_updater.h hle/service/am/debug_functions.cpp hle/service/am/debug_functions.h hle/service/am/display_controller.cpp diff --git a/src/core/hle/service/am/applet_manager.cpp b/src/core/hle/service/am/applet_manager.cpp index 52200d5b2..f6640e835 100644 --- a/src/core/hle/service/am/applet_manager.cpp +++ b/src/core/hle/service/am/applet_manager.cpp @@ -206,6 +206,41 @@ void PushInShowSoftwareKeyboard(Core::System& system, AppletStorageChannel& chan channel.Push(std::make_shared(system, std::move(work_buffer))); } +void PushInShowMyPageData(Core::System& system, AppletStorageChannel& channel) { + const CommonArguments arguments{ + .arguments_version = CommonArgumentVersion::Version3, + .size = CommonArgumentSize::Version3, + .library_version = 0, + .theme_color = ThemeColor::BasicBlack, + .play_startup_sound = true, + .system_tick = system.CoreTiming().GetClockTicks(), + }; + + std::vector argument_data(sizeof(arguments)); + std::vector settings_data{0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCE, + 0x9E, 0xF8, 0xAF, 0xB1, 0xE8, 0x95, 0x90, 0x33, 0x6C, + 0x0B, 0x22, 0x70, 0x07, 0xF4, 0xBB, 0x00}; + settings_data.resize(0x10a8); + std::memcpy(argument_data.data(), &arguments, sizeof(arguments)); + + channel.Push(std::make_shared(system, std::move(argument_data))); + channel.Push(std::make_shared(system, std::move(settings_data))); +} +void PushInShowQlaunch(Core::System& system, AppletStorageChannel& channel) { + const CommonArguments arguments{ + .arguments_version = CommonArgumentVersion::Version3, + .size = CommonArgumentSize::Version3, + .library_version = 0, + .theme_color = ThemeColor::BasicBlack, + .play_startup_sound = true, + .system_tick = system.CoreTiming().GetClockTicks(), + }; + + std::vector argument_data(sizeof(arguments)); + std::memcpy(argument_data.data(), &arguments, sizeof(arguments)); + channel.Push(std::make_shared(system, std::move(argument_data))); +} + } // namespace AppletManager::AppletManager(Core::System& system) : m_system(system) {} @@ -298,6 +333,12 @@ void AppletManager::CreateAndInsertByFrontendAppletParameters( case AppletId::Controller: PushInShowController(m_system, InitializeFakeCallerApplet(m_system, applet)); break; + case AppletId::MyPage: + PushInShowMyPageData(m_system, InitializeFakeCallerApplet(m_system, applet)); + break; + case AppletId::QLaunch: + PushInShowQlaunch(m_system, InitializeFakeCallerApplet(m_system, applet)); + break; default: break; } diff --git a/src/core/hle/service/am/common_state_getter.cpp b/src/core/hle/service/am/common_state_getter.cpp index 937ac0beb..510510b71 100644 --- a/src/core/hle/service/am/common_state_getter.cpp +++ b/src/core/hle/service/am/common_state_getter.cpp @@ -37,7 +37,7 @@ ICommonStateGetter::ICommonStateGetter(Core::System& system_, std::shared_ptr(system); } +void ICommonStateGetter::GetWriterLockAccessorEx(HLERequestContext& ctx) { + LOG_DEBUG(Service_AM, "called"); + + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + + rb.Push(ResultSuccess); + rb.PushIpcInterface(system); +} + void ICommonStateGetter::GetAcquiredSleepLockEvent(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "called"); @@ -271,6 +280,14 @@ void ICommonStateGetter::PerformSystemButtonPressingIfInFocus(HLERequestContext& rb.Push(ResultSuccess); } +void ICommonStateGetter::GetOperationModeSystemInfo(HLERequestContext& ctx) { + LOG_WARNING(Service_AM, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(0); +} + void ICommonStateGetter::GetAppletLaunchedHistory(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); diff --git a/src/core/hle/service/am/common_state_getter.h b/src/core/hle/service/am/common_state_getter.h index bf652790c..483dfa2f5 100644 --- a/src/core/hle/service/am/common_state_getter.h +++ b/src/core/hle/service/am/common_state_getter.h @@ -54,6 +54,7 @@ private: void RequestToAcquireSleepLock(HLERequestContext& ctx); void GetAcquiredSleepLockEvent(HLERequestContext& ctx); void GetReaderLockAccessorEx(HLERequestContext& ctx); + void GetWriterLockAccessorEx(HLERequestContext& ctx); void GetDefaultDisplayResolutionChangeEvent(HLERequestContext& ctx); void GetOperationMode(HLERequestContext& ctx); void GetPerformanceMode(HLERequestContext& ctx); @@ -68,6 +69,7 @@ private: void GetBuiltInDisplayType(HLERequestContext& ctx); void PerformSystemButtonPressingIfInFocus(HLERequestContext& ctx); void GetAppletLaunchedHistory(HLERequestContext& ctx); + void GetOperationModeSystemInfo(HLERequestContext& ctx); void GetSettingsPlatformRegion(HLERequestContext& ctx); void SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled(HLERequestContext& ctx); diff --git a/src/core/hle/service/am/cradle_firmware_updater.cpp b/src/core/hle/service/am/cradle_firmware_updater.cpp new file mode 100644 index 000000000..d6c1f07f0 --- /dev/null +++ b/src/core/hle/service/am/cradle_firmware_updater.cpp @@ -0,0 +1,57 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/am/cradle_firmware_updater.h" +#include "core/hle/service/ipc_helpers.h" + +namespace Service::AM { + +ICradleFirmwareUpdater::ICradleFirmwareUpdater(Core::System& system_) + : ServiceFramework{system_, "ICradleFirmwareUpdater"}, + service_context{system, "IHomeMenuFunctions"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "StartUpdate"}, + {1, &ICradleFirmwareUpdater::FinishUpdate, "FinishUpdate"}, + {2, &ICradleFirmwareUpdater::GetCradleDeviceInfo, "GetCradleDeviceInfo"}, + {3, &ICradleFirmwareUpdater::GetCradleDeviceInfoChangeEvent, "GetCradleDeviceInfoChangeEvent"}, + {4, nullptr, "GetUpdateProgressInfo"}, + {5, nullptr, "GetLastInternalResult"}, + + }; + // clang-format on + + RegisterHandlers(functions); + + cradle_device_info_event = + service_context.CreateEvent("IHomeMenuFunctions:PopFromGeneralChannelEvent"); +} + +ICradleFirmwareUpdater::~ICradleFirmwareUpdater() { + service_context.CloseEvent(cradle_device_info_event); +} + +void ICradleFirmwareUpdater::FinishUpdate(HLERequestContext& ctx) { + LOG_WARNING(Service_AM, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} +void ICradleFirmwareUpdater::GetCradleDeviceInfo(HLERequestContext& ctx) { + LOG_WARNING(Service_AM, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 5}; + rb.Push(ResultSuccess); + rb.Push(0); + rb.Push(0); +} + +void ICradleFirmwareUpdater::GetCradleDeviceInfoChangeEvent(HLERequestContext& ctx) { + LOG_WARNING(Service_AM, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2, 1}; + rb.Push(ResultSuccess); + rb.PushCopyObjects(cradle_device_info_event->GetReadableEvent()); +} + +} // namespace Service::AM diff --git a/src/core/hle/service/am/cradle_firmware_updater.h b/src/core/hle/service/am/cradle_firmware_updater.h new file mode 100644 index 000000000..dc9ec72c5 --- /dev/null +++ b/src/core/hle/service/am/cradle_firmware_updater.h @@ -0,0 +1,25 @@ +// 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 ICradleFirmwareUpdater final : public ServiceFramework { +public: + explicit ICradleFirmwareUpdater(Core::System& system_); + ~ICradleFirmwareUpdater() override; + +private: + void FinishUpdate(HLERequestContext& ctx); + void GetCradleDeviceInfo(HLERequestContext& ctx); + void GetCradleDeviceInfoChangeEvent(HLERequestContext& ctx); + + Kernel::KEvent* cradle_device_info_event; + KernelHelpers::ServiceContext service_context; +}; + +} // namespace Service::AM diff --git a/src/core/hle/service/am/global_state_controller.cpp b/src/core/hle/service/am/global_state_controller.cpp index ed0eb7108..ca2b70dab 100644 --- a/src/core/hle/service/am/global_state_controller.cpp +++ b/src/core/hle/service/am/global_state_controller.cpp @@ -1,13 +1,15 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "core/hle/service/am/cradle_firmware_updater.h" #include "core/hle/service/am/global_state_controller.h" #include "core/hle/service/ipc_helpers.h" namespace Service::AM { IGlobalStateController::IGlobalStateController(Core::System& system_) - : ServiceFramework{system_, "IGlobalStateController"} { + : ServiceFramework{system_, "IGlobalStateController"}, + service_context{system_, "IGlobalStateController"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "RequestToEnterSleep"}, @@ -16,19 +18,53 @@ IGlobalStateController::IGlobalStateController(Core::System& system_) {3, nullptr, "StartShutdownSequence"}, {4, nullptr, "StartRebootSequence"}, {9, nullptr, "IsAutoPowerDownRequested"}, - {10, nullptr, "LoadAndApplyIdlePolicySettings"}, + {10, &IGlobalStateController::LoadAndApplyIdlePolicySettings, "LoadAndApplyIdlePolicySettings"}, {11, nullptr, "NotifyCecSettingsChanged"}, {12, nullptr, "SetDefaultHomeButtonLongPressTime"}, {13, nullptr, "UpdateDefaultDisplayResolution"}, - {14, nullptr, "ShouldSleepOnBoot"}, - {15, nullptr, "GetHdcpAuthenticationFailedEvent"}, - {30, nullptr, "OpenCradleFirmwareUpdater"}, + {14, &IGlobalStateController::ShouldSleepOnBoot, "ShouldSleepOnBoot"}, + {15, &IGlobalStateController::GetHdcpAuthenticationFailedEvent, "GetHdcpAuthenticationFailedEvent"}, + {30, &IGlobalStateController::OpenCradleFirmwareUpdater, "OpenCradleFirmwareUpdater"}, }; // clang-format on RegisterHandlers(functions); + + hdcp_authentification_failed_event = + service_context.CreateEvent("IGlobalStateController::HdcpAuthenticationFailedEvent"); } IGlobalStateController::~IGlobalStateController() = default; +void IGlobalStateController::LoadAndApplyIdlePolicySettings(HLERequestContext& ctx) { + LOG_ERROR(Service_AM, "called"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + +void IGlobalStateController::ShouldSleepOnBoot(HLERequestContext& ctx) { + LOG_ERROR(Service_AM, "called"); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(0); +} + +void IGlobalStateController::GetHdcpAuthenticationFailedEvent(HLERequestContext& ctx) { + LOG_ERROR(Service_AM, "called"); + + IPC::ResponseBuilder rb{ctx, 2, 1}; + rb.Push(ResultSuccess); + rb.PushCopyObjects(hdcp_authentification_failed_event->GetReadableEvent()); +} + +void IGlobalStateController::OpenCradleFirmwareUpdater(HLERequestContext& ctx) { + LOG_ERROR(Service_AM, "called"); + + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(ResultSuccess); + rb.PushIpcInterface(system); +} + } // namespace Service::AM diff --git a/src/core/hle/service/am/global_state_controller.h b/src/core/hle/service/am/global_state_controller.h index 7125464a1..5e21b8c3f 100644 --- a/src/core/hle/service/am/global_state_controller.h +++ b/src/core/hle/service/am/global_state_controller.h @@ -3,6 +3,7 @@ #pragma once +#include "core/hle/service/kernel_helpers.h" #include "core/hle/service/service.h" namespace Service::AM { @@ -11,6 +12,15 @@ class IGlobalStateController final : public ServiceFrameworkGetReadableEvent()); } +void IHomeMenuFunctions::IsRebootEnabled(HLERequestContext& ctx) { + LOG_WARNING(Service_AM, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(true); +} + } // namespace Service::AM diff --git a/src/core/hle/service/am/home_menu_functions.h b/src/core/hle/service/am/home_menu_functions.h index e082d5d73..a6e42ce29 100644 --- a/src/core/hle/service/am/home_menu_functions.h +++ b/src/core/hle/service/am/home_menu_functions.h @@ -15,7 +15,10 @@ public: private: void RequestToGetForeground(HLERequestContext& ctx); + void LockForeground(HLERequestContext& ctx); + void UnlockForeground(HLERequestContext& ctx); void GetPopFromGeneralChannelEvent(HLERequestContext& ctx); + void IsRebootEnabled(HLERequestContext& ctx); KernelHelpers::ServiceContext service_context; diff --git a/src/core/hle/service/am/self_controller.cpp b/src/core/hle/service/am/self_controller.cpp index 65e249c0c..73b09e808 100644 --- a/src/core/hle/service/am/self_controller.cpp +++ b/src/core/hle/service/am/self_controller.cpp @@ -49,7 +49,7 @@ ISelfController::ISelfController(Core::System& system_, std::shared_ptr {46, nullptr, "SetRecordingLayerCompositionEnabled"}, {50, &ISelfController::SetHandlesRequestToDisplay, "SetHandlesRequestToDisplay"}, {51, &ISelfController::ApproveToDisplay, "ApproveToDisplay"}, - {60, nullptr, "OverrideAutoSleepTimeAndDimmingTime"}, + {60, &ISelfController::OverrideAutoSleepTimeAndDimmingTime, "OverrideAutoSleepTimeAndDimmingTime"}, {61, &ISelfController::SetMediaPlaybackState, "SetMediaPlaybackState"}, {62, &ISelfController::SetIdleTimeDetectionExtension, "SetIdleTimeDetectionExtension"}, {63, &ISelfController::GetIdleTimeDetectionExtension, "GetIdleTimeDetectionExtension"}, @@ -61,7 +61,7 @@ ISelfController::ISelfController(Core::System& system_, std::shared_ptr {69, &ISelfController::IsAutoSleepDisabled, "IsAutoSleepDisabled"}, {70, nullptr, "ReportMultimediaError"}, {71, nullptr, "GetCurrentIlluminanceEx"}, - {72, nullptr, "SetInputDetectionPolicy"}, + {72, &ISelfController::SetInputDetectionPolicy, "SetInputDetectionPolicy"}, {80, nullptr, "SetWirelessPriorityMode"}, {90, &ISelfController::GetAccumulatedSuspendedTickValue, "GetAccumulatedSuspendedTickValue"}, {91, &ISelfController::GetAccumulatedSuspendedTickChangedEvent, "GetAccumulatedSuspendedTickChangedEvent"}, @@ -327,6 +327,18 @@ void ISelfController::ApproveToDisplay(HLERequestContext& ctx) { rb.Push(ResultSuccess); } +void ISelfController::OverrideAutoSleepTimeAndDimmingTime(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const auto a = rp.Pop(); + const auto b = rp.Pop(); + const auto c = rp.Pop(); + const auto d = rp.Pop(); + LOG_WARNING(Service_AM, "(STUBBED) called, a={}, b={}, c={}, d={}", a, b, c, d); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + void ISelfController::SetMediaPlaybackState(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u8 state = rp.Pop(); @@ -399,6 +411,13 @@ void ISelfController::IsAutoSleepDisabled(HLERequestContext& ctx) { rb.Push(applet->auto_sleep_disabled); } +void ISelfController::SetInputDetectionPolicy(HLERequestContext& ctx) { + LOG_ERROR(Service_AM, "called."); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + void ISelfController::GetAccumulatedSuspendedTickValue(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called."); diff --git a/src/core/hle/service/am/self_controller.h b/src/core/hle/service/am/self_controller.h index ab21a1881..a7c4e25fd 100644 --- a/src/core/hle/service/am/self_controller.h +++ b/src/core/hle/service/am/self_controller.h @@ -39,12 +39,14 @@ private: void CreateManagedDisplaySeparableLayer(HLERequestContext& ctx); void SetHandlesRequestToDisplay(HLERequestContext& ctx); void ApproveToDisplay(HLERequestContext& ctx); + void OverrideAutoSleepTimeAndDimmingTime(HLERequestContext& ctx); void SetMediaPlaybackState(HLERequestContext& ctx); void SetIdleTimeDetectionExtension(HLERequestContext& ctx); void GetIdleTimeDetectionExtension(HLERequestContext& ctx); void ReportUserIsActive(HLERequestContext& ctx); void SetAutoSleepDisabled(HLERequestContext& ctx); void IsAutoSleepDisabled(HLERequestContext& ctx); + void SetInputDetectionPolicy(HLERequestContext& ctx); void GetAccumulatedSuspendedTickValue(HLERequestContext& ctx); void GetAccumulatedSuspendedTickChangedEvent(HLERequestContext& ctx); void SetAlbumImageTakenNotificationEnabled(HLERequestContext& ctx);