mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Added getLastMessageTime() - this is useful if you want to detect if the connection is lost with the PS3 controller
Credit: Thomas Frederick
This commit is contained in:
parent
37d59a63b2
commit
983a7d664f
2 changed files with 10 additions and 1 deletions
|
@ -343,6 +343,8 @@ void PS3BT::ACLData(uint8_t* ACLData) {
|
|||
if(PS3Connected || PS3MoveConnected || PS3NavigationConnected) {
|
||||
/* Read Report */
|
||||
if(l2capinbuf[8] == 0xA1) { // HID_THDR_DATA_INPUT
|
||||
lastMessageTime = millis(); // Store the last message time
|
||||
|
||||
if(PS3Connected || PS3NavigationConnected)
|
||||
ButtonState = (uint32_t)(l2capinbuf[11] | ((uint16_t)l2capinbuf[12] << 8) | ((uint32_t)l2capinbuf[13] << 16));
|
||||
else if(PS3MoveConnected)
|
||||
|
|
9
PS3BT.h
9
PS3BT.h
|
@ -179,6 +179,11 @@ public:
|
|||
*/
|
||||
void moveSetRumble(uint8_t rumble);
|
||||
|
||||
/** Used to get the millis() of the last message */
|
||||
uint32_t getLastMessageTime() {
|
||||
return lastMessageTime;
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to call your own function when the controller is successfully initialized.
|
||||
* @param funcOnInit Function to call.
|
||||
|
@ -214,10 +219,12 @@ private:
|
|||
uint8_t remote_name[30]; // First 30 chars of remote name
|
||||
bool activeConnection; // Used to indicate if it's already has established a connection
|
||||
|
||||
/* variables used by high level L2CAP task */
|
||||
/* Variables used by high level L2CAP task */
|
||||
uint8_t l2cap_state;
|
||||
uint32_t l2cap_event_flag; // L2CAP flags of received Bluetooth events
|
||||
|
||||
uint32_t lastMessageTime; // Variable used to store the millis value of the last message.
|
||||
|
||||
unsigned long timer;
|
||||
|
||||
uint32_t ButtonState;
|
||||
|
|
Loading…
Reference in a new issue