From 6db6315d7281bac991e5005e8b2bafacbde9c8f0 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 5 Nov 2018 04:49:23 -0600 Subject: [PATCH] Added extra calibration check. Might be useful in some cases where people have reported crashes. --- DS4Windows/DS4Library/DS4Sixaxis.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/DS4Windows/DS4Library/DS4Sixaxis.cs b/DS4Windows/DS4Library/DS4Sixaxis.cs index 8da297e..b082fd9 100644 --- a/DS4Windows/DS4Library/DS4Sixaxis.cs +++ b/DS4Windows/DS4Library/DS4Sixaxis.cs @@ -189,7 +189,11 @@ namespace DS4Windows calibrationData[5].sensNumer = 2 * SixAxis.ACC_RES_PER_G; calibrationData[5].sensDenom = accelRange; - calibrationDone = true; + // Check that denom will not be zero. + calibrationDone = calibrationData[0].sensDenom != 0 && + calibrationData[1].sensDenom != 0 && + calibrationData[2].sensDenom != 0 && + accelRange != 0; } private void applyCalibs(ref int yaw, ref int pitch, ref int roll,