From c007c437363971e64829c5605c93f244250f5dcd Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 13 Apr 2020 11:30:35 -0500 Subject: [PATCH] Fixed possible sign flip issue with radial output curves A weird coincidence allows the old routine to still work by a second unintentional sign flip --- DS4Windows/DS4Control/Mapping.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index f66200f..41654d4 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -969,8 +969,9 @@ namespace DS4Windows double sideX = dState.LX - 128; double sideY = dState.LY - 128.0; double capX = dState.LX >= 128 ? maxOutXRatio * 127.0 : maxOutXRatio * 128.0; double capY = dState.LY >= 128 ? maxOutYRatio * 127.0 : maxOutYRatio * 128.0; - if (Math.Abs(sideX) > capX) capX = sideX; - if (Math.Abs(sideY) > capY) capY = sideY; + double absSideX = Math.Abs(sideX); double absSideY = Math.Abs(sideY); + if (absSideX > capX) capX = absSideX; + if (absSideY > capY) capY = absSideY; double tempRatioX = (dState.LX - 128.0) / capX; double tempRatioY = (dState.LY - 128.0) / capY; double signX = tempRatioX >= 0.0 ? 1.0 : -1.0; @@ -1078,8 +1079,9 @@ namespace DS4Windows double sideX = dState.RX - 128; double sideY = dState.RY - 128.0; double capX = dState.RX >= 128 ? maxOutXRatio * 127.0 : maxOutXRatio * 128.0; double capY = dState.RY >= 128 ? maxOutYRatio * 127.0 : maxOutYRatio * 128.0; - if (Math.Abs(sideX) > capX) capX = sideX; - if (Math.Abs(sideY) > capY) capY = sideY; + double absSideX = Math.Abs(sideX); double absSideY = Math.Abs(sideY); + if (absSideX > capX) capX = absSideX; + if (absSideY > capY) capY = absSideY; double tempRatioX = (dState.RX - 128.0) / capX; double tempRatioY = (dState.RY - 128.0) / capY; double signX = tempRatioX >= 0.0 ? 1.0 : -1.0;