Tweaks to how imu data is used

This commit is contained in:
Travis Nickles 2017-07-16 07:11:58 -05:00
parent 887a4fbdbd
commit dba2b1bbb3
7 changed files with 28 additions and 28 deletions

View File

@ -90,13 +90,13 @@ namespace DS4Windows
buttons[(int)DS4Controls.TouchUpper] = tp != null ? (!priorMouse ? tp.upperDown : tp.priorUpperDown) : false;
buttons[(int)DS4Controls.TouchMulti] = tp != null ? (!priorMouse ? tp.multiDown : tp.priorMultiDown) : false;
int gyroX = exposeState.getAccelX();
gryodirs[(int)DS4Controls.GyroXPos] = gyroX > 0 ? gyroX : 0;
gryodirs[(int)DS4Controls.GyroXNeg] = gyroX < 0 ? gyroX : 0;
int sixAxisX = -exposeState.getAccelX();
gryodirs[(int)DS4Controls.GyroXPos] = sixAxisX > 0 ? sixAxisX : 0;
gryodirs[(int)DS4Controls.GyroXNeg] = sixAxisX < 0 ? sixAxisX : 0;
int gyroZ = exposeState.getAccelZ();
gryodirs[(int)DS4Controls.GyroZPos] = gyroZ > 0 ? gyroZ : 0;
gryodirs[(int)DS4Controls.GyroZNeg] = gyroZ < 0 ? gyroZ : 0;
int sixAxisZ = exposeState.getAccelZ();
gryodirs[(int)DS4Controls.GyroZPos] = sixAxisZ > 0 ? sixAxisZ : 0;
gryodirs[(int)DS4Controls.GyroZNeg] = sixAxisZ < 0 ? sixAxisZ : 0;
swipedirs[(int)DS4Controls.SwipeLeft] = tp != null ? (!priorMouse ? tp.swipeLeftB : tp.priorSwipeLeftB): (byte)0;
swipedirs[(int)DS4Controls.SwipeRight] = tp != null ? (!priorMouse ? tp.swipeRightB : tp.priorSwipeRightB) : (byte)0;

View File

