Fix reading calibration report values. Take connection type into account

This commit is contained in:
Travis Nickles 2017-10-11 18:48:52 -05:00
parent d1e0be33de
commit 3a09132805
2 changed files with 7 additions and 7 deletions

View File

@ -452,7 +452,7 @@ namespace DS4Windows
byte[] calibration = new byte[41];
calibration[0] = conType == ConnectionType.BT ? (byte)0x05 : (byte)0x02;
hDevice.readFeatureData(calibration);
sixAxis.setCalibrationData(ref calibration);
sixAxis.setCalibrationData(ref calibration, conType == ConnectionType.USB);
}
private void timeoutTestThread()

View File

@ -123,7 +123,7 @@ namespace DS4Windows
}
int temInt = 0;
public void setCalibrationData(ref byte[] calibData)
public void setCalibrationData(ref byte[] calibData, bool fromUSB)
{
int pitchPlus, pitchMinus, yawPlus, yawMinus, rollPlus, rollMinus,
accelXPlus, accelXMinus, accelYPlus, accelYMinus, accelZPlus, accelZMinus,
@ -133,7 +133,7 @@ namespace DS4Windows
calibrationData[1].bias = (short)((ushort)(calibData[4] << 8) | calibData[3]);
calibrationData[2].bias = (short)((ushort)(calibData[6] << 8) | calibData[5]);
if (calibData[0] == 5)
if (!fromUSB)
{
pitchPlus = temInt = (short)((ushort)(calibData[8] << 8) | calibData[7]);
yawPlus = temInt = (short)((ushort)(calibData[10] << 8) | calibData[9]);
@ -145,10 +145,10 @@ namespace DS4Windows
else
{
pitchPlus = temInt = (short)((ushort)(calibData[8] << 8) | calibData[7]);
yawPlus = temInt = (short)((ushort)(calibData[10] << 8) | calibData[9]);
rollPlus = temInt = (short)((ushort)(calibData[12] << 8) | calibData[11]);
pitchMinus = temInt = (short)((ushort)(calibData[14] << 8) | calibData[13]);
yawMinus = temInt = (short)((ushort)(calibData[16] << 8) | calibData[15]);
pitchMinus = temInt = (short)((ushort)(calibData[10] << 8) | calibData[9]);
yawPlus = temInt = (short)((ushort)(calibData[12] << 8) | calibData[11]);
yawMinus = temInt = (short)((ushort)(calibData[14] << 8) | calibData[13]);
rollPlus = temInt = (short)((ushort)(calibData[16] << 8) | calibData[15]);
rollMinus = temInt = (short)((ushort)(calibData[18] << 8) | calibData[17]);
}