From 91f70584ec5512f063233230fcf2c65ec4ae3e2f Mon Sep 17 00:00:00 2001 From: madwind Date: Thu, 9 Jan 2025 23:47:44 +0800 Subject: [PATCH] update --- Directory.Packages.props | 2 +- src/Ryujinx.Input.SDL3/SDL3Gamepad.cs | 28 +++++++++++++-------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 7620cf772..42fda069c 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -41,7 +41,7 @@ - + diff --git a/src/Ryujinx.Input.SDL3/SDL3Gamepad.cs b/src/Ryujinx.Input.SDL3/SDL3Gamepad.cs index a4724783f..519ecb1cb 100644 --- a/src/Ryujinx.Input.SDL3/SDL3Gamepad.cs +++ b/src/Ryujinx.Input.SDL3/SDL3Gamepad.cs @@ -159,26 +159,24 @@ namespace Ryujinx.Input.SDL3 const int ElementCount = 3; - float[] values = new float[ElementCount]; + unsafe { - fixed (float* valuesPtr = &values[0]) + float* values = stackalloc float[ElementCount]; + if (!SDL_GetGamepadSensorData(_gamepadHandle, sensorType, values, ElementCount)) { - if (!SDL_GetGamepadSensorData(_gamepadHandle, sensorType, valuesPtr, ElementCount)) - { - return Vector3.Zero; - } + return Vector3.Zero; } + + Vector3 value = new(values[0], values[1], values[2]); + + return inputId switch + { + MotionInputId.Gyroscope => RadToDegree(value), + MotionInputId.Accelerometer => GsToMs2(value), + _ => value + }; } - - Vector3 value = new(values[0], values[1], values[2]); - - return inputId switch - { - MotionInputId.Gyroscope => RadToDegree(value), - MotionInputId.Accelerometer => GsToMs2(value), - _ => value - }; } private static Vector3 RadToDegree(Vector3 rad) => rad * (180 / MathF.PI);