From 382b7deaadd7e2f1d08c9e921e460bb3abf130b2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Trygve=20Laugst=C3=B8l?= Date: Tue, 19 Jul 2011 23:20:40 +0200 Subject: [PATCH] Darwin: Provide libusb_get_device_speed() data References #45. --- libusb/os/darwin_usb.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c index dfad470..298f242 100644 --- a/libusb/os/darwin_usb.c +++ b/libusb/os/darwin_usb.c @@ -678,6 +678,7 @@ static int process_new_device (struct libusb_context *ctx, usb_device_t **device struct libusb_device *dev; struct discovered_devs *discdevs; UInt16 address; + UInt8 devSpeed; int ret = 0, need_unref = 0; do { @@ -710,6 +711,16 @@ static int process_new_device (struct libusb_context *ctx, usb_device_t **device dev->bus_number = locationID >> 24; dev->device_address = address; + (*device)->GetDeviceSpeed (device, &devSpeed); + + switch (devSpeed) { + case kUSBDeviceSpeedLow: dev->speed = LIBUSB_SPEED_LOW; break; + case kUSBDeviceSpeedFull: dev->speed = LIBUSB_SPEED_FULL; break; + case kUSBDeviceSpeedHigh: dev->speed = LIBUSB_SPEED_HIGH; break; + default: + usbi_warn (ctx, "Got unknown device speed %d", devSpeed); + } + /* save our location, we'll need this later */ priv->location = locationID; snprintf(priv->sys_path, 20, "%03i-%04x-%04x-%02x-%02x", address, priv->dev_descriptor.idVendor, priv->dev_descriptor.idProduct, -- 2.7.4