add capssc 1201-1203 debug calls (#408)

This commit is contained in:
HookedBehemoth 2020-04-24 22:10:42 +02:00 committed by GitHub
parent 8cbac97466
commit 8e245a0ba8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 70 additions and 0 deletions

View File

@ -35,6 +35,33 @@ Service* capsscGetServiceSession(void);
*/
Result capsscCaptureRawImageWithTimeout(void* buf, size_t size, ViLayerStack layer_stack, u64 width, u64 height, s64 buffer_count, s64 buffer_index, s64 timeout);
/**
* @brief This takes a raw screenshot, with the screenshot being held until \ref capsscCloseRawScreenShotReadStream is called.
* @note Only available on [3.0.0+]. Requires debug mode.
* @param out_size Pointer to write the size of the captured raw image to. Always 0x384000(1280*720*4).
* @param out_width Pointer to write the width of the captured raw image to. Always 1280.
* @param out_height Pointer to write the height of the captured raw image to. Always 720.
* @param layer_stack \ref ViLayerStack
* @param timeout Timeout in nanoseconds.
*/
Result capsscOpenRawScreenShotReadStream(u64 *out_size, u64 *out_width, u64 *out_height, ViLayerStack layer_stack, s64 timeout);
/**
* @brief Discards a stream opened by \ref capsscOpenRawScreenShotReadStream.
* @note Only available on [3.0.0+]. Requires debug mode.
*/
Result capsscCloseRawScreenShotReadStream(void);
/**
* @brief Reads from a stream opened by \ref capsscOpenRawScreenShotReadStream.
* @note Only available on [3.0.0+]. Requires debug mode.
* @param bytes_read Pointer to write the amounts of bytes written to buffer.
* @param buf Output buffer containing the RGBA8 image.
* @param size Size of buf.
* @param offset Offset in image where read should start.
*/
Result capsscReadRawScreenShotReadStream(u64 *bytes_read, void* buf, size_t size, u64 offset);
/**
* @brief This takes a screenshot, with the screenshot being written as jpeg into the output buffer.
* @note Only available on [9.0.0+]. Requires debug mode before [10.0.0].

View File

@ -43,6 +43,49 @@ Result capsscCaptureRawImageWithTimeout(void* buf, size_t size, ViLayerStack lay
);
}
Result capsscOpenRawScreenShotReadStream(u64 *out_size, u64 *out_width, u64 *out_height, ViLayerStack layer_stack, s64 timeout) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
const struct {
s32 layer_stack;
u32 pad;
u64 timeout;
} in = {layer_stack, 0, timeout};
struct {
u64 size;
u64 width;
u64 height;
} out;
Result rc = serviceDispatchInOut(&g_capsscSrv, 1201, in, out);
if (R_SUCCEEDED(rc)) {
if (out_size) *out_size = out.size;
if (out_width) *out_width = out.width;
if (out_height) *out_height = out.height;
}
return rc;
}
Result capsscCloseRawScreenShotReadStream(void) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatch(&g_capsscSrv, 1202);
}
Result capsscReadRawScreenShotReadStream(u64 *bytes_read, void* buf, size_t size, u64 offset) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchInOut(&g_capsscSrv, 1203, offset, *bytes_read,
.buffer_attrs = { SfBufferAttr_Out | SfBufferAttr_HipcMapAlias },
.buffers = { { buf, size } },
);
}
Result capsscCaptureJpegScreenShot(u64* out_jpeg_size, void* jpeg_buf, size_t jpeg_buf_size, ViLayerStack layer_stack, s64 timeout) {
if (hosversionBefore(9,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);