From 63d3210dd1881801451aae63532e807cd7e85a7e Mon Sep 17 00:00:00 2001 From: skrekhere Date: Sat, 12 Feb 2022 00:10:27 -0800 Subject: [PATCH] fixing up ClampAxis --- Ryujinx.Input/HLE/NpadController.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Ryujinx.Input/HLE/NpadController.cs b/Ryujinx.Input/HLE/NpadController.cs index 649edffb1..f1c108217 100644 --- a/Ryujinx.Input/HLE/NpadController.cs +++ b/Ryujinx.Input/HLE/NpadController.cs @@ -391,7 +391,7 @@ namespace Ryujinx.Input.HLE [MethodImpl(MethodImplOptions.AggressiveInlining)] private static JoystickPosition ApplyDeadzone(float x, float y, float deadzone) { - float magnitudeClamped = Math.Clamp(MathF.Sqrt(x * x + y * y), -1f, 1f); + float magnitudeClamped = Math.Min(MathF.Sqrt(x * x + y * y), 1f); if (magnitudeClamped <= deadzone) { @@ -408,14 +408,12 @@ namespace Ryujinx.Input.HLE [MethodImpl(MethodImplOptions.AggressiveInlining)] private static short ClampAxis(float value) { - if (value <= -short.MaxValue) + if (Math.Sign(value) < 0) { - return -short.MaxValue; - } - else - { - return (short)(value * short.MaxValue); + return (short) Math.Max(value * -short.MinValue, short.MinValue); } + + return (short) Math.Min(value * short.MaxValue, short.MaxValue); } [MethodImpl(MethodImplOptions.AggressiveInlining)]