SystemStateMgr.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using System;
  2. namespace Ryujinx.HLE.OsHle
  3. {
  4. public class SystemStateMgr
  5. {
  6. internal static string[] LanguageCodes = new string[]
  7. {
  8. "ja",
  9. "en-US",
  10. "fr",
  11. "de",
  12. "it",
  13. "es",
  14. "zh-CN",
  15. "ko",
  16. "nl",
  17. "pt",
  18. "ru",
  19. "zh-TW",
  20. "en-GB",
  21. "fr-CA",
  22. "es-419",
  23. "zh-Hans",
  24. "zh-Hant"
  25. };
  26. internal static string[] AudioOutputs = new string[]
  27. {
  28. "AudioTvOutput",
  29. "AudioStereoJackOutput",
  30. "AudioBuiltInSpeakerOutput"
  31. };
  32. internal long DesiredLanguageCode { get; private set; }
  33. internal string ActiveAudioOutput { get; private set; }
  34. public SystemStateMgr()
  35. {
  36. SetLanguage(SystemLanguage.AmericanEnglish);
  37. SetAudioOutputAsBuiltInSpeaker();
  38. }
  39. public void SetLanguage(SystemLanguage Language)
  40. {
  41. DesiredLanguageCode = GetLanguageCode((int)Language);
  42. }
  43. public void SetAudioOutputAsTv()
  44. {
  45. ActiveAudioOutput = AudioOutputs[0];
  46. }
  47. public void SetAudioOutputAsStereoJack()
  48. {
  49. ActiveAudioOutput = AudioOutputs[1];
  50. }
  51. public void SetAudioOutputAsBuiltInSpeaker()
  52. {
  53. ActiveAudioOutput = AudioOutputs[2];
  54. }
  55. internal static long GetLanguageCode(int Index)
  56. {
  57. if ((uint)Index >= LanguageCodes.Length)
  58. {
  59. throw new ArgumentOutOfRangeException(nameof(Index));
  60. }
  61. long Code = 0;
  62. int Shift = 0;
  63. foreach (char Chr in LanguageCodes[Index])
  64. {
  65. Code |= (long)(byte)Chr << Shift++ * 8;
  66. }
  67. return Code;
  68. }
  69. }
  70. }