mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-23 09:49:16 +01:00
Minor tweak for skipping calibration that .NET likes better
Related to issue #330.
This commit is contained in:
parent
1f85128c22
commit
cfa2bea4be
@ -150,7 +150,6 @@ namespace DS4Windows
|
|||||||
public DateTime lastActive = DateTime.UtcNow;
|
public DateTime lastActive = DateTime.UtcNow;
|
||||||
public DateTime firstActive = DateTime.UtcNow;
|
public DateTime firstActive = DateTime.UtcNow;
|
||||||
private bool charging;
|
private bool charging;
|
||||||
private bool isNacon = false;
|
|
||||||
private bool outputRumble = false;
|
private bool outputRumble = false;
|
||||||
private int warnInterval = WARN_INTERVAL_USB;
|
private int warnInterval = WARN_INTERVAL_USB;
|
||||||
public int getWarnInterval()
|
public int getWarnInterval()
|
||||||
@ -414,6 +413,7 @@ namespace DS4Windows
|
|||||||
hDevice = hidDevice;
|
hDevice = hidDevice;
|
||||||
conType = HidConnectionType(hDevice);
|
conType = HidConnectionType(hDevice);
|
||||||
Mac = hDevice.readSerial();
|
Mac = hDevice.readSerial();
|
||||||
|
bool runCalib = true;
|
||||||
if (conType == ConnectionType.USB || conType == ConnectionType.SONYWA)
|
if (conType == ConnectionType.USB || conType == ConnectionType.SONYWA)
|
||||||
{
|
{
|
||||||
inputReport = new byte[64];
|
inputReport = new byte[64];
|
||||||
@ -431,7 +431,7 @@ namespace DS4Windows
|
|||||||
|
|
||||||
else if (tempAttr.VendorId == 0x146B)
|
else if (tempAttr.VendorId == 0x146B)
|
||||||
{
|
{
|
||||||
isNacon = true;
|
runCalib = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
synced = true;
|
synced = true;
|
||||||
@ -457,7 +457,8 @@ namespace DS4Windows
|
|||||||
touchpad = new DS4Touchpad();
|
touchpad = new DS4Touchpad();
|
||||||
sixAxis = new DS4SixAxis();
|
sixAxis = new DS4SixAxis();
|
||||||
Crc32Algorithm.InitializeTable(DefaultPolynomial);
|
Crc32Algorithm.InitializeTable(DefaultPolynomial);
|
||||||
refreshCalibration();
|
if (runCalib)
|
||||||
|
refreshCalibration();
|
||||||
|
|
||||||
if (!hDevice.IsFileStreamOpen())
|
if (!hDevice.IsFileStreamOpen())
|
||||||
{
|
{
|
||||||
@ -977,7 +978,8 @@ namespace DS4Windows
|
|||||||
pbAccel[i-6] = pbInput[i];
|
pbAccel[i-6] = pbInput[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sixAxis.handleSixaxis(gyro, accel, cState, elapsedDeltaTime, isNacon);
|
|
||||||
|
sixAxis.handleSixaxis(gyro, accel, cState, elapsedDeltaTime);
|
||||||
|
|
||||||
/* Debug output of incoming HID data:
|
/* Debug output of incoming HID data:
|
||||||
if (cState.L2 == 0xff && cState.R2 == 0xff)
|
if (cState.L2 == 0xff && cState.R2 == 0xff)
|
||||||
|
@ -115,6 +115,7 @@ namespace DS4Windows
|
|||||||
private CalibData[] calibrationData = new CalibData[6] { new CalibData(), new CalibData(),
|
private CalibData[] calibrationData = new CalibData[6] { new CalibData(), new CalibData(),
|
||||||
new CalibData(), new CalibData(), new CalibData(), new CalibData()
|
new CalibData(), new CalibData(), new CalibData(), new CalibData()
|
||||||
};
|
};
|
||||||
|
private bool calibrationDone = false;
|
||||||
|
|
||||||
public DS4SixAxis()
|
public DS4SixAxis()
|
||||||
{
|
{
|
||||||
@ -187,6 +188,8 @@ namespace DS4Windows
|
|||||||
calibrationData[5].bias = accelZPlus - accelRange / 2;
|
calibrationData[5].bias = accelZPlus - accelRange / 2;
|
||||||
calibrationData[5].sensNumer = 2 * SixAxis.ACC_RES_PER_G;
|
calibrationData[5].sensNumer = 2 * SixAxis.ACC_RES_PER_G;
|
||||||
calibrationData[5].sensDenom = accelRange;
|
calibrationData[5].sensDenom = accelRange;
|
||||||
|
|
||||||
|
calibrationDone = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyCalibs(ref int yaw, ref int pitch, ref int roll,
|
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,
|
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 currentYaw = (short)((ushort)(gyro[3] << 8) | gyro[2]);
|
||||||
int currentPitch = (short)((ushort)(gyro[1] << 8) | gyro[0]);
|
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 AccelY = (short)((ushort)(accel[3] << 8) | accel[2]);
|
||||||
int AccelZ = (short)((ushort)(accel[5] << 8) | accel[4]);
|
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);
|
applyCalibs(ref currentYaw, ref currentPitch, ref currentRoll, ref AccelX, ref AccelY, ref AccelZ);
|
||||||
}
|
|
||||||
|
|
||||||
SixAxisEventArgs args = null;
|
SixAxisEventArgs args = null;
|
||||||
if (AccelX != 0 || AccelY != 0 || AccelZ != 0)
|
if (AccelX != 0 || AccelY != 0 || AccelZ != 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user