mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-12-23 23:21:49 +01:00
Try to correct some problems with imu data usage
This commit is contained in:
parent
c5dd97ebe5
commit
56fff28f65
@ -90,11 +90,11 @@ 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.getGyroX();
|
||||
int gyroX = exposeState.getAccelX();
|
||||
gryodirs[(int)DS4Controls.GyroXPos] = gyroX > 0 ? gyroX : 0;
|
||||
gryodirs[(int)DS4Controls.GyroXNeg] = gyroX < 0 ? gyroX : 0;
|
||||
|
||||
int gyroZ = exposeState.getGyroZ();
|
||||
int gyroZ = exposeState.getAccelZ();
|
||||
gryodirs[(int)DS4Controls.GyroZPos] = gyroZ > 0 ? gyroZ : 0;
|
||||
gryodirs[(int)DS4Controls.GyroZNeg] = gyroZ < 0 ? gyroZ : 0;
|
||||
|
||||
|
@ -2760,25 +2760,25 @@ namespace DS4Windows
|
||||
{
|
||||
case DS4Controls.GyroXPos:
|
||||
{
|
||||
int gyroX = eState.GyroX;
|
||||
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.GyroX;
|
||||
int gyroX = eState.AccelX;
|
||||
result = (byte)(!sOff && sxsens * gyroX < -SXD * 10 ? Math.Min(255, sxsens * -gyroX * 2) : 0);
|
||||
break;
|
||||
}
|
||||
case DS4Controls.GyroZPos:
|
||||
{
|
||||
int gyroZ = eState.GyroZ;
|
||||
int gyroZ = eState.AccelZ;
|
||||
result = (byte)(!sOff && szsens * gyroZ > SZD * 10 ? Math.Min(255, szsens * gyroZ * 2) : 0);
|
||||
break;
|
||||
}
|
||||
case DS4Controls.GyroZNeg:
|
||||
{
|
||||
int gyroZ = eState.GyroZ;
|
||||
int gyroZ = eState.AccelZ;
|
||||
result = (byte)(!sOff && szsens * gyroZ < -SZD * 10 ? Math.Min(255, szsens * -gyroZ * 2) : 0);
|
||||
break;
|
||||
}
|
||||
@ -2882,10 +2882,10 @@ namespace DS4Windows
|
||||
|
||||
switch (control)
|
||||
{
|
||||
case DS4Controls.GyroXPos: result = !sOff ? SXSens[device] * eState.GyroX > 67 : false; break;
|
||||
case DS4Controls.GyroXNeg: result = !sOff ? SXSens[device] * eState.GyroX < -67 : false; break;
|
||||
case DS4Controls.GyroZPos: result = !sOff ? SZSens[device] * eState.GyroZ > 67 : false; break;
|
||||
case DS4Controls.GyroZNeg: result = !sOff ? SZSens[device] * eState.GyroZ < -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;
|
||||
}
|
||||
}
|
||||
@ -3309,10 +3309,10 @@ namespace DS4Windows
|
||||
|
||||
switch (control)
|
||||
{
|
||||
case DS4Controls.GyroXPos: result = !sOff ? SXSens[device] * eState.GyroX > 67 : false; break;
|
||||
case DS4Controls.GyroXNeg: result = !sOff ? SXSens[device] * eState.GyroX < -67 : false; break;
|
||||
case DS4Controls.GyroZPos: result = !sOff ? SZSens[device] * eState.GyroZ > 67 : false; break;
|
||||
case DS4Controls.GyroZNeg: result = !sOff ? SZSens[device] * eState.GyroZ < -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,36 +3548,36 @@ namespace DS4Windows
|
||||
{
|
||||
case DS4Controls.GyroXPos:
|
||||
{
|
||||
if (!sOff && eState.GyroX > SXD * 10)
|
||||
if (!sOff && eState.AccelX > SXD * 10)
|
||||
{
|
||||
if (alt) result = (byte)Math.Min(255, 127 + SXSens[device] * eState.GyroX); else result = (byte)Math.Max(0, 127 - SXSens[device] * eState.GyroX);
|
||||
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.GyroX < -SXD * 10)
|
||||
if (!sOff && eState.AccelX < -SXD * 10)
|
||||
{
|
||||
if (alt) result = (byte)Math.Min(255, 127 + SXSens[device] * -eState.GyroX); else result = (byte)Math.Max(0, 127 - SXSens[device] * -eState.GyroX);
|
||||
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.GyroZPos:
|
||||
{
|
||||
if (!sOff && eState.GyroZ > SZD * 10)
|
||||
if (!sOff && eState.AccelZ > SZD * 10)
|
||||
{
|
||||
if (alt) result = (byte)Math.Min(255, 127 + SZSens[device] * eState.GyroZ); else result = (byte)Math.Max(0, 127 - SZSens[device] * eState.GyroZ);
|
||||
if (alt) result = (byte)Math.Min(255, 127 + SZSens[device] * eState.AccelZ); else result = (byte)Math.Max(0, 127 - SZSens[device] * eState.AccelZ);
|
||||
}
|
||||
else return falseVal;
|
||||
break;
|
||||
}
|
||||
case DS4Controls.GyroZNeg:
|
||||
{
|
||||
if (!sOff && eState.GyroZ < -SZD * 10)
|
||||
if (!sOff && eState.AccelZ < -SZD * 10)
|
||||
{
|
||||
if (alt) result = (byte)Math.Min(255, 127 + SZSens[device] * -eState.GyroZ); else result = (byte)Math.Max(0, 127 - SZSens[device] * -eState.GyroZ);
|
||||
if (alt) result = (byte)Math.Min(255, 127 + SZSens[device] * -eState.AccelZ); else result = (byte)Math.Max(0, 127 - SZSens[device] * -eState.AccelZ);
|
||||
}
|
||||
else result = falseVal;
|
||||
break;
|
||||
|
@ -805,11 +805,11 @@ namespace DS4Windows
|
||||
else
|
||||
{
|
||||
EnableReadings(true);
|
||||
SetDynamicTrackBarValue(tBsixaxisGyroX, (Program.rootHub.ExposedState[tempDeviceNum].GyroX + tBsixaxisGyroX.Value * 2) / 3);
|
||||
SetDynamicTrackBarValue(tBsixaxisGyroY, (Program.rootHub.ExposedState[tempDeviceNum].GyroY + tBsixaxisGyroY.Value * 2) / 3);
|
||||
SetDynamicTrackBarValue(tBsixaxisGyroZ, (Program.rootHub.ExposedState[tempDeviceNum].GyroZ + tBsixaxisGyroZ.Value * 2) / 3);
|
||||
SetDynamicTrackBarValue(tBsixaxisAccelX, (int)(Program.rootHub.ExposedState[tempDeviceNum].AccelX + tBsixaxisAccelX.Value * 2) / 3);
|
||||
SetDynamicTrackBarValue(tBsixaxisAccelY, (int)(Program.rootHub.ExposedState[tempDeviceNum].AccelY + tBsixaxisAccelY.Value * 2) / 3);
|
||||
SetDynamicTrackBarValue(tBsixaxisGyroX, (-Program.rootHub.ExposedState[tempDeviceNum].GyroYaw + tBsixaxisGyroX.Value * 2) / 3);
|
||||
SetDynamicTrackBarValue(tBsixaxisGyroY, (Program.rootHub.ExposedState[tempDeviceNum].GyroPitch + tBsixaxisGyroY.Value * 2) / 3);
|
||||
SetDynamicTrackBarValue(tBsixaxisGyroZ, (-Program.rootHub.ExposedState[tempDeviceNum].GyroRoll + tBsixaxisGyroZ.Value * 2) / 3);
|
||||
SetDynamicTrackBarValue(tBsixaxisAccelX, (int)(-Program.rootHub.ExposedState[tempDeviceNum].AccelX + tBsixaxisAccelX.Value * 2) / 3);
|
||||
SetDynamicTrackBarValue(tBsixaxisAccelY, (int)(-Program.rootHub.ExposedState[tempDeviceNum].AccelY + tBsixaxisAccelY.Value * 2) / 3);
|
||||
SetDynamicTrackBarValue(tBsixaxisAccelZ, (int)(Program.rootHub.ExposedState[tempDeviceNum].AccelZ + tBsixaxisAccelZ.Value * 2) / 3);
|
||||
|
||||
int x = Program.rootHub.getDS4State(tempDeviceNum).LX;
|
||||
@ -902,8 +902,8 @@ namespace DS4Windows
|
||||
(int)(tempRSS * (btnRSTrack.Location.Y - pnlRSTrack.Size.Height / 2f) + pnlRSTrack.Size.Height / 2f));
|
||||
}
|
||||
|
||||
x = -Program.rootHub.ExposedState[tempDeviceNum].GyroX + 127;
|
||||
y = Program.rootHub.ExposedState[tempDeviceNum].GyroZ + 127;
|
||||
x = -Program.rootHub.ExposedState[tempDeviceNum].AccelX + 127;
|
||||
y = Program.rootHub.ExposedState[tempDeviceNum].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)));
|
||||
|
||||
double tempSXS = (double)nUDSXS.Value;
|
||||
|
@ -48,7 +48,6 @@ namespace DS4Windows
|
||||
|
||||
public class DS4SixAxis
|
||||
{
|
||||
//public event EventHandler<SixAxisEventArgs> SixAxisMoved = null; // deltaX/deltaY are set because one or both fingers were already down on a prior sensor reading
|
||||
public event EventHandler<SixAxisEventArgs> SixAccelMoved = null; // no status change for the touchpad itself... but other sensors may have changed, or you may just want to do some processing
|
||||
|
||||
internal int lastGyroX, lastGyroY, lastGyroZ, lastAX, lastAY, lastAZ; // tracks 0, 1 or 2 touches; we maintain touch 1 and 2 separately
|
||||
|
@ -44,74 +44,37 @@ namespace DS4Windows
|
||||
byte R2 { get { return _state.R2; } }
|
||||
int Battery { get { return _state.Battery; } }
|
||||
|
||||
/// <summary> Holds raw DS4 input data from 14 to 19 </summary>
|
||||
public byte[] Accel { set { accel = value; } }
|
||||
public void setAccel(byte[] value)
|
||||
{
|
||||
accel = value;
|
||||
}
|
||||
|
||||
/// <summary> Holds raw DS4 input data from 20 to 25 </summary>
|
||||
public byte[] Gyro { set { gyro = value; } }
|
||||
public void setGyro(byte[] value)
|
||||
{
|
||||
gyro = value;
|
||||
}
|
||||
|
||||
/// <summary> Yaw leftward/counter-clockwise/turn to port or larboard side </summary>
|
||||
/// <remarks> Add double the previous result to this delta and divide by three.</remarks>
|
||||
//public int AccelX { get { return (short)((ushort)(accel[2] << 8) | accel[3]) / 256; } }
|
||||
//public int AccelX { get { return (short)((ushort)(accel[1] << 8) | accel[0]) / 64; } }
|
||||
public int AccelX { get { return (short)((ushort)(gyro[3] << 8) | gyro[2]) / 256; } }
|
||||
public int GyroYaw { get { return (short)((ushort)(gyro[3] << 8) | gyro[2]) / 256; } }
|
||||
public int GyroPitch { get { return (short)((ushort)(gyro[1] << 8) | gyro[0]) / 256; } }
|
||||
public int GyroRoll { get { return (short)((ushort)(gyro[5] << 8) | gyro[4]) / 256; } }
|
||||
|
||||
/// <summary> Pitch upward/backward </summary>
|
||||
/// <remarks> Add double the previous result to this delta and divide by three.</remarks>
|
||||
//public int AccelY { get { return (short)((ushort)(accel[0] << 8) | accel[1] ) / 256; } }
|
||||
//public int AccelY { get { return (short)((ushort)(accel[3] << 8) | accel[2]) / 64; } }
|
||||
public int AccelY { get { return (short)((ushort)(gyro[1] << 8) | gyro[0]) / 256; } }
|
||||
|
||||
/// <summary> roll left/L side of controller down/starboard raising up </summary>
|
||||
/// <remarks> Add double the previous result to this delta and divide by three.</remarks>
|
||||
//public int AccelZ { get { return (short)((ushort)(accel[4] << 8) | accel[5]) / 256; } }
|
||||
//public int AccelZ { get { return (short)((ushort)(accel[5] << 8) | accel[4]) / 64; } }
|
||||
public int AccelZ { get { return (short)((ushort)(gyro[5] << 8) | gyro[4]) / 256; } }
|
||||
|
||||
/// <summary> R side of controller upward </summary>
|
||||
/// <remarks> Add double the previous result to this delta and divide by three.</remarks>
|
||||
//public int GyroX { get { return (short)((ushort)(gyro[0] << 8) | gyro[1]) / 64; } }
|
||||
//public int GyroX { get { return (short)((ushort)(gyro[3] << 8) | gyro[2]) / 256; } }
|
||||
public int GyroX { get { return (short)((ushort)(accel[1] << 8) | accel[0]) / 64; } }
|
||||
|
||||
public int getGyroX()
|
||||
public int AccelX { get { return (short)((ushort)(accel[1] << 8) | accel[0]) / 64; } }
|
||||
public int getAccelX()
|
||||
{
|
||||
//return (short)((ushort)(gyro[0] << 8) | gyro[1]) / 64;
|
||||
//return (short)((ushort)(gyro[3] << 8) | gyro[2]) / 256;
|
||||
return (short)((ushort)(accel[1] << 8) | accel[0]) / 64;
|
||||
}
|
||||
|
||||
/// <summary> touchpad and button face side of controller upward </summary>
|
||||
/// <remarks> Add double the previous result to this delta and divide by three.</remarks>
|
||||
//public int GyroY { get { return (short)((ushort)(gyro[2] << 8) | gyro[3]) / 64; } }
|
||||
//public int GyroY { get { return (short)((ushort)(gyro[1] << 8) | gyro[0]) / 256; } }
|
||||
public int GyroY { get { return (short)((ushort)(accel[3] << 8) | accel[2]) / 64; } }
|
||||
|
||||
public int getGyroY()
|
||||
public int AccelY { get { return (short)((ushort)(accel[3] << 8) | accel[2]) / 64; } }
|
||||
public int getAccelY()
|
||||
{
|
||||
//return (short)((ushort)(gyro[2] << 8) | gyro[3]) / 64;
|
||||
//return (short)((ushort)(gyro[1] << 8) | gyro[0]) / 256;
|
||||
return (short)((ushort)(accel[3] << 8) | accel[2]) / 64;
|
||||
}
|
||||
|
||||
/// <summary> Audio/expansion ports upward and light bar/shoulders/bumpers/USB port downward </summary>
|
||||
/// <remarks> Add double the previous result to this delta and divide by three.</remarks>
|
||||
//public int GyroZ { get { return (short)((ushort)(gyro[4] << 8) | gyro[5]) / 64; } }
|
||||
//public int GyroZ { get { return (short)((ushort)(gyro[5] << 8) | gyro[4]) / 256; } }
|
||||
public int GyroZ { get { return (short)((ushort)(accel[5] << 8) | accel[4]) / 64; } }
|
||||
|
||||
public int getGyroZ()
|
||||
public int AccelZ { get { return (short)((ushort)(accel[5] << 8) | accel[4]) / 64; } }
|
||||
public int getAccelZ()
|
||||
{
|
||||
//return (short)((ushort)(gyro[4] << 8) | gyro[5]) / 64;
|
||||
//return (short)((ushort)(gyro[5] << 8) | gyro[4]) / 256;
|
||||
return (short)((ushort)(accel[5] << 8) | accel[4]) / 64;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user