From 31aa0a1aac5066061b3ed82e95d5b33b7bb3a4c0 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Wed, 15 Apr 2020 06:27:48 -0500 Subject: [PATCH] Fixed NaN problem when cap is 0 --- DS4Windows/DS4Control/Mapping.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index 41654d4..e6530ea 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -1082,8 +1082,8 @@ namespace DS4Windows 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 tempRatioX = capX > 0 ? (dState.RX - 128.0) / capX : 0; + double tempRatioY = capY > 0 ? (dState.RY - 128.0) / capY : 0; double signX = tempRatioX >= 0.0 ? 1.0 : -1.0; double signY = tempRatioY >= 0.0 ? 1.0 : -1.0;