mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-09-10 13:43:17 +02:00
Fix latest version of hbl/hb-menu (#795)
* Fix latest version of hbl/hb-menu This implement GetSettingsItemValueSize (required by hbl) and GetInternetConnectionStatus (required by hb-menu). * Address comments
This commit is contained in:
parent
8a8ea4c8c0
commit
2b5ec23aa7
@ -1,5 +1,7 @@
|
|||||||
|
using Ryujinx.Common;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.HLE.HOS.Services.Nifm.StaticService.GeneralService;
|
using Ryujinx.HLE.HOS.Services.Nifm.StaticService.GeneralService;
|
||||||
|
using Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
@ -71,6 +73,27 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
|
|||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Command(18)]
|
||||||
|
// GetInternetConnectionStatus() -> nn::nifm::detail::sf::InternetConnectionStatus
|
||||||
|
public ResultCode GetInternetConnectionStatus(ServiceCtx context)
|
||||||
|
{
|
||||||
|
if (!NetworkInterface.GetIsNetworkAvailable())
|
||||||
|
{
|
||||||
|
return ResultCode.NoInternetConnection;
|
||||||
|
}
|
||||||
|
|
||||||
|
InternetConnectionStatus internetConnectionStatus = new InternetConnectionStatus
|
||||||
|
{
|
||||||
|
Type = InternetConnectionType.WiFi,
|
||||||
|
WifiStrength = 3,
|
||||||
|
State = InternetConnectionState.Connected,
|
||||||
|
};
|
||||||
|
|
||||||
|
context.ResponseData.WriteStruct(internetConnectionStatus);
|
||||||
|
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
[Command(21)]
|
[Command(21)]
|
||||||
// IsAnyInternetRequestAccepted(buffer<nn::nifm::ClientId, 0x19, 4>) -> bool
|
// IsAnyInternetRequestAccepted(buffer<nn::nifm::ClientId, 0x19, 4>) -> bool
|
||||||
public ResultCode IsAnyInternetRequestAccepted(ServiceCtx context)
|
public ResultCode IsAnyInternetRequestAccepted(ServiceCtx context)
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
|
||||||
|
{
|
||||||
|
enum InternetConnectionState : byte
|
||||||
|
{
|
||||||
|
ConnectingType0 = 0,
|
||||||
|
ConnectingType1 = 1,
|
||||||
|
ConnectingType2 = 2,
|
||||||
|
ConnectingType3 = 3,
|
||||||
|
Connected = 4,
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
|
||||||
|
{
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
struct InternetConnectionStatus
|
||||||
|
{
|
||||||
|
public InternetConnectionType Type;
|
||||||
|
public byte WifiStrength;
|
||||||
|
public InternetConnectionState State;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
|
||||||
|
{
|
||||||
|
enum InternetConnectionType : byte
|
||||||
|
{
|
||||||
|
Invalid = 0,
|
||||||
|
WiFi = 1,
|
||||||
|
Ethernet = 2,
|
||||||
|
}
|
||||||
|
}
|
@ -103,6 +103,50 @@ namespace Ryujinx.HLE.HOS.Services.Settings
|
|||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Command(37)]
|
||||||
|
// GetSettingsItemValueSize(buffer<nn::settings::SettingsName, 0x19>, buffer<nn::settings::SettingsItemKey, 0x19>) -> u64
|
||||||
|
public ResultCode GetSettingsItemValueSize(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;
|
||||||
|
|
||||||
|
byte[] Class = context.Memory.ReadBytes(classPos, classSize);
|
||||||
|
byte[] name = context.Memory.ReadBytes(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)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
[Command(38)]
|
[Command(38)]
|
||||||
// GetSettingsItemValue(buffer<nn::settings::SettingsName, 0x19, 0x48>, buffer<nn::settings::SettingsItemKey, 0x19, 0x48>) -> (u64, buffer<unknown, 6, 0>)
|
// GetSettingsItemValue(buffer<nn::settings::SettingsName, 0x19, 0x48>, buffer<nn::settings::SettingsItemKey, 0x19, 0x48>) -> (u64, buffer<unknown, 6, 0>)
|
||||||
public ResultCode GetSettingsItemValue(ServiceCtx context)
|
public ResultCode GetSettingsItemValue(ServiceCtx context)
|
||||||
|
Loading…
Reference in New Issue
Block a user