Skip to content

Commit

Permalink
Read bcdUSB from ioregistry
Browse files Browse the repository at this point in the history
Seems like there is a bcdUSB property from SDK 10.11 and on.

Signed-off-by: Tormod Volden <[email protected]>
  • Loading branch information
tormodvolden committed Sep 14, 2024
1 parent 7f188ac commit b9be7d0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions libusb/os/darwin_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1105,16 +1105,18 @@ static enum libusb_error darwin_cache_device_descriptor (struct libusb_context *
(*device)->GetDeviceProduct (device, &idProduct);
(*device)->GetDeviceVendor (device, &idVendor);

/* Try synthesize a device descriptor from OS cached values */
/* Try synthesize a device descriptor from OS cached values.
If anything fails, fall back to requesting descriptor from device. */
do {
IOUSBDeviceDescriptor *desc = &dev->dev_descriptor;
UInt16 bcdDevice;
UInt16 bcdDevice, bcdUSB;

/* If anything fails, fall back to requesting descriptor from device */
if (!get_ioregistry_value_number (dev->service, CFSTR("bMaxPacketSize0"), kCFNumberSInt8Type, &desc->bMaxPacketSize0))
if (!get_ioregistry_value_number (dev->service, CFSTR("bcdUSB"), kCFNumberSInt16Type, &bcdUSB))
break;
desc->bcdUSB = libusb_cpu_to_le16(bcdUSB); // TODO: verify on BE

desc->bcdUSB = libusb_cpu_to_le16(0x0200); // FIXME get from somewhere
if (!get_ioregistry_value_number (dev->service, CFSTR("bMaxPacketSize0"), kCFNumberSInt8Type, &desc->bMaxPacketSize0))
break;

desc->bDeviceClass = bDeviceClass;
(*device)->GetDeviceSubClass (device, &desc->bDeviceSubClass);
Expand Down

0 comments on commit b9be7d0

Please sign in to comment.