Esempio n. 1
0
        public void HandleSixaxis(byte[] gyro, byte[] accel, DS4State state)
        {
            int currentX = (short)((ushort)(gyro[0] << 8) | gyro[1]) / 64;
            int currentY = (short)((ushort)(gyro[2] << 8) | gyro[3]) / 64;
            int currentZ = (short)((ushort)(gyro[4] << 8) | gyro[5]) / 64;
            int AccelX = (short)((ushort)(accel[2] << 8) | accel[3]) / 256;
            int AccelY = (short)((ushort)(accel[0] << 8) | accel[1]) / 256;
            int AccelZ = (short)((ushort)(accel[4] << 8) | accel[5]) / 256;

            if ((AccelX == 0) && (AccelY == 0) && (AccelZ == 0))
            {
                return;
            }

            if (SixAccelMoved != null)
            {
                SixAxis sPrev = new SixAxis(lastGyroX, lastGyroY, lastGyroZ, lastAX, lastAY, lastAZ);
                SixAxis now = new SixAxis(currentX, currentY, currentZ, AccelX, AccelY, AccelZ, sPrev);
                SixAxisEventArgs args = new SixAxisEventArgs(state.ReportTimeStamp, now);
                SixAccelMoved(this, args);
            }

            lastGyroX = currentX;
            lastGyroY = currentY;
            lastGyroZ = currentZ;
            lastAX = AccelX;
            lastAY = AccelY;
            lastAZ = AccelZ;
        }
Esempio n. 2
0
 public SixAxis(int X, int Y, int Z, int aX, int aY, int aZ, SixAxis prevAxis = null)
 {
     gyroX = X;
     gyroY = Y;
     gyroZ = Z;
     accelX = aX;
     accelY = aY;
     accelZ = aZ;
     previousAxis = prevAxis;
     if (previousAxis != null)
     {
         deltaX = X - previousAxis.gyroX;
         deltaY = Y - previousAxis.gyroY;
         deltaZ = Z - previousAxis.gyroZ;
     }
 }
Esempio n. 3
0
 public SixAxisEventArgs(DateTime utcTimestamp, SixAxis sa)
 {
     sixAxis = sa;
     timeStamp = utcTimestamp;
 }