IApplicationFunctions.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.HLE.HOS.Ipc;
  3. using System.Collections.Generic;
  4. namespace Ryujinx.HLE.HOS.Services.Am
  5. {
  6. class IApplicationFunctions : IpcService
  7. {
  8. private Dictionary<int, ServiceProcessRequest> _commands;
  9. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
  10. public IApplicationFunctions()
  11. {
  12. _commands = new Dictionary<int, ServiceProcessRequest>
  13. {
  14. { 1, PopLaunchParameter },
  15. { 20, EnsureSaveData },
  16. { 21, GetDesiredLanguage },
  17. { 22, SetTerminateResult },
  18. { 23, GetDisplayVersion },
  19. { 40, NotifyRunning },
  20. { 50, GetPseudoDeviceId },
  21. { 66, InitializeGamePlayRecording },
  22. { 67, SetGamePlayRecordingState }
  23. };
  24. }
  25. public long PopLaunchParameter(ServiceCtx context)
  26. {
  27. //Only the first 0x18 bytes of the Data seems to be actually used.
  28. MakeObject(context, new IStorage(StorageHelper.MakeLaunchParams()));
  29. return 0;
  30. }
  31. public long EnsureSaveData(ServiceCtx context)
  32. {
  33. long uIdLow = context.RequestData.ReadInt64();
  34. long uIdHigh = context.RequestData.ReadInt64();
  35. Logger.PrintStub(LogClass.ServiceAm);
  36. context.ResponseData.Write(0L);
  37. return 0;
  38. }
  39. public long GetDesiredLanguage(ServiceCtx context)
  40. {
  41. context.ResponseData.Write(context.Device.System.State.DesiredLanguageCode);
  42. return 0;
  43. }
  44. public long SetTerminateResult(ServiceCtx context)
  45. {
  46. int errorCode = context.RequestData.ReadInt32();
  47. string result = GetFormattedErrorCode(errorCode);
  48. Logger.PrintInfo(LogClass.ServiceAm, $"Result = 0x{errorCode:x8} ({result}).");
  49. return 0;
  50. }
  51. private string GetFormattedErrorCode(int errorCode)
  52. {
  53. int module = (errorCode >> 0) & 0x1ff;
  54. int description = (errorCode >> 9) & 0x1fff;
  55. return $"{(2000 + module):d4}-{description:d4}";
  56. }
  57. public long GetDisplayVersion(ServiceCtx context)
  58. {
  59. //FIXME: Need to check correct version on a switch.
  60. context.ResponseData.Write(1L);
  61. context.ResponseData.Write(0L);
  62. return 0;
  63. }
  64. public long NotifyRunning(ServiceCtx context)
  65. {
  66. context.ResponseData.Write(1);
  67. return 0;
  68. }
  69. public long GetPseudoDeviceId(ServiceCtx context)
  70. {
  71. Logger.PrintStub(LogClass.ServiceAm);
  72. context.ResponseData.Write(0L);
  73. context.ResponseData.Write(0L);
  74. return 0;
  75. }
  76. public long InitializeGamePlayRecording(ServiceCtx context)
  77. {
  78. Logger.PrintStub(LogClass.ServiceAm);
  79. return 0;
  80. }
  81. public long SetGamePlayRecordingState(ServiceCtx context)
  82. {
  83. int state = context.RequestData.ReadInt32();
  84. Logger.PrintStub(LogClass.ServiceAm);
  85. return 0;
  86. }
  87. }
  88. }