diff --git a/Ryujinx.Core/OsHle/Services/Set/ISystemSettingsServer.cs b/Ryujinx.Core/OsHle/Services/Set/ISystemSettingsServer.cs index 173e78c870..22577c9f79 100644 --- a/Ryujinx.Core/OsHle/Services/Set/ISystemSettingsServer.cs +++ b/Ryujinx.Core/OsHle/Services/Set/ISystemSettingsServer.cs @@ -17,9 +17,10 @@ namespace Ryujinx.Core.OsHle.Services.Set { m_Commands = new Dictionary() { - { 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; + } } -} \ No newline at end of file +}