ISettingsServer.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using Ryujinx.Core.OsHle.Ipc;
  2. using System.Collections.Generic;
  3. namespace Ryujinx.Core.OsHle.Services.Set
  4. {
  5. class ISettingsServer : IpcService
  6. {
  7. private Dictionary<int, ServiceProcessRequest> m_Commands;
  8. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
  9. public ISettingsServer()
  10. {
  11. m_Commands = new Dictionary<int, ServiceProcessRequest>()
  12. {
  13. { 0, GetLanguageCode },
  14. { 1, GetAvailableLanguageCodes },
  15. { 3, GetAvailableLanguageCodeCount }
  16. };
  17. }
  18. public static long GetLanguageCode(ServiceCtx Context)
  19. {
  20. Context.ResponseData.Write(Context.Ns.Os.SystemState.DesiredLanguageCode);
  21. return 0;
  22. }
  23. public static long GetAvailableLanguageCodes(ServiceCtx Context)
  24. {
  25. long Position = Context.Request.RecvListBuff[0].Position;
  26. short Size = Context.Request.RecvListBuff[0].Size;
  27. int Count = (int)((uint)Size / 8);
  28. if (Count > SystemStateMgr.LanguageCodes.Length)
  29. {
  30. Count = SystemStateMgr.LanguageCodes.Length;
  31. }
  32. for (int Index = 0; Index < Count; Index++)
  33. {
  34. Context.Memory.WriteInt64(Position, SystemStateMgr.GetLanguageCode(Index));
  35. Position += 8;
  36. }
  37. Context.ResponseData.Write(Count);
  38. return 0;
  39. }
  40. public static long GetAvailableLanguageCodeCount(ServiceCtx Context)
  41. {
  42. Context.ResponseData.Write(SystemStateMgr.LanguageCodes.Length);
  43. return 0;
  44. }
  45. }
  46. }