diff options
| author | emmauss <emmausssss@gmail.com> | 2021-07-23 23:01:36 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-24 01:01:36 +0200 |
| commit | 8c7986eb58ec7130c1e3698cae02eb20ac52ab11 (patch) | |
| tree | ffd7dca0dce388267471dcf5d0d481440e06ea50 /Ryujinx.Input/HLE/NpadManager.cs | |
| parent | 4b60371e64601dba46387f8b7260b3deb770e097 (diff) | |
Ensure right joycon motion data is set (#2488)
* motion fix
* mirror motion data on right joycon in pair mode when using native motion source
* fix
* addressed comments
Diffstat (limited to 'Ryujinx.Input/HLE/NpadManager.cs')
| -rw-r--r-- | Ryujinx.Input/HLE/NpadManager.cs | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/Ryujinx.Input/HLE/NpadManager.cs b/Ryujinx.Input/HLE/NpadManager.cs index c46f80b0..03bde64b 100644 --- a/Ryujinx.Input/HLE/NpadManager.cs +++ b/Ryujinx.Input/HLE/NpadManager.cs @@ -1,5 +1,6 @@ using Ryujinx.Common.Configuration.Hid; using Ryujinx.Common.Configuration.Hid.Controller; +using Ryujinx.Common.Configuration.Hid.Controller.Motion; using Ryujinx.Common.Configuration.Hid.Keyboard; using Ryujinx.HLE.HOS.Services.Hid; using System; @@ -163,10 +164,12 @@ namespace Ryujinx.Input.HLE foreach (InputConfig inputConfig in _inputConfig) { GamepadInput inputState = default; - SixAxisInput motionState = default; + (SixAxisInput, SixAxisInput) motionState = default; NpadController controller = _controllers[(int)inputConfig.PlayerIndex]; + bool isJoyconPair = false; + // Do we allow input updates and is a controller connected? if (!_blockInputUpdates && controller != null) { @@ -179,7 +182,11 @@ namespace Ryujinx.Input.HLE inputState.Buttons |= _device.Hid.UpdateStickButtons(inputState.LStick, inputState.RStick); - motionState = controller.GetHLEMotionState(); + isJoyconPair = inputConfig.ControllerType == Common.Configuration.Hid.ControllerType.JoyconPair; + + var altMotionState = isJoyconPair ? controller.GetHLEMotionState(true) : default; + + motionState = (controller.GetHLEMotionState(), altMotionState); if (_enableKeyboard) { @@ -189,14 +196,21 @@ namespace Ryujinx.Input.HLE else { // Ensure that orientation isn't null - motionState.Orientation = new float[9]; + motionState.Item1.Orientation = new float[9]; } inputState.PlayerId = (Ryujinx.HLE.HOS.Services.Hid.PlayerIndex)inputConfig.PlayerIndex; - motionState.PlayerId = (Ryujinx.HLE.HOS.Services.Hid.PlayerIndex)inputConfig.PlayerIndex; + motionState.Item1.PlayerId = (Ryujinx.HLE.HOS.Services.Hid.PlayerIndex)inputConfig.PlayerIndex; hleInputStates.Add(inputState); - hleMotionStates.Add(motionState); + hleMotionStates.Add(motionState.Item1); + + if (isJoyconPair && !motionState.Item2.Equals(default)) + { + motionState.Item2.PlayerId = (Ryujinx.HLE.HOS.Services.Hid.PlayerIndex)inputConfig.PlayerIndex; + + hleMotionStates.Add(motionState.Item2); + } } _device.Hid.Npads.Update(hleInputStates); |
