caps: Implement SaveScreenShot calls and cleanup (#2140)
* caps: Implement SaveScreenShot calls and cleanup This PR implement: - caps:u IAlbumApplicationService (32) SetShimLibraryVersion - caps:c IAlbumControlService (33) SetShimLibraryVersion - caps:su IScreenShotApplicationService (32) SetShimLibraryVersion - caps:su IScreenShotApplicationService (203/205/210) SaveScreenShotEx0/SaveScreenShotEx1/SaveScreenShotEx2 ImageSharp is used to save the raw screenshot data as a JPG file following what the service does. All screenshots are save in: `%AppData%\Ryujinx\sdcard\Nintendo\Album` folder. (as example a screenshot file path will be `%AppData%\Ryujinx\sdcard\Nintendo\Album\2021\03\26\2021032601020300-0123456789ABCDEF0123456789ABCDEF.jpg` This is needed by Animal Crossing: New Horizon where screenshots looks like this: And this is needed in Monster Hunter Rise but screenshots are currently empty due to another issue. * remove useless comment * Addresses gdkchan feedback * Addresses gdkchan feedback 2 * remove useless comment 2 * Fix nits
This commit is contained in:
parent
4bd1ad16f9
commit
32be8caa9d
13 changed files with 327 additions and 10 deletions
|
@ -1,4 +1,5 @@
|
|||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.HLE.HOS.Services.Caps.Types;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Caps
|
||||
{
|
||||
|
@ -11,12 +12,87 @@ namespace Ryujinx.HLE.HOS.Services.Caps
|
|||
// SetShimLibraryVersion(pid, u64, nn::applet::AppletResourceUserId)
|
||||
public ResultCode SetShimLibraryVersion(ServiceCtx context)
|
||||
{
|
||||
ulong shimLibraryVersion = context.RequestData.ReadUInt64();
|
||||
return context.Device.System.CaptureManager.SetShimLibraryVersion(context);
|
||||
}
|
||||
|
||||
[Command(203)]
|
||||
// SaveScreenShotEx0(bytes<0x40> ScreenShotAttribute, u32 unknown, u64 AppletResourceUserId, pid, buffer<bytes, 0x45> ScreenshotData) -> bytes<0x20> ApplicationAlbumEntry
|
||||
public ResultCode SaveScreenShotEx0(ServiceCtx context)
|
||||
{
|
||||
// TODO: Use the ScreenShotAttribute.
|
||||
ScreenShotAttribute screenShotAttribute = context.RequestData.ReadStruct<ScreenShotAttribute>();
|
||||
|
||||
uint unknown = context.RequestData.ReadUInt32();
|
||||
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
||||
ulong pidPlaceholder = context.RequestData.ReadUInt64();
|
||||
|
||||
long screenshotDataPosition = context.Request.SendBuff[0].Position;
|
||||
long screenshotDataSize = context.Request.SendBuff[0].Size;
|
||||
|
||||
byte[] screenshotData = context.Memory.GetSpan((ulong)screenshotDataPosition, (int)screenshotDataSize, true).ToArray();
|
||||
|
||||
ResultCode resultCode = context.Device.System.CaptureManager.SaveScreenShot(screenshotData, appletResourceUserId, context.Device.Application.TitleId, out ApplicationAlbumEntry applicationAlbumEntry);
|
||||
|
||||
context.ResponseData.WriteStruct(applicationAlbumEntry);
|
||||
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
[Command(205)] // 8.0.0+
|
||||
// SaveScreenShotEx1(bytes<0x40> ScreenShotAttribute, u32 unknown, u64 AppletResourceUserId, pid, buffer<bytes, 0x15> ApplicationData, buffer<bytes, 0x45> ScreenshotData) -> bytes<0x20> ApplicationAlbumEntry
|
||||
public ResultCode SaveScreenShotEx1(ServiceCtx context)
|
||||
{
|
||||
// TODO: Use the ScreenShotAttribute.
|
||||
ScreenShotAttribute screenShotAttribute = context.RequestData.ReadStruct<ScreenShotAttribute>();
|
||||
|
||||
uint unknown = context.RequestData.ReadUInt32();
|
||||
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
||||
ulong pidPlaceholder = context.RequestData.ReadUInt64();
|
||||
|
||||
long applicationDataPosition = context.Request.SendBuff[0].Position;
|
||||
long applicationDataSize = context.Request.SendBuff[0].Size;
|
||||
|
||||
long screenshotDataPosition = context.Request.SendBuff[1].Position;
|
||||
long screenshotDataSize = context.Request.SendBuff[1].Size;
|
||||
|
||||
// TODO: Parse the application data: At 0x00 it's UserData (Size of 0x400), at 0x404 it's a uint UserDataSize (Always empty for now).
|
||||
byte[] applicationData = context.Memory.GetSpan((ulong)applicationDataPosition, (int)applicationDataSize).ToArray();
|
||||
|
||||
byte[] screenshotData = context.Memory.GetSpan((ulong)screenshotDataPosition, (int)screenshotDataSize, true).ToArray();
|
||||
|
||||
ResultCode resultCode = context.Device.System.CaptureManager.SaveScreenShot(screenshotData, appletResourceUserId, context.Device.Application.TitleId, out ApplicationAlbumEntry applicationAlbumEntry);
|
||||
|
||||
context.ResponseData.WriteStruct(applicationAlbumEntry);
|
||||
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
[Command(210)]
|
||||
// SaveScreenShotEx2(bytes<0x40> ScreenShotAttribute, u32 unknown, u64 AppletResourceUserId, buffer<bytes, 0x15> UserIdList, buffer<bytes, 0x45> ScreenshotData) -> bytes<0x20> ApplicationAlbumEntry
|
||||
public ResultCode SaveScreenShotEx2(ServiceCtx context)
|
||||
{
|
||||
// TODO: Use the ScreenShotAttribute.
|
||||
ScreenShotAttribute screenShotAttribute = context.RequestData.ReadStruct<ScreenShotAttribute>();
|
||||
|
||||
uint unknown = context.RequestData.ReadUInt32();
|
||||
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceCaps, new { shimLibraryVersion, appletResourceUserId });
|
||||
long userIdListPosition = context.Request.SendBuff[0].Position;
|
||||
long userIdListSize = context.Request.SendBuff[0].Size;
|
||||
|
||||
return ResultCode.Success;
|
||||
long screenshotDataPosition = context.Request.SendBuff[1].Position;
|
||||
long screenshotDataSize = context.Request.SendBuff[1].Size;
|
||||
|
||||
// TODO: Parse the UserIdList.
|
||||
byte[] userIdList = context.Memory.GetSpan((ulong)userIdListPosition, (int)userIdListSize).ToArray();
|
||||
|
||||
byte[] screenshotData = context.Memory.GetSpan((ulong)screenshotDataPosition, (int)screenshotDataSize, true).ToArray();
|
||||
|
||||
ResultCode resultCode = context.Device.System.CaptureManager.SaveScreenShot(screenshotData, appletResourceUserId, context.Device.Application.TitleId, out ApplicationAlbumEntry applicationAlbumEntry);
|
||||
|
||||
context.ResponseData.WriteStruct(applicationAlbumEntry);
|
||||
|
||||
return resultCode;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue