fix motionData

This commit is contained in:
madwind 2024-12-28 09:07:22 +08:00
parent 20fdbff964
commit 6dec7ff8ba

View File

@ -1,5 +1,6 @@
using Ryujinx.Common.Configuration.Hid; using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Hid.Controller; using Ryujinx.Common.Configuration.Hid.Controller;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
@ -81,12 +82,23 @@ namespace Ryujinx.Input.SDL2
public Vector3 GetMotionData(MotionInputId inputId) public Vector3 GetMotionData(MotionInputId inputId)
{ {
return inputId switch Vector3 motionData;
switch (inputId)
{ {
MotionInputId.SecondAccelerometer => right.GetMotionData(MotionInputId.Accelerometer), case MotionInputId.Accelerometer:
MotionInputId.SecondGyroscope => right.GetMotionData(MotionInputId.Gyroscope), case MotionInputId.Gyroscope:
_ => left.GetMotionData(inputId) motionData = left.GetMotionData(inputId);
}; return new Vector3(-motionData.Z, motionData.Y, motionData.X);
case MotionInputId.SecondAccelerometer:
motionData = right.GetMotionData(MotionInputId.Accelerometer);
return new Vector3(motionData.Z, motionData.Y, -motionData.X);
case MotionInputId.SecondGyroscope:
motionData = right.GetMotionData(MotionInputId.Gyroscope);
return new Vector3(motionData.Z, motionData.Y, -motionData.X);
case MotionInputId.Invalid:
default:
return Vector3.Zero;
}
} }
public GamepadStateSnapshot GetStateSnapshot() public GamepadStateSnapshot GetStateSnapshot()