mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2025-02-17 00:16:20 +01:00
Attempt to use timestamp from ds4. Preserve changes.
This commit is contained in:
parent
9d88fda0d2
commit
8250f9be5c
@ -42,7 +42,8 @@ namespace DS4Windows
|
|||||||
deltaX = Global.getGyroMouseHorizontalAxis(deviceNumber) == 0 ? arg.sixAxis.gyroYawFull :
|
deltaX = Global.getGyroMouseHorizontalAxis(deviceNumber) == 0 ? arg.sixAxis.gyroYawFull :
|
||||||
arg.sixAxis.gyroRollFull;
|
arg.sixAxis.gyroRollFull;
|
||||||
deltaY = -arg.sixAxis.gyroPitchFull;
|
deltaY = -arg.sixAxis.gyroPitchFull;
|
||||||
tempDouble = arg.sixAxis.elapsed * 0.001 * 200.0; // Base default speed on 5 ms
|
//tempDouble = arg.sixAxis.elapsed * 0.001 * 200.0; // Base default speed on 5 ms
|
||||||
|
tempDouble = arg.sixAxis.elapsed * 200.0; // Base default speed on 5 ms
|
||||||
|
|
||||||
gyroSmooth = Global.getGyroSmoothing(deviceNumber);
|
gyroSmooth = Global.getGyroSmoothing(deviceNumber);
|
||||||
double gyroSmoothWeight = 0.0;
|
double gyroSmoothWeight = 0.0;
|
||||||
|
@ -644,6 +644,10 @@ namespace DS4Windows
|
|||||||
bool ds4InactiveFrame = true;
|
bool ds4InactiveFrame = true;
|
||||||
bool idleInput = true;
|
bool idleInput = true;
|
||||||
|
|
||||||
|
bool timeStampInit = false;
|
||||||
|
uint timeStampPrevious = 0;
|
||||||
|
uint deltaTimeCurrent = 0;
|
||||||
|
|
||||||
private void performDs4Input()
|
private void performDs4Input()
|
||||||
{
|
{
|
||||||
firstActive = DateTime.UtcNow;
|
firstActive = DateTime.UtcNow;
|
||||||
@ -661,6 +665,9 @@ namespace DS4Windows
|
|||||||
|
|
||||||
int maxBatteryValue = 0;
|
int maxBatteryValue = 0;
|
||||||
int tempBattery = 0;
|
int tempBattery = 0;
|
||||||
|
uint tempStamp = 0;
|
||||||
|
double elapsedDeltaTime = 0.0;
|
||||||
|
uint tempDelta = 0;
|
||||||
|
|
||||||
while (!exitInputThread)
|
while (!exitInputThread)
|
||||||
{
|
{
|
||||||
@ -848,10 +855,31 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
catch { currerror = "Index out of bounds: touchpad"; }
|
catch { currerror = "Index out of bounds: touchpad"; }
|
||||||
|
|
||||||
|
tempStamp = (uint)((ushort)(inputReport[11] << 8) | inputReport[10]);
|
||||||
|
if (timeStampInit == false)
|
||||||
|
{
|
||||||
|
timeStampInit = true;
|
||||||
|
deltaTimeCurrent = tempStamp * 16u / 3u;
|
||||||
|
}
|
||||||
|
else if (timeStampPrevious > tempStamp)
|
||||||
|
{
|
||||||
|
tempDelta = ushort.MaxValue - timeStampPrevious + tempStamp + 1u;
|
||||||
|
deltaTimeCurrent = tempDelta * 16u / 3u;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tempDelta = tempStamp - timeStampPrevious;
|
||||||
|
deltaTimeCurrent = tempDelta * 16u / 3u;
|
||||||
|
}
|
||||||
|
|
||||||
|
cState.elapsedNanoSec = deltaTimeCurrent;
|
||||||
|
timeStampPrevious = tempStamp;
|
||||||
|
elapsedDeltaTime = 0.000001 * deltaTimeCurrent; // Convert from nanoseconds to seconds
|
||||||
|
|
||||||
// Store Gyro and Accel values
|
// Store Gyro and Accel values
|
||||||
Array.Copy(inputReport, 13, gyro, 0, 6);
|
Array.Copy(inputReport, 13, gyro, 0, 6);
|
||||||
Array.Copy(inputReport, 19, accel, 0, 6);
|
Array.Copy(inputReport, 19, accel, 0, 6);
|
||||||
sixAxis.handleSixaxis(gyro, accel, cState, lastTimeElapsedDouble);
|
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)
|
||||||
|
@ -23,6 +23,7 @@ namespace DS4Windows
|
|||||||
public double LYUnit;
|
public double LYUnit;
|
||||||
public double RXUnit;
|
public double RXUnit;
|
||||||
public double RYUnit;
|
public double RYUnit;
|
||||||
|
public uint elapsedNanoSec = 0;
|
||||||
public SixAxis Motion = null;
|
public SixAxis Motion = null;
|
||||||
public static readonly int DEFAULT_AXISDIR_VALUE = 127;
|
public static readonly int DEFAULT_AXISDIR_VALUE = 127;
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ namespace DS4Windows
|
|||||||
LYUnit = 0.0;
|
LYUnit = 0.0;
|
||||||
RXUnit = 0.0;
|
RXUnit = 0.0;
|
||||||
RYUnit = 0.0;
|
RYUnit = 0.0;
|
||||||
|
elapsedNanoSec = 0;
|
||||||
Motion = new SixAxis(0, 0, 0, 0, 0, 0, 0.0);
|
Motion = new SixAxis(0, 0, 0, 0, 0, 0, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,6 +95,7 @@ namespace DS4Windows
|
|||||||
LYUnit = state.LYUnit;
|
LYUnit = state.LYUnit;
|
||||||
RXUnit = state.RXUnit;
|
RXUnit = state.RXUnit;
|
||||||
RYUnit = state.RYUnit;
|
RYUnit = state.RYUnit;
|
||||||
|
elapsedNanoSec = state.elapsedNanoSec;
|
||||||
Motion = state.Motion;
|
Motion = state.Motion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,6 +148,7 @@ namespace DS4Windows
|
|||||||
state.LYUnit = LYUnit;
|
state.LYUnit = LYUnit;
|
||||||
state.RXUnit = RXUnit;
|
state.RXUnit = RXUnit;
|
||||||
state.RYUnit = RYUnit;
|
state.RYUnit = RYUnit;
|
||||||
|
state.elapsedNanoSec = elapsedNanoSec;
|
||||||
state.Motion = Motion;
|
state.Motion = Motion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user