ICommonStateGetter.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using Ryujinx.Core.OsHle.Ipc;
  2. using System.Collections.Generic;
  3. namespace Ryujinx.Core.OsHle.Objects.Am
  4. {
  5. class ICommonStateGetter : IIpcInterface
  6. {
  7. private Dictionary<int, ServiceProcessRequest> m_Commands;
  8. public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
  9. public ICommonStateGetter()
  10. {
  11. m_Commands = new Dictionary<int, ServiceProcessRequest>()
  12. {
  13. { 0, GetEventHandle },
  14. { 1, ReceiveMessage },
  15. { 5, GetOperationMode },
  16. { 6, GetPerformanceMode },
  17. { 9, GetCurrentFocusState },
  18. };
  19. }
  20. private enum FocusState
  21. {
  22. InFocus = 1,
  23. OutOfFocus = 2
  24. }
  25. private enum OperationMode
  26. {
  27. Handheld = 0,
  28. Docked = 1
  29. }
  30. public long GetEventHandle(ServiceCtx Context)
  31. {
  32. Context.ResponseData.Write(0L);
  33. return 0;
  34. }
  35. public long ReceiveMessage(ServiceCtx Context)
  36. {
  37. //Program expects 0xF at 0x17ae70 on puyo sdk,
  38. //otherwise runs on a infinite loop until it reads said value.
  39. //What it means is still unknown.
  40. Context.ResponseData.Write(0xfL);
  41. return 0; //0x680;
  42. }
  43. public long GetOperationMode(ServiceCtx Context)
  44. {
  45. Context.ResponseData.Write((byte)OperationMode.Handheld);
  46. return 0;
  47. }
  48. public long GetPerformanceMode(ServiceCtx Context)
  49. {
  50. Context.ResponseData.Write((byte)0);
  51. return 0;
  52. }
  53. public long GetCurrentFocusState(ServiceCtx Context)
  54. {
  55. Context.ResponseData.Write((byte)FocusState.InFocus);
  56. return 0;
  57. }
  58. }
  59. }