ISettingsServer.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using Ryujinx.HLE.OsHle.Ipc;
  2. using System.Collections.Generic;
  3. namespace Ryujinx.HLE.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. { 5, GetAvailableLanguageCodes2 }
  17. };
  18. }
  19. public static long GetLanguageCode(ServiceCtx Context)
  20. {
  21. Context.ResponseData.Write(Context.Ns.Os.SystemState.DesiredLanguageCode);
  22. return 0;
  23. }
  24. public static long GetAvailableLanguageCodes(ServiceCtx Context)
  25. {
  26. GetAvailableLanguagesCodesImpl(
  27. Context,
  28. Context.Request.RecvListBuff[0].Position,
  29. Context.Request.RecvListBuff[0].Size);
  30. return 0;
  31. }
  32. public static long GetAvailableLanguageCodeCount(ServiceCtx Context)
  33. {
  34. Context.ResponseData.Write(SystemStateMgr.LanguageCodes.Length);
  35. return 0;
  36. }
  37. public static long GetAvailableLanguageCodes2(ServiceCtx Context)
  38. {
  39. GetAvailableLanguagesCodesImpl(
  40. Context,
  41. Context.Request.ReceiveBuff[0].Position,
  42. Context.Request.ReceiveBuff[0].Size);
  43. return 0;
  44. }
  45. public static long GetAvailableLanguagesCodesImpl(ServiceCtx Context, long Position, long Size)
  46. {
  47. int Count = (int)(Size / 8);
  48. if (Count > SystemStateMgr.LanguageCodes.Length)
  49. {
  50. Count = SystemStateMgr.LanguageCodes.Length;
  51. }
  52. for (int Index = 0; Index < Count; Index++)
  53. {
  54. Context.Memory.WriteInt64(Position, SystemStateMgr.GetLanguageCode(Index));
  55. Position += 8;
  56. }
  57. Context.ResponseData.Write(Count);
  58. return 0;
  59. }
  60. }
  61. }