IApplicationFunctions.cs 3.3 KB

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