2021-06-23 22:52:55 +02:00
|
|
|
|
using Ryujinx.Common.Logging;
|
|
|
|
|
using Ryujinx.HLE.HOS.Services.Hid.HidServer;
|
|
|
|
|
using Ryujinx.HLE.HOS.Services.Hid.Types;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Hid
|
2019-09-19 02:45:11 +02:00
|
|
|
|
{
|
|
|
|
|
[Service("hid:sys")]
|
|
|
|
|
class IHidSystemServer : IpcService
|
|
|
|
|
{
|
|
|
|
|
public IHidSystemServer(ServiceCtx context) { }
|
2021-06-23 22:52:55 +02:00
|
|
|
|
|
|
|
|
|
[CommandHipc(303)]
|
|
|
|
|
// ApplyNpadSystemCommonPolicy(u64)
|
|
|
|
|
public ResultCode ApplyNpadSystemCommonPolicy(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
ulong commonPolicy = context.RequestData.ReadUInt64();
|
|
|
|
|
|
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { commonPolicy });
|
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[CommandHipc(306)]
|
|
|
|
|
// GetLastActiveNpad(u32) -> u8, u8
|
|
|
|
|
public ResultCode GetLastActiveNpad(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
// TODO: RequestData seems to have garbage data, reading an extra uint seems to fix the issue.
|
|
|
|
|
context.RequestData.ReadUInt32();
|
|
|
|
|
|
|
|
|
|
ResultCode resultCode = GetAppletFooterUiTypeImpl(context, out AppletFooterUiType appletFooterUiType);
|
|
|
|
|
|
|
|
|
|
context.ResponseData.Write((byte)appletFooterUiType);
|
|
|
|
|
context.ResponseData.Write((byte)0);
|
|
|
|
|
|
|
|
|
|
return resultCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[CommandHipc(307)]
|
|
|
|
|
// GetNpadSystemExtStyle() -> u64
|
|
|
|
|
public ResultCode GetNpadSystemExtStyle(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
foreach (PlayerIndex playerIndex in context.Device.Hid.Npads.GetSupportedPlayers())
|
|
|
|
|
{
|
|
|
|
|
if (HidUtils.GetNpadIdTypeFromIndex(playerIndex) > NpadIdType.Handheld)
|
|
|
|
|
{
|
|
|
|
|
return ResultCode.InvalidNpadIdType;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
context.ResponseData.Write((ulong)context.Device.Hid.Npads.SupportedStyleSets);
|
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[CommandHipc(314)] // 9.0.0+
|
|
|
|
|
// GetAppletFooterUiType(u32) -> u8
|
|
|
|
|
public ResultCode GetAppletFooterUiType(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
ResultCode resultCode = GetAppletFooterUiTypeImpl(context, out AppletFooterUiType appletFooterUiType);
|
|
|
|
|
|
|
|
|
|
context.ResponseData.Write((byte)appletFooterUiType);
|
|
|
|
|
|
|
|
|
|
return resultCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ResultCode GetAppletFooterUiTypeImpl(ServiceCtx context, out AppletFooterUiType appletFooterUiType)
|
|
|
|
|
{
|
|
|
|
|
NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32();
|
|
|
|
|
PlayerIndex playerIndex = HidUtils.GetIndexFromNpadIdType(npadIdType);
|
|
|
|
|
|
|
|
|
|
appletFooterUiType = context.Device.Hid.SharedMemory.Npads[(int)playerIndex].InternalState.AppletFooterUiType;
|
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
2019-09-19 02:45:11 +02:00
|
|
|
|
}
|
|
|
|
|
}
|