IApplicationFunctions.cs 3.5 KB

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