Archived
1
0
Fork 0
forked from Mirror/Ryujinx

Fix GetDesiredLanguage and expose a way to set the desired language, default to english

This commit is contained in:
gdkchan 2018-04-29 20:18:46 -03:00
parent f73a182b20
commit 071754aaeb
5 changed files with 83 additions and 63 deletions

View file

@ -18,7 +18,7 @@ namespace Ryujinx.Core.OsHle
private ConcurrentDictionary<int, Process> Processes; 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 HidSharedMem { get; private set; }
internal HSharedMem FontSharedMem { get; private set; } internal HSharedMem FontSharedMem { get; private set; }

View file

@ -48,11 +48,7 @@ namespace Ryujinx.Core.OsHle.Services.Am
public long GetDesiredLanguage(ServiceCtx Context) public long GetDesiredLanguage(ServiceCtx Context)
{ {
Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed."); Context.ResponseData.Write(Context.Ns.Os.SystemState.DesiredLanguageCode);
//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);
return 0; return 0;
} }

View file

@ -1,33 +1,10 @@
using Ryujinx.Core.OsHle.Ipc; using Ryujinx.Core.OsHle.Ipc;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
namespace Ryujinx.Core.OsHle.Services.Set namespace Ryujinx.Core.OsHle.Services.Set
{ {
class ISettingsServer : IpcService 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; private Dictionary<int, ServiceProcessRequest> m_Commands;
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => 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) public static long GetLanguageCode(ServiceCtx Context)
{ {
Context.ResponseData.Write(LanguageCodetoLongBE(LanguageCodes[1])); Context.ResponseData.Write(Context.Ns.Os.SystemState.DesiredLanguageCode);
return 0; 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) public static long GetAvailableLanguageCodes(ServiceCtx Context)
{ {
long Position = Context.Request.RecvListBuff[0].Position; long Position = Context.Request.RecvListBuff[0].Position;
@ -74,24 +33,16 @@ namespace Ryujinx.Core.OsHle.Services.Set
int Count = (int)((uint)Size / 8); 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++) for (int Index = 0; Index < Count; Index++)
{ {
string LanguageCode = LanguageCodes[Index]; Context.Memory.WriteInt64(Position, SystemStateMgr.GetLanguageCode(Index));
foreach (char Chr in LanguageCode) Position += 8;
{
Context.Memory.WriteByte(Position++, (byte)Chr);
}
for (int Offs = 0; Offs < (8 - LanguageCode.Length); Offs++)
{
Context.Memory.WriteByte(Position++, 0);
}
} }
Context.ResponseData.Write(Count); Context.ResponseData.Write(Count);
@ -101,7 +52,7 @@ namespace Ryujinx.Core.OsHle.Services.Set
public static long GetAvailableLanguageCodeCount(ServiceCtx Context) public static long GetAvailableLanguageCodeCount(ServiceCtx Context)
{ {
Context.ResponseData.Write(LanguageCodes.Length); Context.ResponseData.Write(SystemStateMgr.LanguageCodes.Length);
return 0; return 0;
} }

View file

@ -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
}
}

View file

@ -1,7 +1,30 @@
using System;
namespace Ryujinx.Core.OsHle 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[] internal static string[] AudioOutputs = new string[]
{ {
"AudioTvOutput", "AudioTvOutput",
@ -9,13 +32,22 @@ namespace Ryujinx.Core.OsHle
"AudioBuiltInSpeakerOutput" "AudioBuiltInSpeakerOutput"
}; };
public string ActiveAudioOutput { get; private set; } internal long DesiredLanguageCode { get; private set; }
internal string ActiveAudioOutput { get; private set; }
public SystemStateMgr() public SystemStateMgr()
{ {
SetLanguage(SystemLanguage.AmericanEnglish);
SetAudioOutputAsBuiltInSpeaker(); SetAudioOutputAsBuiltInSpeaker();
} }
public void SetLanguage(SystemLanguage Language)
{
DesiredLanguageCode = GetLanguageCode((int)Language);
}
public void SetAudioOutputAsTv() public void SetAudioOutputAsTv()
{ {
ActiveAudioOutput = AudioOutputs[0]; ActiveAudioOutput = AudioOutputs[0];
@ -30,5 +62,23 @@ namespace Ryujinx.Core.OsHle
{ {
ActiveAudioOutput = AudioOutputs[2]; 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;
}
} }
} }