SystemStateMgr.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using Ryujinx.HLE.Loaders.Npdm;
  2. using System;
  3. namespace Ryujinx.HLE.OsHle
  4. {
  5. public class SystemStateMgr
  6. {
  7. internal 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. internal static string[] AudioOutputs = new string[]
  28. {
  29. "AudioTvOutput",
  30. "AudioStereoJackOutput",
  31. "AudioBuiltInSpeakerOutput"
  32. };
  33. internal long DesiredLanguageCode { get; private set; }
  34. internal string ActiveAudioOutput { get; private set; }
  35. public SystemStateMgr()
  36. {
  37. SetLanguage(SystemLanguage.AmericanEnglish);
  38. SetAudioOutputAsBuiltInSpeaker();
  39. }
  40. public void SetLanguage(SystemLanguage Language)
  41. {
  42. DesiredLanguageCode = GetLanguageCode((int)Language);
  43. }
  44. public void SetAudioOutputAsTv()
  45. {
  46. ActiveAudioOutput = AudioOutputs[0];
  47. }
  48. public void SetAudioOutputAsStereoJack()
  49. {
  50. ActiveAudioOutput = AudioOutputs[1];
  51. }
  52. public void SetAudioOutputAsBuiltInSpeaker()
  53. {
  54. ActiveAudioOutput = AudioOutputs[2];
  55. }
  56. internal static long GetLanguageCode(int Index)
  57. {
  58. if ((uint)Index >= LanguageCodes.Length)
  59. {
  60. throw new ArgumentOutOfRangeException(nameof(Index));
  61. }
  62. long Code = 0;
  63. int Shift = 0;
  64. foreach (char Chr in LanguageCodes[Index])
  65. {
  66. Code |= (long)(byte)Chr << Shift++ * 8;
  67. }
  68. return Code;
  69. }
  70. }
  71. }