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]; byte[] calibration = new byte[41];
calibration[0] = conType == ConnectionType.BT ? (byte)0x05 : (byte)0x02; calibration[0] = conType == ConnectionType.BT ? (byte)0x05 : (byte)0x02;
hDevice.readFeatureData(calibration); hDevice.readFeatureData(calibration);
sixAxis.setCalibrationData(ref calibration); sixAxis.setCalibrationData(ref calibration, conType == ConnectionType.USB);
} }
private void timeoutTestThread() private void timeoutTestThread()

View File

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