Update ISystemSettingsServer.cs

Implement `GetSettingsItemValue`.
This commit is contained in:
Ac_K 2018-04-25 20:41:56 +02:00 committed by GitHub
parent e4f59c8a52
commit dadd5e8102
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,9 +17,10 @@ namespace Ryujinx.Core.OsHle.Services.Set
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 4, GetFirmwareVersion2 },
{ 23, GetColorSetId },
{ 24, SetColorSetId }
{ 4, GetFirmwareVersion2 },
{ 23, GetColorSetId },
{ 24, SetColorSetId },
{ 38, GetSettingsItemValue }
};
}
@ -83,5 +84,55 @@ namespace Ryujinx.Core.OsHle.Services.Set
Context.Ns.Settings.ThemeColor = (ColorSet)ColorSetId;
return 0;
}
public static long GetSettingsItemValue(ServiceCtx Context)
{
long ClassPos = Context.Request.PtrBuff[0].Position;
long ClassSize = Context.Request.PtrBuff[0].Size;
long NamePos = Context.Request.PtrBuff[1].Position;
long NameSize = Context.Request.PtrBuff[1].Size;
long ReplyPos = Context.Request.ReceiveBuff[0].Position;
long ReplySize = Context.Request.ReceiveBuff[0].Size;
byte[] Class = AMemoryHelper.ReadBytes(Context.Memory, ClassPos, ClassSize);
byte[] Name = AMemoryHelper.ReadBytes(Context.Memory, NamePos, NameSize);
string AskedSetting = Encoding.ASCII.GetString(Class).Trim('\0') + "!" + Encoding.ASCII.GetString(Name).Trim('\0');
NxSettings.Settings.TryGetValue(AskedSetting, out object NxSetting);
if (NxSetting != null)
{
byte[] SettingBuffer = new byte[ReplySize];
if (NxSetting is string StringValue)
{
//Ain't be able to test, so we need to know what the size of ReplySize is...
//Array.Resize(ref SettingBuffer, StringValue.Length);
SettingBuffer = Encoding.ASCII.GetBytes(StringValue);
}
if (NxSetting is int IntValue)
{
SettingBuffer = BitConverter.GetBytes(IntValue);
}
else if (NxSetting is bool BoolValue)
{
SettingBuffer[0] = BoolValue ? (byte)1 : (byte)0;
}
else
{
throw new NotImplementedException(NxSetting.GetType().Name);
}
AMemoryHelper.WriteBytes(Context.Memory, ReplyPos, SettingBuffer);
Context.Ns.Log.PrintInfo(Logging.LogClass.ServiceSet, $"{AskedSetting} set value: {NxSetting} as {NxSetting.GetType()}");
}
else Context.Ns.Log.PrintError(Logging.LogClass.ServiceSet, $"{AskedSetting} not found!");
return 0;
}
}
}
}