Minor tweak for skipping calibration that .NET likes better

Related to issue #330.
This commit is contained in:
Travis Nickles 2018-07-10 00:46:25 -05:00
parent 1f85128c22
commit cfa2bea4be
2 changed files with 11 additions and 8 deletions

View File

@ -150,7 +150,6 @@ namespace DS4Windows
public DateTime lastActive = DateTime.UtcNow;
public DateTime firstActive = DateTime.UtcNow;
private bool charging;
private bool isNacon = false;
private bool outputRumble = false;
private int warnInterval = WARN_INTERVAL_USB;
public int getWarnInterval()
@ -414,6 +413,7 @@ namespace DS4Windows
hDevice = hidDevice;
conType = HidConnectionType(hDevice);
Mac = hDevice.readSerial();
bool runCalib = true;
if (conType == ConnectionType.USB || conType == ConnectionType.SONYWA)
{
inputReport = new byte[64];
@ -431,7 +431,7 @@ namespace DS4Windows
else if (tempAttr.VendorId == 0x146B)
{
isNacon = true;
runCalib = false;
}
synced = true;
@ -457,7 +457,8 @@ namespace DS4Windows
touchpad = new DS4Touchpad();
sixAxis = new DS4SixAxis();
Crc32Algorithm.InitializeTable(DefaultPolynomial);
refreshCalibration();
if (runCalib)
refreshCalibration();
if (!hDevice.IsFileStreamOpen())
{
@ -977,7 +978,8 @@ namespace DS4Windows
pbAccel[i-6] = pbInput[i];
}
}
sixAxis.handleSixaxis(gyro, accel, cState, elapsedDeltaTime, isNacon);
sixAxis.handleSixaxis(gyro, accel, cState, elapsedDeltaTime);
/* Debug output of incoming HID data:
if (cState.L2 == 0xff && cState.R2 == 0xff)

View File

@ -115,6 +115,7 @@ namespace DS4Windows
private CalibData[] calibrationData = new CalibData[6] { new CalibData(), new CalibData(),
new CalibData(), new CalibData(), new CalibData(), new CalibData()
};
private bool calibrationDone = false;
public DS4SixAxis()
{
@ -187,6 +188,8 @@ namespace DS4Windows
calibrationData[5].bias = accelZPlus - accelRange / 2;
calibrationData[5].sensNumer = 2 * SixAxis.ACC_RES_PER_G;
calibrationData[5].sensDenom = accelRange;
calibrationDone = true;
}
private void applyCalibs(ref int yaw, ref int pitch, ref int roll,
@ -218,7 +221,7 @@ namespace DS4Windows
}
public void handleSixaxis(byte[] gyro, byte[] accel, DS4State state,
double elapsedDelta, bool disableCalibs)
double elapsedDelta)
{
int currentYaw = (short)((ushort)(gyro[3] << 8) | gyro[2]);
int currentPitch = (short)((ushort)(gyro[1] << 8) | gyro[0]);
@ -227,10 +230,8 @@ namespace DS4Windows
int AccelY = (short)((ushort)(accel[3] << 8) | accel[2]);
int AccelZ = (short)((ushort)(accel[5] << 8) | accel[4]);
if (!disableCalibs)
{
if (calibrationDone)
applyCalibs(ref currentYaw, ref currentPitch, ref currentRoll, ref AccelX, ref AccelY, ref AccelZ);
}
SixAxisEventArgs args = null;
if (AccelX != 0 || AccelY != 0 || AccelZ != 0)