From 8e6ab3f3ae6fc86a18c78c010b6d9b351b488a4d Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Sat, 20 Jul 2013 22:07:03 +0200 Subject: [PATCH] Clear buttonState properly Caused an issue on some dongles --- PS3BT.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/PS3BT.cpp b/PS3BT.cpp index 34afd011..6f9a4d23 100644 --- a/PS3BT.cpp +++ b/PS3BT.cpp @@ -459,9 +459,6 @@ void PS3BT::L2CAP_task() { if (remote_name[0] == 'M') { // First letter in Motion Controller ('M') for (uint8_t i = 0; i < BULK_MAXPKTSIZE; i++) // Reset l2cap in buffer as it sometimes read it as a button has been pressed l2capinbuf[i] = 0; - ButtonState = 0; - OldButtonState = 0; - l2cap_state = L2CAP_HID_PS3_LED; } else l2cap_state = L2CAP_HID_ENABLE_SIXAXIS; @@ -502,12 +499,9 @@ void PS3BT::Run() { if (millis() - timer > 1000) { // loop 1 second before sending the command for (uint8_t i = 0; i < BULK_MAXPKTSIZE; i++) // Reset l2cap in buffer as it sometimes read it as a button has been pressed l2capinbuf[i] = 0; - ButtonState = 0; - OldButtonState = 0; - - enable_sixaxis(); for (uint8_t i = 15; i < 19; i++) l2capinbuf[i] = 0x7F; // Set the analog joystick values to center position + enable_sixaxis(); l2cap_state = L2CAP_HID_PS3_LED; timer = millis(); } @@ -532,6 +526,10 @@ void PS3BT::Run() { #endif PS3MoveConnected = true; } + ButtonState = 0; // Clear all values + OldButtonState = 0; + ButtonClickState = 0; + onInit(); // Turn on the LED on the controller l2cap_state = L2CAP_DONE; }