From f500cc9b4c639ed90502bb52fe87be1185b9347f Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Sun, 15 Nov 2020 19:02:54 +0100 Subject: [PATCH] Only use simple pairing with the Xbox One S controller, as it did not work with the PS4 --- BTD.cpp | 17 +++++++++++------ BTD.h | 3 +++ BTHID.cpp | 6 ++++-- XBOXONESBT.h | 1 + 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/BTD.cpp b/BTD.cpp index bd2d2587..32efeb86 100644 --- a/BTD.cpp +++ b/BTD.cpp @@ -29,6 +29,7 @@ connectToWii(false), pairWithWii(false), connectToHIDDevice(false), pairWithHIDDevice(false), +useSimplePairing(false), pUsb(p), // Pointer to USB class instance - mandatory bAddress(0), // Device address - mandatory bNumEP(1), // If config descriptor needs to be parsed @@ -658,7 +659,7 @@ void BTD::HCI_event_task() { #endif connectToHIDDevice = true; // Used to indicate to the BTHID service, that it should connect to this device } else { -#ifdef DEBUG_USB_HOST +#ifdef EXTRADEBUG Notify(PSTR("\r\nPairing was successful"), 0x80); #endif } @@ -823,11 +824,12 @@ void BTD::HCI_task() { if(btdName != NULL) { hci_write_local_name(btdName); hci_state = HCI_WRITE_NAME_STATE; - } else { + } else if(useSimplePairing) { hci_read_local_extended_features(0); // "Requests the normal LMP features as returned by Read_Local_Supported_Features" //hci_read_local_extended_features(1); // Read page 1 hci_state = HCI_LOCAL_EXTENDED_FEATURES_STATE; - } + } else + hci_state = HCI_CHECK_DEVICE_SERVICE; } break; @@ -837,9 +839,12 @@ void BTD::HCI_task() { Notify(PSTR("\r\nThe name was set to: "), 0x80); NotifyStr(btdName, 0x80); #endif - hci_read_local_extended_features(0); // "Requests the normal LMP features as returned by Read_Local_Supported_Features" - //hci_read_local_extended_features(1); // Read page 1 - hci_state = HCI_LOCAL_EXTENDED_FEATURES_STATE; + if(useSimplePairing) { + hci_read_local_extended_features(0); // "Requests the normal LMP features as returned by Read_Local_Supported_Features" + //hci_read_local_extended_features(1); // Read page 1 + hci_state = HCI_LOCAL_EXTENDED_FEATURES_STATE; + } else + hci_state = HCI_CHECK_DEVICE_SERVICE; } break; diff --git a/BTD.h b/BTD.h index e0b3a46d..5337dea9 100644 --- a/BTD.h +++ b/BTD.h @@ -530,6 +530,9 @@ public: return pollInterval; }; + /** Used by the drivers to enable simple pairing */ + bool useSimplePairing; + protected: /** Pointer to USB class instance. */ USB *pUsb; diff --git a/BTHID.cpp b/BTHID.cpp index ad2a0ac2..dc5ab207 100644 --- a/BTHID.cpp +++ b/BTHID.cpp @@ -258,8 +258,9 @@ void BTHID::ACLData(uint8_t* l2capinbuf) { #endif } else if(l2capinbuf[6] == sdp_dcid[0] && l2capinbuf[7] == sdp_dcid[1]) { // SDP if(l2capinbuf[8] == SDP_SERVICE_SEARCH_REQUEST) { +#ifdef EXTRADEBUG Notify(PSTR("\r\nSDP_SERVICE_SEARCH_REQUEST"), 0x80); - +#endif // Send response l2capoutbuf[0] = SDP_SERVICE_SEARCH_RESPONSE; l2capoutbuf[1] = l2capinbuf[9];//transactionIDHigh; @@ -278,8 +279,9 @@ void BTHID::ACLData(uint8_t* l2capinbuf) { SDP_Command(l2capoutbuf, 10); } else if(l2capinbuf[8] == SDP_SERVICE_ATTRIBUTE_REQUEST) { +#ifdef EXTRADEBUG Notify(PSTR("\r\nSDP_SERVICE_ATTRIBUTE_REQUEST"), 0x80); - +#endif // Send response l2capoutbuf[0] = SDP_SERVICE_ATTRIBUTE_RESPONSE; l2capoutbuf[1] = l2capinbuf[9];//transactionIDHigh; diff --git a/XBOXONESBT.h b/XBOXONESBT.h index 82b17d24..58395790 100644 --- a/XBOXONESBT.h +++ b/XBOXONESBT.h @@ -35,6 +35,7 @@ public: XBOXONESBT(BTD *p, bool pair = false) : BTHID(p, pair) { XBOXONESParser::Reset(); + pBtd->useSimplePairing = true; // The Xbox One S controller only works via simple pairing }; /**