From cbcdf4711818d0b57e62d33838d5e1eafcc692b6 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Sat, 20 Jul 2024 16:16:51 +0100 Subject: [PATCH] More HidServer improvements --- .../HOS/Services/Hid/IHidServer.cs | 616 ------------------ src/Ryujinx.Horizon/Hid/HidServer.cs | 291 ++++++--- .../Sdk/Hid/ControllerConfig.cs | 2 +- src/Ryujinx.Horizon/Sdk/Hid/Hid.cs | 3 +- .../Sdk/Hid/HidDevices/NpadDevices.cs | 62 +- src/Ryujinx.Horizon/Sdk/Hid/IHidServer.cs | 50 +- .../Sdk/Hid/Npad/ControllerType.cs | 19 - .../Sdk/Hid/SharedMemory/Npad/NpadStyleTag.cs | 2 +- 8 files changed, 277 insertions(+), 768 deletions(-) delete mode 100644 src/Ryujinx.Horizon/Sdk/Hid/Npad/ControllerType.cs diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs b/src/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs index 5834e0fee..415b629b7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs @@ -76,89 +76,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid 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)] // SendKeyboardLockKeyEvent(uint flags, pid) public ResultCode SendKeyboardLockKeyEvent(ServiceCtx context) @@ -445,145 +362,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid 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)] // IsSixAxisSensorAtRest(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) -> bool IsAsRest public ResultCode IsSixAxisSensorAtRest(ServiceCtx context) @@ -644,80 +422,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid 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)] // SetSupportedNpadIdType(nn::applet::AppletResourceUserId, array) public ResultCode SetSupportedNpadIdType(ServiceCtx context) @@ -1348,248 +1052,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid 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, ulong Counter0, array, 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 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+ // GetNpadLeftRightInterfaceType(uint NpadId) -> uchar LeftInterfaceType, uchar RightInterfaceType public ResultCode GetNpadLeftRightInterfaceType(ServiceCtx context) @@ -1761,84 +1223,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid 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+ // SetTouchScreenResolution(int width, int height, nn::applet::AppletResourceUserId) public ResultCode SetTouchScreenResolution(ServiceCtx context) diff --git a/src/Ryujinx.Horizon/Hid/HidServer.cs b/src/Ryujinx.Horizon/Hid/HidServer.cs index 3ed3f3efa..115f9fdf5 100644 --- a/src/Ryujinx.Horizon/Hid/HidServer.cs +++ b/src/Ryujinx.Horizon/Hid/HidServer.cs @@ -2,6 +2,8 @@ using Ryujinx.Common.Logging; using Ryujinx.Horizon.Common; using Ryujinx.Horizon.Sdk.Applet; 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.Vibration; using Ryujinx.Horizon.Sdk.Sf; @@ -11,6 +13,51 @@ namespace Ryujinx.Horizon.Hid { 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)] public Result CreateAppletResource(out IAppletResource arg0, AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) { @@ -22,7 +69,14 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(1)] 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; } @@ -30,7 +84,16 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(11)] 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; } @@ -38,7 +101,16 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(21)] 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; } @@ -46,7 +118,21 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(31)] 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; } @@ -54,13 +140,15 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(32)] 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; } [CmifCommand(40)] - public Result AcquireXpadIdEventHandle(out int arg0, ulong arg1) + public Result AcquireXpadIdEventHandle(out int arg0, ulong xpadId) { Logger.Stub?.PrintStub(LogClass.ServiceHid); @@ -68,7 +156,7 @@ namespace Ryujinx.Horizon.Hid } [CmifCommand(41)] - public Result ReleaseXpadIdEventHandle(ulong arg0) + public Result ReleaseXpadIdEventHandle(ulong xpadId) { Logger.Stub?.PrintStub(LogClass.ServiceHid); @@ -220,17 +308,26 @@ namespace Ryujinx.Horizon.Hid } [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; } [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; } @@ -238,23 +335,30 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(75)] 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; } [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; } [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; } @@ -262,23 +366,29 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(78)] 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; } [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; } [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; } @@ -286,7 +396,9 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(81)] 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; } @@ -326,7 +438,7 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(86)] 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; } @@ -334,7 +446,9 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(87)] 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; } @@ -342,14 +456,15 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(88)] 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; } [CmifCommand(89)] - public Result ResetIsSixAxisSensorDeviceNewlyAssigned(AppletResourceUserId appletResourceUserId, - SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid) + public Result ResetIsSixAxisSensorDeviceNewlyAssigned(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, [ClientProcessId] ulong pid) { Logger.Stub?.PrintStub(LogClass.ServiceHid); @@ -357,25 +472,29 @@ namespace Ryujinx.Horizon.Hid } [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; } [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; } [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; } @@ -647,7 +766,7 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(209)] public Result BeginPermitVibrationSession(AppletResourceUserId appletResourceUserId) { - Logger.Stub?.PrintStub(LogClass.ServiceHid); + Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId }); return Result.Success; } @@ -661,9 +780,12 @@ namespace Ryujinx.Horizon.Hid } [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; } @@ -679,7 +801,7 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(300)] public Result ActivateConsoleSixAxisSensor(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) { - Logger.Stub?.PrintStub(LogClass.ServiceHid); + Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId }); return Result.Success; } @@ -687,7 +809,7 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(301)] 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; } @@ -695,7 +817,7 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(302)] 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; } @@ -703,7 +825,7 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(303)] public Result ActivateSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) { - Logger.Stub?.PrintStub(LogClass.ServiceHid); + Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId }); return Result.Success; } @@ -711,7 +833,7 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(304)] public Result StartSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) { - Logger.Stub?.PrintStub(LogClass.ServiceHid); + Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId }); return Result.Success; } @@ -719,15 +841,17 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(305)] public Result StopSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) { - Logger.Stub?.PrintStub(LogClass.ServiceHid); + Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId }); return Result.Success; } [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 is a buffer or not... + + Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, counter0, counter1 }); return Result.Success; } @@ -735,23 +859,27 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(307)] public Result FinalizeSevenSixAxisSensor(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) { - Logger.Stub?.PrintStub(LogClass.ServiceHid); + Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId }); return Result.Success; } [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; } [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; } @@ -759,55 +887,68 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(310)] public Result ResetSevenSixAxisSensorTimestamp(AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid) { - Logger.Stub?.PrintStub(LogClass.ServiceHid); + Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId }); return Result.Success; } [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; } [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; } [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; } [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; } [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; } [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; } @@ -919,7 +1060,7 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(511)] public Result ReadPalmaUniqueCode(PalmaConnectionHandle palmaConnectionHandle) { - Logger.Stub?.PrintStub(LogClass.ServiceHid); + Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle }); return Result.Success; } @@ -927,7 +1068,7 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(512)] public Result SetPalmaUniqueCodeInvalid(PalmaConnectionHandle palmaConnectionHandle) { - Logger.Stub?.PrintStub(LogClass.ServiceHid); + Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle }); return Result.Success; } @@ -1005,9 +1146,9 @@ namespace Ryujinx.Horizon.Hid } [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; } @@ -1031,7 +1172,7 @@ namespace Ryujinx.Horizon.Hid [CmifCommand(525)] public Result SetPalmaBoostMode(bool arg0) { - Logger.Stub?.PrintStub(LogClass.ServiceHid); + // NOTE: Stubbed in system module. return Result.Success; } @@ -1069,25 +1210,29 @@ namespace Ryujinx.Horizon.Hid } [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; } [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; } [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; } diff --git a/src/Ryujinx.Horizon/Sdk/Hid/ControllerConfig.cs b/src/Ryujinx.Horizon/Sdk/Hid/ControllerConfig.cs index 7afb7f3d4..902ac0d00 100644 --- a/src/Ryujinx.Horizon/Sdk/Hid/ControllerConfig.cs +++ b/src/Ryujinx.Horizon/Sdk/Hid/ControllerConfig.cs @@ -5,6 +5,6 @@ namespace Ryujinx.Horizon.Sdk.Hid public struct ControllerConfig { public PlayerIndex Player; - public ControllerType Type; + public NpadStyleTag Type; } } diff --git a/src/Ryujinx.Horizon/Sdk/Hid/Hid.cs b/src/Ryujinx.Horizon/Sdk/Hid/Hid.cs index 59d122a90..0032c7918 100644 --- a/src/Ryujinx.Horizon/Sdk/Hid/Hid.cs +++ b/src/Ryujinx.Horizon/Sdk/Hid/Hid.cs @@ -5,7 +5,6 @@ using Ryujinx.Horizon.Sdk.Hid.HidDevices; using Ryujinx.Horizon.Sdk.Hid.Npad; using System.Collections.Generic; using System.Runtime.CompilerServices; -using ControllerType = Ryujinx.Horizon.Sdk.Hid.Npad.ControllerType; using PlayerIndex = Ryujinx.Horizon.Sdk.Hid.Npad.PlayerIndex; namespace Ryujinx.Horizon.Sdk.Hid @@ -68,7 +67,7 @@ namespace Ryujinx.Horizon.Sdk.Hid for (int i = 0; i < npadConfig.Length; ++i) { npadConfig[i].Player = (PlayerIndex)inputConfig[i].PlayerIndex; - npadConfig[i].Type = (ControllerType)inputConfig[i].ControllerType; + npadConfig[i].Type = inputConfig[i].ControllerType; } Npads.Configure(npadConfig); diff --git a/src/Ryujinx.Horizon/Sdk/Hid/HidDevices/NpadDevices.cs b/src/Ryujinx.Horizon/Sdk/Hid/HidDevices/NpadDevices.cs index c1c969264..f95f07c74 100644 --- a/src/Ryujinx.Horizon/Sdk/Hid/HidDevices/NpadDevices.cs +++ b/src/Ryujinx.Horizon/Sdk/Hid/HidDevices/NpadDevices.cs @@ -18,7 +18,7 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices private long _lastNotifyTimestamp; public const int MaxControllers = 9; // Players 1-8 and Handheld - private ControllerType[] _configuredTypes; + private NpadStyleTag[] _configuredTypes; private readonly Event[] _styleSetUpdateEvents; private readonly bool[] _supportedPlayers; private VibrationValue _neutralVibrationValue = new() @@ -31,18 +31,18 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices internal NpadJoyHoldType JoyHold { get; set; } internal bool SixAxisActive = false; // TODO: link to hidserver when implemented - internal ControllerType SupportedStyleSets { get; set; } + internal NpadStyleTag SupportedStyleSets { get; set; } public Dictionary> RumbleQueues = new(); public Dictionary LastVibrationValues = new(); public NpadDevices(bool active = true) : base(active) { - _configuredTypes = new ControllerType[MaxControllers]; + _configuredTypes = new NpadStyleTag[MaxControllers]; - SupportedStyleSets = ControllerType.Handheld | ControllerType.JoyconPair | - ControllerType.JoyconLeft | ControllerType.JoyconRight | - ControllerType.ProController; + SupportedStyleSets = NpadStyleTag.Handheld | NpadStyleTag.JoyDual | + NpadStyleTag.JoyLeft | NpadStyleTag.JoyRight | + NpadStyleTag.FullKey; _supportedPlayers = new bool[MaxControllers]; _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; configuredCount = 0; 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; } - 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++; if (primaryIndex == PlayerIndex.Unknown) @@ -125,19 +125,19 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices public void Configure(params ControllerConfig[] configs) { - _configuredTypes = new ControllerType[MaxControllers]; + _configuredTypes = new NpadStyleTag[MaxControllers]; for (int i = 0; i < configs.Length; ++i) { PlayerIndex player = configs[i].Player; - ControllerType controllerType = configs[i].Type; + NpadStyleTag controllerType = configs[i].Type; if (player > PlayerIndex.Handheld) { throw new InvalidOperationException("Player must be Player1-8 or Handheld"); } - if (controllerType == ControllerType.Handheld) + if (controllerType == NpadStyleTag.Handheld) { player = PlayerIndex.Handheld; } @@ -178,28 +178,28 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices // Remap/Init if necessary for (int i = 0; i < MaxControllers; ++i) { - ControllerType config = _configuredTypes[i]; + NpadStyleTag config = _configuredTypes[i]; // 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 - 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 if ((config & SupportedStyleSets) == 0 || !_supportedPlayers[i]) { - config = ControllerType.None; + config = NpadStyleTag.None; } 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; - ControllerType oldType = (ControllerType)controller.StyleSet; + NpadStyleTag oldType = controller.StyleSet; if (oldType == type) { @@ -225,7 +225,7 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices controller = NpadInternalState.Create(); // Reset it - if (type == ControllerType.None) + if (type == NpadStyleTag.None) { _styleSetUpdateEvents[(int)player].ReadableEvent.Signal(); // Signal disconnect _activeCount--; @@ -255,7 +255,7 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices switch (type) { #pragma warning disable IDE0055 // Disable formatting - case ControllerType.ProController: + case NpadStyleTag.FullKey: controller.StyleSet = NpadStyleTag.FullKey; controller.DeviceType = DeviceType.FullKey; controller.SystemProperties |= NpadSystemProperties.IsAbxyButtonOriented | @@ -263,7 +263,7 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices NpadSystemProperties.IsMinusAvailable; controller.AppletFooterUiType = AppletFooterUiType.SwitchProController; break; - case ControllerType.Handheld: + case NpadStyleTag.Handheld: controller.StyleSet = NpadStyleTag.Handheld; controller.DeviceType = DeviceType.HandheldLeft | DeviceType.HandheldRight; @@ -272,7 +272,7 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices NpadSystemProperties.IsMinusAvailable; controller.AppletFooterUiType = AppletFooterUiType.HandheldJoyConLeftJoyConRight; break; - case ControllerType.JoyconPair: + case NpadStyleTag.JoyDual: controller.StyleSet = NpadStyleTag.JoyDual; controller.DeviceType = DeviceType.JoyLeft | DeviceType.JoyRight; @@ -281,7 +281,7 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices NpadSystemProperties.IsMinusAvailable; controller.AppletFooterUiType = _device.System.State.DockedMode ? AppletFooterUiType.JoyDual : AppletFooterUiType.HandheldJoyConLeftJoyConRight; break; - case ControllerType.JoyconLeft: + case NpadStyleTag.JoyLeft: controller.StyleSet = NpadStyleTag.JoyLeft; controller.JoyAssignmentMode = NpadJoyAssignmentMode.Single; controller.DeviceType = DeviceType.JoyLeft; @@ -289,7 +289,7 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices NpadSystemProperties.IsMinusAvailable; controller.AppletFooterUiType = _device.System.State.DockedMode ? AppletFooterUiType.JoyDualLeftOnly : AppletFooterUiType.HandheldJoyConLeftOnly; break; - case ControllerType.JoyconRight: + case NpadStyleTag.JoyRight: controller.StyleSet = NpadStyleTag.JoyRight; controller.JoyAssignmentMode = NpadJoyAssignmentMode.Single; controller.DeviceType = DeviceType.JoyRight; @@ -297,7 +297,7 @@ namespace Ryujinx.Horizon.Sdk.Hid.HidDevices NpadSystemProperties.IsPlusAvailable; controller.AppletFooterUiType = _device.System.State.DockedMode ? AppletFooterUiType.JoyDualRightOnly : AppletFooterUiType.HandheldJoyConRightOnly; break; - case ControllerType.Pokeball: + case NpadStyleTag.Palma: controller.StyleSet = NpadStyleTag.Palma; controller.DeviceType = DeviceType.Palma; controller.AppletFooterUiType = AppletFooterUiType.None; diff --git a/src/Ryujinx.Horizon/Sdk/Hid/IHidServer.cs b/src/Ryujinx.Horizon/Sdk/Hid/IHidServer.cs index cbea40e25..ef8b8744f 100644 --- a/src/Ryujinx.Horizon/Sdk/Hid/IHidServer.cs +++ b/src/Ryujinx.Horizon/Sdk/Hid/IHidServer.cs @@ -15,8 +15,8 @@ namespace Ryujinx.Horizon.Sdk.Hid Result ActivateMouse(AppletResourceUserId appletResourceUserId, ulong pid); Result ActivateKeyboard(AppletResourceUserId appletResourceUserId, ulong pid); Result SendKeyboardLockKeyEvent(AppletResourceUserId appletResourceUserId, KeyboardLockKeyEvent keyboardLockKeyEvent, ulong pid); - Result AcquireXpadIdEventHandle(out int arg0, ulong arg1); - Result ReleaseXpadIdEventHandle(ulong arg0); + Result AcquireXpadIdEventHandle(out int arg0, ulong xpadId); + Result ReleaseXpadIdEventHandle(ulong xpadId); Result ActivateXpad(AppletResourceUserId appletResourceUserId, uint basixXpadId, ulong pid); Result GetXpadIds(out long arg0, Span basicXpadIds); 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 GetSixAxisSensorFusionParameters(out float arg0, out float arg1, 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 GetAccelerometerParameters(out float arg0, out float arg1, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid); + Result SetAccelerometerParameters(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, float x, float y, 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 SetAccelerometerPlayMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, uint arg2, ulong pid); - Result GetAccelerometerPlayMode(out uint arg0, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid); + Result SetAccelerometerPlayMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, uint accelerometerPlayMode, ulong pid); + Result GetAccelerometerPlayMode(out uint accelerometerPlayMode, 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 GetGyroscopeZeroDriftMode(out uint arg0, AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid); + Result SetGyroscopeZeroDriftMode(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, GyroscopeZeroDriftMode gyroscopeZeroDriftMode, ulong pid); + Result GetGyroscopeZeroDriftMode(out GyroscopeZeroDriftMode gyroscopeZeroDriftMode, 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 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 GetSixAxisSensorIcInformation(AppletResourceUserId appletResourceUserId, out SixAxisSensorIcInformation sixAxisSensorIcInformation, SixAxisSensorHandle sixAxisSensorHandle, ulong pid); Result ResetIsSixAxisSensorDeviceNewlyAssigned(AppletResourceUserId appletResourceUserId, SixAxisSensorHandle sixAxisSensorHandle, ulong pid); - Result ActivateGesture(AppletResourceUserId appletResourceUserId, int arg1, ulong pid); - Result SetSupportedNpadStyleSet(AppletResourceUserId appletResourceUserId, NpadStyleTag arg1, ulong pid); - Result GetSupportedNpadStyleSet(AppletResourceUserId appletResourceUserId, out NpadStyleTag arg1, ulong pid); + Result ActivateGesture(AppletResourceUserId appletResourceUserId, int unknown, ulong pid); + Result SetSupportedNpadStyleSet(AppletResourceUserId appletResourceUserId, NpadStyleTag supportedStyleSets, ulong pid); + Result GetSupportedNpadStyleSet(AppletResourceUserId appletResourceUserId, out NpadStyleTag supportedStyleSets, ulong pid); Result SetSupportedNpadIdType(AppletResourceUserId appletResourceUserId, ReadOnlySpan arg1, ulong pid); Result ActivateNpad(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 BeginPermitVibrationSession(AppletResourceUserId appletResourceUserId); 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 ActivateConsoleSixAxisSensor(AppletResourceUserId appletResourceUserId, 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 StartSevenSixAxisSensor(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 SetSevenSixAxisSensorFusionStrength(AppletResourceUserId appletResourceUserId, float arg1, ulong pid); - Result GetSevenSixAxisSensorFusionStrength(out float arg0, AppletResourceUserId appletResourceUserId, ulong pid); + Result SetSevenSixAxisSensorFusionStrength(AppletResourceUserId appletResourceUserId, float sevenSixAxisSensorFusionStrength, ulong pid); + Result GetSevenSixAxisSensorFusionStrength(out float sevenSixSensorFusionStrength, AppletResourceUserId appletResourceUserId, ulong pid); Result ResetSevenSixAxisSensorTimestamp(AppletResourceUserId appletResourceUserId, ulong pid); - Result IsUsbFullKeyControllerEnabled(out bool arg0); - Result EnableUsbFullKeyController(bool arg0); - Result IsUsbFullKeyControllerConnected(out bool arg0, uint arg1); - Result HasBattery(out bool arg0, uint arg1); - Result HasLeftRightBattery(out bool arg0, out bool arg1, uint arg2); - Result GetNpadInterfaceType(out byte arg0, uint arg1); + Result IsUsbFullKeyControllerEnabled(out bool isUsbFullKeyControllerEnabled); + Result EnableUsbFullKeyController(bool usbFullKeyControllerEnabled); + Result IsUsbFullKeyControllerConnected(out bool isConnected, uint unknown); + Result HasBattery(out bool hasBattery, uint npadId); + Result HasLeftRightBattery(out bool hasLeftBattery, out bool hasRightBattery, uint npadId); + Result GetNpadInterfaceType(out byte npadInterfaceType, uint npadId); Result GetNpadLeftRightInterfaceType(out byte arg0, out byte arg1, uint arg2); Result GetNpadOfHighestBatteryLevel(out uint arg0, ReadOnlySpan 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 ReadPalmaPlayLog(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 PairPalma(PalmaConnectionHandle palmaConnectionHandle); Result SetPalmaBoostMode(bool arg0); @@ -141,9 +141,9 @@ namespace Ryujinx.Horizon.Sdk.Hid Result EnablePalmaBoostMode(AppletResourceUserId appletResourceUserId, bool arg1, ulong pid); Result GetPalmaBluetoothAddress(out Address arg0, PalmaConnectionHandle palmaConnectionHandle); Result SetDisallowedPalmaConnection(AppletResourceUserId appletResourceUserId, ReadOnlySpan
arg1, ulong pid); - Result SetNpadCommunicationMode(AppletResourceUserId appletResourceUserId, long arg1, ulong pid); - Result GetNpadCommunicationMode(out long arg0); - Result SetTouchScreenConfiguration(AppletResourceUserId appletResourceUserId, TouchScreenConfigurationForNx arg1, ulong pid); + Result SetNpadCommunicationMode(AppletResourceUserId appletResourceUserId, long npadCommunicationMode, ulong pid); + Result GetNpadCommunicationMode(out long npadCommunicationMode); + Result SetTouchScreenConfiguration(AppletResourceUserId appletResourceUserId, TouchScreenConfigurationForNx touchScreenConfigurationForNx, ulong pid); Result IsFirmwareUpdateNeededForNotification(out bool arg0, int arg1, AppletResourceUserId appletResourceUserId, ulong pid); Result ActivateDigitizer(AppletResourceUserId appletResourceUserId, ulong pid); } diff --git a/src/Ryujinx.Horizon/Sdk/Hid/Npad/ControllerType.cs b/src/Ryujinx.Horizon/Sdk/Hid/Npad/ControllerType.cs deleted file mode 100644 index 4d7200e4f..000000000 --- a/src/Ryujinx.Horizon/Sdk/Hid/Npad/ControllerType.cs +++ /dev/null @@ -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, - } -} diff --git a/src/Ryujinx.Horizon/Sdk/Hid/SharedMemory/Npad/NpadStyleTag.cs b/src/Ryujinx.Horizon/Sdk/Hid/SharedMemory/Npad/NpadStyleTag.cs index 0eb45a315..3f6f73cd4 100644 --- a/src/Ryujinx.Horizon/Sdk/Hid/SharedMemory/Npad/NpadStyleTag.cs +++ b/src/Ryujinx.Horizon/Sdk/Hid/SharedMemory/Npad/NpadStyleTag.cs @@ -6,7 +6,7 @@ namespace Ryujinx.Horizon.Sdk.Hid /// Nintendo pad style /// [Flags] - enum NpadStyleTag : uint + public enum NpadStyleTag : uint { /// /// No type.