Make imu data part of the DS4State

This commit is contained in:
Travis Nickles 2017-07-16 03:30:49 -05:00
parent 817505a989
commit 887a4fbdbd
5 changed files with 20 additions and 27 deletions

View File

@ -747,7 +747,7 @@ namespace DS4Windows
}
}
device.getExposedState(ExposedState[ind], CurrentState[ind]);
device.getCurrentState(CurrentState[ind]);
DS4State cState = CurrentState[ind];
device.getPreviousState(PreviousState[ind]);
DS4State pState = PreviousState[ind];

View File

@ -1196,12 +1196,13 @@ namespace DS4Windows
return pState.Clone();
}
public void getExposedState(DS4StateExposed expState, DS4State state)
/*public void getExposedState(DS4StateExposed expState, DS4State state)
{
cState.CopyTo(state);
expState.setAccel(accel);
expState.setGyro(gyro);
//expState.setAccel(accel);
//expState.setGyro(gyro);
}
*/
public void getCurrentState(DS4State state)
{

View File

@ -74,6 +74,7 @@ namespace DS4Windows
sPrev = new SixAxis(lastGyroX, lastGyroY, lastGyroZ, lastAX, lastAY, lastAZ, lastMilliseconds);
now = new SixAxis(currentX, currentY, currentZ, AccelX, AccelY, AccelZ, milliseconds, sPrev);
args = new SixAxisEventArgs(state.ReportTimeStamp, now);
state.Motion = now;
SixAccelMoved(this, args);
}

View File

@ -23,6 +23,7 @@ namespace DS4Windows
public double LYUnit;
public double RXUnit;
public double RYUnit;
public SixAxis Motion = null;
public static readonly int DEFAULT_AXISDIR_VALUE = 127;
public DS4State()
@ -45,6 +46,7 @@ namespace DS4Windows
LYUnit = 0.0;
RXUnit = 0.0;
RYUnit = 0.0;
Motion = null;
}
public DS4State(DS4State state)
@ -91,6 +93,7 @@ namespace DS4Windows
LYUnit = state.LYUnit;
RXUnit = state.RXUnit;
RYUnit = state.RYUnit;
Motion = state.Motion;
}
public DS4State Clone()
@ -142,6 +145,7 @@ namespace DS4Windows
state.LYUnit = LYUnit;
state.RXUnit = RXUnit;
state.RYUnit = RYUnit;
state.Motion = Motion;
}
public void calculateStickAngles()

View File

@ -4,13 +4,12 @@ namespace DS4Windows
public class DS4StateExposed
{
private DS4State _state;
private byte[] accel = new byte[] { 0, 0, 0, 0, 0, 0 },
gyro = new byte[] { 0, 0, 0, 0, 0, 0 };
public DS4StateExposed()
{
_state = new DS4State();
}
public DS4StateExposed(DS4State state)
{
_state = state;
@ -44,38 +43,26 @@ namespace DS4Windows
byte R2 { get { return _state.R2; } }
int Battery { get { return _state.Battery; } }
public byte[] Accel { set { accel = value; } }
public void setAccel(byte[] value)
{
accel = value;
}
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 byte[] Gyro { set { gyro = value; } }
public void setGyro(byte[] value)
{
gyro = value;
}
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; } }
public int AccelX { get { return (short)((ushort)(accel[1] << 8) | accel[0]) / 64; } }
public int AccelX { get { return _state.Motion.accelX; } }
public int getAccelX()
{
return (short)((ushort)(accel[1] << 8) | accel[0]) / 64;
return _state.Motion.accelX;
}
public int AccelY { get { return (short)((ushort)(accel[3] << 8) | accel[2]) / 64; } }
public int AccelY { get { return _state.Motion.accelY; } }
public int getAccelY()
{
return (short)((ushort)(accel[3] << 8) | accel[2]) / 64;
return _state.Motion.accelY;
}
public int AccelZ { get { return (short)((ushort)(accel[5] << 8) | accel[4]) / 64; } }
public int AccelZ { get { return _state.Motion.accelZ; } }
public int getAccelZ()
{
return (short)((ushort)(accel[5] << 8) | accel[4]) / 64;
return _state.Motion.accelZ;
}
}
}