mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-23 01:39:17 +01:00
Use proper delta time for trackball mode
It had been using the previous poll delta time instead
This commit is contained in:
parent
4bb6b08f72
commit
f906554743
@ -141,8 +141,8 @@ namespace DS4Windows
|
||||
if (Global.getTrackballMode(deviceNum))
|
||||
{
|
||||
int iIndex = trackballBufferTail;
|
||||
trackballXBuffer[iIndex] = (arg.touches[0].deltaX * TRACKBALL_SCALE) / dev.getCurrentStateRef().Motion.elapsed;
|
||||
trackballYBuffer[iIndex] = (arg.touches[0].deltaY * TRACKBALL_SCALE) / dev.getCurrentStateRef().Motion.elapsed;
|
||||
trackballXBuffer[iIndex] = (arg.touches[0].deltaX * TRACKBALL_SCALE) / dev.getCurrentStateRef().elapsedTime;
|
||||
trackballYBuffer[iIndex] = (arg.touches[0].deltaY * TRACKBALL_SCALE) / dev.getCurrentStateRef().elapsedTime;
|
||||
trackballBufferTail = (iIndex + 1) % TRACKBALL_BUFFER_LEN;
|
||||
if (trackballBufferHead == trackballBufferTail)
|
||||
trackballBufferHead = (trackballBufferHead + 1) % TRACKBALL_BUFFER_LEN;
|
||||
@ -284,12 +284,12 @@ namespace DS4Windows
|
||||
int signX = Math.Sign(trackballXVel);
|
||||
int signY = Math.Sign(trackballYVel);
|
||||
|
||||
double trackXvDecay = Math.Min(Math.Abs(trackballXVel), trackballAccel * s.Motion.elapsed * normX);
|
||||
double trackYvDecay = Math.Min(Math.Abs(trackballYVel), trackballAccel * s.Motion.elapsed * normY);
|
||||
double trackXvDecay = Math.Min(Math.Abs(trackballXVel), trackballAccel * s.elapsedTime * normX);
|
||||
double trackYvDecay = Math.Min(Math.Abs(trackballYVel), trackballAccel * s.elapsedTime * normY);
|
||||
double xVNew = trackballXVel - (trackXvDecay * signX);
|
||||
double yVNew = trackballYVel - (trackYvDecay * signY);
|
||||
double xMotion = (xVNew * s.Motion.elapsed) / TRACKBALL_SCALE;
|
||||
double yMotion = (yVNew * s.Motion.elapsed) / TRACKBALL_SCALE;
|
||||
double xMotion = (xVNew * s.elapsedTime) / TRACKBALL_SCALE;
|
||||
double yMotion = (yVNew * s.elapsedTime) / TRACKBALL_SCALE;
|
||||
if (xMotion != 0.0)
|
||||
{
|
||||
xMotion += trackballDXRemain;
|
||||
@ -363,12 +363,12 @@ namespace DS4Windows
|
||||
double normY = Math.Abs(Math.Sin(tempAngle));
|
||||
int signX = Math.Sign(trackballXVel);
|
||||
int signY = Math.Sign(trackballYVel);
|
||||
double trackXvDecay = Math.Min(Math.Abs(trackballXVel), trackballAccel * s.Motion.elapsed * normX);
|
||||
double trackYvDecay = Math.Min(Math.Abs(trackballYVel), trackballAccel * s.Motion.elapsed * normY);
|
||||
double trackXvDecay = Math.Min(Math.Abs(trackballXVel), trackballAccel * s.elapsedTime * normX);
|
||||
double trackYvDecay = Math.Min(Math.Abs(trackballYVel), trackballAccel * s.elapsedTime * normY);
|
||||
double xVNew = trackballXVel - (trackXvDecay * signX);
|
||||
double yVNew = trackballYVel - (trackYvDecay * signY);
|
||||
double xMotion = (xVNew * s.Motion.elapsed) / TRACKBALL_SCALE;
|
||||
double yMotion = (yVNew * s.Motion.elapsed) / TRACKBALL_SCALE;
|
||||
double xMotion = (xVNew * s.elapsedTime) / TRACKBALL_SCALE;
|
||||
double yMotion = (yVNew * s.elapsedTime) / TRACKBALL_SCALE;
|
||||
if (xMotion != 0.0)
|
||||
{
|
||||
xMotion += trackballDXRemain;
|
||||
|
@ -845,6 +845,27 @@ namespace DS4Windows
|
||||
//Console.WriteLine(MacAddress.ToString() + " " + System.DateTime.UtcNow.ToString("o") + "> power subsystem octet: 0x" + inputReport[30].ToString("x02"));
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
timeStampPrevious = tempStamp;
|
||||
elapsedDeltaTime = 0.000001 * deltaTimeCurrent; // Convert from microseconds to seconds
|
||||
cState.elapsedTime = elapsedDeltaTime;
|
||||
|
||||
// XXX DS4State mapping needs fixup, turn touches into an array[4] of structs. And include the touchpad details there instead.
|
||||
try
|
||||
{
|
||||
@ -869,27 +890,6 @@ namespace DS4Windows
|
||||
}
|
||||
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.elapsedMicroSec = deltaTimeCurrent;
|
||||
timeStampPrevious = tempStamp;
|
||||
elapsedDeltaTime = 0.000001 * deltaTimeCurrent; // Convert from microseconds to seconds
|
||||
|
||||
// Store Gyro and Accel values
|
||||
Array.Copy(inputReport, 13, gyro, 0, 6);
|
||||
Array.Copy(inputReport, 19, accel, 0, 6);
|
||||
|
@ -23,7 +23,7 @@ namespace DS4Windows
|
||||
public double LYUnit;
|
||||
public double RXUnit;
|
||||
public double RYUnit;
|
||||
public uint elapsedMicroSec = 0;
|
||||
public double elapsedTime = 0.0;
|
||||
public SixAxis Motion = null;
|
||||
public static readonly int DEFAULT_AXISDIR_VALUE = 127;
|
||||
|
||||
@ -47,7 +47,7 @@ namespace DS4Windows
|
||||
LYUnit = 0.0;
|
||||
RXUnit = 0.0;
|
||||
RYUnit = 0.0;
|
||||
elapsedMicroSec = 0;
|
||||
elapsedTime = 0.0;
|
||||
Motion = new SixAxis(0, 0, 0, 0, 0, 0, 0.0);
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ namespace DS4Windows
|
||||
LYUnit = state.LYUnit;
|
||||
RXUnit = state.RXUnit;
|
||||
RYUnit = state.RYUnit;
|
||||
elapsedMicroSec = state.elapsedMicroSec;
|
||||
elapsedTime = state.elapsedTime;
|
||||
Motion = state.Motion;
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ namespace DS4Windows
|
||||
state.LYUnit = LYUnit;
|
||||
state.RXUnit = RXUnit;
|
||||
state.RYUnit = RYUnit;
|
||||
state.elapsedMicroSec = elapsedMicroSec;
|
||||
state.elapsedTime = elapsedTime;
|
||||
state.Motion = Motion;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user