ISelfController.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. using Ryujinx.HLE.HOS.Ipc;
  2. using Ryujinx.HLE.HOS.Kernel;
  3. using Ryujinx.HLE.Logging;
  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. public ISelfController(Horizon System)
  14. {
  15. m_Commands = new Dictionary<int, ServiceProcessRequest>()
  16. {
  17. { 0, Exit },
  18. { 1, LockExit },
  19. { 2, UnlockExit },
  20. { 9, GetLibraryAppletLaunchableEvent },
  21. { 10, SetScreenShotPermission },
  22. { 11, SetOperationModeChangedNotification },
  23. { 12, SetPerformanceModeChangedNotification },
  24. { 13, SetFocusHandlingMode },
  25. { 14, SetRestartMessageEnabled },
  26. { 16, SetOutOfFocusSuspendingEnabled },
  27. { 19, SetScreenShotImageOrientation },
  28. { 50, SetHandlesRequestToDisplay }
  29. };
  30. LaunchableEvent = new KEvent(System);
  31. }
  32. public long Exit(ServiceCtx Context)
  33. {
  34. Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
  35. return 0;
  36. }
  37. public long LockExit(ServiceCtx Context)
  38. {
  39. Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
  40. return 0;
  41. }
  42. public long UnlockExit(ServiceCtx Context)
  43. {
  44. Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
  45. return 0;
  46. }
  47. public long GetLibraryAppletLaunchableEvent(ServiceCtx Context)
  48. {
  49. LaunchableEvent.ReadableEvent.Signal();
  50. if (Context.Process.HandleTable.GenerateHandle(LaunchableEvent.ReadableEvent, out int Handle) != KernelResult.Success)
  51. {
  52. throw new InvalidOperationException("Out of handles!");
  53. }
  54. Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
  55. Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
  56. return 0;
  57. }
  58. public long SetScreenShotPermission(ServiceCtx Context)
  59. {
  60. bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
  61. Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
  62. return 0;
  63. }
  64. public long SetOperationModeChangedNotification(ServiceCtx Context)
  65. {
  66. bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
  67. Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
  68. return 0;
  69. }
  70. public long SetPerformanceModeChangedNotification(ServiceCtx Context)
  71. {
  72. bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
  73. Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
  74. return 0;
  75. }
  76. public long SetFocusHandlingMode(ServiceCtx Context)
  77. {
  78. bool Flag1 = Context.RequestData.ReadByte() != 0 ? true : false;
  79. bool Flag2 = Context.RequestData.ReadByte() != 0 ? true : false;
  80. bool Flag3 = Context.RequestData.ReadByte() != 0 ? true : false;
  81. Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
  82. return 0;
  83. }
  84. public long SetRestartMessageEnabled(ServiceCtx Context)
  85. {
  86. bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
  87. Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
  88. return 0;
  89. }
  90. public long SetOutOfFocusSuspendingEnabled(ServiceCtx Context)
  91. {
  92. bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
  93. Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
  94. return 0;
  95. }
  96. public long SetScreenShotImageOrientation(ServiceCtx Context)
  97. {
  98. int Orientation = Context.RequestData.ReadInt32();
  99. Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
  100. return 0;
  101. }
  102. public long SetHandlesRequestToDisplay(ServiceCtx Context)
  103. {
  104. bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
  105. Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
  106. return 0;
  107. }
  108. }
  109. }