Esempio n. 1
0
        public void handleSixaxis(byte[] gyro, byte[] accel, DS4State state)
        {
            //bool touchPadIsDown = sensors.TouchButton;

            /*if (!PacketChanged(data, touchPacketOffset) && touchPadIsDown == lastTouchPadIsDown)
             * {
             *  if (SixAxisUnchanged != null)
             *      SixAxisUnchanged(this, EventArgs.Empty);
             *  return;
             * }*/
            /* byte touchID1 = (byte)(data[0 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] & 0x7F);
             * byte touchID2 = (byte)(data[4 + TOUCHPAD_DATA_OFFSET + touchPacketOffset] & 0x7F);*/
            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;
            SixAxisEventArgs args;

            //if (sensors.Touch1 || sensors.Touch2)
            {
                /* if (SixAxisMoved != null)
                 * {
                 *   SixAxis sPrev, now;
                 *   sPrev = new SixAxis(lastGyroX, lastGyroY, lastGyroZ, lastAX,lastAY,lastAZ);
                 *   now = new SixAxis(currentX, currentY, currentZ, AccelX, AccelY, AccelZ, sPrev);
                 *   args = new SixAxisEventArgs(state.ReportTimeStamp, now);
                 *   SixAxisMoved(this, args);
                 * }
                 *
                 * lastGyroX = currentX;
                 * lastGyroY = currentY;
                 * lastGyroZ = currentZ;
                 * lastAX = AccelX;
                 * lastAY = AccelY;
                 * lastAZ = AccelZ;*/
            }
            if (AccelX != 0 || AccelY != 0 || AccelZ != 0)
            {
                if (SixAccelMoved != null)
                {
                    SixAxis sPrev, now;
                    sPrev = new SixAxis(lastGyroX, lastGyroY, lastGyroZ, lastAX, lastAY, lastAZ);
                    now   = new SixAxis(currentX, currentY, currentZ, AccelX, AccelY, AccelZ, sPrev);
                    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(System.DateTime utcTimestamp, SixAxis sa)
 {
     sixAxis        = sa;
     this.timeStamp = utcTimestamp;
 }