diff --git a/PS3BT.cpp b/PS3BT.cpp index 78712b6b..e47db9fe 100644 --- a/PS3BT.cpp +++ b/PS3BT.cpp @@ -464,25 +464,25 @@ int32_t PS3BT::getSensor(Sensor a) return 0; if (a == aX || a == aY || a == aZ || a == gZ) return ((l2capinbuf[(uint16_t)a] << 8) | l2capinbuf[(uint16_t)a + 1]); - else if (a == mXmove || a == mYmove || a == mZmove) + else if (a == mXmove || a == mYmove || a == mZmove) // These are all 12-bits long { // Might not be correct, haven't tested it yet - if (a == mXmove) + /*if (a == mXmove) return ((l2capinbuf[(uint16_t)a + 1] << 0x04) | (l2capinbuf[(uint16_t)a] << 0x0C)); - //return (((unsigned char)l2capinbuf[(unsigned int)a + 1]) | (((unsigned char)l2capinbuf[(unsigned int)a] & 0x0F)) << 8); else if (a == mYmove) return ((l2capinbuf[(uint16_t)a + 1] & 0xF0) | (l2capinbuf[(uint16_t)a] << 0x08)); - //return (((unsigned char)l2capinbuf[(unsigned int)a + 1]) | (((unsigned char)l2capinbuf[(unsigned int)a] & 0x0F)) << 8); else if (a == mZmove) - return ((l2capinbuf[(uint16_t)a + 1] << 0x0F) | (l2capinbuf[(uint16_t)a] << 0x0C)); - //return ((((unsigned char)l2capinbuf[(unsigned int)a + 1] & 0xF0) >> 4) | ((unsigned char)l2capinbuf[(unsigned int)a] << 4)); - else - return 0; + return ((l2capinbuf[(uint16_t)a + 1] << 0x0F) | (l2capinbuf[(uint16_t)a] << 0x0C)); + */ + if (a == mXmove || a == mYmove) + return (((l2capinbuf[(uint16_t)a] & 0x0F) << 8) | (l2capinbuf[(uint16_t)a + 1])); + else // mZmove + return ((l2capinbuf[(uint16_t)a] << 4) | (l2capinbuf[(uint16_t)a + 1] >> 4)); } - else if (a == tempMove) - return (((l2capinbuf[(uint16_t)a + 1] & 0xF0) >> 4) | (l2capinbuf[(uint16_t)a] << 4)); + else if (a == tempMove) // The tempearature is 12 bits long too + return ((l2capinbuf[(uint16_t)a] << 4) | ((l2capinbuf[(uint16_t)a + 1] & 0xF0) >> 4)); else // aXmove, aYmove, aZmove, gXmove, gYmove and gZmove - return ((l2capinbuf[(uint16_t)a + 1] << 8) | l2capinbuf[(uint16_t)a]); + return (l2capinbuf[(uint16_t)a] | (l2capinbuf[(uint16_t)a + 1] << 8)); } double PS3BT::getAngle(Angle a) { double accXval; @@ -946,14 +946,14 @@ void PS3BT::ACL_event_task() Notify(PSTR(" Identifier: ")); PrintHex(l2capinbuf[9]); */ - if ((l2capinbuf[13] | l2capinbuf[12]) == L2CAP_PSM_HID_CTRL) + if ((l2capinbuf[12] | (l2capinbuf[13] << 8)) == L2CAP_PSM_HID_CTRL) { identifier = l2capinbuf[9]; control_scid[0] = l2capinbuf[14]; control_scid[1] = l2capinbuf[15]; l2cap_event_flag |= L2CAP_EV_CONTROL_CONNECTION_REQUEST; } - else if ((l2capinbuf[13] | l2capinbuf[12]) == L2CAP_PSM_HID_INTR) + else if ((l2capinbuf[12] | (l2capinbuf[13] << 8)) == L2CAP_PSM_HID_INTR) { identifier = l2capinbuf[9]; interrupt_scid[0] = l2capinbuf[14]; @@ -1000,7 +1000,7 @@ void PS3BT::ACL_event_task() if (l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) { #ifdef DEBUG - Notify(PSTR("\r\nDisconnected Request: Disconnected Control")); + Notify(PSTR("\r\nDisconnect Request: Control Channel")); #endif identifier = l2capinbuf[9]; l2cap_disconnection_response(identifier,control_dcid,control_scid); @@ -1008,7 +1008,7 @@ void PS3BT::ACL_event_task() else if (l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) { #ifdef DEBUG - Notify(PSTR("\r\nDisconnected Request: Disconnected Interrupt")); + Notify(PSTR("\r\nDisconnect Request: Interrupt Channel")); #endif identifier = l2capinbuf[9]; l2cap_disconnection_response(identifier,interrupt_dcid,interrupt_scid); @@ -1018,13 +1018,13 @@ void PS3BT::ACL_event_task() { if (l2capinbuf[12] == control_scid[0] && l2capinbuf[13] == control_scid[1]) { - //Serial.print("\r\nDisconnected Response: Disconnected Control"); + //Serial.print("\r\nDisconnect Response: Control Channel"); identifier = l2capinbuf[9]; l2cap_event_flag |= L2CAP_EV_CONTROL_DISCONNECT_RESPONSE; } else if (l2capinbuf[12] == interrupt_scid[0] && l2capinbuf[13] == interrupt_scid[1]) { - //Serial.print("\r\nDisconnected Response: Disconnected Interrupt"); + //Serial.print("\r\nDisconnect Response: Interrupt Channel"); identifier = l2capinbuf[9]; l2cap_event_flag |= L2CAP_EV_INTERRUPT_DISCONNECT_RESPONSE; } diff --git a/PS3BT.h b/PS3BT.h index 2e0e4fad..db67f9da 100644 --- a/PS3BT.h +++ b/PS3BT.h @@ -413,7 +413,7 @@ private: uint32_t timerHID;// timer used see if there has to be a delay before a new HID command uint32_t timerBulbRumble;// used to continuously set PS3 Move controller Bulb and rumble values - uint8_t my_bdaddr[6]; //Change to your dongles Bluetooth address in PS3BT.cpp + uint8_t my_bdaddr[6]; // Change to your dongles Bluetooth address in the constructor uint8_t hcibuf[BULK_MAXPKTSIZE];//General purpose buffer for hci data uint8_t l2capinbuf[BULK_MAXPKTSIZE];//General purpose buffer for l2cap in data uint8_t l2capoutbuf[BULK_MAXPKTSIZE];//General purpose buffer for l2cap out data diff --git a/PS3USB.h b/PS3USB.h index 21550aea..6e34dba8 100644 --- a/PS3USB.h +++ b/PS3USB.h @@ -226,7 +226,7 @@ private: uint32_t ButtonState; uint32_t OldButtonState; - uint8_t my_bdaddr[6]; // Change to your dongles Bluetooth address in PS3BT.cpp + uint8_t my_bdaddr[6]; // Change to your dongles Bluetooth address in the constructor uint8_t readBuf[EP_MAXPKTSIZE]; // General purpose buffer for input data uint8_t writeBuf[EP_MAXPKTSIZE]; // General purpose buffer for output data