IDisplayController.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.HLE.HOS.Ipc;
  3. using Ryujinx.HLE.HOS.Kernel.Common;
  4. using Ryujinx.HLE.HOS.Kernel.Memory;
  5. using System;
  6. namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
  7. {
  8. class IDisplayController : IpcService
  9. {
  10. private KTransferMemory _transferMem;
  11. private bool _lastApplicationCaptureBufferAcquired;
  12. private bool _callerAppletCaptureBufferAcquired;
  13. public IDisplayController(ServiceCtx context)
  14. {
  15. _transferMem = context.Device.System.AppletCaptureBufferTransfer;
  16. }
  17. [CommandHipc(8)] // 2.0.0+
  18. // TakeScreenShotOfOwnLayer(b8, s32)
  19. public ResultCode TakeScreenShotOfOwnLayer(ServiceCtx context)
  20. {
  21. bool unknown1 = context.RequestData.ReadBoolean();
  22. int unknown2 = context.RequestData.ReadInt32();
  23. Logger.Stub?.PrintStub(LogClass.ServiceAm, new { unknown1, unknown2 });
  24. return ResultCode.Success;
  25. }
  26. [CommandHipc(11)]
  27. // ReleaseLastApplicationCaptureBuffer()
  28. public ResultCode ReleaseLastApplicationCaptureBuffer(ServiceCtx context)
  29. {
  30. if (!_lastApplicationCaptureBufferAcquired)
  31. {
  32. return ResultCode.BufferNotAcquired;
  33. }
  34. _lastApplicationCaptureBufferAcquired = false;
  35. return ResultCode.Success;
  36. }
  37. [CommandHipc(15)]
  38. // ReleaseCallerAppletCaptureBuffer()
  39. public ResultCode ReleaseCallerAppletCaptureBuffer(ServiceCtx context)
  40. {
  41. if (!_callerAppletCaptureBufferAcquired)
  42. {
  43. return ResultCode.BufferNotAcquired;
  44. }
  45. _callerAppletCaptureBufferAcquired = false;
  46. return ResultCode.Success;
  47. }
  48. [CommandHipc(16)]
  49. // AcquireLastApplicationCaptureBufferEx() -> (b8, handle<copy>)
  50. public ResultCode AcquireLastApplicationCaptureBufferEx(ServiceCtx context)
  51. {
  52. if (_lastApplicationCaptureBufferAcquired)
  53. {
  54. return ResultCode.BufferAlreadyAcquired;
  55. }
  56. if (context.Process.HandleTable.GenerateHandle(_transferMem, out int handle) != KernelResult.Success)
  57. {
  58. throw new InvalidOperationException("Out of handles!");
  59. }
  60. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
  61. _lastApplicationCaptureBufferAcquired = true;
  62. context.ResponseData.Write(_lastApplicationCaptureBufferAcquired);
  63. return ResultCode.Success;
  64. }
  65. [CommandHipc(18)]
  66. // AcquireCallerAppletCaptureBufferEx() -> (b8, handle<copy>)
  67. public ResultCode AcquireCallerAppletCaptureBufferEx(ServiceCtx context)
  68. {
  69. if (_callerAppletCaptureBufferAcquired)
  70. {
  71. return ResultCode.BufferAlreadyAcquired;
  72. }
  73. if (context.Process.HandleTable.GenerateHandle(_transferMem, out int handle) != KernelResult.Success)
  74. {
  75. throw new InvalidOperationException("Out of handles!");
  76. }
  77. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
  78. _callerAppletCaptureBufferAcquired = true;
  79. context.ResponseData.Write(_callerAppletCaptureBufferAcquired);
  80. return ResultCode.Success;
  81. }
  82. }
  83. }