Refactoring commands handling (#728)

* Refactoring commands handling

- Use Reflection to handle commands ID.
- Add all symbols (from SwIPC so not all time accurate).
- Re-sort some services commands methods.
- Some cleanup.
- Keep some empty constructor for consistency.

* Fix order in IProfile
This commit is contained in:
Ac_K 2019-07-12 03:13:43 +02:00 committed by gdkchan
parent f723f6f39a
commit 560ccbeb2d
99 changed files with 1035 additions and 1983 deletions

View file

@ -1,8 +1,6 @@
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.SystemState;
using System;
using System.Collections.Generic;
using static Ryujinx.HLE.HOS.ErrorCode;
@ -11,27 +9,9 @@ namespace Ryujinx.HLE.HOS.Services.Set
[Service("set")]
class ISettingsServer : IpcService
{
private Dictionary<int, ServiceProcessRequest> _commands;
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
public ISettingsServer(ServiceCtx context)
{
_commands = new Dictionary<int, ServiceProcessRequest>
{
{ 0, GetLanguageCode },
{ 1, GetAvailableLanguageCodes },
{ 2, MakeLanguageCode }, // 4.0.0+
{ 3, GetAvailableLanguageCodeCount },
//{ 4, GetRegionCode },
{ 5, GetAvailableLanguageCodes2 },
{ 6, GetAvailableLanguageCodeCount2 },
//{ 7, GetKeyCodeMap }, // 4.0.0+
{ 8, GetQuestFlag }, // 5.0.0+
//{ 9, GetKeyCodeMap2 }, // 6.0.0+
};
}
public ISettingsServer(ServiceCtx context) { }
[Command(0)]
// GetLanguageCode() -> nn::settings::LanguageCode
public static long GetLanguageCode(ServiceCtx context)
{
@ -40,6 +20,7 @@ namespace Ryujinx.HLE.HOS.Services.Set
return 0;
}
[Command(1)]
// GetAvailableLanguageCodes() -> (u32, buffer<nn::settings::LanguageCode, 0xa>)
public static long GetAvailableLanguageCodes(ServiceCtx context)
{
@ -50,6 +31,7 @@ namespace Ryujinx.HLE.HOS.Services.Set
0xF);
}
[Command(2)] // 4.0.0+
// MakeLanguageCode(nn::settings::Language language_index) -> nn::settings::LanguageCode
public static long MakeLanguageCode(ServiceCtx context)
{
@ -65,6 +47,7 @@ namespace Ryujinx.HLE.HOS.Services.Set
return 0;
}
[Command(3)]
// GetAvailableLanguageCodeCount() -> u32
public static long GetAvailableLanguageCodeCount(ServiceCtx context)
{
@ -73,6 +56,7 @@ namespace Ryujinx.HLE.HOS.Services.Set
return 0;
}
[Command(5)]
// GetAvailableLanguageCodes2() -> (u32, buffer<nn::settings::LanguageCode, 6>)
public static long GetAvailableLanguageCodes2(ServiceCtx context)
{
@ -83,6 +67,7 @@ namespace Ryujinx.HLE.HOS.Services.Set
SystemStateMgr.LanguageCodes.Length);
}
[Command(6)]
// GetAvailableLanguageCodeCount2() -> u32
public static long GetAvailableLanguageCodeCount2(ServiceCtx context)
{
@ -91,6 +76,7 @@ namespace Ryujinx.HLE.HOS.Services.Set
return 0;
}
[Command(8)] // 5.0.0+
// GetQuestFlag() -> bool
public static long GetQuestFlag(ServiceCtx context)
{
@ -122,4 +108,4 @@ namespace Ryujinx.HLE.HOS.Services.Set
return 0;
}
}
}
}

View file

@ -2,10 +2,8 @@ using LibHac.Fs;
using LibHac.Fs.NcaUtils;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.FileSystem;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.SystemState;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
@ -14,28 +12,16 @@ namespace Ryujinx.HLE.HOS.Services.Set
[Service("set:sys")]
class ISystemSettingsServer : IpcService
{
private Dictionary<int, ServiceProcessRequest> _commands;
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
public ISystemSettingsServer(ServiceCtx context)
{
_commands = new Dictionary<int, ServiceProcessRequest>
{
{ 3, GetFirmwareVersion },
{ 4, GetFirmwareVersion2 },
{ 23, GetColorSetId },
{ 24, SetColorSetId },
{ 38, GetSettingsItemValue }
};
}
public ISystemSettingsServer(ServiceCtx context) { }
[Command(3)]
// GetFirmwareVersion() -> buffer<nn::settings::system::FirmwareVersion, 0x1a, 0x100>
public static long GetFirmwareVersion(ServiceCtx context)
{
return GetFirmwareVersion2(context);
}
[Command(4)]
// GetFirmwareVersion2() -> buffer<nn::settings::system::FirmwareVersion, 0x1a, 0x100>
public static long GetFirmwareVersion2(ServiceCtx context)
{
@ -95,6 +81,7 @@ namespace Ryujinx.HLE.HOS.Services.Set
return 0;
}
[Command(23)]
// GetColorSetId() -> i32
public static long GetColorSetId(ServiceCtx context)
{
@ -103,6 +90,7 @@ namespace Ryujinx.HLE.HOS.Services.Set
return 0;
}
[Command(24)]
// GetColorSetId() -> i32
public static long SetColorSetId(ServiceCtx context)
{
@ -113,6 +101,7 @@ namespace Ryujinx.HLE.HOS.Services.Set
return 0;
}
[Command(38)]
// GetSettingsItemValue(buffer<nn::settings::SettingsName, 0x19, 0x48>, buffer<nn::settings::SettingsItemKey, 0x19, 0x48>) -> (u64, buffer<unknown, 6, 0>)
public static long GetSettingsItemValue(ServiceCtx context)
{
@ -206,4 +195,4 @@ namespace Ryujinx.HLE.HOS.Services.Set
}
}
}
}
}