Fixed NaN problem when cap is 0

This commit is contained in:
Travis Nickles 2020-04-15 06:27:48 -05:00
parent c007c43736
commit 31aa0a1aac

View File

@ -1082,8 +1082,8 @@ namespace DS4Windows
double absSideX = Math.Abs(sideX); double absSideY = Math.Abs(sideY); double absSideX = Math.Abs(sideX); double absSideY = Math.Abs(sideY);
if (absSideX > capX) capX = absSideX; if (absSideX > capX) capX = absSideX;
if (absSideY > capY) capY = absSideY; if (absSideY > capY) capY = absSideY;
double tempRatioX = (dState.RX - 128.0) / capX; double tempRatioX = capX > 0 ? (dState.RX - 128.0) / capX : 0;
double tempRatioY = (dState.RY - 128.0) / capY; double tempRatioY = capY > 0 ? (dState.RY - 128.0) / capY : 0;
double signX = tempRatioX >= 0.0 ? 1.0 : -1.0; double signX = tempRatioX >= 0.0 ? 1.0 : -1.0;
double signY = tempRatioY >= 0.0 ? 1.0 : -1.0; double signY = tempRatioY >= 0.0 ? 1.0 : -1.0;