IHomeMenuFunctions.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 IHomeMenuFunctions : IpcService
  9. {
  10. private KEvent _channelEvent;
  11. private int _channelEventHandle;
  12. public IHomeMenuFunctions(Horizon system)
  13. {
  14. // TODO: Signal this Event somewhere in future.
  15. _channelEvent = new KEvent(system.KernelContext);
  16. }
  17. [CommandHipc(10)]
  18. // RequestToGetForeground()
  19. public ResultCode RequestToGetForeground(ServiceCtx context)
  20. {
  21. Logger.Stub?.PrintStub(LogClass.ServiceAm);
  22. return ResultCode.Success;
  23. }
  24. [CommandHipc(21)]
  25. // GetPopFromGeneralChannelEvent() -> handle<copy>
  26. public ResultCode GetPopFromGeneralChannelEvent(ServiceCtx context)
  27. {
  28. if (_channelEventHandle == 0)
  29. {
  30. if (context.Process.HandleTable.GenerateHandle(_channelEvent.ReadableEvent, out _channelEventHandle) != KernelResult.Success)
  31. {
  32. throw new InvalidOperationException("Out of handles!");
  33. }
  34. }
  35. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_channelEventHandle);
  36. Logger.Stub?.PrintStub(LogClass.ServiceAm);
  37. return ResultCode.Success;
  38. }
  39. }
  40. }