diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index 77da3ae7e..48ff76eee 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -550,6 +550,27 @@ void Module::Interface::CancelLibraryApplet(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_APT, "(STUBBED) called exiting=%d", exiting); } +void Module::Interface::SendCaptureBufferInfo(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x40, 1, 2); // 0x00400042 + u32 size = rp.Pop(); + ASSERT(size == 0x20); + apt->screen_capture_buffer = rp.PopStaticBuffer(); + + IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + rb.Push(RESULT_SUCCESS); +} + +void Module::Interface::ReceiveCaptureBufferInfo(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x41, 1, 0); // 0x00410040 + u32 size = rp.Pop(); + ASSERT(size == 0x20); + + IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); + rb.Push(RESULT_SUCCESS); + rb.Push(static_cast(apt->screen_capture_buffer.size())); + rb.PushStaticBuffer(std::move(apt->screen_capture_buffer), 0); +} + void Module::Interface::SetScreenCapPostPermission(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x55, 1, 0); // 0x00550040 diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h index c80658edf..7abbcd8bb 100644 --- a/src/core/hle/service/apt/apt.h +++ b/src/core/hle/service/apt/apt.h @@ -14,7 +14,7 @@ namespace Kernel { class Mutex; class SharedMemory; -} +} // namespace Kernel namespace Service { namespace APT { @@ -212,7 +212,7 @@ public: * Outputs: * 0 : Return Header * 1 : Result of function, 0 on success, otherwise error code - */ + */ void SendParameter(Kernel::HLERequestContext& ctx); /** @@ -313,7 +313,7 @@ public: * Outputs: * 0 : Return Header * 1 : Result of function, 0 on success, otherwise error code - */ + */ void StartApplication(Kernel::HLERequestContext& ctx); /** @@ -420,6 +420,33 @@ public: */ void CancelLibraryApplet(Kernel::HLERequestContext& ctx); + /** + * APT::SendCaptureBufferInfo service function + * Inputs: + * 0 : Command header [0x00400042] + * 1 : Size + * 2 : (Size << 14) | 2 + * 3 : void*, CaptureBufferInfo + * Outputs: + * 0 : Header code + * 1 : Result code + */ + void SendCaptureBufferInfo(Kernel::HLERequestContext& ctx); + + /** + * APT::ReceiveCaptureBufferInfo service function + * Inputs: + * 0 : Command header [0x00410040] + * 1 : Size + * 64 : Size << 14 | 2 + * 65 : void*, CaptureBufferInfo + * Outputs: + * 0 : Header code + * 1 : Result code + * 2 : Actual Size + */ + void ReceiveCaptureBufferInfo(Kernel::HLERequestContext& ctx); + /** * APT::GetStartupArgument service function * Inputs: @@ -496,6 +523,8 @@ private: // APT::CheckNew3DSApp will check this unknown_ns_state_field to determine processing mode u8 unknown_ns_state_field = 0; + std::vector screen_capture_buffer; + ScreencapPostPermission screen_capture_post_permission = ScreencapPostPermission::CleanThePermission; // TODO(JamePeng): verify the initial value diff --git a/src/core/hle/service/apt/apt_a.cpp b/src/core/hle/service/apt/apt_a.cpp index e9f0459c2..19b1de05c 100644 --- a/src/core/hle/service/apt/apt_a.cpp +++ b/src/core/hle/service/apt/apt_a.cpp @@ -73,8 +73,8 @@ APT_A::APT_A(std::shared_ptr apt) {0x003D0042, nullptr, "SendDspWakeUp"}, {0x003E0080, nullptr, "ReplySleepQuery"}, {0x003F0040, nullptr, "ReplySleepNotificationComplete"}, - {0x00400042, nullptr, "SendCaptureBufferInfo"}, - {0x00410040, nullptr, "ReceiveCaptureBufferInfo"}, + {0x00400042, &APT_A::SendCaptureBufferInfo, "SendCaptureBufferInfo"}, + {0x00410040, &APT_A::ReceiveCaptureBufferInfo, "ReceiveCaptureBufferInfo"}, {0x00420080, nullptr, "SleepSystem"}, {0x00430040, &APT_A::NotifyToWait, "NotifyToWait"}, {0x00440000, &APT_A::GetSharedFont, "GetSharedFont"}, diff --git a/src/core/hle/service/apt/apt_s.cpp b/src/core/hle/service/apt/apt_s.cpp index d8c1c2230..67ed7b9d9 100644 --- a/src/core/hle/service/apt/apt_s.cpp +++ b/src/core/hle/service/apt/apt_s.cpp @@ -73,8 +73,8 @@ APT_S::APT_S(std::shared_ptr apt) {0x003D0042, nullptr, "SendDspWakeUp"}, {0x003E0080, nullptr, "ReplySleepQuery"}, {0x003F0040, nullptr, "ReplySleepNotificationComplete"}, - {0x00400042, nullptr, "SendCaptureBufferInfo"}, - {0x00410040, nullptr, "ReceiveCaptureBufferInfo"}, + {0x00400042, &APT_S::SendCaptureBufferInfo, "SendCaptureBufferInfo"}, + {0x00410040, &APT_S::ReceiveCaptureBufferInfo, "ReceiveCaptureBufferInfo"}, {0x00420080, nullptr, "SleepSystem"}, {0x00430040, &APT_S::NotifyToWait, "NotifyToWait"}, {0x00440000, &APT_S::GetSharedFont, "GetSharedFont"}, diff --git a/src/core/hle/service/apt/apt_u.cpp b/src/core/hle/service/apt/apt_u.cpp index 8475827e2..193fdd78a 100644 --- a/src/core/hle/service/apt/apt_u.cpp +++ b/src/core/hle/service/apt/apt_u.cpp @@ -73,8 +73,8 @@ APT_U::APT_U(std::shared_ptr apt) {0x003D0042, nullptr, "SendDspWakeUp"}, {0x003E0080, nullptr, "ReplySleepQuery"}, {0x003F0040, nullptr, "ReplySleepNotificationComplete"}, - {0x00400042, nullptr, "SendCaptureBufferInfo"}, - {0x00410040, nullptr, "ReceiveCaptureBufferInfo"}, + {0x00400042, &APT_U::SendCaptureBufferInfo, "SendCaptureBufferInfo"}, + {0x00410040, &APT_U::ReceiveCaptureBufferInfo, "ReceiveCaptureBufferInfo"}, {0x00420080, nullptr, "SleepSystem"}, {0x00430040, &APT_U::NotifyToWait, "NotifyToWait"}, {0x00440000, &APT_U::GetSharedFont, "GetSharedFont"},