More HidServer improvements

This commit is contained in:
Isaac Marovitz 2024-07-20 16:16:51 +01:00
parent 0c79bfc064
commit cbcdf47118
No known key found for this signature in database
GPG key ID: 97250B2B09A132E1
8 changed files with 277 additions and 768 deletions

View file

@ -76,89 +76,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid
return ResultCode.Success; return ResultCode.Success;
} }
[CommandCmif(1)]
// ActivateDebugPad(nn::applet::AppletResourceUserId)
public ResultCode ActivateDebugPad(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
// Initialize entries to avoid issues with some games.
for (int entry = 0; entry < Ryujinx.Horizon.Sdk.Hid.Hid.SharedMemEntryCount; entry++)
{
context.Device.Hid.DebugPad.Update();
}
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return ResultCode.Success;
}
[CommandCmif(11)]
// ActivateTouchScreen(nn::applet::AppletResourceUserId)
public ResultCode ActivateTouchScreen(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
context.Device.Hid.Touchscreen.Active = true;
// Initialize entries to avoid issues with some games.
for (int entry = 0; entry < Ryujinx.Horizon.Sdk.Hid.Hid.SharedMemEntryCount; entry++)
{
context.Device.Hid.Touchscreen.Update();
}
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return ResultCode.Success;
}
[CommandCmif(21)]
// ActivateMouse(nn::applet::AppletResourceUserId)
public ResultCode ActivateMouse(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
context.Device.Hid.Mouse.Active = true;
// Initialize entries to avoid issues with some games.
for (int entry = 0; entry < Ryujinx.Horizon.Sdk.Hid.Hid.SharedMemEntryCount; entry++)
{
context.Device.Hid.Mouse.Update(0, 0);
}
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return ResultCode.Success;
}
[CommandCmif(31)]
// ActivateKeyboard(nn::applet::AppletResourceUserId)
public ResultCode ActivateKeyboard(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
context.Device.Hid.Keyboard.Active = true;
// Initialize entries to avoid issues with some games.
KeyboardInput emptyInput = new()
{
Keys = new ulong[4],
};
for (int entry = 0; entry < Ryujinx.Horizon.Sdk.Hid.Hid.SharedMemEntryCount; entry++)
{
context.Device.Hid.Keyboard.Update(emptyInput);
}
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return ResultCode.Success;
}
[CommandCmif(32)] [CommandCmif(32)]
// SendKeyboardLockKeyEvent(uint flags, pid) // SendKeyboardLockKeyEvent(uint flags, pid)
public ResultCode SendKeyboardLockKeyEvent(ServiceCtx context) public ResultCode SendKeyboardLockKeyEvent(ServiceCtx context)
@ -445,145 +362,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid
return ResultCode.Success; return ResultCode.Success;
} }
[CommandCmif(73)]
// SetAccelerometerParameters(nn::hid::SixAxisSensorHandle, float X, float Y, nn::applet::AppletResourceUserId)
public ResultCode SetAccelerometerParameters(ServiceCtx context)
{
int sixAxisSensorHandle = context.RequestData.ReadInt32();
context.RequestData.BaseStream.Position += 4; // Padding
_accelerometerParams = new AccelerometerParameters
{
X = context.RequestData.ReadInt32(),
Y = context.RequestData.ReadInt32(),
};
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _accelerometerParams.X, _accelerometerParams.Y });
return ResultCode.Success;
}
[CommandCmif(74)]
// GetAccelerometerParameters(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) -> float X, float Y
public ResultCode GetAccelerometerParameters(ServiceCtx context)
{
int sixAxisSensorHandle = context.RequestData.ReadInt32();
context.RequestData.BaseStream.Position += 4; // Padding
long appletResourceUserId = context.RequestData.ReadInt64();
context.ResponseData.Write(_accelerometerParams.X);
context.ResponseData.Write(_accelerometerParams.Y);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _accelerometerParams.X, _accelerometerParams.Y });
return ResultCode.Success;
}
[CommandCmif(75)]
// ResetAccelerometerParameters(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId)
public ResultCode ResetAccelerometerParameters(ServiceCtx context)
{
int sixAxisSensorHandle = context.RequestData.ReadInt32();
context.RequestData.BaseStream.Position += 4; // Padding
long appletResourceUserId = context.RequestData.ReadInt64();
_accelerometerParams.X = 0;
_accelerometerParams.Y = 0;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _accelerometerParams.X, _accelerometerParams.Y });
return ResultCode.Success;
}
[CommandCmif(76)]
// SetAccelerometerPlayMode(nn::hid::SixAxisSensorHandle, uint PlayMode, nn::applet::AppletResourceUserId)
public ResultCode SetAccelerometerPlayMode(ServiceCtx context)
{
int sixAxisSensorHandle = context.RequestData.ReadInt32();
context.RequestData.BaseStream.Position += 4; // Padding
_accelerometerPlayMode = context.RequestData.ReadUInt32();
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _accelerometerPlayMode });
return ResultCode.Success;
}
[CommandCmif(77)]
// GetAccelerometerPlayMode(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) -> uint PlayMode
public ResultCode GetAccelerometerPlayMode(ServiceCtx context)
{
int sixAxisSensorHandle = context.RequestData.ReadInt32();
context.RequestData.BaseStream.Position += 4; // Padding
long appletResourceUserId = context.RequestData.ReadInt64();
context.ResponseData.Write(_accelerometerPlayMode);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _accelerometerPlayMode });
return ResultCode.Success;
}
[CommandCmif(78)]
// ResetAccelerometerPlayMode(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId)
public ResultCode ResetAccelerometerPlayMode(ServiceCtx context)
{
int sixAxisSensorHandle = context.RequestData.ReadInt32();
context.RequestData.BaseStream.Position += 4; // Padding
long appletResourceUserId = context.RequestData.ReadInt64();
_accelerometerPlayMode = 0;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _accelerometerPlayMode });
return ResultCode.Success;
}
[CommandCmif(79)]
// SetGyroscopeZeroDriftMode(nn::hid::SixAxisSensorHandle, uint GyroscopeZeroDriftMode, nn::applet::AppletResourceUserId)
public ResultCode SetGyroscopeZeroDriftMode(ServiceCtx context)
{
int sixAxisSensorHandle = context.RequestData.ReadInt32();
_gyroscopeZeroDriftMode = (GyroscopeZeroDriftMode)context.RequestData.ReadInt32();
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _gyroscopeZeroDriftMode });
return ResultCode.Success;
}
[CommandCmif(80)]
// GetGyroscopeZeroDriftMode(nn::applet::AppletResourceUserId, nn::hid::SixAxisSensorHandle) -> int GyroscopeZeroDriftMode
public ResultCode GetGyroscopeZeroDriftMode(ServiceCtx context)
{
int sixAxisSensorHandle = context.RequestData.ReadInt32();
context.RequestData.BaseStream.Position += 4; // Padding
long appletResourceUserId = context.RequestData.ReadInt64();
context.ResponseData.Write((int)_gyroscopeZeroDriftMode);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _gyroscopeZeroDriftMode });
return ResultCode.Success;
}
[CommandCmif(81)]
// ResetGyroscopeZeroDriftMode(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId)
public ResultCode ResetGyroscopeZeroDriftMode(ServiceCtx context)
{
int sixAxisSensorHandle = context.RequestData.ReadInt32();
context.RequestData.BaseStream.Position += 4; // Padding
long appletResourceUserId = context.RequestData.ReadInt64();
_gyroscopeZeroDriftMode = GyroscopeZeroDriftMode.Standard;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _gyroscopeZeroDriftMode });
return ResultCode.Success;
}
[CommandCmif(82)] [CommandCmif(82)]
// IsSixAxisSensorAtRest(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) -> bool IsAsRest // IsSixAxisSensorAtRest(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) -> bool IsAsRest
public ResultCode IsSixAxisSensorAtRest(ServiceCtx context) public ResultCode IsSixAxisSensorAtRest(ServiceCtx context)
@ -644,80 +422,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid
return ResultCode.Success; return ResultCode.Success;
} }
[CommandCmif(87)] // 13.0.0+
// LoadSixAxisSensorCalibrationParameter(nn::applet::AppletResourceUserId, nn::hid::SixAxisSensorHandle, u64 unknown)
public ResultCode LoadSixAxisSensorCalibrationParameter(ServiceCtx context)
{
int sixAxisSensorHandle = context.RequestData.ReadInt32();
context.RequestData.BaseStream.Position += 4; // Padding
long appletResourceUserId = context.RequestData.ReadInt64();
// TODO: CalibrationParameter have to be determined.
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle });
return ResultCode.Success;
}
[CommandCmif(88)] // 13.0.0+
// GetSixAxisSensorIcInformation(nn::applet::AppletResourceUserId, nn::hid::SixAxisSensorHandle) -> u64 unknown
public ResultCode GetSixAxisSensorIcInformation(ServiceCtx context)
{
int sixAxisSensorHandle = context.RequestData.ReadInt32();
context.RequestData.BaseStream.Position += 4; // Padding
long appletResourceUserId = context.RequestData.ReadInt64();
// TODO: IcInformation have to be determined.
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle });
return ResultCode.Success;
}
[CommandCmif(91)]
// ActivateGesture(nn::applet::AppletResourceUserId, int Unknown0)
public ResultCode ActivateGesture(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
int unknown0 = context.RequestData.ReadInt32();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, unknown0 });
return ResultCode.Success;
}
[CommandCmif(100)]
// SetSupportedNpadStyleSet(pid, nn::applet::AppletResourceUserId, nn::hid::NpadStyleTag)
public ResultCode SetSupportedNpadStyleSet(ServiceCtx context)
{
ulong pid = context.Request.HandleDesc.PId;
ControllerType type = (ControllerType)context.RequestData.ReadInt32();
context.RequestData.BaseStream.Position += 4; // Padding
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { pid, appletResourceUserId, type });
context.Device.Hid.Npads.SupportedStyleSets = type;
return ResultCode.Success;
}
[CommandCmif(101)]
// GetSupportedNpadStyleSet(pid, nn::applet::AppletResourceUserId) -> uint nn::hid::NpadStyleTag
public ResultCode GetSupportedNpadStyleSet(ServiceCtx context)
{
#pragma warning disable IDE0059 // Remove unnecessary value assignment
ulong pid = context.Request.HandleDesc.PId;
#pragma warning restore IDE0059
long appletResourceUserId = context.RequestData.ReadInt64();
context.ResponseData.Write((int)context.Device.Hid.Npads.SupportedStyleSets);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, context.Device.Hid.Npads.SupportedStyleSets });
return ResultCode.Success;
}
[CommandCmif(102)] [CommandCmif(102)]
// SetSupportedNpadIdType(nn::applet::AppletResourceUserId, array<NpadIdType, 9>) // SetSupportedNpadIdType(nn::applet::AppletResourceUserId, array<NpadIdType, 9>)
public ResultCode SetSupportedNpadIdType(ServiceCtx context) public ResultCode SetSupportedNpadIdType(ServiceCtx context)
@ -1348,248 +1052,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid
return ResultCode.Success; return ResultCode.Success;
} }
[CommandCmif(209)] // 4.0.0+
// BeginPermitVibrationSession(nn::applet::AppletResourceUserId)
public ResultCode BeginPermitVibrationSession(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return ResultCode.Success;
}
[CommandCmif(210)] // 4.0.0+
// EndPermitVibrationSession()
public ResultCode EndPermitVibrationSession(ServiceCtx context)
{
Logger.Stub?.PrintStub(LogClass.ServiceHid);
return ResultCode.Success;
}
[CommandCmif(211)] // 7.0.0+
// IsVibrationDeviceMounted(nn::hid::VibrationDeviceHandle, nn::applet::AppletResourceUserId)
public ResultCode IsVibrationDeviceMounted(ServiceCtx context)
{
#pragma warning disable IDE0059 // Remove unnecessary value assignment
int vibrationDeviceHandle = context.RequestData.ReadInt32();
long appletResourceUserId = context.RequestData.ReadInt64();
#pragma warning restore IDE0059
// NOTE: Service use vibrationDeviceHandle to get the PlayerIndex.
// And return false if (npadIdType >= (NpadIdType)8 && npadIdType != NpadIdType.Handheld && npadIdType != NpadIdType.Unknown)
context.ResponseData.Write(true);
return ResultCode.Success;
}
[CommandCmif(300)]
// ActivateConsoleSixAxisSensor(nn::applet::AppletResourceUserId)
public ResultCode ActivateConsoleSixAxisSensor(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return ResultCode.Success;
}
[CommandCmif(301)]
// StartConsoleSixAxisSensor(nn::hid::ConsoleSixAxisSensorHandle, nn::applet::AppletResourceUserId)
public ResultCode StartConsoleSixAxisSensor(ServiceCtx context)
{
int consoleSixAxisSensorHandle = context.RequestData.ReadInt32();
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, consoleSixAxisSensorHandle });
return ResultCode.Success;
}
[CommandCmif(302)]
// StopConsoleSixAxisSensor(nn::hid::ConsoleSixAxisSensorHandle, nn::applet::AppletResourceUserId)
public ResultCode StopConsoleSixAxisSensor(ServiceCtx context)
{
int consoleSixAxisSensorHandle = context.RequestData.ReadInt32();
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, consoleSixAxisSensorHandle });
return ResultCode.Success;
}
[CommandCmif(303)] // 5.0.0+
// ActivateSevenSixAxisSensor(nn::applet::AppletResourceUserId)
public ResultCode ActivateSevenSixAxisSensor(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return ResultCode.Success;
}
[CommandCmif(304)] // 5.0.0+
// StartSevenSixAxisSensor(nn::applet::AppletResourceUserId)
public ResultCode StartSevenSixAxisSensor(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return ResultCode.Success;
}
[CommandCmif(305)] // 5.0.0+
// StopSevenSixAxisSensor(nn::applet::AppletResourceUserId)
public ResultCode StopSevenSixAxisSensor(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return ResultCode.Success;
}
[CommandCmif(306)] // 5.0.0+
// InitializeSevenSixAxisSensor(array<nn::sf::NativeHandle>, ulong Counter0, array<nn::sf::NativeHandle>, ulong Counter1, nn::applet::AppletResourceUserId)
public ResultCode InitializeSevenSixAxisSensor(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
long counter0 = context.RequestData.ReadInt64();
long counter1 = context.RequestData.ReadInt64();
// TODO: Determine if array<nn::sf::NativeHandle> is a buffer or not...
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, counter0, counter1 });
return ResultCode.Success;
}
[CommandCmif(307)] // 5.0.0+
// FinalizeSevenSixAxisSensor(nn::applet::AppletResourceUserId)
public ResultCode FinalizeSevenSixAxisSensor(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return ResultCode.Success;
}
[CommandCmif(308)] // 5.0.0+
// SetSevenSixAxisSensorFusionStrength(float Strength, nn::applet::AppletResourceUserId)
public ResultCode SetSevenSixAxisSensorFusionStrength(ServiceCtx context)
{
_sevenSixAxisSensorFusionStrength = context.RequestData.ReadSingle();
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, _sevenSixAxisSensorFusionStrength });
return ResultCode.Success;
}
[CommandCmif(309)] // 5.0.0+
// GetSevenSixAxisSensorFusionStrength(nn::applet::AppletResourceUserId) -> float Strength
public ResultCode GetSevenSixAxisSensorFusionStrength(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
context.ResponseData.Write(_sevenSixAxisSensorFusionStrength);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, _sevenSixAxisSensorFusionStrength });
return ResultCode.Success;
}
[CommandCmif(310)] // 6.0.0+
// ResetSevenSixAxisSensorTimestamp(pid, nn::applet::AppletResourceUserId)
public ResultCode ResetSevenSixAxisSensorTimestamp(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return ResultCode.Success;
}
[CommandCmif(400)]
// IsUsbFullKeyControllerEnabled() -> bool IsEnabled
public ResultCode IsUsbFullKeyControllerEnabled(ServiceCtx context)
{
context.ResponseData.Write(_usbFullKeyControllerEnabled);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { _usbFullKeyControllerEnabled });
return ResultCode.Success;
}
[CommandCmif(401)]
// EnableUsbFullKeyController(bool Enable)
public ResultCode EnableUsbFullKeyController(ServiceCtx context)
{
_usbFullKeyControllerEnabled = context.RequestData.ReadBoolean();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { _usbFullKeyControllerEnabled });
return ResultCode.Success;
}
[CommandCmif(402)]
// IsUsbFullKeyControllerConnected(uint Unknown0) -> bool Connected
public ResultCode IsUsbFullKeyControllerConnected(ServiceCtx context)
{
int unknown0 = context.RequestData.ReadInt32();
context.ResponseData.Write(true); //FullKeyController is always connected ?
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { unknown0, Connected = true });
return ResultCode.Success;
}
[CommandCmif(403)] // 4.0.0+
// HasBattery(uint NpadId) -> bool HasBattery
public ResultCode HasBattery(ServiceCtx context)
{
int npadId = context.RequestData.ReadInt32();
context.ResponseData.Write(true); //Npad always got a battery ?
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { npadId, HasBattery = true });
return ResultCode.Success;
}
[CommandCmif(404)] // 4.0.0+
// HasLeftRightBattery(uint NpadId) -> bool HasLeftBattery, bool HasRightBattery
public ResultCode HasLeftRightBattery(ServiceCtx context)
{
int npadId = context.RequestData.ReadInt32();
context.ResponseData.Write(true); //Npad always got a left battery ?
context.ResponseData.Write(true); //Npad always got a right battery ?
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { npadId, HasLeftBattery = true, HasRightBattery = true });
return ResultCode.Success;
}
[CommandCmif(405)] // 4.0.0+
// GetNpadInterfaceType(uint NpadId) -> uchar InterfaceType
public ResultCode GetNpadInterfaceType(ServiceCtx context)
{
int npadId = context.RequestData.ReadInt32();
context.ResponseData.Write((byte)0);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { npadId, NpadInterfaceType = 0 });
return ResultCode.Success;
}
[CommandCmif(406)] // 4.0.0+ [CommandCmif(406)] // 4.0.0+
// GetNpadLeftRightInterfaceType(uint NpadId) -> uchar LeftInterfaceType, uchar RightInterfaceType // GetNpadLeftRightInterfaceType(uint NpadId) -> uchar LeftInterfaceType, uchar RightInterfaceType
public ResultCode GetNpadLeftRightInterfaceType(ServiceCtx context) public ResultCode GetNpadLeftRightInterfaceType(ServiceCtx context)
@ -1761,84 +1223,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid
return ResultCode.Success; return ResultCode.Success;
} }
[CommandCmif(511)] // 5.0.0+
// ReadPalmaUniqueCode(nn::hid::PalmaConnectionHandle)
public ResultCode ReadPalmaUniqueCode(ServiceCtx context)
{
int palmaConnectionHandle = context.RequestData.ReadInt32();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
return ResultCode.Success;
}
[CommandCmif(512)] // 5.0.0+
// SetPalmaUniqueCodeInvalid(nn::hid::PalmaConnectionHandle)
public ResultCode SetPalmaUniqueCodeInvalid(ServiceCtx context)
{
int palmaConnectionHandle = context.RequestData.ReadInt32();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
return ResultCode.Success;
}
[CommandCmif(522)] // 5.1.0+
// SetIsPalmaAllConnectable(nn::applet::AppletResourceUserId, bool, pid)
public ResultCode SetIsPalmaAllConnectable(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
long unknownBool = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, unknownBool });
return ResultCode.Success;
}
[CommandCmif(525)] // 5.1.0+
// SetPalmaBoostMode(bool)
public ResultCode SetPalmaBoostMode(ServiceCtx context)
{
// NOTE: Stubbed in system module.
return ResultCode.Success;
}
[CommandCmif(1000)]
// SetNpadCommunicationMode(long CommunicationMode, nn::applet::AppletResourceUserId)
public ResultCode SetNpadCommunicationMode(ServiceCtx context)
{
_npadCommunicationMode = context.RequestData.ReadInt64();
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, _npadCommunicationMode });
return ResultCode.Success;
}
[CommandCmif(1001)]
// GetNpadCommunicationMode() -> long CommunicationMode
public ResultCode GetNpadCommunicationMode(ServiceCtx context)
{
context.ResponseData.Write(_npadCommunicationMode);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { _npadCommunicationMode });
return ResultCode.Success;
}
[CommandCmif(1002)] // 9.0.0+
// SetTouchScreenConfiguration(nn::hid::TouchScreenConfigurationForNx, nn::applet::AppletResourceUserId)
public ResultCode SetTouchScreenConfiguration(ServiceCtx context)
{
long touchScreenConfigurationForNx = context.RequestData.ReadInt64();
long appletResourceUserId = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, touchScreenConfigurationForNx });
return ResultCode.Success;
}
[CommandCmif(1004)] // 17.0.0+ [CommandCmif(1004)] // 17.0.0+
// SetTouchScreenResolution(int width, int height, nn::applet::AppletResourceUserId) // SetTouchScreenResolution(int width, int height, nn::applet::AppletResourceUserId)
public ResultCode SetTouchScreenResolution(ServiceCtx context) public ResultCode SetTouchScreenResolution(ServiceCtx context)

