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
This commit is contained in:
emmauss
2021-07-23 23:01:36 +00:00
committed by GitHub
parent 4b60371e64
commit 8c7986eb58
3 changed files with 63 additions and 25 deletions

View File

@ -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);