ISettingsServer.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 static string[] LanguageCodes = new string[]
  8. {
  9. "ja",
  10. "en-US",
  11. "fr",
  12. "de",
  13. "it",
  14. "es",
  15. "zh-CN",
  16. "ko",
  17. "nl",
  18. "pt",
  19. "ru",
  20. "zh-TW",
  21. "en-GB",
  22. "fr-CA",
  23. "es-419",
  24. "zh-Hans",
  25. "zh-Hant"
  26. };
  27. private Dictionary<int, ServiceProcessRequest> m_Commands;
  28. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
  29. public ISettingsServer()
  30. {
  31. m_Commands = new Dictionary<int, ServiceProcessRequest>()
  32. {
  33. { 1, GetAvailableLanguageCodes },
  34. { 3, GetAvailableLanguageCodeCount }
  35. };
  36. }
  37. public static long GetAvailableLanguageCodes(ServiceCtx Context)
  38. {
  39. long Position = Context.Request.RecvListBuff[0].Position;
  40. short Size = Context.Request.RecvListBuff[0].Size;
  41. int Count = (int)((uint)Size / 8);
  42. if (Count > LanguageCodes.Length)
  43. {
  44. Count = LanguageCodes.Length;
  45. }
  46. for (int Index = 0; Index < Count; Index++)
  47. {
  48. string LanguageCode = LanguageCodes[Index];
  49. foreach (char Chr in LanguageCode)
  50. {
  51. Context.Memory.WriteByte(Position++, (byte)Chr);
  52. }
  53. for (int Offs = 0; Offs < (8 - LanguageCode.Length); Offs++)
  54. {
  55. Context.Memory.WriteByte(Position++, 0);
  56. }
  57. }
  58. Context.ResponseData.Write(Count);
  59. return 0;
  60. }
  61. public static long GetAvailableLanguageCodeCount(ServiceCtx Context)
  62. {
  63. Context.ResponseData.Write(LanguageCodes.Length);
  64. return 0;
  65. }
  66. }
  67. }