uint8_tdummy;// I can not figure out what this data is for, it seems to change randomly, maybe a timestamp?
struct{
struct{
uint8_tcounter:7;// Increments every time a finger is touching the touchpad
uint8_ttouching:1;// The top bit is cleared if the finger is touching the touchpad
};
struct{
uint16_tx:12;
uint16_ty:12;
};
}finger[2];// 0 = first finger, 1 = second finger
};
structPS4Data{
/* Button and joystick values */
uint8_treport_id;// Always 0x01
uint8_thatValue[4];
PS4Buttonsbtn;
uint8_ttrigger[2];
// I still need to figure out how to make the PS4 controller send out the rest of the data via Bluetooth
/* Gyro and accelerometer values */
uint8_tdummy[3];// First two looks random, while the third one might be some kind of status
int16_tgyroY,gyroZ,gyroX;
int16_taccX,accZ,accY;
/* The rest is data for the touchpad */
uint8_tdummy2[9];// Byte 5 looks like some kind of status (maybe battery status), bit 1 of byte 9 is set every time a finger is moving around the touchpad
touchpadXYxy[3];// It looks like it sends out three coordinates each time, this is possible because the microcontroller inside the PS4 controller is much faster than the Bluetooth connection.
// The last data is read from the last position in the array while the oldest measurement is from the first position.
// The first position will also keep it's value after the finger is released, while the other two will set them to zero.
// Note that if you read fast enough from the device, then only the first one will contain any data.
// The last three bytes are always: 0x00, 0x80, 0x00
};
enumDPADEnum{
DPAD_UP=0x0,
DPAD_UP_RIGHT=0x1,
DPAD_RIGHT=0x2,
DPAD_RIGHT_DOWN=0x3,
DPAD_DOWN=0x4,
DPAD_DOWN_LEFT=0x5,
DPAD_LEFT=0x6,
DPAD_LEFT_UP=0x7,
DPAD_OFF=0x8,
};
/** This class parses all the data sent by the PS4 controller */