diff options
| author | TSR Berry <20988865+TSRBerry@users.noreply.github.com> | 2023-04-08 01:22:00 +0200 |
|---|---|---|
| committer | Mary <thog@protonmail.com> | 2023-04-27 23:51:14 +0200 |
| commit | cee712105850ac3385cd0091a923438167433f9f (patch) | |
| tree | 4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /src/Ryujinx.HLE/HOS/SystemState | |
| parent | cd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff) | |
Move solution and projects to src
Diffstat (limited to 'src/Ryujinx.HLE/HOS/SystemState')
| -rw-r--r-- | src/Ryujinx.HLE/HOS/SystemState/AppletStateMgr.cs | 42 | ||||
| -rw-r--r-- | src/Ryujinx.HLE/HOS/SystemState/ColorSet.cs | 8 | ||||
| -rw-r--r-- | src/Ryujinx.HLE/HOS/SystemState/KeyboardLayout.cs | 25 | ||||
| -rw-r--r-- | src/Ryujinx.HLE/HOS/SystemState/RegionCode.cs | 17 | ||||
| -rw-r--r-- | src/Ryujinx.HLE/HOS/SystemState/SystemLanguage.cs | 24 | ||||
| -rw-r--r-- | src/Ryujinx.HLE/HOS/SystemState/SystemStateMgr.cs | 90 | ||||
| -rw-r--r-- | src/Ryujinx.HLE/HOS/SystemState/TitleLanguage.cs | 22 |
7 files changed, 228 insertions, 0 deletions
diff --git a/src/Ryujinx.HLE/HOS/SystemState/AppletStateMgr.cs b/src/Ryujinx.HLE/HOS/SystemState/AppletStateMgr.cs new file mode 100644 index 00000000..5704ef4b --- /dev/null +++ b/src/Ryujinx.HLE/HOS/SystemState/AppletStateMgr.cs @@ -0,0 +1,42 @@ +using Ryujinx.HLE.HOS.Kernel.Threading; +using Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy; +using System.Collections.Concurrent; + +namespace Ryujinx.HLE.HOS.SystemState +{ + class AppletStateMgr + { + public ConcurrentQueue<AppletMessage> Messages { get; } + + public FocusState FocusState { get; private set; } + + public KEvent MessageEvent { get; } + + public IdDictionary AppletResourceUserIds { get; } + + public IdDictionary IndirectLayerHandles { get; } + + public AppletStateMgr(Horizon system) + { + Messages = new ConcurrentQueue<AppletMessage>(); + MessageEvent = new KEvent(system.KernelContext); + + AppletResourceUserIds = new IdDictionary(); + IndirectLayerHandles = new IdDictionary(); + } + + public void SetFocus(bool isFocused) + { + FocusState = isFocused ? FocusState.InFocus : FocusState.OutOfFocus; + + Messages.Enqueue(AppletMessage.FocusStateChanged); + + if (isFocused) + { + Messages.Enqueue(AppletMessage.ChangeIntoForeground); + } + + MessageEvent.ReadableEvent.Signal(); + } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/SystemState/ColorSet.cs b/src/Ryujinx.HLE/HOS/SystemState/ColorSet.cs new file mode 100644 index 00000000..4d7a7e2f --- /dev/null +++ b/src/Ryujinx.HLE/HOS/SystemState/ColorSet.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.HLE.HOS.SystemState +{ + public enum ColorSet + { + BasicWhite = 0, + BasicBlack = 1 + } +} diff --git a/src/Ryujinx.HLE/HOS/SystemState/KeyboardLayout.cs b/src/Ryujinx.HLE/HOS/SystemState/KeyboardLayout.cs new file mode 100644 index 00000000..ba35ea6b --- /dev/null +++ b/src/Ryujinx.HLE/HOS/SystemState/KeyboardLayout.cs @@ -0,0 +1,25 @@ +namespace Ryujinx.HLE.HOS.SystemState +{ + // nn::settings::KeyboardLayout + public enum KeyboardLayout + { + Default = 0, + EnglishUs, + EnglishUsInternational, + EnglishUk, + French, + FrenchCa, + Spanish, + SpanishLatin, + German, + Italian, + Portuguese, + Russian, + Korean, + ChineseSimplified, + ChineseTraditional, + + Min = Default, + Max = ChineseTraditional + } +} diff --git a/src/Ryujinx.HLE/HOS/SystemState/RegionCode.cs b/src/Ryujinx.HLE/HOS/SystemState/RegionCode.cs new file mode 100644 index 00000000..dd6ed8fa --- /dev/null +++ b/src/Ryujinx.HLE/HOS/SystemState/RegionCode.cs @@ -0,0 +1,17 @@ +namespace Ryujinx.HLE.HOS.SystemState +{ + // nn::settings::RegionCode + public enum RegionCode + { + Japan, + USA, + Europe, + Australia, + China, + Korea, + Taiwan, + + Min = Japan, + Max = Taiwan + } +} diff --git a/src/Ryujinx.HLE/HOS/SystemState/SystemLanguage.cs b/src/Ryujinx.HLE/HOS/SystemState/SystemLanguage.cs new file mode 100644 index 00000000..3f755105 --- /dev/null +++ b/src/Ryujinx.HLE/HOS/SystemState/SystemLanguage.cs @@ -0,0 +1,24 @@ +namespace Ryujinx.HLE.HOS.SystemState +{ + public enum SystemLanguage + { + Japanese, + AmericanEnglish, + French, + German, + Italian, + Spanish, + Chinese, + Korean, + Dutch, + Portuguese, + Russian, + Taiwanese, + BritishEnglish, + CanadianFrench, + LatinAmericanSpanish, + SimplifiedChinese, + TraditionalChinese, + BrazilianPortuguese + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/SystemState/SystemStateMgr.cs b/src/Ryujinx.HLE/HOS/SystemState/SystemStateMgr.cs new file mode 100644 index 00000000..6627700f --- /dev/null +++ b/src/Ryujinx.HLE/HOS/SystemState/SystemStateMgr.cs @@ -0,0 +1,90 @@ +using System; + +namespace Ryujinx.HLE.HOS.SystemState +{ + public class SystemStateMgr + { + internal static string[] LanguageCodes = new string[] + { + "ja", + "en-US", + "fr", + "de", + "it", + "es", + "zh-CN", + "ko", + "nl", + "pt", + "ru", + "zh-TW", + "en-GB", + "fr-CA", + "es-419", + "zh-Hans", + "zh-Hant", + "pt-BR" + }; + + internal long DesiredKeyboardLayout { get; private set; } + + internal SystemLanguage DesiredSystemLanguage { get; private set; } + + internal long DesiredLanguageCode { get; private set; } + + internal uint DesiredRegionCode { get; private set; } + + public TitleLanguage DesiredTitleLanguage { get; private set; } + + public bool DockedMode { get; set; } + + public ColorSet ThemeColor { get; set; } + + public string DeviceNickName { get; set; } + + public SystemStateMgr() + { + // TODO: Let user specify fields. + DesiredKeyboardLayout = (long)KeyboardLayout.Default; + DeviceNickName = "Ryujinx's Switch"; + } + + public void SetLanguage(SystemLanguage language) + { + DesiredSystemLanguage = language; + DesiredLanguageCode = GetLanguageCode((int)DesiredSystemLanguage); + + DesiredTitleLanguage = language switch + { + SystemLanguage.Taiwanese or + SystemLanguage.TraditionalChinese => TitleLanguage.TraditionalChinese, + SystemLanguage.Chinese or + SystemLanguage.SimplifiedChinese => TitleLanguage.SimplifiedChinese, + _ => Enum.Parse<TitleLanguage>(Enum.GetName<SystemLanguage>(language)), + }; + } + + public void SetRegion(RegionCode region) + { + DesiredRegionCode = (uint)region; + } + + internal static long GetLanguageCode(int index) + { + if ((uint)index >= LanguageCodes.Length) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + + long code = 0; + int shift = 0; + + foreach (char chr in LanguageCodes[index]) + { + code |= (long)(byte)chr << shift++ * 8; + } + + return code; + } + } +}
\ No newline at end of file diff --git a/src/Ryujinx.HLE/HOS/SystemState/TitleLanguage.cs b/src/Ryujinx.HLE/HOS/SystemState/TitleLanguage.cs new file mode 100644 index 00000000..c612259b --- /dev/null +++ b/src/Ryujinx.HLE/HOS/SystemState/TitleLanguage.cs @@ -0,0 +1,22 @@ +namespace Ryujinx.HLE.HOS.SystemState +{ + public enum TitleLanguage + { + AmericanEnglish, + BritishEnglish, + Japanese, + French, + German, + LatinAmericanSpanish, + Spanish, + Italian, + Dutch, + CanadianFrench, + Portuguese, + Russian, + Korean, + TraditionalChinese, + SimplifiedChinese, + BrazilianPortuguese + } +} |
