#ifndef eGizmo_PS2Controller_h #define eGizmo_PS2Controller_h #include #include #define SER_SYNC1 0 #define SER_SYNC2 1 #define SER_FETCHDATA 2 #define DATALENGTH 15 #define DEFAULTIDLEJSDATA 128 typedef struct controllerData controllerData; struct controllerData { bool up; bool down; bool left; bool right; bool triangle; bool circle; bool cross; bool square; bool left1; bool left2; bool right1; bool right2; bool start; byte leftx; byte lefty; byte rightx; byte righty; }; class eGizmo_PS2Controller{ public: eGizmo_PS2Controller (SoftwareSerial *ss); eGizmo_PS2Controller (HardwareSerial *hs); void begin(uint32_t baudrate); void end(void); bool update(void); void fetch(void); bool up; bool down; bool left; bool right; bool triangle; bool circle; bool cross; bool square; bool left1; bool left2; bool right1; bool right2; bool start; byte leftx; byte lefty; byte rightx; byte righty; private: Stream *mySerial; HardwareSerial *hwSerial; SoftwareSerial *swSerial; byte inputData[DATALENGTH]; byte serial_state; byte serial_rxcounter; bool serial_available; //true when data packet is available }; #endif