2021-06-28 20:54:45 +02:00
|
|
|
using Ryujinx.Common.Logging;
|
|
|
|
using Ryujinx.HLE.HOS.Ipc;
|
|
|
|
using Ryujinx.HLE.HOS.Kernel.Memory;
|
2023-01-04 23:15:45 +01:00
|
|
|
using Ryujinx.Horizon.Common;
|
2021-06-28 20:54:45 +02:00
|
|
|
using System;
|
|
|
|
|
2019-09-19 02:45:11 +02:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
|
2018-02-10 01:14:55 +01:00
|
|
|
{
|
2018-03-19 19:58:46 +01:00
|
|
|
class IDisplayController : IpcService
|
2018-02-10 01:14:55 +01:00
|
|
|
{
|
2021-06-28 20:54:45 +02:00
|
|
|
private KTransferMemory _transferMem;
|
|
|
|
private bool _lastApplicationCaptureBufferAcquired;
|
|
|
|
private bool _callerAppletCaptureBufferAcquired;
|
|
|
|
|
|
|
|
public IDisplayController(ServiceCtx context)
|
|
|
|
{
|
|
|
|
_transferMem = context.Device.System.AppletCaptureBufferTransfer;
|
|
|
|
}
|
|
|
|
|
2023-04-15 01:00:34 +02:00
|
|
|
[CommandCmif(8)] // 2.0.0+
|
2021-06-28 20:54:45 +02:00
|
|
|
// TakeScreenShotOfOwnLayer(b8, s32)
|
|
|
|
public ResultCode TakeScreenShotOfOwnLayer(ServiceCtx context)
|
|
|
|
{
|
|
|
|
bool unknown1 = context.RequestData.ReadBoolean();
|
|
|
|
int unknown2 = context.RequestData.ReadInt32();
|
|
|
|
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { unknown1, unknown2 });
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
|
2023-04-15 01:00:34 +02:00
|
|
|
[CommandCmif(11)]
|
2021-06-28 20:54:45 +02:00
|
|
|
// ReleaseLastApplicationCaptureBuffer()
|
|
|
|
public ResultCode ReleaseLastApplicationCaptureBuffer(ServiceCtx context)
|
|
|
|
{
|
|
|
|
if (!_lastApplicationCaptureBufferAcquired)
|
|
|
|
{
|
|
|
|
return ResultCode.BufferNotAcquired;
|
|
|
|
}
|
|
|
|
|
|
|
|
_lastApplicationCaptureBufferAcquired = false;
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
|
2023-04-15 01:00:34 +02:00
|
|
|
[CommandCmif(15)]
|
2021-06-28 20:54:45 +02:00
|
|
|
// ReleaseCallerAppletCaptureBuffer()
|
|
|
|
public ResultCode ReleaseCallerAppletCaptureBuffer(ServiceCtx context)
|
|
|
|
{
|
|
|
|
if (!_callerAppletCaptureBufferAcquired)
|
|
|
|
{
|
|
|
|
return ResultCode.BufferNotAcquired;
|
|
|
|
}
|
|
|
|
|
|
|
|
_callerAppletCaptureBufferAcquired = false;
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
|
2023-04-15 01:00:34 +02:00
|
|
|
[CommandCmif(16)]
|
2021-06-28 20:54:45 +02:00
|
|
|
// AcquireLastApplicationCaptureBufferEx() -> (b8, handle<copy>)
|
|
|
|
public ResultCode AcquireLastApplicationCaptureBufferEx(ServiceCtx context)
|
|
|
|
{
|
|
|
|
if (_lastApplicationCaptureBufferAcquired)
|
|
|
|
{
|
|
|
|
return ResultCode.BufferAlreadyAcquired;
|
|
|
|
}
|
|
|
|
|
2023-01-04 23:15:45 +01:00
|
|
|
if (context.Process.HandleTable.GenerateHandle(_transferMem, out int handle) != Result.Success)
|
2021-06-28 20:54:45 +02:00
|
|
|
{
|
|
|
|
throw new InvalidOperationException("Out of handles!");
|
|
|
|
}
|
|
|
|
|
|
|
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
|
|
|
|
|
|
|
|
_lastApplicationCaptureBufferAcquired = true;
|
|
|
|
|
|
|
|
context.ResponseData.Write(_lastApplicationCaptureBufferAcquired);
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
|
2023-04-15 01:00:34 +02:00
|
|
|
[CommandCmif(18)]
|
2021-06-28 20:54:45 +02:00
|
|
|
// AcquireCallerAppletCaptureBufferEx() -> (b8, handle<copy>)
|
|
|
|
public ResultCode AcquireCallerAppletCaptureBufferEx(ServiceCtx context)
|
|
|
|
{
|
|
|
|
if (_callerAppletCaptureBufferAcquired)
|
|
|
|
{
|
|
|
|
return ResultCode.BufferAlreadyAcquired;
|
|
|
|
}
|
|
|
|
|
2023-01-04 23:15:45 +01:00
|
|
|
if (context.Process.HandleTable.GenerateHandle(_transferMem, out int handle) != Result.Success)
|
2021-06-28 20:54:45 +02:00
|
|
|
{
|
|
|
|
throw new InvalidOperationException("Out of handles!");
|
|
|
|
}
|
|
|
|
|
|
|
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
|
|
|
|
|
|
|
|
_callerAppletCaptureBufferAcquired = true;
|
|
|
|
|
|
|
|
context.ResponseData.Write(_callerAppletCaptureBufferAcquired);
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
2018-02-10 01:14:55 +01:00
|
|
|
}
|
|
|
|
}
|