From 22c83006a3edb90d96829dd08adc74d310e2dc01 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Thu, 27 May 2021 22:26:46 +0100 Subject: [PATCH] Stub application copyright image AM calls These are used on HOS to control the screenshot overlay image for developer copyrights. --- .../am/controller/IApplicationFunctions.cpp | 41 +++++++++++++++++++ .../am/controller/IApplicationFunctions.h | 27 +++++++++++- 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.cpp b/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.cpp index f202fc9d..5b95be9f 100644 --- a/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.cpp +++ b/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.cpp @@ -62,6 +62,47 @@ namespace skyline::service::am { return {}; } + Result IApplicationFunctions::InitializeApplicationCopyrightFrameBuffer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + i32 width{request.Pop()}; + i32 height{request.Pop()}; + u64 transferMemorySize{request.Pop()}; + + constexpr i32 MaximumFbWidth{1280}; + constexpr i32 MaximumFbHeight{720}; + constexpr u64 RequiredFbAlignment{0x40000}; + + if (width > MaximumFbWidth || height > MaximumFbHeight || !util::IsAligned(transferMemorySize, RequiredFbAlignment)) + return result::InvalidParameters; + + state.logger->Debug("Dimensions: ({}, {}) Transfer Memory Size: {}", width, height, transferMemorySize); + + return {}; + } + + Result IApplicationFunctions::SetApplicationCopyrightImage(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + i32 x{request.Pop()}; + i32 y{request.Pop()}; + i32 width{request.Pop()}; + i32 height{request.Pop()}; + + enum class WindowOriginMode : i32 { + LowerLeft, + UpperLeft + } originMode = request.Pop(); + + if (y < 0 || x < 0 || width < 1 || height < 1) + return result::InvalidParameters; + + state.logger->Debug("Position: ({}, {}) Dimensions: ({}, {}) Origin mode: {}", x, y, width, height, static_cast(originMode)); + return {}; + } + + Result IApplicationFunctions::SetApplicationCopyrightVisibility(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + u8 visiblity{request.Pop()}; + state.logger->Debug("Visiblity: {}", visiblity); + return {}; + } + Result IApplicationFunctions::GetGpuErrorDetectedSystemEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { auto handle{state.process->InsertItem(gpuErrorEvent)}; state.logger->Debug("GPU Error Event Handle: 0x{:X}", handle); diff --git a/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.h b/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.h index ca6a6b89..c4ee7404 100644 --- a/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.h +++ b/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.h @@ -7,6 +7,10 @@ #include namespace skyline::service::am { + namespace result { + constexpr Result InvalidParameters(128, 506); + } + /** * @brief This is used to notify an application about its own state * @url https://switchbrew.org/wiki/Applet_Manager_services#IApplicationFunctions @@ -60,6 +64,24 @@ namespace skyline::service::am { */ Result SetGamePlayRecordingState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + /** + * @brief Uses the given transfer memory to setup memory for the screenshot copyright image + * @url https://switchbrew.org/wiki/Applet_Manager_services#InitializeApplicationCopyrightFrameBuffer + */ + Result InitializeApplicationCopyrightFrameBuffer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief Sets the copyright image for screenshots using the buffer from InitializeApplicationCopyrightFrameBuffer + * @url https://switchbrew.org/wiki/Applet_Manager_services#SetApplicationCopyrightImage + */ + Result SetApplicationCopyrightImage(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief Controls the visibility of the screenshot copyright image + * @url https://switchbrew.org/wiki/Applet_Manager_services#SetApplicationCopyrightVisibility + */ + Result SetApplicationCopyrightVisibility(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + /** * @brief Obtains a handle to the system GPU error KEvent * @url https://switchbrew.org/wiki/Applet_Manager_services#GetGpuErrorDetectedSystemEvent @@ -74,8 +96,11 @@ namespace skyline::service::am { SFUNC(0x32, IApplicationFunctions, GetPseudoDeviceId), SFUNC(0x42, IApplicationFunctions, InitializeGamePlayRecording), SFUNC(0x43, IApplicationFunctions, SetGamePlayRecordingState), - SFUNC(0x64, IApplicationFunctions, SetGamePlayRecordingState), + SFUNC(0x64, IApplicationFunctions, InitializeApplicationCopyrightFrameBuffer), + SFUNC(0x65, IApplicationFunctions, SetApplicationCopyrightImage), + SFUNC(0x66, IApplicationFunctions, SetApplicationCopyrightVisibility), SFUNC(0x82, IApplicationFunctions, GetGpuErrorDetectedSystemEvent) ) + }; }