@ -2760,13 +2760,13 @@ namespace DS4Windows
{
case DS4Controls.GyroXPos:
{
int gyroX = eState.AccelX;
int gyroX = -eState.AccelX;
result = (byte)(!sOff && sxsens * gyroX > SXD * 10 ? Math.Min(255, sxsens * gyroX * 2) : 0);
break;
}
case DS4Controls.GyroXNeg:
{
int gyroX = eState.AccelX;
int gyroX = -eState.AccelX;
result = (byte)(!sOff && sxsens * gyroX < -SXD * 10 ? Math.Min(255, sxsens * -gyroX * 2) : 0);
break;
}
@ -2882,8 +2882,8 @@ namespace DS4Windows
switch (control)
{
case DS4Controls.GyroXPos: result = !sOff ? SXSens[device] * eState.AccelX > 67 : false; break;
case DS4Controls.GyroXNeg: result = !sOff ? SXSens[device] * eState.AccelX < -67 : false; break;
case DS4Controls.GyroXPos: result = !sOff ? SXSens[device] * -eState.AccelX > 67 : false; break;
case DS4Controls.GyroXNeg: result = !sOff ? SXSens[device] * -eState.AccelX < -67 : false; break;
case DS4Controls.GyroZPos: result = !sOff ? SZSens[device] * eState.AccelZ > 67 : false; break;
case DS4Controls.GyroZNeg: result = !sOff ? SZSens[device] * eState.AccelZ < -67 : false; break;
default: break;
@ -3548,18 +3548,18 @@ namespace DS4Windows
{
case DS4Controls.GyroXPos:
{
if (!sOff && eState.AccelX > SXD * 10)
if (!sOff && -eState.AccelX > SXD * 10)
{
if (alt) result = (byte)Math.Min(255, 127 + SXSens[device] * eState.AccelX); else result = (byte)Math.Max(0, 127 - SXSens[device] * eState.AccelX);
if (alt) result = (byte)Math.Min(255, 127 + SXSens[device] * -eState.AccelX); else result = (byte)Math.Max(0, 127 - SXSens[device] * -eState.AccelX);
}
else result = falseVal;
break;
}
case DS4Controls.GyroXNeg:
{
if (!sOff && eState.AccelX < -SXD * 10)
if (!sOff && -eState.AccelX < -SXD * 10)
{
if (alt) result = (byte)Math.Min(255, 127 + SXSens[device] * -eState.AccelX); else result = (byte)Math.Max(0, 127 - SXSens[device] * -eState.AccelX);
if (alt) result = (byte)Math.Min(255, 127 + SXSens[device] * eState.AccelX); else result = (byte)Math.Max(0, 127 - SXSens[device] * eState.AccelX);
}
else result = falseVal;
break;

View File

@ -21,7 +21,7 @@ namespace DS4Windows
private double GYRO_MOUSE_COEFFICIENT = 0.0095;
private int GYRO_MOUSE_DEADZONE = 12;
private double GYRO_MOUSE_OFFSET = 0.1463;
private double GYRO_SMOOTH_MOUSE_OFFSET = 0.14698;
private double GYRO_SMOOTH_MOUSE_OFFSET = 0.14695;
private const int SMOOTH_BUFFER_LEN = 3;
private double[] xSmoothBuffer = new double[SMOOTH_BUFFER_LEN];
@ -41,7 +41,7 @@ namespace DS4Windows
deltaX = Global.getGyroMouseHorizontalAxis(deviceNumber) == 0 ? arg.sixAxis.gyroYawFull :
arg.sixAxis.gyroRollFull;
deltaY = -arg.sixAxis.gyroPitchFull;
tempDouble = arg.sixAxis.elapsed * 0.001 * 250.0;
tempDouble = arg.sixAxis.elapsed * 0.001 * 250.0; // Base default speed on 4 ms
gyroSmooth = Global.getGyroSmoothing(deviceNumber);
double gyroSmoothWeight = 0.0;

View File

@ -805,8 +805,8 @@ namespace DS4Windows
SetDynamicTrackBarValue(tBsixaxisGyroX, (exposeState.GyroYaw + tBsixaxisGyroX.Value * 2) / 3);
SetDynamicTrackBarValue(tBsixaxisGyroY, (exposeState.GyroPitch + tBsixaxisGyroY.Value * 2) / 3);
SetDynamicTrackBarValue(tBsixaxisGyroZ, (exposeState.GyroRoll + tBsixaxisGyroZ.Value * 2) / 3);
SetDynamicTrackBarValue(tBsixaxisAccelX, (-exposeState.AccelX + tBsixaxisAccelX.Value * 2) / 3);
SetDynamicTrackBarValue(tBsixaxisAccelY, (-exposeState.AccelY + tBsixaxisAccelY.Value * 2) / 3);
SetDynamicTrackBarValue(tBsixaxisAccelX, (exposeState.AccelX + tBsixaxisAccelX.Value * 2) / 3);
SetDynamicTrackBarValue(tBsixaxisAccelY, (exposeState.AccelY + tBsixaxisAccelY.Value * 2) / 3);
SetDynamicTrackBarValue(tBsixaxisAccelZ, (exposeState.AccelZ + tBsixaxisAccelZ.Value * 2) / 3);
int x = baseState.LX;
@ -899,7 +899,7 @@ namespace DS4Windows
(int)(tempRSS * (btnRSTrack.Location.Y - pnlRSTrack.Size.Height / 2f) + pnlRSTrack.Size.Height / 2f));
}
x = -exposeState.AccelX + 127;
x = exposeState.AccelX + 127;
y = exposeState.AccelZ + 127;
btnSATrack.Location = new Point((int)(dpix * Global.Clamp(0, x / 2.09, pnlSATrack.Size.Width)), (int)(dpiy * Global.Clamp(0, y / 2.09, pnlSATrack.Size.Height)));

View File

@ -23,18 +23,18 @@ namespace DS4Windows
public readonly SixAxis previousAxis = null;
public SixAxis(int X, int Y, int Z, int aX, int aY, int aZ, double milliseconds, SixAxis prevAxis = null)
{
gyroX = X / 256;
gyroX = -X / 256;
gyroY = Y / 256;
gyroZ = Z / 256;
gyroZ = -Z / 256;
gyroYawFull = -X;
gyroPitchFull = Y;
gyroRollFull = -Z;
accelX = aX / 64;
accelY = aY / 64;
accelX = -aX / 64;
accelY = -aY / 64;
accelZ = aZ / 64;
accelXFull = aX;
accelYFull = aY;
accelXFull = -aX;
accelYFull = -aY;
accelZFull = aZ;
elapsed = milliseconds;

View File

@ -46,7 +46,7 @@ namespace DS4Windows
LYUnit = 0.0;
RXUnit = 0.0;
RYUnit = 0.0;
Motion = null;
Motion = new SixAxis(0, 0, 0, 0, 0, 0, 0.0);
}
public DS4State(DS4State state)

View File

@ -43,9 +43,9 @@ namespace DS4Windows
byte R2 { get { return _state.R2; } }
int Battery { get { return _state.Battery; } }
public int GyroYaw { get { return -_state.Motion.gyroX; } }
public int GyroYaw { get { return _state.Motion.gyroX; } }
public int GyroPitch { get { return _state.Motion.gyroY; } }
public int GyroRoll { get { return -_state.Motion.gyroZ; } }
public int GyroRoll { get { return _state.Motion.gyroZ; } }
public int AccelX { get { return _state.Motion.accelX; } }
public int getAccelX()