ISelfController.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.HLE.HOS.Ipc;
  3. using Ryujinx.HLE.HOS.Kernel.Common;
  4. using Ryujinx.HLE.HOS.Kernel.Threading;
  5. using System;
  6. namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
  7. {
  8. class ISelfController : IpcService
  9. {
  10. private KEvent _libraryAppletLaunchableEvent;
  11. private KEvent _accumulatedSuspendedTickChangedEvent;
  12. private int _accumulatedSuspendedTickChangedEventHandle = 0;
  13. private int _idleTimeDetectionExtension;
  14. public ISelfController(Horizon system)
  15. {
  16. _libraryAppletLaunchableEvent = new KEvent(system);
  17. }
  18. [Command(0)]
  19. // Exit()
  20. public ResultCode Exit(ServiceCtx context)
  21. {
  22. Logger.PrintStub(LogClass.ServiceAm);
  23. return ResultCode.Success;
  24. }
  25. [Command(1)]
  26. // LockExit()
  27. public ResultCode LockExit(ServiceCtx context)
  28. {
  29. Logger.PrintStub(LogClass.ServiceAm);
  30. return ResultCode.Success;
  31. }
  32. [Command(2)]
  33. // UnlockExit()
  34. public ResultCode UnlockExit(ServiceCtx context)
  35. {
  36. Logger.PrintStub(LogClass.ServiceAm);
  37. return ResultCode.Success;
  38. }
  39. [Command(9)]
  40. // GetLibraryAppletLaunchableEvent() -> handle<copy>
  41. public ResultCode GetLibraryAppletLaunchableEvent(ServiceCtx context)
  42. {
  43. _libraryAppletLaunchableEvent.ReadableEvent.Signal();
  44. if (context.Process.HandleTable.GenerateHandle(_libraryAppletLaunchableEvent.ReadableEvent, out int handle) != KernelResult.Success)
  45. {
  46. throw new InvalidOperationException("Out of handles!");
  47. }
  48. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
  49. Logger.PrintStub(LogClass.ServiceAm);
  50. return ResultCode.Success;
  51. }
  52. [Command(10)]
  53. // SetScreenShotPermission(u32)
  54. public ResultCode SetScreenShotPermission(ServiceCtx context)
  55. {
  56. bool enable = context.RequestData.ReadByte() != 0;
  57. Logger.PrintStub(LogClass.ServiceAm);
  58. return ResultCode.Success;
  59. }
  60. [Command(11)]
  61. // SetOperationModeChangedNotification(b8)
  62. public ResultCode SetOperationModeChangedNotification(ServiceCtx context)
  63. {
  64. bool enable = context.RequestData.ReadByte() != 0;
  65. Logger.PrintStub(LogClass.ServiceAm);
  66. return ResultCode.Success;
  67. }
  68. [Command(12)]
  69. // SetPerformanceModeChangedNotification(b8)
  70. public ResultCode SetPerformanceModeChangedNotification(ServiceCtx context)
  71. {
  72. bool enable = context.RequestData.ReadByte() != 0;
  73. Logger.PrintStub(LogClass.ServiceAm);
  74. return ResultCode.Success;
  75. }
  76. [Command(13)]
  77. // SetFocusHandlingMode(b8, b8, b8)
  78. public ResultCode SetFocusHandlingMode(ServiceCtx context)
  79. {
  80. bool flag1 = context.RequestData.ReadByte() != 0;
  81. bool flag2 = context.RequestData.ReadByte() != 0;
  82. bool flag3 = context.RequestData.ReadByte() != 0;
  83. Logger.PrintStub(LogClass.ServiceAm);
  84. return ResultCode.Success;
  85. }
  86. [Command(14)]
  87. // SetRestartMessageEnabled(b8)
  88. public ResultCode SetRestartMessageEnabled(ServiceCtx context)
  89. {
  90. bool enable = context.RequestData.ReadByte() != 0;
  91. Logger.PrintStub(LogClass.ServiceAm);
  92. return ResultCode.Success;
  93. }
  94. [Command(16)] // 2.0.0+
  95. // SetOutOfFocusSuspendingEnabled(b8)
  96. public ResultCode SetOutOfFocusSuspendingEnabled(ServiceCtx context)
  97. {
  98. bool enable = context.RequestData.ReadByte() != 0;
  99. Logger.PrintStub(LogClass.ServiceAm);
  100. return ResultCode.Success;
  101. }
  102. [Command(19)] // 3.0.0+
  103. public ResultCode SetScreenShotImageOrientation(ServiceCtx context)
  104. {
  105. int orientation = context.RequestData.ReadInt32();
  106. Logger.PrintStub(LogClass.ServiceAm);
  107. return ResultCode.Success;
  108. }
  109. [Command(50)]
  110. // SetHandlesRequestToDisplay(b8)
  111. public ResultCode SetHandlesRequestToDisplay(ServiceCtx context)
  112. {
  113. bool enable = context.RequestData.ReadByte() != 0;
  114. Logger.PrintStub(LogClass.ServiceAm);
  115. return ResultCode.Success;
  116. }
  117. [Command(62)]
  118. // SetIdleTimeDetectionExtension(u32)
  119. public ResultCode SetIdleTimeDetectionExtension(ServiceCtx context)
  120. {
  121. _idleTimeDetectionExtension = context.RequestData.ReadInt32();
  122. Logger.PrintStub(LogClass.ServiceAm, new { _idleTimeDetectionExtension });
  123. return ResultCode.Success;
  124. }
  125. [Command(63)]
  126. // GetIdleTimeDetectionExtension() -> u32
  127. public ResultCode GetIdleTimeDetectionExtension(ServiceCtx context)
  128. {
  129. context.ResponseData.Write(_idleTimeDetectionExtension);
  130. Logger.PrintStub(LogClass.ServiceAm, new { _idleTimeDetectionExtension });
  131. return ResultCode.Success;
  132. }
  133. [Command(91)] // 6.0.0+
  134. // GetAccumulatedSuspendedTickChangedEvent() -> handle<copy>
  135. public ResultCode GetAccumulatedSuspendedTickChangedEvent(ServiceCtx context)
  136. {
  137. if (_accumulatedSuspendedTickChangedEventHandle == 0)
  138. {
  139. _accumulatedSuspendedTickChangedEvent = new KEvent(context.Device.System);
  140. _accumulatedSuspendedTickChangedEvent.ReadableEvent.Signal();
  141. if (context.Process.HandleTable.GenerateHandle(_accumulatedSuspendedTickChangedEvent.ReadableEvent, out _accumulatedSuspendedTickChangedEventHandle) != KernelResult.Success)
  142. {
  143. throw new InvalidOperationException("Out of handles!");
  144. }
  145. }
  146. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_accumulatedSuspendedTickChangedEventHandle);
  147. return ResultCode.Success;
  148. }
  149. }
  150. }