mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-11-25 19:45:13 +00:00
Fix GetDesiredLanguage and expose a way to set the desired language, default to english
This commit is contained in:
parent
f73a182b20
commit
071754aaeb
5 changed files with 83 additions and 63 deletions
|
@ -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; }
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
Context.Memory.WriteInt64(Position, SystemStateMgr.GetLanguageCode(Index));
|
||||
|
||||
foreach (char Chr in LanguageCode)
|
||||
{
|
||||
Context.Memory.WriteByte(Position++, (byte)Chr);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
23
Ryujinx.Core/OsHle/SystemLanguage.cs
Normal file
23
Ryujinx.Core/OsHle/SystemLanguage.cs
Normal 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
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue