From 78062121325f99e1a068eed8f0fe7c76017b9c6a Mon Sep 17 00:00:00 2001 From: Kristian Lauszus Date: Mon, 3 Feb 2014 23:06:27 +0100 Subject: [PATCH] Removed some unnecessary functions and some other cleanup --- BTHID.cpp | 2 +- BTHID.h | 3 +-- PS4BT.h | 14 +------------- PS4Parser.h | 12 ++++-------- PS4USB.h | 4 ++-- 5 files changed, 9 insertions(+), 26 deletions(-) diff --git a/BTHID.cpp b/BTHID.cpp index 37da8f04..01f190a7 100644 --- a/BTHID.cpp +++ b/BTHID.cpp @@ -190,7 +190,7 @@ void BTHID::ACLData(uint8_t* l2capinbuf) { #endif if(l2capinbuf[8] == 0xA1) { // HID_THDR_DATA_INPUT uint16_t length = ((uint16_t)l2capinbuf[5] << 8 | l2capinbuf[4]); - ParseBTHID(this, (uint8_t)(length - 1), &l2capinbuf[9]); + ParseBTHIDData((uint8_t)(length - 1), &l2capinbuf[9]); switch(l2capinbuf[9]) { case 0x01: // Keyboard or Joystick events diff --git a/BTHID.h b/BTHID.h index 58b907a4..2419e58b 100644 --- a/BTHID.h +++ b/BTHID.h @@ -109,11 +109,10 @@ protected: /** @name Overridable functions */ /** * Used to parse Bluetooth HID data to any class that inherits this class. - * @param bthid Pointer to this class. * @param len The length of the incoming data. * @param buf Pointer to the data buffer. */ - virtual void ParseBTHID(BTHID *bthid, uint8_t len, uint8_t *buf) { + virtual void ParseBTHIDData(uint8_t len, uint8_t *buf) { return; }; /** Called when a device is connected */ diff --git a/PS4BT.h b/PS4BT.h index 33bb58ec..bd42786a 100644 --- a/PS4BT.h +++ b/PS4BT.h @@ -46,14 +46,6 @@ public: return BTHID::connected; }; - /** - * Used to call your own function when the device is successfully initialized. - * @param funcOnInit Function to call. - */ - void attachOnInit(void (*funcOnInit)(void)) { - pFuncOnInit = funcOnInit; - }; - protected: /** @name BTHID implementation */ /** @@ -62,7 +54,7 @@ protected: * @param len The length of the incoming data. * @param buf Pointer to the data buffer. */ - virtual void ParseBTHID(BTHID *bthid, uint8_t len, uint8_t *buf) { + virtual void ParseBTHIDData(uint8_t len, uint8_t *buf) { PS4Parser::Parse(len, buf); }; @@ -73,8 +65,6 @@ protected: */ virtual void OnInitBTHID() { enable_sixaxis(); // Make the controller send out the entire output report - if (pFuncOnInit) - pFuncOnInit(); // Call the user function }; /** Used to reset the different buffers to there default values */ @@ -84,8 +74,6 @@ protected: /**@}*/ private: - void (*pFuncOnInit)(void); // Pointer to function called in onInit() - void HID_Command(uint8_t *data, uint8_t nbytes) { pBtd->L2CAP_Command(hci_handle, data, nbytes, control_scid[0], control_scid[1]); }; diff --git a/PS4Parser.h b/PS4Parser.h index 4c1d9d4b..cedbc0b4 100644 --- a/PS4Parser.h +++ b/PS4Parser.h @@ -74,14 +74,10 @@ union PS4Buttons { struct touchpadXY { uint8_t dummy; // I can not figure out what this data is for, it seems to change randomly, maybe a timestamp? struct { - struct { - uint8_t counter : 7; // Increments every time a finger is touching the touchpad - uint8_t touching : 1; // The top bit is cleared if the finger is touching the touchpad - }; - struct { - uint16_t x : 12; - uint16_t y : 12; - }; + uint8_t counter : 7; // Increments every time a finger is touching the touchpad + uint8_t touching : 1; // The top bit is cleared if the finger is touching the touchpad + uint16_t x : 12; + uint16_t y : 12; } finger[2]; // 0 = first finger, 1 = second finger }; diff --git a/PS4USB.h b/PS4USB.h index 1ea2a421..fcb514c3 100644 --- a/PS4USB.h +++ b/PS4USB.h @@ -21,8 +21,8 @@ #include "hiduniversal.h" #include "PS4Parser.h" -#define PS4_VID 0x054C // Sony Corporation -#define PS4_PID 0x05C4 // PS4 Controller +#define PS4_VID 0x054C // Sony Corporation +#define PS4_PID 0x05C4 // PS4 Controller /** * This class implements support for the PS4 controller via USB.