Move solution and projects to src
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
namespace Ryujinx.HLE.HOS.Services.Am.Tcap
|
||||
{
|
||||
[Service("set:cal")]
|
||||
class IFactorySettingsServer : IpcService
|
||||
{
|
||||
public IFactorySettingsServer(ServiceCtx context) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Ryujinx.HLE.HOS.Services.Settings
|
||||
{
|
||||
[Service("set:fd")]
|
||||
class IFirmwareDebugSettingsServer : IpcService
|
||||
{
|
||||
public IFirmwareDebugSettingsServer(ServiceCtx context) { }
|
||||
}
|
||||
}
|
||||
247
src/Ryujinx.HLE/HOS/Services/Settings/ISettingsServer.cs
Normal file
247
src/Ryujinx.HLE/HOS/Services/Settings/ISettingsServer.cs
Normal file
@@ -0,0 +1,247 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.HOS.SystemState;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Settings
|
||||
{
|
||||
[Service("set")]
|
||||
class ISettingsServer : IpcService
|
||||
{
|
||||
public ISettingsServer(ServiceCtx context) { }
|
||||
|
||||
[CommandCmif(0)]
|
||||
// GetLanguageCode() -> nn::settings::LanguageCode
|
||||
public ResultCode GetLanguageCode(ServiceCtx context)
|
||||
{
|
||||
context.ResponseData.Write(context.Device.System.State.DesiredLanguageCode);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(1)]
|
||||
// GetAvailableLanguageCodes() -> (u32, buffer<nn::settings::LanguageCode, 0xa>)
|
||||
public ResultCode GetAvailableLanguageCodes(ServiceCtx context)
|
||||
{
|
||||
return GetAvailableLanguagesCodesImpl(
|
||||
context,
|
||||
context.Request.RecvListBuff[0].Position,
|
||||
context.Request.RecvListBuff[0].Size,
|
||||
0xF);
|
||||
}
|
||||
|
||||
[CommandCmif(2)] // 4.0.0+
|
||||
// MakeLanguageCode(nn::settings::Language language_index) -> nn::settings::LanguageCode
|
||||
public ResultCode MakeLanguageCode(ServiceCtx context)
|
||||
{
|
||||
int languageIndex = context.RequestData.ReadInt32();
|
||||
|
||||
if ((uint)languageIndex >= (uint)SystemStateMgr.LanguageCodes.Length)
|
||||
{
|
||||
return ResultCode.LanguageOutOfRange;
|
||||
}
|
||||
|
||||
context.ResponseData.Write(SystemStateMgr.GetLanguageCode(languageIndex));
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(3)]
|
||||
// GetAvailableLanguageCodeCount() -> u32
|
||||
public ResultCode GetAvailableLanguageCodeCount(ServiceCtx context)
|
||||
{
|
||||
context.ResponseData.Write(Math.Min(SystemStateMgr.LanguageCodes.Length, 0xF));
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(4)]
|
||||
// GetRegionCode() -> u32 nn::settings::RegionCode
|
||||
public ResultCode GetRegionCode(ServiceCtx context)
|
||||
{
|
||||
// NOTE: Service mount 0x8000000000000050 savedata and read the region code here.
|
||||
|
||||
RegionCode regionCode = (RegionCode)context.Device.System.State.DesiredRegionCode;
|
||||
|
||||
if (regionCode < RegionCode.Min || regionCode > RegionCode.Max)
|
||||
{
|
||||
regionCode = RegionCode.USA;
|
||||
}
|
||||
|
||||
context.ResponseData.Write((uint)regionCode);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(5)]
|
||||
// GetAvailableLanguageCodes2() -> (u32, buffer<nn::settings::LanguageCode, 6>)
|
||||
public ResultCode GetAvailableLanguageCodes2(ServiceCtx context)
|
||||
{
|
||||
return GetAvailableLanguagesCodesImpl(
|
||||
context,
|
||||
context.Request.ReceiveBuff[0].Position,
|
||||
context.Request.ReceiveBuff[0].Size,
|
||||
SystemStateMgr.LanguageCodes.Length);
|
||||
}
|
||||
|
||||
[CommandCmif(6)]
|
||||
// GetAvailableLanguageCodeCount2() -> u32
|
||||
public ResultCode GetAvailableLanguageCodeCount2(ServiceCtx context)
|
||||
{
|
||||
context.ResponseData.Write(SystemStateMgr.LanguageCodes.Length);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(7)] // 4.0.0+
|
||||
// GetKeyCodeMap() -> buffer<nn::kpr::KeyCodeMap, 0x16>
|
||||
public ResultCode GetKeyCodeMap(ServiceCtx context)
|
||||
{
|
||||
return GetKeyCodeMapImpl(context, 1);
|
||||
}
|
||||
|
||||
[CommandCmif(8)] // 5.0.0+
|
||||
// GetQuestFlag() -> bool
|
||||
public ResultCode GetQuestFlag(ServiceCtx context)
|
||||
{
|
||||
context.ResponseData.Write(false);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceSet);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(9)] // 6.0.0+
|
||||
// GetKeyCodeMap2() -> buffer<nn::kpr::KeyCodeMap, 0x16>
|
||||
public ResultCode GetKeyCodeMap2(ServiceCtx context)
|
||||
{
|
||||
return GetKeyCodeMapImpl(context, 2);
|
||||
}
|
||||
|
||||
[CommandCmif(11)] // 10.1.0+
|
||||
// GetDeviceNickName() -> buffer<nn::settings::system::DeviceNickName, 0x16>
|
||||
public ResultCode GetDeviceNickName(ServiceCtx context)
|
||||
{
|
||||
ulong deviceNickNameBufferPosition = context.Request.ReceiveBuff[0].Position;
|
||||
ulong deviceNickNameBufferSize = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
if (deviceNickNameBufferPosition == 0)
|
||||
{
|
||||
return ResultCode.NullDeviceNicknameBuffer;
|
||||
}
|
||||
|
||||
if (deviceNickNameBufferSize != 0x80)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceSet, "Wrong buffer size");
|
||||
}
|
||||
|
||||
context.Memory.Write(deviceNickNameBufferPosition, Encoding.ASCII.GetBytes(context.Device.System.State.DeviceNickName + '\0'));
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
private ResultCode GetKeyCodeMapImpl(ServiceCtx context, int version)
|
||||
{
|
||||
if (context.Request.ReceiveBuff[0].Size != 0x1000)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceSet, "Wrong buffer size");
|
||||
}
|
||||
|
||||
byte[] keyCodeMap;
|
||||
|
||||
switch ((KeyboardLayout)context.Device.System.State.DesiredKeyboardLayout)
|
||||
{
|
||||
case KeyboardLayout.EnglishUs:
|
||||
|
||||
long langCode = context.Device.System.State.DesiredLanguageCode;
|
||||
|
||||
if (langCode == 0x736e61482d687a) // Zh-Hans
|
||||
{
|
||||
keyCodeMap = KeyCodeMaps.ChineseSimplified;
|
||||
}
|
||||
else if (langCode == 0x746e61482d687a) // Zh-Hant
|
||||
{
|
||||
keyCodeMap = KeyCodeMaps.ChineseTraditional;
|
||||
}
|
||||
else
|
||||
{
|
||||
keyCodeMap = KeyCodeMaps.EnglishUk;
|
||||
}
|
||||
|
||||
break;
|
||||
case KeyboardLayout.EnglishUsInternational:
|
||||
keyCodeMap = KeyCodeMaps.EnglishUsInternational;
|
||||
break;
|
||||
case KeyboardLayout.EnglishUk:
|
||||
keyCodeMap = KeyCodeMaps.EnglishUk;
|
||||
break;
|
||||
case KeyboardLayout.French:
|
||||
keyCodeMap = KeyCodeMaps.French;
|
||||
break;
|
||||
case KeyboardLayout.FrenchCa:
|
||||
keyCodeMap = KeyCodeMaps.FrenchCa;
|
||||
break;
|
||||
case KeyboardLayout.Spanish:
|
||||
keyCodeMap = KeyCodeMaps.Spanish;
|
||||
break;
|
||||
case KeyboardLayout.SpanishLatin:
|
||||
keyCodeMap = KeyCodeMaps.SpanishLatin;
|
||||
break;
|
||||
case KeyboardLayout.German:
|
||||
keyCodeMap = KeyCodeMaps.German;
|
||||
break;
|
||||
case KeyboardLayout.Italian:
|
||||
keyCodeMap = KeyCodeMaps.Italian;
|
||||
break;
|
||||
case KeyboardLayout.Portuguese:
|
||||
keyCodeMap = KeyCodeMaps.Portuguese;
|
||||
break;
|
||||
case KeyboardLayout.Russian:
|
||||
keyCodeMap = KeyCodeMaps.Russian;
|
||||
break;
|
||||
case KeyboardLayout.Korean:
|
||||
keyCodeMap = KeyCodeMaps.Korean;
|
||||
break;
|
||||
case KeyboardLayout.ChineseSimplified:
|
||||
keyCodeMap = KeyCodeMaps.ChineseSimplified;
|
||||
break;
|
||||
case KeyboardLayout.ChineseTraditional:
|
||||
keyCodeMap = KeyCodeMaps.ChineseTraditional;
|
||||
break;
|
||||
default: // KeyboardLayout.Default
|
||||
keyCodeMap = KeyCodeMaps.Default;
|
||||
break;
|
||||
}
|
||||
|
||||
context.Memory.Write(context.Request.ReceiveBuff[0].Position, keyCodeMap);
|
||||
|
||||
if (version == 1 && context.Device.System.State.DesiredKeyboardLayout == (long)KeyboardLayout.Default)
|
||||
{
|
||||
context.Memory.Write(context.Request.ReceiveBuff[0].Position, (byte)0x01);
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
private ResultCode GetAvailableLanguagesCodesImpl(ServiceCtx context, ulong position, ulong size, int maxSize)
|
||||
{
|
||||
int count = (int)(size / 8);
|
||||
|
||||
if (count > maxSize)
|
||||
{
|
||||
count = maxSize;
|
||||
}
|
||||
|
||||
for (int index = 0; index < count; index++)
|
||||
{
|
||||
context.Memory.Write(position, SystemStateMgr.GetLanguageCode(index));
|
||||
|
||||
position += 8;
|
||||
}
|
||||
|
||||
context.ResponseData.Write(count);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
348
src/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs
Normal file
348
src/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs
Normal file
@@ -0,0 +1,348 @@
|
||||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.Ncm;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.HOS.SystemState;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Settings
|
||||
{
|
||||
[Service("set:sys")]
|
||||
class ISystemSettingsServer : IpcService
|
||||
{
|
||||
public ISystemSettingsServer(ServiceCtx context) { }
|
||||
|
||||
[CommandCmif(3)]
|
||||
// GetFirmwareVersion() -> buffer<nn::settings::system::FirmwareVersion, 0x1a, 0x100>
|
||||
public ResultCode GetFirmwareVersion(ServiceCtx context)
|
||||
{
|
||||
return GetFirmwareVersion2(context);
|
||||
}
|
||||
|
||||
[CommandCmif(4)]
|
||||
// GetFirmwareVersion2() -> buffer<nn::settings::system::FirmwareVersion, 0x1a, 0x100>
|
||||
public ResultCode GetFirmwareVersion2(ServiceCtx context)
|
||||
{
|
||||
ulong replyPos = context.Request.RecvListBuff[0].Position;
|
||||
|
||||
context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(0x100L);
|
||||
|
||||
byte[] firmwareData = GetFirmwareData(context.Device);
|
||||
|
||||
if (firmwareData != null)
|
||||
{
|
||||
context.Memory.Write(replyPos, firmwareData);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
const byte majorFwVersion = 0x03;
|
||||
const byte minorFwVersion = 0x00;
|
||||
const byte microFwVersion = 0x00;
|
||||
const byte unknown = 0x00; //Build?
|
||||
|
||||
const int revisionNumber = 0x0A;
|
||||
|
||||
const string platform = "NX";
|
||||
const string unknownHex = "7fbde2b0bba4d14107bf836e4643043d9f6c8e47";
|
||||
const string version = "3.0.0";
|
||||
const string build = "NintendoSDK Firmware for NX 3.0.0-10.0";
|
||||
|
||||
// http://switchbrew.org/index.php?title=System_Version_Title
|
||||
using (MemoryStream ms = new MemoryStream(0x100))
|
||||
{
|
||||
BinaryWriter writer = new BinaryWriter(ms);
|
||||
|
||||
writer.Write(majorFwVersion);
|
||||
writer.Write(minorFwVersion);
|
||||
writer.Write(microFwVersion);
|
||||
writer.Write(unknown);
|
||||
|
||||
writer.Write(revisionNumber);
|
||||
|
||||
writer.Write(Encoding.ASCII.GetBytes(platform));
|
||||
|
||||
ms.Seek(0x28, SeekOrigin.Begin);
|
||||
|
||||
writer.Write(Encoding.ASCII.GetBytes(unknownHex));
|
||||
|
||||
ms.Seek(0x68, SeekOrigin.Begin);
|
||||
|
||||
writer.Write(Encoding.ASCII.GetBytes(version));
|
||||
|
||||
ms.Seek(0x80, SeekOrigin.Begin);
|
||||
|
||||
writer.Write(Encoding.ASCII.GetBytes(build));
|
||||
|
||||
context.Memory.Write(replyPos, ms.ToArray());
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(23)]
|
||||
// GetColorSetId() -> i32
|
||||
public ResultCode GetColorSetId(ServiceCtx context)
|
||||
{
|
||||
context.ResponseData.Write((int)context.Device.System.State.ThemeColor);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(24)]
|
||||
// GetColorSetId() -> i32
|
||||
public ResultCode SetColorSetId(ServiceCtx context)
|
||||
{
|
||||
int colorSetId = context.RequestData.ReadInt32();
|
||||
|
||||
context.Device.System.State.ThemeColor = (ColorSet)colorSetId;
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(37)]
|
||||
// GetSettingsItemValueSize(buffer<nn::settings::SettingsName, 0x19>, buffer<nn::settings::SettingsItemKey, 0x19>) -> u64
|
||||
public ResultCode GetSettingsItemValueSize(ServiceCtx context)
|
||||
{
|
||||
ulong classPos = context.Request.PtrBuff[0].Position;
|
||||
ulong classSize = context.Request.PtrBuff[0].Size;
|
||||
|
||||
ulong namePos = context.Request.PtrBuff[1].Position;
|
||||
ulong nameSize = context.Request.PtrBuff[1].Size;
|
||||
|
||||
byte[] classBuffer = new byte[classSize];
|
||||
|
||||
context.Memory.Read(classPos, classBuffer);
|
||||
|
||||
byte[] nameBuffer = new byte[nameSize];
|
||||
|
||||
context.Memory.Read(namePos, nameBuffer);
|
||||
|
||||
string askedSetting = Encoding.ASCII.GetString(classBuffer).Trim('\0') + "!" + Encoding.ASCII.GetString(nameBuffer).Trim('\0');
|
||||
|
||||
NxSettings.Settings.TryGetValue(askedSetting, out object nxSetting);
|
||||
|
||||
if (nxSetting != null)
|
||||
{
|
||||
ulong settingSize;
|
||||
|
||||
if (nxSetting is string stringValue)
|
||||
{
|
||||
settingSize = (ulong)stringValue.Length + 1;
|
||||
}
|
||||
else if (nxSetting is int)
|
||||
{
|
||||
settingSize = sizeof(int);
|
||||
}
|
||||
else if (nxSetting is bool)
|
||||
{
|
||||
settingSize = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException(nxSetting.GetType().Name);
|
||||
}
|
||||
|
||||
context.ResponseData.Write(settingSize);
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(38)]
|
||||
// GetSettingsItemValue(buffer<nn::settings::SettingsName, 0x19, 0x48>, buffer<nn::settings::SettingsItemKey, 0x19, 0x48>) -> (u64, buffer<unknown, 6, 0>)
|
||||
public ResultCode GetSettingsItemValue(ServiceCtx context)
|
||||
{
|
||||
ulong classPos = context.Request.PtrBuff[0].Position;
|
||||
ulong classSize = context.Request.PtrBuff[0].Size;
|
||||
|
||||
ulong namePos = context.Request.PtrBuff[1].Position;
|
||||
ulong nameSize = context.Request.PtrBuff[1].Size;
|
||||
|
||||
ulong replyPos = context.Request.ReceiveBuff[0].Position;
|
||||
ulong replySize = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
byte[] classBuffer = new byte[classSize];
|
||||
|
||||
context.Memory.Read(classPos, classBuffer);
|
||||
|
||||
byte[] nameBuffer = new byte[nameSize];
|
||||
|
||||
context.Memory.Read(namePos, nameBuffer);
|
||||
|
||||
string askedSetting = Encoding.ASCII.GetString(classBuffer).Trim('\0') + "!" + Encoding.ASCII.GetString(nameBuffer).Trim('\0');
|
||||
|
||||
NxSettings.Settings.TryGetValue(askedSetting, out object nxSetting);
|
||||
|
||||
if (nxSetting != null)
|
||||
{
|
||||
byte[] settingBuffer = new byte[replySize];
|
||||
|
||||
if (nxSetting is string stringValue)
|
||||
{
|
||||
if ((ulong)(stringValue.Length + 1) > replySize)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.ServiceSet, $"{askedSetting} String value size is too big!");
|
||||
}
|
||||
else
|
||||
{
|
||||
settingBuffer = Encoding.ASCII.GetBytes(stringValue + "\0");
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
context.Memory.Write(replyPos, settingBuffer);
|
||||
|
||||
Logger.Debug?.Print(LogClass.ServiceSet, $"{askedSetting} set value: {nxSetting} as {nxSetting.GetType()}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Error?.Print(LogClass.ServiceSet, $"{askedSetting} not found!");
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(60)]
|
||||
// IsUserSystemClockAutomaticCorrectionEnabled() -> bool
|
||||
public ResultCode IsUserSystemClockAutomaticCorrectionEnabled(ServiceCtx context)
|
||||
{
|
||||
// NOTE: When set to true, is automatically synced with the internet.
|
||||
context.ResponseData.Write(true);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceSet);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(62)]
|
||||
// GetDebugModeFlag() -> bool
|
||||
public ResultCode GetDebugModeFlag(ServiceCtx context)
|
||||
{
|
||||
context.ResponseData.Write(false);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceSet);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(77)]
|
||||
// GetDeviceNickName() -> buffer<nn::settings::system::DeviceNickName, 0x16>
|
||||
public ResultCode GetDeviceNickName(ServiceCtx context)
|
||||
{
|
||||
ulong deviceNickNameBufferPosition = context.Request.ReceiveBuff[0].Position;
|
||||
ulong deviceNickNameBufferSize = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
if (deviceNickNameBufferPosition == 0)
|
||||
{
|
||||
return ResultCode.NullDeviceNicknameBuffer;
|
||||
}
|
||||
|
||||
if (deviceNickNameBufferSize != 0x80)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceSet, "Wrong buffer size");
|
||||
}
|
||||
|
||||
context.Memory.Write(deviceNickNameBufferPosition, Encoding.ASCII.GetBytes(context.Device.System.State.DeviceNickName + '\0'));
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(78)]
|
||||
// SetDeviceNickName(buffer<nn::settings::system::DeviceNickName, 0x15>)
|
||||
public ResultCode SetDeviceNickName(ServiceCtx context)
|
||||
{
|
||||
ulong deviceNickNameBufferPosition = context.Request.SendBuff[0].Position;
|
||||
ulong deviceNickNameBufferSize = context.Request.SendBuff[0].Size;
|
||||
|
||||
byte[] deviceNickNameBuffer = new byte[deviceNickNameBufferSize];
|
||||
|
||||
context.Memory.Read(deviceNickNameBufferPosition, deviceNickNameBuffer);
|
||||
|
||||
context.Device.System.State.DeviceNickName = Encoding.ASCII.GetString(deviceNickNameBuffer);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(90)]
|
||||
// GetMiiAuthorId() -> nn::util::Uuid
|
||||
public ResultCode GetMiiAuthorId(ServiceCtx context)
|
||||
{
|
||||
// NOTE: If miiAuthorId is null ResultCode.NullMiiAuthorIdBuffer is returned.
|
||||
// Doesn't occur in our case.
|
||||
|
||||
context.ResponseData.Write(Mii.Helper.GetDeviceId());
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
public byte[] GetFirmwareData(Switch device)
|
||||
{
|
||||
const ulong SystemVersionTitleId = 0x0100000000000809;
|
||||
|
||||
string contentPath = device.System.ContentManager.GetInstalledContentPath(SystemVersionTitleId, StorageId.BuiltInSystem, NcaContentType.Data);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(contentPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string firmwareTitlePath = device.FileSystem.SwitchPathToSystemPath(contentPath);
|
||||
|
||||
using(IStorage firmwareStorage = new LocalStorage(firmwareTitlePath, FileAccess.Read))
|
||||
{
|
||||
Nca firmwareContent = new Nca(device.System.KeySet, firmwareStorage);
|
||||
|
||||
if (!firmwareContent.CanOpenSection(NcaSectionType.Data))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
IFileSystem firmwareRomFs = firmwareContent.OpenFileSystem(NcaSectionType.Data, device.System.FsIntegrityCheckLevel);
|
||||
|
||||
using var firmwareFile = new UniqueRef<IFile>();
|
||||
|
||||
Result result = firmwareRomFs.OpenFile(ref firmwareFile.Ref, "/file".ToU8Span(), OpenMode.Read);
|
||||
if (result.IsFailure())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
result = firmwareFile.Get.GetSize(out long fileSize);
|
||||
if (result.IsFailure())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] data = new byte[fileSize];
|
||||
|
||||
result = firmwareFile.Get.Read(out _, 0, data);
|
||||
if (result.IsFailure())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
4849
src/Ryujinx.HLE/HOS/Services/Settings/KeyCodeMaps.cs
Normal file
4849
src/Ryujinx.HLE/HOS/Services/Settings/KeyCodeMaps.cs
Normal file
File diff suppressed because it is too large
Load Diff
1712
src/Ryujinx.HLE/HOS/Services/Settings/NxSettings.cs
Normal file
1712
src/Ryujinx.HLE/HOS/Services/Settings/NxSettings.cs
Normal file
File diff suppressed because it is too large
Load Diff
126
src/Ryujinx.HLE/HOS/Services/Settings/ResultCode.cs
Normal file
126
src/Ryujinx.HLE/HOS/Services/Settings/ResultCode.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
namespace Ryujinx.HLE.HOS.Services.Settings
|
||||
{
|
||||
enum ResultCode
|
||||
{
|
||||
ModuleId = 105,
|
||||
ErrorCodeShift = 9,
|
||||
|
||||
Success = 0,
|
||||
|
||||
NullSettingsName = (201 << ErrorCodeShift) | ModuleId,
|
||||
NullSettingsKey = (202 << ErrorCodeShift) | ModuleId,
|
||||
NullSettingsValue = (203 << ErrorCodeShift) | ModuleId,
|
||||
NullSettingsValueBuffer = (205 << ErrorCodeShift) | ModuleId,
|
||||
NullSettingValueSizeBuffer = (208 << ErrorCodeShift) | ModuleId,
|
||||
NullDebugModeFlagBuffer = (209 << ErrorCodeShift) | ModuleId,
|
||||
SettingGroupNameHasZeroLength = (221 << ErrorCodeShift) | ModuleId,
|
||||
EmptySettingsItemKey = (222 << ErrorCodeShift) | ModuleId,
|
||||
SettingGroupNameIsTooLong = (241 << ErrorCodeShift) | ModuleId,
|
||||
SettingNameIsTooLong = (242 << ErrorCodeShift) | ModuleId,
|
||||
SettingGroupNameEndsWithDotOrContainsInvalidCharacters = (261 << ErrorCodeShift) | ModuleId,
|
||||
SettingNameEndsWithDotOrContainsInvalidCharacters = (262 << ErrorCodeShift) | ModuleId,
|
||||
NullLanguageCodeBuffer = (621 << ErrorCodeShift) | ModuleId,
|
||||
LanguageOutOfRange = (625 << ErrorCodeShift) | ModuleId,
|
||||
NullNetworkSettingsBuffer = (631 << ErrorCodeShift) | ModuleId,
|
||||
NullNetworkSettingsOutputCountBuffer = (632 << ErrorCodeShift) | ModuleId,
|
||||
NullBacklightSettingsBuffer = (641 << ErrorCodeShift) | ModuleId,
|
||||
NullBluetoothDeviceSettingBuffer = (651 << ErrorCodeShift) | ModuleId,
|
||||
NullBluetoothDeviceSettingOutputCountBuffer = (652 << ErrorCodeShift) | ModuleId,
|
||||
NullBluetoothEnableFlagBuffer = (653 << ErrorCodeShift) | ModuleId,
|
||||
NullBluetoothAFHEnableFlagBuffer = (654 << ErrorCodeShift) | ModuleId,
|
||||
NullBluetoothBoostEnableFlagBuffer = (655 << ErrorCodeShift) | ModuleId,
|
||||
NullBLEPairingSettingsBuffer = (656 << ErrorCodeShift) | ModuleId,
|
||||
NullBLEPairingSettingsEntryCountBuffer = (657 << ErrorCodeShift) | ModuleId,
|
||||
NullExternalSteadyClockSourceIDBuffer = (661 << ErrorCodeShift) | ModuleId,
|
||||
NullUserSystemClockContextBuffer = (662 << ErrorCodeShift) | ModuleId,
|
||||
NullNetworkSystemClockContextBuffer = (663 << ErrorCodeShift) | ModuleId,
|
||||
NullUserSystemClockAutomaticCorrectionEnabledFlagBuffer = (664 << ErrorCodeShift) | ModuleId,
|
||||
NullShutdownRTCValueBuffer = (665 << ErrorCodeShift) | ModuleId,
|
||||
NullExternalSteadyClockInternalOffsetBuffer = (666 << ErrorCodeShift) | ModuleId,
|
||||
NullAccountSettingsBuffer = (671 << ErrorCodeShift) | ModuleId,
|
||||
NullAudioVolumeBuffer = (681 << ErrorCodeShift) | ModuleId,
|
||||
NullForceMuteOnHeadphoneRemovedBuffer = (683 << ErrorCodeShift) | ModuleId,
|
||||
NullHeadphoneVolumeWarningCountBuffer = (684 << ErrorCodeShift) | ModuleId,
|
||||
InvalidAudioOutputMode = (687 << ErrorCodeShift) | ModuleId,
|
||||
NullHeadphoneVolumeUpdateFlagBuffer = (688 << ErrorCodeShift) | ModuleId,
|
||||
NullConsoleInformationUploadFlagBuffer = (691 << ErrorCodeShift) | ModuleId,
|
||||
NullAutomaticApplicationDownloadFlagBuffer = (701 << ErrorCodeShift) | ModuleId,
|
||||
NullNotificationSettingsBuffer = (702 << ErrorCodeShift) | ModuleId,
|
||||
NullAccountNotificationSettingsEntryCountBuffer = (703 << ErrorCodeShift) | ModuleId,
|
||||
NullAccountNotificationSettingsBuffer = (704 << ErrorCodeShift) | ModuleId,
|
||||
NullVibrationMasterVolumeBuffer = (711 << ErrorCodeShift) | ModuleId,
|
||||
NullNXControllerSettingsBuffer = (712 << ErrorCodeShift) | ModuleId,
|
||||
NullNXControllerSettingsEntryCountBuffer = (713 << ErrorCodeShift) | ModuleId,
|
||||
NullUSBFullKeyEnableFlagBuffer = (714 << ErrorCodeShift) | ModuleId,
|
||||
NullTVSettingsBuffer = (721 << ErrorCodeShift) | ModuleId,
|
||||
NullEDIDBuffer = (722 << ErrorCodeShift) | ModuleId,
|
||||
NullDataDeletionSettingsBuffer = (731 << ErrorCodeShift) | ModuleId,
|
||||
NullInitialSystemAppletProgramIDBuffer = (741 << ErrorCodeShift) | ModuleId,
|
||||
NullOverlayDispProgramIDBuffer = (742 << ErrorCodeShift) | ModuleId,
|
||||
NullIsInRepairProcessBuffer = (743 << ErrorCodeShift) | ModuleId,
|
||||
NullRequiresRunRepairTimeReviserBuffer = (744 << ErrorCodeShift) | ModuleId,
|
||||
NullDeviceTimezoneLocationNameBuffer = (751 << ErrorCodeShift) | ModuleId,
|
||||
NullPrimaryAlbumStorageBuffer = (761 << ErrorCodeShift) | ModuleId,
|
||||
NullUSB30EnableFlagBuffer = (771 << ErrorCodeShift) | ModuleId,
|
||||
NullUSBTypeCPowerSourceCircuitVersionBuffer = (772 << ErrorCodeShift) | ModuleId,
|
||||
NullBatteryLotBuffer = (781 << ErrorCodeShift) | ModuleId,
|
||||
NullSerialNumberBuffer = (791 << ErrorCodeShift) | ModuleId,
|
||||
NullLockScreenFlagBuffer = (801 << ErrorCodeShift) | ModuleId,
|
||||
NullColorSetIDBuffer = (803 << ErrorCodeShift) | ModuleId,
|
||||
NullQuestFlagBuffer = (804 << ErrorCodeShift) | ModuleId,
|
||||
NullWirelessCertificationFileSizeBuffer = (805 << ErrorCodeShift) | ModuleId,
|
||||
NullWirelessCertificationFileBuffer = (806 << ErrorCodeShift) | ModuleId,
|
||||
NullInitialLaunchSettingsBuffer = (807 << ErrorCodeShift) | ModuleId,
|
||||
NullDeviceNicknameBuffer = (808 << ErrorCodeShift) | ModuleId,
|
||||
NullBatteryPercentageFlagBuffer = (809 << ErrorCodeShift) | ModuleId,
|
||||
NullAppletLaunchFlagsBuffer = (810 << ErrorCodeShift) | ModuleId,
|
||||
NullWirelessLANEnableFlagBuffer = (1012 << ErrorCodeShift) | ModuleId,
|
||||
NullProductModelBuffer = (1021 << ErrorCodeShift) | ModuleId,
|
||||
NullNFCEnableFlagBuffer = (1031 << ErrorCodeShift) | ModuleId,
|
||||
NullECIDeviceCertificateBuffer = (1041 << ErrorCodeShift) | ModuleId,
|
||||
NullETicketDeviceCertificateBuffer = (1042 << ErrorCodeShift) | ModuleId,
|
||||
NullSleepSettingsBuffer = (1051 << ErrorCodeShift) | ModuleId,
|
||||
NullEULAVersionBuffer = (1061 << ErrorCodeShift) | ModuleId,
|
||||
NullEULAVersionEntryCountBuffer = (1062 << ErrorCodeShift) | ModuleId,
|
||||
NullLDNChannelBuffer = (1071 << ErrorCodeShift) | ModuleId,
|
||||
NullSSLKeyBuffer = (1081 << ErrorCodeShift) | ModuleId,
|
||||
NullSSLCertificateBuffer = (1082 << ErrorCodeShift) | ModuleId,
|
||||
NullTelemetryFlagsBuffer = (1091 << ErrorCodeShift) | ModuleId,
|
||||
NullGamecardKeyBuffer = (1101 << ErrorCodeShift) | ModuleId,
|
||||
NullGamecardCertificateBuffer = (1102 << ErrorCodeShift) | ModuleId,
|
||||
NullPTMBatteryLotBuffer = (1111 << ErrorCodeShift) | ModuleId,
|
||||
NullPTMFuelGaugeParameterBuffer = (1112 << ErrorCodeShift) | ModuleId,
|
||||
NullECIDeviceKeyBuffer = (1121 << ErrorCodeShift) | ModuleId,
|
||||
NullETicketDeviceKeyBuffer = (1122 << ErrorCodeShift) | ModuleId,
|
||||
NullSpeakerParameterBuffer = (1131 << ErrorCodeShift) | ModuleId,
|
||||
NullFirmwareVersionBuffer = (1141 << ErrorCodeShift) | ModuleId,
|
||||
NullFirmwareVersionDigestBuffer = (1142 << ErrorCodeShift) | ModuleId,
|
||||
NullRebootlessSystemUpdateVersionBuffer = (1143 << ErrorCodeShift) | ModuleId,
|
||||
NullMiiAuthorIDBuffer = (1151 << ErrorCodeShift) | ModuleId,
|
||||
NullFatalFlagsBuffer = (1161 << ErrorCodeShift) | ModuleId,
|
||||
NullAutoUpdateEnableFlagBuffer = (1171 << ErrorCodeShift) | ModuleId,
|
||||
NullExternalRTCResetFlagBuffer = (1181 << ErrorCodeShift) | ModuleId,
|
||||
NullPushNotificationActivityModeBuffer = (1191 << ErrorCodeShift) | ModuleId,
|
||||
NullServiceDiscoveryControlSettingBuffer = (1201 << ErrorCodeShift) | ModuleId,
|
||||
NullErrorReportSharePermissionBuffer = (1211 << ErrorCodeShift) | ModuleId,
|
||||
NullLCDVendorIDBuffer = (1221 << ErrorCodeShift) | ModuleId,
|
||||
NullConsoleSixAxisSensorAccelerationBiasBuffer = (1231 << ErrorCodeShift) | ModuleId,
|
||||
NullConsoleSixAxisSensorAngularVelocityBiasBuffer = (1232 << ErrorCodeShift) | ModuleId,
|
||||
NullConsoleSixAxisSensorAccelerationGainBuffer = (1233 << ErrorCodeShift) | ModuleId,
|
||||
NullConsoleSixAxisSensorAngularVelocityGainBuffer = (1234 << ErrorCodeShift) | ModuleId,
|
||||
NullConsoleSixAxisSensorAngularVelocityTimeBiasBuffer = (1235 << ErrorCodeShift) | ModuleId,
|
||||
NullConsoleSixAxisSensorAngularAccelerationBuffer = (1236 << ErrorCodeShift) | ModuleId,
|
||||
NullKeyboardLayoutBuffer = (1241 << ErrorCodeShift) | ModuleId,
|
||||
InvalidKeyboardLayout = (1245 << ErrorCodeShift) | ModuleId,
|
||||
NullWebInspectorFlagBuffer = (1251 << ErrorCodeShift) | ModuleId,
|
||||
NullAllowedSSLHostsBuffer = (1252 << ErrorCodeShift) | ModuleId,
|
||||
NullAllowedSSLHostsEntryCountBuffer = (1253 << ErrorCodeShift) | ModuleId,
|
||||
NullHostFSMountPointBuffer = (1254 << ErrorCodeShift) | ModuleId,
|
||||
NullAmiiboKeyBuffer = (1271 << ErrorCodeShift) | ModuleId,
|
||||
NullAmiiboECQVCertificateBuffer = (1272 << ErrorCodeShift) | ModuleId,
|
||||
NullAmiiboECDSACertificateBuffer = (1273 << ErrorCodeShift) | ModuleId,
|
||||
NullAmiiboECQVBLSKeyBuffer = (1274 << ErrorCodeShift) | ModuleId,
|
||||
NullAmiiboECQVBLSCertificateBuffer = (1275 << ErrorCodeShift) | ModuleId,
|
||||
NullAmiiboECQVBLSRootCertificateBuffer = (1276 << ErrorCodeShift) | ModuleId
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Ryujinx.HLE.HOS.Services.Settings.Types
|
||||
{
|
||||
enum PlatformRegion
|
||||
{
|
||||
Global = 1,
|
||||
China = 2
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user