IHomeMenuFunctions.cs 1.5 KB

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