ISettingsServer.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using Ryujinx.HLE.HOS.Ipc;
  2. using Ryujinx.HLE.HOS.SystemState;
  3. using System.Collections.Generic;
  4. namespace Ryujinx.HLE.HOS.Services.Set
  5. {
  6. class ISettingsServer : IpcService
  7. {
  8. private Dictionary<int, ServiceProcessRequest> _commands;
  9. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
  10. public ISettingsServer()
  11. {
  12. _commands = new Dictionary<int, ServiceProcessRequest>
  13. {
  14. { 0, GetLanguageCode },
  15. { 1, GetAvailableLanguageCodes },
  16. { 3, GetAvailableLanguageCodeCount },
  17. { 5, GetAvailableLanguageCodes2 }
  18. };
  19. }
  20. public static long GetLanguageCode(ServiceCtx context)
  21. {
  22. context.ResponseData.Write(context.Device.System.State.DesiredLanguageCode);
  23. return 0;
  24. }
  25. public static long GetAvailableLanguageCodes(ServiceCtx context)
  26. {
  27. GetAvailableLanguagesCodesImpl(
  28. context,
  29. context.Request.RecvListBuff[0].Position,
  30. context.Request.RecvListBuff[0].Size);
  31. return 0;
  32. }
  33. public static long GetAvailableLanguageCodeCount(ServiceCtx context)
  34. {
  35. context.ResponseData.Write(SystemStateMgr.LanguageCodes.Length);
  36. return 0;
  37. }
  38. public static long GetAvailableLanguageCodes2(ServiceCtx context)
  39. {
  40. GetAvailableLanguagesCodesImpl(
  41. context,
  42. context.Request.ReceiveBuff[0].Position,
  43. context.Request.ReceiveBuff[0].Size);
  44. return 0;
  45. }
  46. public static long GetAvailableLanguagesCodesImpl(ServiceCtx context, long position, long size)
  47. {
  48. int count = (int)(size / 8);
  49. if (count > SystemStateMgr.LanguageCodes.Length)
  50. {
  51. count = SystemStateMgr.LanguageCodes.Length;
  52. }
  53. for (int index = 0; index < count; index++)
  54. {
  55. context.Memory.WriteInt64(position, SystemStateMgr.GetLanguageCode(index));
  56. position += 8;
  57. }
  58. context.ResponseData.Write(count);
  59. return 0;
  60. }
  61. }
  62. }