ISelfController.cs 5.3 KB

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