View file

@ -2,6 +2,8 @@ using Ryujinx.Common.Logging;
using Ryujinx.Horizon.Common; using Ryujinx.Horizon.Common;
using Ryujinx.Horizon.Sdk.Applet; using Ryujinx.Horizon.Sdk.Applet;
using Ryujinx.Horizon.Sdk.Hid; using Ryujinx.Horizon.Sdk.Hid;
using Ryujinx.Horizon.Sdk.Hid.HidDevices;
using Ryujinx.Horizon.Sdk.Hid.Npad;
using Ryujinx.Horizon.Sdk.Hid.SixAxis; using Ryujinx.Horizon.Sdk.Hid.SixAxis;
using Ryujinx.Horizon.Sdk.Hid.Vibration; using Ryujinx.Horizon.Sdk.Hid.Vibration;
using Ryujinx.Horizon.Sdk.Sf; using Ryujinx.Horizon.Sdk.Sf;
@ -11,6 +13,51 @@ namespace Ryujinx.Horizon.Hid
{ {
partial class HidServer : IHidServer partial class HidServer : IHidServer
{ {
internal const int SharedMemEntryCount = 17;
public DebugPadDevice DebugPad;
public TouchDevice Touchscreen;
public MouseDevice Mouse;
public KeyboardDevice Keyboard;
public NpadDevices Npads;
private bool _sixAxisSensorFusionEnabled;
private bool _unintendedHomeButtonInputProtectionEnabled;
private bool _npadAnalogStickCenterClampEnabled;
private bool _vibrationPermitted;
private bool _usbFullKeyControllerEnabled;
private readonly bool _isFirmwareUpdateAvailableForSixAxisSensor;
private bool _isSixAxisSensorUnalteredPassthroughEnabled;
private NpadHandheldActivationMode _npadHandheldActivationMode;
private GyroscopeZeroDriftMode _gyroscopeZeroDriftMode;
private long _npadCommunicationMode;
private uint _accelerometerPlayMode;
private float _sevenSixAxisSensorFusionStrength;
private SensorFusionParameters _sensorFusionParams;
private AccelerometerParameters _accelerometerParams;
public HidServer()
{
DebugPad = new DebugPadDevice(true);
Touchscreen = new TouchDevice(true);
Mouse = new MouseDevice(false);
Keyboard = new KeyboardDevice(false);
Npads = new NpadDevices(true);
_npadHandheldActivationMode = NpadHandheldActivationMode.Dual;
_gyroscopeZeroDriftMode = GyroscopeZeroDriftMode.Standard;
_isFirmwareUpdateAvailableForSixAxisSensor = false;
_sensorFusionParams = new SensorFusionParameters();
_accelerometerParams = new AccelerometerParameters();
_vibrationPermitted = true;
}
[CmifCommand(0)] [CmifCommand(0)]
public Result CreateAppletResource(out IAppletResource arg0, AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) public Result CreateAppletResource(out IAppletResource arg0, AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
{ {
@ -22,7 +69,14 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(1)] [CmifCommand(1)]
public Result ActivateDebugPad(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) public Result ActivateDebugPad(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); // Initialize entries to avoid issues with some games.
for (int i = 0; i < SharedMemEntryCount; i++)
{
DebugPad.Update();
}
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return Result.Success; return Result.Success;
} }
@ -30,7 +84,16 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(11)] [CmifCommand(11)]
public Result ActivateTouchScreen(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) public Result ActivateTouchScreen(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Touchscreen.Active = true;
// Initialize entries to avoid issues with some games.
for (int i = 0; i < SharedMemEntryCount; i++)
{
Touchscreen.Update();
}
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return Result.Success; return Result.Success;
} }
@ -38,7 +101,16 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(21)] [CmifCommand(21)]
public Result ActivateMouse(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) public Result ActivateMouse(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Mouse.Active = true;
// Initialize entries to avoid issues with some games.
for (int i = 0; i < SharedMemEntryCount; i++)
{
Mouse.Update(0, 0);
}
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return Result.Success; return Result.Success;
} }
@ -46,7 +118,21 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(31)] [CmifCommand(31)]
public Result ActivateKeyboard(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) public Result ActivateKeyboard(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Keyboard.Active = true;
// Initialize entries to avoid issues with some games.
KeyboardInput emptyInput = new()
{
Keys = new ulong[4],
};
for (int i = 0; i < SharedMemEntryCount; i++)
{
Keyboard.Update(emptyInput);
}
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return Result.Success; return Result.Success;
} }
@ -54,13 +140,15 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(32)] [CmifCommand(32)]
public Result SendKeyboardLockKeyEvent(AppletResourceUserId appletResourceUserId, KeyboardLockKeyEvent keyboardLockKeyEvent, [ClientProcessId] ulong pid) public Result SendKeyboardLockKeyEvent(AppletResourceUserId appletResourceUserId, KeyboardLockKeyEvent keyboardLockKeyEvent, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); // NOTE: This signals the keyboard driver about lock events.
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { keyboardLockKeyEvent });
return Result.Success; return Result.Success;
} }
[CmifCommand(40)] [CmifCommand(40)]
public Result AcquireXpadIdEventHandle(out int arg0, ulong arg1) public Result AcquireXpadIdEventHandle(out int arg0, ulong xpadId)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid);
@ -68,7 +156,7 @@ namespace Ryujinx.Horizon.Hid
} }
[CmifCommand(41)] [CmifCommand(41)]
public Result ReleaseXpadIdEventHandle(ulong arg0) public Result ReleaseXpadIdEventHandle(ulong xpadId)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid);
@ -220,17 +308,26 @@ namespace Ryujinx.Horizon.Hid
} }
[CmifCommand(73)] [CmifCommand(73)]
public Result SetAccelerometerParameters(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, float arg2, float arg3, [ClientProcessId] ulong pid) public Result SetAccelerometerParameters(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, float x, float y, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); _accelerometerParams = new AccelerometerParameters
{
X = x,
Y = y,
};
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _accelerometerParams.X, _accelerometerParams.Y });
return Result.Success; return Result.Success;
} }
[CmifCommand(74)] [CmifCommand(74)]
public Result GetAccelerometerParameters(out float arg0, out float arg1, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid) public Result GetAccelerometerParameters(out float x, out float y, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); x = _accelerometerParams.X;
y = _accelerometerParams.Y;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _accelerometerParams.X, _accelerometerParams.Y });
return Result.Success; return Result.Success;
} }
@ -238,23 +335,30 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(75)] [CmifCommand(75)]
public Result ResetAccelerometerParameters(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid) public Result ResetAccelerometerParameters(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); _accelerometerParams.X = 0;
_accelerometerParams.Y = 0;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _accelerometerParams.X, _accelerometerParams.Y });
return Result.Success; return Result.Success;
} }
[CmifCommand(76)] [CmifCommand(76)]
public Result SetAccelerometerPlayMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, uint arg2, [ClientProcessId] ulong pid) public Result SetAccelerometerPlayMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, uint accelerometerPlayMode, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); _accelerometerPlayMode = accelerometerPlayMode;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _accelerometerPlayMode });
return Result.Success; return Result.Success;
} }
[CmifCommand(77)] [CmifCommand(77)]
public Result GetAccelerometerPlayMode(out uint arg0, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid) public Result GetAccelerometerPlayMode(out uint accelerometerPlayMode, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); accelerometerPlayMode = _accelerometerPlayMode;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _accelerometerPlayMode });
return Result.Success; return Result.Success;
} }
@ -262,23 +366,29 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(78)] [CmifCommand(78)]
public Result ResetAccelerometerPlayMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid) public Result ResetAccelerometerPlayMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); _accelerometerPlayMode = 0;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _accelerometerPlayMode });
return Result.Success; return Result.Success;
} }
[CmifCommand(79)] [CmifCommand(79)]
public Result SetGyroscopeZeroDriftMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, uint arg2, [ClientProcessId] ulong pid) public Result SetGyroscopeZeroDriftMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, GyroscopeZeroDriftMode gyroscopeZeroDriftMode, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); _gyroscopeZeroDriftMode = gyroscopeZeroDriftMode;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _gyroscopeZeroDriftMode });
return Result.Success; return Result.Success;
} }
[CmifCommand(80)] [CmifCommand(80)]
public Result GetGyroscopeZeroDriftMode(out uint arg0, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid) public Result GetGyroscopeZeroDriftMode(out GyroscopeZeroDriftMode gyroscopeZeroDriftMode, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); gyroscopeZeroDriftMode = _gyroscopeZeroDriftMode;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _gyroscopeZeroDriftMode });
return Result.Success; return Result.Success;
} }
@ -286,7 +396,9 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(81)] [CmifCommand(81)]
public Result ResetGyroscopeZeroDriftMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid) public Result ResetGyroscopeZeroDriftMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); _gyroscopeZeroDriftMode = GyroscopeZeroDriftMode.Standard;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle, _gyroscopeZeroDriftMode });
return Result.Success; return Result.Success;
} }
@ -326,7 +438,7 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(86)] [CmifCommand(86)]
public Result StoreSixAxisSensorCalibrationParameter(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, in SixAxisSensorCalibrationParameter sixAxisSensorCalibrationParameter, [ClientProcessId] ulong pid) public Result StoreSixAxisSensorCalibrationParameter(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, in SixAxisSensorCalibrationParameter sixAxisSensorCalibrationParameter, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { sixAxisSensorHandle, sixAxisSensorCalibrationParameter });
return Result.Success; return Result.Success;
} }
@ -334,7 +446,9 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(87)] [CmifCommand(87)]
public Result LoadSixAxisSensorCalibrationParameter(AppletResourceUserId appletResourceUserId, out SixAxisSensorCalibrationParameter sixAxisSensorCalibrationParameter, SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid) public Result LoadSixAxisSensorCalibrationParameter(AppletResourceUserId appletResourceUserId, out SixAxisSensorCalibrationParameter sixAxisSensorCalibrationParameter, SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); // TODO: CalibrationParameter have to be determined.
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle });
return Result.Success; return Result.Success;
} }
@ -342,14 +456,15 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(88)] [CmifCommand(88)]
public Result GetSixAxisSensorIcInformation(AppletResourceUserId appletResourceUserId, out SixAxisSensorIcInformation sixAxisSensorIcInformation, SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid) public Result GetSixAxisSensorIcInformation(AppletResourceUserId appletResourceUserId, out SixAxisSensorIcInformation sixAxisSensorIcInformation, SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); // TODO: IcInformation have to be determined.
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, sixAxisSensorHandle });
return Result.Success; return Result.Success;
} }
[CmifCommand(89)] [CmifCommand(89)]
public Result ResetIsSixAxisSensorDeviceNewlyAssigned(AppletResourceUserId appletResourceUserId, public Result ResetIsSixAxisSensorDeviceNewlyAssigned(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid)
SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid);
@ -357,25 +472,29 @@ namespace Ryujinx.Horizon.Hid
} }
[CmifCommand(91)] [CmifCommand(91)]
public Result ActivateGesture(AppletResourceUserId appletResourceUserId, int arg1, [ClientProcessId] ulong pid) public Result ActivateGesture(AppletResourceUserId appletResourceUserId, int unknown, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, unknown });
return Result.Success; return Result.Success;
} }
[CmifCommand(100)] [CmifCommand(100)]
public Result SetSupportedNpadStyleSet(AppletResourceUserId appletResourceUserId, NpadStyleTag arg1, [ClientProcessId] ulong pid) public Result SetSupportedNpadStyleSet(AppletResourceUserId appletResourceUserId, NpadStyleTag supportedStyleSets, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { pid, appletResourceUserId, supportedStyleSets });
Npads.SupportedStyleSets = supportedStyleSets;
return Result.Success; return Result.Success;
} }
[CmifCommand(101)] [CmifCommand(101)]
public Result GetSupportedNpadStyleSet(AppletResourceUserId appletResourceUserId, out NpadStyleTag arg1, [ClientProcessId] ulong pid) public Result GetSupportedNpadStyleSet(AppletResourceUserId appletResourceUserId, out NpadStyleTag supportedStyleSets, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); supportedStyleSets = Npads.SupportedStyleSets;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, Npads.SupportedStyleSets });
return Result.Success; return Result.Success;
} }
@ -647,7 +766,7 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(209)] [CmifCommand(209)]
public Result BeginPermitVibrationSession(AppletResourceUserId appletResourceUserId) public Result BeginPermitVibrationSession(AppletResourceUserId appletResourceUserId)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return Result.Success; return Result.Success;
} }
@ -661,9 +780,12 @@ namespace Ryujinx.Horizon.Hid
} }
[CmifCommand(211)] [CmifCommand(211)]
public Result IsVibrationDeviceMounted(out bool arg0, AppletResourceUserId appletResourceUserId, VibrationDeviceHandle vibrationDeviceHandle, [ClientProcessId] ulong pid) public Result IsVibrationDeviceMounted(out bool isVibrationDeviceMounted, AppletResourceUserId appletResourceUserId, VibrationDeviceHandle vibrationDeviceHandle, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); // NOTE: Service use vibrationDeviceHandle to get the PlayerIndex.
// And return false if (npadIdType >= (NpadIdType)8 && npadIdType != NpadIdType.Handheld && npadIdType != NpadIdType.Unknown)
isVibrationDeviceMounted = true;
return Result.Success; return Result.Success;
} }
@ -679,7 +801,7 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(300)] [CmifCommand(300)]
public Result ActivateConsoleSixAxisSensor(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) public Result ActivateConsoleSixAxisSensor(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return Result.Success; return Result.Success;
} }
@ -687,7 +809,7 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(301)] [CmifCommand(301)]
public Result StartConsoleSixAxisSensor(AppletResourceUserId appletResourceUserId, ConsoleSixAxisSensorHandle consoleSixAxisSensorHandle, [ClientProcessId] ulong pid) public Result StartConsoleSixAxisSensor(AppletResourceUserId appletResourceUserId, ConsoleSixAxisSensorHandle consoleSixAxisSensorHandle, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, consoleSixAxisSensorHandle });
return Result.Success; return Result.Success;
} }
@ -695,7 +817,7 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(302)] [CmifCommand(302)]
public Result StopConsoleSixAxisSensor(AppletResourceUserId appletResourceUserId, ConsoleSixAxisSensorHandle consoleSixAxisSensorHandle, [ClientProcessId] ulong pid) public Result StopConsoleSixAxisSensor(AppletResourceUserId appletResourceUserId, ConsoleSixAxisSensorHandle consoleSixAxisSensorHandle, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, consoleSixAxisSensorHandle });
return Result.Success; return Result.Success;
} }
@ -703,7 +825,7 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(303)] [CmifCommand(303)]
public Result ActivateSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) public Result ActivateSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return Result.Success; return Result.Success;
} }
@ -711,7 +833,7 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(304)] [CmifCommand(304)]
public Result StartSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) public Result StartSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return Result.Success; return Result.Success;
} }
@ -719,15 +841,17 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(305)] [CmifCommand(305)]
public Result StopSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) public Result StopSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return Result.Success; return Result.Success;
} }
[CmifCommand(306)] [CmifCommand(306)]
public Result InitializeSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, int arg1, ulong arg2, int arg3, ulong arg4, [ClientProcessId] ulong pid) public Result InitializeSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, int nativeHandle0, ulong counter0, int nativeHandle1, ulong counter1, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); // TODO: Determine if array<nn::sf::NativeHandle> is a buffer or not...
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, counter0, counter1 });
return Result.Success; return Result.Success;
} }
@ -735,23 +859,27 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(307)] [CmifCommand(307)]
public Result FinalizeSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) public Result FinalizeSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return Result.Success; return Result.Success;
} }
[CmifCommand(308)] [CmifCommand(308)]
public Result SetSevenSixAxisSensorFusionStrength(AppletResourceUserId appletResourceUserId, float arg1, [ClientProcessId] ulong pid) public Result SetSevenSixAxisSensorFusionStrength(AppletResourceUserId appletResourceUserId, float sevenSixAxisSensorFusionStrength, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); _sevenSixAxisSensorFusionStrength = sevenSixAxisSensorFusionStrength;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, _sevenSixAxisSensorFusionStrength });
return Result.Success; return Result.Success;
} }
[CmifCommand(309)] [CmifCommand(309)]
public Result GetSevenSixAxisSensorFusionStrength(out float arg0, AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) public Result GetSevenSixAxisSensorFusionStrength(out float sevenSixSensorFusionStrength, AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); sevenSixSensorFusionStrength = _sevenSixAxisSensorFusionStrength;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, _sevenSixAxisSensorFusionStrength });
return Result.Success; return Result.Success;
} }
@ -759,55 +887,68 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(310)] [CmifCommand(310)]
public Result ResetSevenSixAxisSensorTimestamp(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) public Result ResetSevenSixAxisSensorTimestamp(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return Result.Success; return Result.Success;
} }
[CmifCommand(400)] [CmifCommand(400)]
public Result IsUsbFullKeyControllerEnabled(out bool arg0) public Result IsUsbFullKeyControllerEnabled(out bool isUsbFullKeyControllerEnabled)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); isUsbFullKeyControllerEnabled = _usbFullKeyControllerEnabled;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { _usbFullKeyControllerEnabled });
return Result.Success; return Result.Success;
} }
[CmifCommand(401)] [CmifCommand(401)]
public Result EnableUsbFullKeyController(bool arg0) public Result EnableUsbFullKeyController(bool usbFullKeyControllerEnabled)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); _usbFullKeyControllerEnabled = usbFullKeyControllerEnabled;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { _usbFullKeyControllerEnabled });
return Result.Success; return Result.Success;
} }
[CmifCommand(402)] [CmifCommand(402)]
public Result IsUsbFullKeyControllerConnected(out bool arg0, uint arg1) public Result IsUsbFullKeyControllerConnected(out bool isConnected, uint unknown)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); isConnected = true; // FullKeyController is always connected?
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { unknown, Connected = true });
return Result.Success; return Result.Success;
} }
[CmifCommand(403)] [CmifCommand(403)]
public Result HasBattery(out bool arg0, uint arg1) public Result HasBattery(out bool hasBattery, uint npadId)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); hasBattery = true; // Npad always has a battery?
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { npadId, HasBattery = true });
return Result.Success; return Result.Success;
} }
[CmifCommand(404)] [CmifCommand(404)]
public Result HasLeftRightBattery(out bool arg0, out bool arg1, uint arg2) public Result HasLeftRightBattery(out bool hasLeftBattery, out bool hasRightBattery, uint npadId)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); hasLeftBattery = true; // Npad always has a left battery?
hasRightBattery = true; // Npad always has a right battery?
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { npadId, HasLeftBattery = true, HasRightBattery = true });
return Result.Success; return Result.Success;
} }
[CmifCommand(405)] [CmifCommand(405)]
public Result GetNpadInterfaceType(out byte arg0, uint arg1) public Result GetNpadInterfaceType(out byte npadInterfaceType, uint npadId)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); npadInterfaceType = 0;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { npadId, NpadInterfaceType = 0 });
return Result.Success; return Result.Success;
} }
@ -919,7 +1060,7 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(511)] [CmifCommand(511)]
public Result ReadPalmaUniqueCode(PalmaConnectionHandle palmaConnectionHandle) public Result ReadPalmaUniqueCode(PalmaConnectionHandle palmaConnectionHandle)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
return Result.Success; return Result.Success;
} }
@ -927,7 +1068,7 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(512)] [CmifCommand(512)]
public Result SetPalmaUniqueCodeInvalid(PalmaConnectionHandle palmaConnectionHandle) public Result SetPalmaUniqueCodeInvalid(PalmaConnectionHandle palmaConnectionHandle)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
return Result.Success; return Result.Success;
} }
@ -1005,9 +1146,9 @@ namespace Ryujinx.Horizon.Hid
} }
[CmifCommand(522)] [CmifCommand(522)]
public Result SetIsPalmaAllConnectable(AppletResourceUserId appletResourceUserId, bool arg1, [ClientProcessId] ulong pid) public Result SetIsPalmaAllConnectable(AppletResourceUserId appletResourceUserId, bool unknownBool, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, unknownBool });
return Result.Success; return Result.Success;
} }
@ -1031,7 +1172,7 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(525)] [CmifCommand(525)]
public Result SetPalmaBoostMode(bool arg0) public Result SetPalmaBoostMode(bool arg0)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); // NOTE: Stubbed in system module.
return Result.Success; return Result.Success;
} }
@ -1069,25 +1210,29 @@ namespace Ryujinx.Horizon.Hid
} }
[CmifCommand(1000)] [CmifCommand(1000)]
public Result SetNpadCommunicationMode(AppletResourceUserId appletResourceUserId, long arg1, [ClientProcessId] ulong pid) public Result SetNpadCommunicationMode(AppletResourceUserId appletResourceUserId, long npadCommunicationMode, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); _npadCommunicationMode = npadCommunicationMode;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, _npadCommunicationMode });
return Result.Success; return Result.Success;
} }
[CmifCommand(1001)] [CmifCommand(1001)]
public Result GetNpadCommunicationMode(out long arg0) public Result GetNpadCommunicationMode(out long npadCommunicationMode)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); npadCommunicationMode = _npadCommunicationMode;
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { _npadCommunicationMode });
return Result.Success; return Result.Success;
} }
[CmifCommand(1002)] [CmifCommand(1002)]
public Result SetTouchScreenConfiguration(AppletResourceUserId appletResourceUserId, TouchScreenConfigurationForNx arg1, [ClientProcessId] ulong pid) public Result SetTouchScreenConfiguration(AppletResourceUserId appletResourceUserId, TouchScreenConfigurationForNx touchScreenConfigurationForNx, [ClientProcessId] ulong pid)
{ {
Logger.Stub?.PrintStub(LogClass.ServiceHid); Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, touchScreenConfigurationForNx });
return Result.Success; return Result.Success;
} }

