aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-04-29 20:18:46 -0300
committergdkchan <gab.dark.100@gmail.com>2018-04-29 20:18:46 -0300
commit071754aaeb1c9113c5818421b7cca1f3c717052a (patch)
treeb277c17580e3c0d9cf456d89ad715ee2a03e2333
parentf73a182b20970f993abc1f1329dfab1e5d3b3354 (diff)
Fix GetDesiredLanguage and expose a way to set the desired language, default to english
-rw-r--r--Ryujinx.Core/OsHle/Horizon.cs2
-rw-r--r--Ryujinx.Core/OsHle/Services/Am/IApplicationFunctions.cs6
-rw-r--r--Ryujinx.Core/OsHle/Services/Set/ISettingsServer.cs61
-rw-r--r--Ryujinx.Core/OsHle/SystemLanguage.cs23
-rw-r--r--Ryujinx.Core/OsHle/SystemStateMgr.cs54
5 files changed, 83 insertions, 63 deletions
diff --git a/Ryujinx.Core/OsHle/Horizon.cs b/Ryujinx.Core/OsHle/Horizon.cs
index 3b31bfc6..0cc3d815 100644
--- a/Ryujinx.Core/OsHle/Horizon.cs
+++ b/Ryujinx.Core/OsHle/Horizon.cs
@@ -18,7 +18,7 @@ namespace Ryujinx.Core.OsHle
private ConcurrentDictionary<int, Process> Processes;
- internal SystemStateMgr SystemState { get; private set; }
+ public SystemStateMgr SystemState { get; private set; }
internal HSharedMem HidSharedMem { get; private set; }
internal HSharedMem FontSharedMem { get; private set; }
diff --git a/Ryujinx.Core/OsHle/Services/Am/IApplicationFunctions.cs b/Ryujinx.Core/OsHle/Services/Am/IApplicationFunctions.cs
index 8433f9d5..47152cd9 100644
--- a/Ryujinx.Core/OsHle/Services/Am/IApplicationFunctions.cs
+++ b/Ryujinx.Core/OsHle/Services/Am/IApplicationFunctions.cs
@@ -48,11 +48,7 @@ namespace Ryujinx.Core.OsHle.Services.Am
public long GetDesiredLanguage(ServiceCtx Context)
{
- Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
-
- //This is an enumerator where each number is a differnet language.
- //0 is Japanese and 1 is English, need to figure out the other codes.
- Context.ResponseData.Write(1L);
+ Context.ResponseData.Write(Context.Ns.Os.SystemState.DesiredLanguageCode);
return 0;
}
diff --git a/Ryujinx.Core/OsHle/Services/Set/ISettingsServer.cs b/Ryujinx.Core/OsHle/Services/Set/ISettingsServer.cs
index ea0303f0..c80de80c 100644
--- a/Ryujinx.Core/OsHle/Services/Set/ISettingsServer.cs
+++ b/Ryujinx.Core/OsHle/Services/Set/ISettingsServer.cs
@@ -1,33 +1,10 @@
using Ryujinx.Core.OsHle.Ipc;
-using System;
using System.Collections.Generic;
-using System.IO;
namespace Ryujinx.Core.OsHle.Services.Set
{
class ISettingsServer : IpcService
{
- private 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"
- };
-
private Dictionary<int, ServiceProcessRequest> m_Commands;
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
@@ -44,29 +21,11 @@ namespace Ryujinx.Core.OsHle.Services.Set
public static long GetLanguageCode(ServiceCtx Context)
{
- Context.ResponseData.Write(LanguageCodetoLongBE(LanguageCodes[1]));
+ Context.ResponseData.Write(Context.Ns.Os.SystemState.DesiredLanguageCode);
return 0;
}
- private static long LanguageCodetoLongBE(string LanguageCode)
- {
- using (MemoryStream MS = new MemoryStream())
- {
- foreach (char Chr in LanguageCode)
- {
- MS.WriteByte((byte)Chr);
- }
-
- for (int Offs = 0; Offs < (8 - LanguageCode.Length); Offs++)
- {
- MS.WriteByte(0);
- }
-
- return BitConverter.ToInt64(MS.ToArray(), 0);
- }
- }
-
public static long GetAvailableLanguageCodes(ServiceCtx Context)
{
long Position = Context.Request.RecvListBuff[0].Position;
@@ -74,24 +33,16 @@ namespace Ryujinx.Core.OsHle.Services.Set
int Count = (int)((uint)Size / 8);
- if (Count > LanguageCodes.Length)
+ if (Count > SystemStateMgr.LanguageCodes.Length)
{
- Count = LanguageCodes.Length;
+ Count = SystemStateMgr.LanguageCodes.Length;
}
for (int Index = 0; Index < Count; Index++)
{
- string LanguageCode = LanguageCodes[Index];
-
- foreach (char Chr in LanguageCode)
- {
- Context.Memory.WriteByte(Position++, (byte)Chr);
- }
+ Context.Memory.WriteInt64(Position, SystemStateMgr.GetLanguageCode(Index));
- for (int Offs = 0; Offs < (8 - LanguageCode.Length); Offs++)
- {
- Context.Memory.WriteByte(Position++, 0);
- }
+ Position += 8;
}
Context.ResponseData.Write(Count);
@@ -101,7 +52,7 @@ namespace Ryujinx.Core.OsHle.Services.Set
public static long GetAvailableLanguageCodeCount(ServiceCtx Context)
{
- Context.ResponseData.Write(LanguageCodes.Length);
+ Context.ResponseData.Write(SystemStateMgr.LanguageCodes.Length);
return 0;
}
diff --git a/Ryujinx.Core/OsHle/SystemLanguage.cs b/Ryujinx.Core/OsHle/SystemLanguage.cs
new file mode 100644
index 00000000..470362c0
--- /dev/null
+++ b/Ryujinx.Core/OsHle/SystemLanguage.cs
@@ -0,0 +1,23 @@
+namespace Ryujinx.Core.OsHle
+{
+ public enum SystemLanguage
+ {
+ Japanese,
+ AmericanEnglish,
+ French,
+ German,
+ Italian,
+ Spanish,
+ Chinese,
+ Korean,
+ Dutch,
+ Portuguese,
+ Russian,
+ Taiwanese,
+ BritishEnglish,
+ CanadianFrench,
+ LatinAmericanSpanish,
+ SimplifiedChinese,
+ TraditionalChinese
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Core/OsHle/SystemStateMgr.cs b/Ryujinx.Core/OsHle/SystemStateMgr.cs
index 3223abfb..0756c7d1 100644
--- a/Ryujinx.Core/OsHle/SystemStateMgr.cs
+++ b/Ryujinx.Core/OsHle/SystemStateMgr.cs
@@ -1,7 +1,30 @@
+using System;
+
namespace Ryujinx.Core.OsHle
{
- class SystemStateMgr
+ 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"
+ };
+
internal static string[] AudioOutputs = new string[]
{
"AudioTvOutput",
@@ -9,13 +32,22 @@ namespace Ryujinx.Core.OsHle
"AudioBuiltInSpeakerOutput"
};
- public string ActiveAudioOutput { get; private set; }
+ internal long DesiredLanguageCode { get; private set; }
+
+ internal string ActiveAudioOutput { get; private set; }
public SystemStateMgr()
{
+ SetLanguage(SystemLanguage.AmericanEnglish);
+
SetAudioOutputAsBuiltInSpeaker();
}
+ public void SetLanguage(SystemLanguage Language)
+ {
+ DesiredLanguageCode = GetLanguageCode((int)Language);
+ }
+
public void SetAudioOutputAsTv()
{
ActiveAudioOutput = AudioOutputs[0];
@@ -30,5 +62,23 @@ namespace Ryujinx.Core.OsHle
{
ActiveAudioOutput = AudioOutputs[2];
}
+
+ 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