ISelfController.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. using System.Collections.Generic;
  7. namespace Ryujinx.HLE.HOS.Services.Am
  8. {
  9. class ISelfController : IpcService
  10. {
  11. private Dictionary<int, ServiceProcessRequest> _commands;
  12. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
  13. private KEvent _launchableEvent;
  14. private int _idleTimeDetectionExtension;
  15. public ISelfController(Horizon system)
  16. {
  17. _commands = new Dictionary<int, ServiceProcessRequest>
  18. {
  19. { 0, Exit },
  20. { 1, LockExit },
  21. { 2, UnlockExit },
  22. { 9, GetLibraryAppletLaunchableEvent },
  23. { 10, SetScreenShotPermission },
  24. { 11, SetOperationModeChangedNotification },
  25. { 12, SetPerformanceModeChangedNotification },
  26. { 13, SetFocusHandlingMode },
  27. { 14, SetRestartMessageEnabled },
  28. { 16, SetOutOfFocusSuspendingEnabled },
  29. { 19, SetScreenShotImageOrientation },
  30. { 50, SetHandlesRequestToDisplay },
  31. { 62, SetIdleTimeDetectionExtension },
  32. { 63, GetIdleTimeDetectionExtension }
  33. };
  34. _launchableEvent = new KEvent(system);
  35. }
  36. public long Exit(ServiceCtx context)
  37. {
  38. Logger.PrintStub(LogClass.ServiceAm);
  39. return 0;
  40. }
  41. public long LockExit(ServiceCtx context)
  42. {
  43. Logger.PrintStub(LogClass.ServiceAm);
  44. return 0;
  45. }
  46. public long UnlockExit(ServiceCtx context)
  47. {
  48. Logger.PrintStub(LogClass.ServiceAm);
  49. return 0;
  50. }
  51. public long GetLibraryAppletLaunchableEvent(ServiceCtx context)
  52. {
  53. _launchableEvent.ReadableEvent.Signal();
  54. if (context.Process.HandleTable.GenerateHandle(_launchableEvent.ReadableEvent, out int handle) != KernelResult.Success)
  55. {
  56. throw new InvalidOperationException("Out of handles!");
  57. }
  58. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
  59. Logger.PrintStub(LogClass.ServiceAm);
  60. return 0;
  61. }
  62. public long SetScreenShotPermission(ServiceCtx context)
  63. {
  64. bool enable = context.RequestData.ReadByte() != 0;
  65. Logger.PrintStub(LogClass.ServiceAm);
  66. return 0;
  67. }
  68. public long SetOperationModeChangedNotification(ServiceCtx context)
  69. {
  70. bool enable = context.RequestData.ReadByte() != 0;
  71. Logger.PrintStub(LogClass.ServiceAm);
  72. return 0;
  73. }
  74. public long SetPerformanceModeChangedNotification(ServiceCtx context)
  75. {
  76. bool enable = context.RequestData.ReadByte() != 0;
  77. Logger.PrintStub(LogClass.ServiceAm);
  78. return 0;
  79. }
  80. public long SetFocusHandlingMode(ServiceCtx context)
  81. {
  82. bool flag1 = context.RequestData.ReadByte() != 0;
  83. bool flag2 = context.RequestData.ReadByte() != 0;
  84. bool flag3 = context.RequestData.ReadByte() != 0;
  85. Logger.PrintStub(LogClass.ServiceAm);
  86. return 0;
  87. }
  88. public long SetRestartMessageEnabled(ServiceCtx context)
  89. {
  90. bool enable = context.RequestData.ReadByte() != 0;
  91. Logger.PrintStub(LogClass.ServiceAm);
  92. return 0;
  93. }
  94. public long SetOutOfFocusSuspendingEnabled(ServiceCtx context)
  95. {
  96. bool enable = context.RequestData.ReadByte() != 0;
  97. Logger.PrintStub(LogClass.ServiceAm);
  98. return 0;
  99. }
  100. public long SetScreenShotImageOrientation(ServiceCtx context)
  101. {
  102. int orientation = context.RequestData.ReadInt32();
  103. Logger.PrintStub(LogClass.ServiceAm);
  104. return 0;
  105. }
  106. public long SetHandlesRequestToDisplay(ServiceCtx context)
  107. {
  108. bool enable = context.RequestData.ReadByte() != 0;
  109. Logger.PrintStub(LogClass.ServiceAm);
  110. return 0;
  111. }
  112. // SetIdleTimeDetectionExtension(u32)
  113. public long SetIdleTimeDetectionExtension(ServiceCtx context)
  114. {
  115. _idleTimeDetectionExtension = context.RequestData.ReadInt32();
  116. Logger.PrintStub(LogClass.ServiceAm, new { _idleTimeDetectionExtension });
  117. return 0;
  118. }
  119. // GetIdleTimeDetectionExtension() -> u32
  120. public long GetIdleTimeDetectionExtension(ServiceCtx context)
  121. {
  122. context.ResponseData.Write(_idleTimeDetectionExtension);
  123. Logger.PrintStub(LogClass.ServiceAm, new { _idleTimeDetectionExtension });
  124. return 0;
  125. }
  126. }
  127. }