View file

@ -5,6 +5,6 @@ namespace Ryujinx.Horizon.Sdk.Hid
public struct ControllerConfig public struct ControllerConfig
{ {
public PlayerIndex Player; public PlayerIndex Player;
public ControllerType Type; public NpadStyleTag Type;
} }
} }

View file

@ -5,7 +5,6 @@ using Ryujinx.Horizon.Sdk.Hid.HidDevices;
using Ryujinx.Horizon.Sdk.Hid.Npad; using Ryujinx.Horizon.Sdk.Hid.Npad;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using ControllerType = Ryujinx.Horizon.Sdk.Hid.Npad.ControllerType;
using PlayerIndex = Ryujinx.Horizon.Sdk.Hid.Npad.PlayerIndex; using PlayerIndex = Ryujinx.Horizon.Sdk.Hid.Npad.PlayerIndex;
namespace Ryujinx.Horizon.Sdk.Hid namespace Ryujinx.Horizon.Sdk.Hid
@ -68,7 +67,7 @@ namespace Ryujinx.Horizon.Sdk.Hid
for (int i = 0; i < npadConfig.Length; ++i) for (int i = 0; i < npadConfig.Length; ++i)
{ {
npadConfig[i].Player = (PlayerIndex)inputConfig[i].PlayerIndex; npadConfig[i].Player = (PlayerIndex)inputConfig[i].PlayerIndex;
npadConfig[i].Type = (ControllerType)inputConfig[i].ControllerType; npadConfig[i].Type = inputConfig[i].ControllerType;
} }
Npads.Configure(npadConfig); Npads.Configure(npadConfig);

