From 752d9a70ba56741cbc0013f254f3219376713684 Mon Sep 17 00:00:00 2001 From: Kristian Lauszus Date: Wed, 8 Aug 2012 21:07:58 +0200 Subject: [PATCH] Now works with hubs --- PS3USB.cpp | 12 ++++++------ RFCOMM.cpp | 2 +- XBOXUSB.cpp | 14 +++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/PS3USB.cpp b/PS3USB.cpp index c6a58845..91ff9574 100644 --- a/PS3USB.cpp +++ b/PS3USB.cpp @@ -109,18 +109,18 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) { // Get device descriptor rcode = pUsb->getDevDescr(0, 0, sizeof(USB_DEVICE_DESCRIPTOR), (uint8_t*)buf);// Get device descriptor - addr, ep, nbytes, data - VID = ((USB_DEVICE_DESCRIPTOR*)buf)->idVendor; - PID = ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct; - - if(VID != PS3_VID || (PID != PS3_PID && PID != PS3NAVIGATION_PID && PID != PS3MOVE_PID)) - goto FailUnknownDevice; - // Restore p->epinfo p->epinfo = oldep_ptr; if(rcode) goto FailGetDevDescr; + VID = ((USB_DEVICE_DESCRIPTOR*)buf)->idVendor; + PID = ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct; + + if(VID != PS3_VID || (PID != PS3_PID && PID != PS3NAVIGATION_PID && PID != PS3MOVE_PID)) + goto FailUnknownDevice; + // Allocate new address according to device class bAddress = addrPool.AllocAddress(parent, false, port); diff --git a/RFCOMM.cpp b/RFCOMM.cpp index 30ecfffd..06bf723f 100644 --- a/RFCOMM.cpp +++ b/RFCOMM.cpp @@ -242,7 +242,7 @@ FailUnknownDevice: #ifdef DEBUG Notify(PSTR("\r\nUnknown Device Connected:")); #endif - pUsb->setAddr(bAddress, 0, 0); + pUsb->setAddr(bAddress, 0, 0); // Reset address rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; goto Fail; Fail: diff --git a/XBOXUSB.cpp b/XBOXUSB.cpp index fd5b824d..76e0b3b3 100644 --- a/XBOXUSB.cpp +++ b/XBOXUSB.cpp @@ -83,6 +83,12 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) { // Get device descriptor rcode = pUsb->getDevDescr(0, 0, sizeof(USB_DEVICE_DESCRIPTOR), (uint8_t*)buf);// Get device descriptor - addr, ep, nbytes, data + // Restore p->epinfo + p->epinfo = oldep_ptr; + + if(rcode) + goto FailGetDevDescr; + VID = ((USB_DEVICE_DESCRIPTOR*)buf)->idVendor; PID = ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct; @@ -99,13 +105,7 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) { Notify(PSTR("\r\nThis library only supports Xbox 360 controllers via USB")); #endif goto FailUnknownDevice; - } - - // Restore p->epinfo - p->epinfo = oldep_ptr; - - if(rcode) - goto FailGetDevDescr; + } // Allocate new address according to device class bAddress = addrPool.AllocAddress(parent, false, port);