View file

@ -18,7 +18,7 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices
private long _lastNotifyTimestamp; private long _lastNotifyTimestamp;
public const int MaxControllers = 9; // Players 1-8 and Handheld public const int MaxControllers = 9; // Players 1-8 and Handheld
private ControllerType[] _configuredTypes; private NpadStyleTag[] _configuredTypes;
private readonly Event[] _styleSetUpdateEvents; private readonly Event[] _styleSetUpdateEvents;
private readonly bool[] _supportedPlayers; private readonly bool[] _supportedPlayers;
private VibrationValue _neutralVibrationValue = new() private VibrationValue _neutralVibrationValue = new()
@ -31,18 +31,18 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices
internal NpadJoyHoldType JoyHold { get; set; } internal NpadJoyHoldType JoyHold { get; set; }
internal bool SixAxisActive = false; // TODO: link to hidserver when implemented internal bool SixAxisActive = false; // TODO: link to hidserver when implemented
internal ControllerType SupportedStyleSets { get; set; } internal NpadStyleTag SupportedStyleSets { get; set; }
public Dictionary<PlayerIndex, ConcurrentQueue<(VibrationValue, VibrationValue)>> RumbleQueues = new(); public Dictionary<PlayerIndex, ConcurrentQueue<(VibrationValue, VibrationValue)>> RumbleQueues = new();
public Dictionary<PlayerIndex, (VibrationValue, VibrationValue)> LastVibrationValues = new(); public Dictionary<PlayerIndex, (VibrationValue, VibrationValue)> LastVibrationValues = new();
public NpadDevices(bool active = true) : base(active) public NpadDevices(bool active = true) : base(active)
{ {
_configuredTypes = new ControllerType[MaxControllers]; _configuredTypes = new NpadStyleTag[MaxControllers];
SupportedStyleSets = ControllerType.Handheld | ControllerType.JoyconPair | SupportedStyleSets = NpadStyleTag.Handheld | NpadStyleTag.JoyDual |
ControllerType.JoyconLeft | ControllerType.JoyconRight | NpadStyleTag.JoyLeft | NpadStyleTag.JoyRight |
ControllerType.ProController; NpadStyleTag.FullKey;
_supportedPlayers = new bool[MaxControllers]; _supportedPlayers = new bool[MaxControllers];
_supportedPlayers.AsSpan().Fill(true); _supportedPlayers.AsSpan().Fill(true);
@ -89,23 +89,23 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices
} }
} }
public bool Validate(int playerMin, int playerMax, ControllerType acceptedTypes, out int configuredCount, out PlayerIndex primaryIndex) public bool Validate(int playerMin, int playerMax, NpadStyleTag acceptedTypes, out int configuredCount, out PlayerIndex primaryIndex)
{ {
primaryIndex = PlayerIndex.Unknown; primaryIndex = PlayerIndex.Unknown;
configuredCount = 0; configuredCount = 0;
for (int i = 0; i < MaxControllers; ++i) for (int i = 0; i < MaxControllers; ++i)
{ {
ControllerType npad = _configuredTypes[i]; NpadStyleTag npad = _configuredTypes[i];
if (npad == ControllerType.Handheld && _device.System.State.DockedMode) if (npad == NpadStyleTag.Handheld && _device.System.State.DockedMode)
{ {
continue; continue;
} }
ControllerType currentType = (ControllerType)_device.Hid.SharedMemory.Npads[i].InternalState.StyleSet; NpadStyleTag currentType = (NpadStyleTag)_device.Hid.SharedMemory.Npads[i].InternalState.StyleSet;
if (currentType != ControllerType.None && (npad & acceptedTypes) != 0 && _supportedPlayers[i]) if (currentType != NpadStyleTag.None && (npad & acceptedTypes) != 0 && _supportedPlayers[i])
{ {
configuredCount++; configuredCount++;
if (primaryIndex == PlayerIndex.Unknown) if (primaryIndex == PlayerIndex.Unknown)
@ -125,19 +125,19 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices
public void Configure(params ControllerConfig[] configs) public void Configure(params ControllerConfig[] configs)
{ {
_configuredTypes = new ControllerType[MaxControllers]; _configuredTypes = new NpadStyleTag[MaxControllers];
for (int i = 0; i < configs.Length; ++i) for (int i = 0; i < configs.Length; ++i)
{ {
PlayerIndex player = configs[i].Player; PlayerIndex player = configs[i].Player;
ControllerType controllerType = configs[i].Type; NpadStyleTag controllerType = configs[i].Type;
if (player > PlayerIndex.Handheld) if (player > PlayerIndex.Handheld)
{ {
throw new InvalidOperationException("Player must be Player1-8 or Handheld"); throw new InvalidOperationException("Player must be Player1-8 or Handheld");
} }
if (controllerType == ControllerType.Handheld) if (controllerType == NpadStyleTag.Handheld)
{ {
player = PlayerIndex.Handheld; player = PlayerIndex.Handheld;
} }
@ -178,28 +178,28 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices
// Remap/Init if necessary // Remap/Init if necessary
for (int i = 0; i < MaxControllers; ++i) for (int i = 0; i < MaxControllers; ++i)
{ {
ControllerType config = _configuredTypes[i]; NpadStyleTag config = _configuredTypes[i];
// Remove Handheld config when Docked // Remove Handheld config when Docked
if (config == ControllerType.Handheld && _device.System.State.DockedMode) if (config == NpadStyleTag.Handheld && _device.System.State.DockedMode)
{ {
config = ControllerType.None; config = NpadStyleTag.None;
} }
// Auto-remap ProController and JoyconPair // Auto-remap ProController and JoyconPair
if (config == ControllerType.JoyconPair && (SupportedStyleSets & ControllerType.JoyconPair) == 0 && (SupportedStyleSets & ControllerType.ProController) != 0) if (config == NpadStyleTag.JoyDual && (SupportedStyleSets & NpadStyleTag.JoyDual) == 0 && (SupportedStyleSets & NpadStyleTag.FullKey) != 0)
{ {
config = ControllerType.ProController; config = NpadStyleTag.FullKey;
} }
else if (config == ControllerType.ProController && (SupportedStyleSets & ControllerType.ProController) == 0 && (SupportedStyleSets & ControllerType.JoyconPair) != 0) else if (config == NpadStyleTag.FullKey && (SupportedStyleSets & NpadStyleTag.FullKey) == 0 && (SupportedStyleSets & NpadStyleTag.JoyDual) != 0)
{ {
config = ControllerType.JoyconPair; config = NpadStyleTag.JoyDual;
} }
// Check StyleSet and PlayerSet // Check StyleSet and PlayerSet
if ((config & SupportedStyleSets) == 0 || !_supportedPlayers[i]) if ((config & SupportedStyleSets) == 0 || !_supportedPlayers[i])
{ {
config = ControllerType.None; config = NpadStyleTag.None;
} }
SetupNpad((PlayerIndex)i, config); SetupNpad((PlayerIndex)i, config);
@ -212,11 +212,11 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices
} }
} }
private void SetupNpad(PlayerIndex player, ControllerType type) private void SetupNpad(PlayerIndex player, NpadStyleTag type)
{ {
ref NpadInternalState controller = ref _device.Hid.SharedMemory.Npads[(int)player].InternalState; ref NpadInternalState controller = ref _device.Hid.SharedMemory.Npads[(int)player].InternalState;
ControllerType oldType = (ControllerType)controller.StyleSet; NpadStyleTag oldType = controller.StyleSet;
if (oldType == type) if (oldType == type)
{ {
@ -225,7 +225,7 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices
controller = NpadInternalState.Create(); // Reset it controller = NpadInternalState.Create(); // Reset it
if (type == ControllerType.None) if (type == NpadStyleTag.None)
{ {
_styleSetUpdateEvents[(int)player].ReadableEvent.Signal(); // Signal disconnect _styleSetUpdateEvents[(int)player].ReadableEvent.Signal(); // Signal disconnect
_activeCount--; _activeCount--;
@ -255,7 +255,7 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices
switch (type) switch (type)
{ {
#pragma warning disable IDE0055 // Disable formatting #pragma warning disable IDE0055 // Disable formatting
case ControllerType.ProController: case NpadStyleTag.FullKey:
controller.StyleSet = NpadStyleTag.FullKey; controller.StyleSet = NpadStyleTag.FullKey;
controller.DeviceType = DeviceType.FullKey; controller.DeviceType = DeviceType.FullKey;
controller.SystemProperties |= NpadSystemProperties.IsAbxyButtonOriented | controller.SystemProperties |= NpadSystemProperties.IsAbxyButtonOriented |
@ -263,7 +263,7 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices
NpadSystemProperties.IsMinusAvailable; NpadSystemProperties.IsMinusAvailable;
controller.AppletFooterUiType = AppletFooterUiType.SwitchProController; controller.AppletFooterUiType = AppletFooterUiType.SwitchProController;
break; break;
case ControllerType.Handheld: case NpadStyleTag.Handheld:
controller.StyleSet = NpadStyleTag.Handheld; controller.StyleSet = NpadStyleTag.Handheld;
controller.DeviceType = DeviceType.HandheldLeft | controller.DeviceType = DeviceType.HandheldLeft |
DeviceType.HandheldRight; DeviceType.HandheldRight;
@ -272,7 +272,7 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices
NpadSystemProperties.IsMinusAvailable; NpadSystemProperties.IsMinusAvailable;
controller.AppletFooterUiType = AppletFooterUiType.HandheldJoyConLeftJoyConRight; controller.AppletFooterUiType = AppletFooterUiType.HandheldJoyConLeftJoyConRight;
break; break;
case ControllerType.JoyconPair: case NpadStyleTag.JoyDual:
controller.StyleSet = NpadStyleTag.JoyDual; controller.StyleSet = NpadStyleTag.JoyDual;
controller.DeviceType = DeviceType.JoyLeft | controller.DeviceType = DeviceType.JoyLeft |
DeviceType.JoyRight; DeviceType.JoyRight;
@ -281,7 +281,7 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices
NpadSystemProperties.IsMinusAvailable; NpadSystemProperties.IsMinusAvailable;
controller.AppletFooterUiType = _device.System.State.DockedMode ? AppletFooterUiType.JoyDual : AppletFooterUiType.HandheldJoyConLeftJoyConRight; controller.AppletFooterUiType = _device.System.State.DockedMode ? AppletFooterUiType.JoyDual : AppletFooterUiType.HandheldJoyConLeftJoyConRight;
break; break;
case ControllerType.JoyconLeft: case NpadStyleTag.JoyLeft:
controller.StyleSet = NpadStyleTag.JoyLeft; controller.StyleSet = NpadStyleTag.JoyLeft;
controller.JoyAssignmentMode = NpadJoyAssignmentMode.Single; controller.JoyAssignmentMode = NpadJoyAssignmentMode.Single;
controller.DeviceType = DeviceType.JoyLeft; controller.DeviceType = DeviceType.JoyLeft;
@ -289,7 +289,7 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices
NpadSystemProperties.IsMinusAvailable; NpadSystemProperties.IsMinusAvailable;
controller.AppletFooterUiType = _device.System.State.DockedMode ? AppletFooterUiType.JoyDualLeftOnly : AppletFooterUiType.HandheldJoyConLeftOnly; controller.AppletFooterUiType = _device.System.State.DockedMode ? AppletFooterUiType.JoyDualLeftOnly : AppletFooterUiType.HandheldJoyConLeftOnly;
break; break;
case ControllerType.JoyconRight: case NpadStyleTag.JoyRight:
controller.StyleSet = NpadStyleTag.JoyRight; controller.StyleSet = NpadStyleTag.JoyRight;
controller.JoyAssignmentMode = NpadJoyAssignmentMode.Single; controller.JoyAssignmentMode = NpadJoyAssignmentMode.Single;
controller.DeviceType = DeviceType.JoyRight; controller.DeviceType = DeviceType.JoyRight;
@ -297,7 +297,7 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices
NpadSystemProperties.IsPlusAvailable; NpadSystemProperties.IsPlusAvailable;
controller.AppletFooterUiType = _device.System.State.DockedMode ? AppletFooterUiType.JoyDualRightOnly : AppletFooterUiType.HandheldJoyConRightOnly; controller.AppletFooterUiType = _device.System.State.DockedMode ? AppletFooterUiType.JoyDualRightOnly : AppletFooterUiType.HandheldJoyConRightOnly;
break; break;
case ControllerType.Pokeball: case NpadStyleTag.Palma:
controller.StyleSet = NpadStyleTag.Palma; controller.StyleSet = NpadStyleTag.Palma;
controller.DeviceType = DeviceType.Palma; controller.DeviceType = DeviceType.Palma;
controller.AppletFooterUiType = AppletFooterUiType.None; controller.AppletFooterUiType = AppletFooterUiType.None;

View file

@ -15,8 +15,8 @@ namespace Ryujinx.Horizon.Sdk.Hid
Result ActivateMouse(AppletResourceUserId appletResourceUserId, ulong pid); Result ActivateMouse(AppletResourceUserId appletResourceUserId, ulong pid);
Result ActivateKeyboard(AppletResourceUserId appletResourceUserId, ulong pid); Result ActivateKeyboard(AppletResourceUserId appletResourceUserId, ulong pid);
Result SendKeyboardLockKeyEvent(AppletResourceUserId appletResourceUserId, KeyboardLockKeyEvent keyboardLockKeyEvent, ulong pid); Result SendKeyboardLockKeyEvent(AppletResourceUserId appletResourceUserId, KeyboardLockKeyEvent keyboardLockKeyEvent, ulong pid);
Result AcquireXpadIdEventHandle(out int arg0, ulong arg1); Result AcquireXpadIdEventHandle(out int arg0, ulong xpadId);
Result ReleaseXpadIdEventHandle(ulong arg0); Result ReleaseXpadIdEventHandle(ulong xpadId);
Result ActivateXpad(AppletResourceUserId appletResourceUserId, uint basixXpadId, ulong pid); Result ActivateXpad(AppletResourceUserId appletResourceUserId, uint basixXpadId, ulong pid);
Result GetXpadIds(out long arg0, Span<uint> basicXpadIds); Result GetXpadIds(out long arg0, Span<uint> basicXpadIds);
Result ActivateJoyXpad(uint joyXpadId); Result ActivateJoyXpad(uint joyXpadId);
@ -35,14 +35,14 @@ namespace Ryujinx.Horizon.Sdk.Hid
Result SetSixAxisSensorFusionParameters(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, float arg2, float arg3, ulong pid); Result SetSixAxisSensorFusionParameters(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, float arg2, float arg3, ulong pid);
Result GetSixAxisSensorFusionParameters(out float arg0, out float arg1, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid); Result GetSixAxisSensorFusionParameters(out float arg0, out float arg1, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid);
Result ResetSixAxisSensorFusionParameters(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid); Result ResetSixAxisSensorFusionParameters(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid);
Result SetAccelerometerParameters(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, float arg2, float arg3, ulong pid); Result SetAccelerometerParameters(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, float x, float y, ulong pid);
Result GetAccelerometerParameters(out float arg0, out float arg1, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid); Result GetAccelerometerParameters(out float x, out float y, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid);
Result ResetAccelerometerParameters(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid); Result ResetAccelerometerParameters(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid);
Result SetAccelerometerPlayMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, uint arg2, ulong pid); Result SetAccelerometerPlayMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, uint accelerometerPlayMode, ulong pid);
Result GetAccelerometerPlayMode(out uint arg0, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid); Result GetAccelerometerPlayMode(out uint accelerometerPlayMode, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid);
Result ResetAccelerometerPlayMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid); Result ResetAccelerometerPlayMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid);
Result SetGyroscopeZeroDriftMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, uint arg2, ulong pid); Result SetGyroscopeZeroDriftMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, GyroscopeZeroDriftMode gyroscopeZeroDriftMode, ulong pid);
Result GetGyroscopeZeroDriftMode(out uint arg0, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid); Result GetGyroscopeZeroDriftMode(out GyroscopeZeroDriftMode gyroscopeZeroDriftMode, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid);
Result ResetGyroscopeZeroDriftMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid); Result ResetGyroscopeZeroDriftMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid);
Result IsSixAxisSensorAtRest(out bool arg0, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid); Result IsSixAxisSensorAtRest(out bool arg0, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid);
Result IsFirmwareUpdateAvailableForSixAxisSensor(out bool arg0, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid); Result IsFirmwareUpdateAvailableForSixAxisSensor(out bool arg0, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid);
@ -52,9 +52,9 @@ namespace Ryujinx.Horizon.Sdk.Hid
Result LoadSixAxisSensorCalibrationParameter(AppletResourceUserId appletResourceUserId, out SixAxisSensorCalibrationParameter sixAxisSensorCalibrationParameter, SixAxisSensorHandle sixAxisSensorHandle, ulong pid); Result LoadSixAxisSensorCalibrationParameter(AppletResourceUserId appletResourceUserId, out SixAxisSensorCalibrationParameter sixAxisSensorCalibrationParameter, SixAxisSensorHandle sixAxisSensorHandle, ulong pid);
Result GetSixAxisSensorIcInformation(AppletResourceUserId appletResourceUserId, out SixAxisSensorIcInformation sixAxisSensorIcInformation, SixAxisSensorHandle sixAxisSensorHandle, ulong pid); Result GetSixAxisSensorIcInformation(AppletResourceUserId appletResourceUserId, out SixAxisSensorIcInformation sixAxisSensorIcInformation, SixAxisSensorHandle sixAxisSensorHandle, ulong pid);
Result ResetIsSixAxisSensorDeviceNewlyAssigned(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid); Result ResetIsSixAxisSensorDeviceNewlyAssigned(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid);
Result ActivateGesture(AppletResourceUserId appletResourceUserId, int arg1, ulong pid); Result ActivateGesture(AppletResourceUserId appletResourceUserId, int unknown, ulong pid);
Result SetSupportedNpadStyleSet(AppletResourceUserId appletResourceUserId, NpadStyleTag arg1, ulong pid); Result SetSupportedNpadStyleSet(AppletResourceUserId appletResourceUserId, NpadStyleTag supportedStyleSets, ulong pid);
Result GetSupportedNpadStyleSet(AppletResourceUserId appletResourceUserId, out NpadStyleTag arg1, ulong pid); Result GetSupportedNpadStyleSet(AppletResourceUserId appletResourceUserId, out NpadStyleTag supportedStyleSets, ulong pid);
Result SetSupportedNpadIdType(AppletResourceUserId appletResourceUserId, ReadOnlySpan<uint> arg1, ulong pid); Result SetSupportedNpadIdType(AppletResourceUserId appletResourceUserId, ReadOnlySpan<uint> arg1, ulong pid);
Result ActivateNpad(AppletResourceUserId appletResourceUserId, ulong pid); Result ActivateNpad(AppletResourceUserId appletResourceUserId, ulong pid);
Result DeactivateNpad(AppletResourceUserId appletResourceUserId, ulong pid); Result DeactivateNpad(AppletResourceUserId appletResourceUserId, ulong pid);
@ -90,7 +90,7 @@ namespace Ryujinx.Horizon.Sdk.Hid
Result GetActualVibrationGcErmCommand(out VibrationGcErmCommand vibrationGcErmCommand, AppletResourceUserId appletResourceUserId, VibrationDeviceHandle vibrationDeviceHandle, ulong pid); Result GetActualVibrationGcErmCommand(out VibrationGcErmCommand vibrationGcErmCommand, AppletResourceUserId appletResourceUserId, VibrationDeviceHandle vibrationDeviceHandle, ulong pid);
Result BeginPermitVibrationSession(AppletResourceUserId appletResourceUserId); Result BeginPermitVibrationSession(AppletResourceUserId appletResourceUserId);
Result EndPermitVibrationSession(); Result EndPermitVibrationSession();
Result IsVibrationDeviceMounted(out bool arg0, AppletResourceUserId appletResourceUserId, VibrationDeviceHandle vibrationDeviceHandle, ulong pid); Result IsVibrationDeviceMounted(out bool isVibrationDeviceMounted, AppletResourceUserId appletResourceUserId, VibrationDeviceHandle vibrationDeviceHandle, ulong pid);
Result SendVibrationValueInBool(AppletResourceUserId appletResourceUserId, VibrationDeviceHandle vibrationDeviceHandle, bool arg2, ulong pid); Result SendVibrationValueInBool(AppletResourceUserId appletResourceUserId, VibrationDeviceHandle vibrationDeviceHandle, bool arg2, ulong pid);
Result ActivateConsoleSixAxisSensor(AppletResourceUserId appletResourceUserId, ulong pid); Result ActivateConsoleSixAxisSensor(AppletResourceUserId appletResourceUserId, ulong pid);
Result StartConsoleSixAxisSensor(AppletResourceUserId appletResourceUserId, ConsoleSixAxisSensorHandle consoleSixAxisSensorHandle, ulong pid); Result StartConsoleSixAxisSensor(AppletResourceUserId appletResourceUserId, ConsoleSixAxisSensorHandle consoleSixAxisSensorHandle, ulong pid);
@ -98,17 +98,17 @@ namespace Ryujinx.Horizon.Sdk.Hid
Result ActivateSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, ulong pid); Result ActivateSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, ulong pid);
Result StartSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, ulong pid); Result StartSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, ulong pid);
Result StopSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, ulong pid); Result StopSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, ulong pid);
Result InitializeSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, int arg1, ulong arg2, int arg3, ulong arg4, ulong pid); Result InitializeSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, int nativeHandle0, ulong counter0, int nativeHandle1, ulong counter1, ulong pid);
Result FinalizeSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, ulong pid); Result FinalizeSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, ulong pid);
Result SetSevenSixAxisSensorFusionStrength(AppletResourceUserId appletResourceUserId, float arg1, ulong pid); Result SetSevenSixAxisSensorFusionStrength(AppletResourceUserId appletResourceUserId, float sevenSixAxisSensorFusionStrength, ulong pid);
Result GetSevenSixAxisSensorFusionStrength(out float arg0, AppletResourceUserId appletResourceUserId, ulong pid); Result GetSevenSixAxisSensorFusionStrength(out float sevenSixSensorFusionStrength, AppletResourceUserId appletResourceUserId, ulong pid);
Result ResetSevenSixAxisSensorTimestamp(AppletResourceUserId appletResourceUserId, ulong pid); Result ResetSevenSixAxisSensorTimestamp(AppletResourceUserId appletResourceUserId, ulong pid);
Result IsUsbFullKeyControllerEnabled(out bool arg0); Result IsUsbFullKeyControllerEnabled(out bool isUsbFullKeyControllerEnabled);
Result EnableUsbFullKeyController(bool arg0); Result EnableUsbFullKeyController(bool usbFullKeyControllerEnabled);
Result IsUsbFullKeyControllerConnected(out bool arg0, uint arg1); Result IsUsbFullKeyControllerConnected(out bool isConnected, uint unknown);
Result HasBattery(out bool arg0, uint arg1); Result HasBattery(out bool hasBattery, uint npadId);
Result HasLeftRightBattery(out bool arg0, out bool arg1, uint arg2); Result HasLeftRightBattery(out bool hasLeftBattery, out bool hasRightBattery, uint npadId);
Result GetNpadInterfaceType(out byte arg0, uint arg1); Result GetNpadInterfaceType(out byte npadInterfaceType, uint npadId);
Result GetNpadLeftRightInterfaceType(out byte arg0, out byte arg1, uint arg2); Result GetNpadLeftRightInterfaceType(out byte arg0, out byte arg1, uint arg2);
Result GetNpadOfHighestBatteryLevel(out uint arg0, ReadOnlySpan<uint> arg1, AppletResourceUserId appletResourceUserId, ulong pid); Result GetNpadOfHighestBatteryLevel(out uint arg0, ReadOnlySpan<uint> arg1, AppletResourceUserId appletResourceUserId, ulong pid);
Result GetPalmaConnectionHandle(out PalmaConnectionHandle palmaConnectionHandle, uint arg1, AppletResourceUserId appletResourceUserId, ulong pid); Result GetPalmaConnectionHandle(out PalmaConnectionHandle palmaConnectionHandle, uint arg1, AppletResourceUserId appletResourceUserId, ulong pid);
@ -133,7 +133,7 @@ namespace Ryujinx.Horizon.Sdk.Hid
Result GetPalmaOperationResult(PalmaConnectionHandle palmaConnectionHandle); Result GetPalmaOperationResult(PalmaConnectionHandle palmaConnectionHandle);
Result ReadPalmaPlayLog(PalmaConnectionHandle palmaConnectionHandle, ushort arg1); Result ReadPalmaPlayLog(PalmaConnectionHandle palmaConnectionHandle, ushort arg1);
Result ResetPalmaPlayLog(PalmaConnectionHandle palmaConnectionHandle, ushort arg1); Result ResetPalmaPlayLog(PalmaConnectionHandle palmaConnectionHandle, ushort arg1);
Result SetIsPalmaAllConnectable(AppletResourceUserId appletResourceUserId, bool arg1, ulong pid); Result SetIsPalmaAllConnectable(AppletResourceUserId appletResourceUserId, bool unknownBool, ulong pid);
Result SetIsPalmaPairedConnectable(AppletResourceUserId appletResourceUserId, bool arg1, ulong pid); Result SetIsPalmaPairedConnectable(AppletResourceUserId appletResourceUserId, bool arg1, ulong pid);
Result PairPalma(PalmaConnectionHandle palmaConnectionHandle); Result PairPalma(PalmaConnectionHandle palmaConnectionHandle);
Result SetPalmaBoostMode(bool arg0); Result SetPalmaBoostMode(bool arg0);
@ -141,9 +141,9 @@ namespace Ryujinx.Horizon.Sdk.Hid
Result EnablePalmaBoostMode(AppletResourceUserId appletResourceUserId, bool arg1, ulong pid); Result EnablePalmaBoostMode(AppletResourceUserId appletResourceUserId, bool arg1, ulong pid);
Result GetPalmaBluetoothAddress(out Address arg0, PalmaConnectionHandle palmaConnectionHandle); Result GetPalmaBluetoothAddress(out Address arg0, PalmaConnectionHandle palmaConnectionHandle);
Result SetDisallowedPalmaConnection(AppletResourceUserId appletResourceUserId, ReadOnlySpan<Address> arg1, ulong pid); Result SetDisallowedPalmaConnection(AppletResourceUserId appletResourceUserId, ReadOnlySpan<Address> arg1, ulong pid);
Result SetNpadCommunicationMode(AppletResourceUserId appletResourceUserId, long arg1, ulong pid); Result SetNpadCommunicationMode(AppletResourceUserId appletResourceUserId, long npadCommunicationMode, ulong pid);
Result GetNpadCommunicationMode(out long arg0); Result GetNpadCommunicationMode(out long npadCommunicationMode);
Result SetTouchScreenConfiguration(AppletResourceUserId appletResourceUserId, TouchScreenConfigurationForNx arg1, ulong pid); Result SetTouchScreenConfiguration(AppletResourceUserId appletResourceUserId, TouchScreenConfigurationForNx touchScreenConfigurationForNx, ulong pid);
Result IsFirmwareUpdateNeededForNotification(out bool arg0, int arg1, AppletResourceUserId appletResourceUserId, ulong pid); Result IsFirmwareUpdateNeededForNotification(out bool arg0, int arg1, AppletResourceUserId appletResourceUserId, ulong pid);
Result ActivateDigitizer(AppletResourceUserId appletResourceUserId, ulong pid); Result ActivateDigitizer(AppletResourceUserId appletResourceUserId, ulong pid);
} }

View file

@ -1,19 +0,0 @@
using System;
namespace Ryujinx.Horizon.Sdk.Hid.Npad
{
[Flags]
public enum ControllerType
{
None,
ProController = 1 << 0,
Handheld = 1 << 1,
JoyconPair = 1 << 2,
JoyconLeft = 1 << 3,
JoyconRight = 1 << 4,
Invalid = 1 << 5,
Pokeball = 1 << 6,
SystemExternal = 1 << 29,
System = 1 << 30,
}
}

View file

@ -6,7 +6,7 @@ namespace Ryujinx.Horizon.Sdk.Hid
/// Nintendo pad style /// Nintendo pad style
/// </summary> /// </summary>
[Flags] [Flags]
enum NpadStyleTag : uint public enum NpadStyleTag : uint
{ {
/// <summary> /// <summary>
/// No type. /// No type.