mirror of
https://github.com/libusb/libusb
synced 2024-11-21 06:26:10 -07:00
windows: Base HID device descriptor on cached values
Instead of filling in the blanks with hard-coded made-up values that are sometimes correct, use the cached descriptor values retrieved during enumeration, which should be a better fallback. References #1360 Closes #1378 Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
This commit is contained in:
parent
d04fc0e60b
commit
4528752cbe
2 changed files with 12 additions and 10 deletions
|
@ -3513,24 +3513,26 @@ static int _hid_wcslen(WCHAR *str)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _hid_get_device_descriptor(struct hid_device_priv *hid_priv, void *data, size_t *size)
|
static int _hid_get_device_descriptor(struct libusb_device *dev, struct hid_device_priv *hid_priv, void *data, size_t *size)
|
||||||
{
|
{
|
||||||
struct libusb_device_descriptor d;
|
struct libusb_device_descriptor d;
|
||||||
|
|
||||||
|
/* Copy some values from the cached device descriptor
|
||||||
|
* because we cannot get them through HID */
|
||||||
d.bLength = LIBUSB_DT_DEVICE_SIZE;
|
d.bLength = LIBUSB_DT_DEVICE_SIZE;
|
||||||
d.bDescriptorType = LIBUSB_DT_DEVICE;
|
d.bDescriptorType = LIBUSB_DT_DEVICE;
|
||||||
d.bcdUSB = 0x0200; /* 2.00 */
|
d.bcdUSB = dev->device_descriptor.bcdUSB;
|
||||||
d.bDeviceClass = 0;
|
d.bDeviceClass = dev->device_descriptor.bDeviceClass;
|
||||||
d.bDeviceSubClass = 0;
|
d.bDeviceSubClass = dev->device_descriptor.bDeviceSubClass;
|
||||||
d.bDeviceProtocol = 0;
|
d.bDeviceProtocol = dev->device_descriptor.bDeviceProtocol;
|
||||||
d.bMaxPacketSize0 = 64; /* fix this! */
|
d.bMaxPacketSize0 = dev->device_descriptor.bMaxPacketSize0;
|
||||||
d.idVendor = (uint16_t)hid_priv->vid;
|
d.idVendor = (uint16_t)hid_priv->vid;
|
||||||
d.idProduct = (uint16_t)hid_priv->pid;
|
d.idProduct = (uint16_t)hid_priv->pid;
|
||||||
d.bcdDevice = 0x0100;
|
d.bcdDevice = dev->device_descriptor.bcdDevice;
|
||||||
d.iManufacturer = hid_priv->string_index[0];
|
d.iManufacturer = hid_priv->string_index[0];
|
||||||
d.iProduct = hid_priv->string_index[1];
|
d.iProduct = hid_priv->string_index[1];
|
||||||
d.iSerialNumber = hid_priv->string_index[2];
|
d.iSerialNumber = hid_priv->string_index[2];
|
||||||
d.bNumConfigurations = 1;
|
d.bNumConfigurations = dev->device_descriptor.bNumConfigurations;
|
||||||
|
|
||||||
if (*size > LIBUSB_DT_DEVICE_SIZE)
|
if (*size > LIBUSB_DT_DEVICE_SIZE)
|
||||||
*size = LIBUSB_DT_DEVICE_SIZE;
|
*size = LIBUSB_DT_DEVICE_SIZE;
|
||||||
|
@ -3758,7 +3760,7 @@ static int _hid_get_descriptor(struct libusb_device *dev, HANDLE hid_handle, int
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case LIBUSB_DT_DEVICE:
|
case LIBUSB_DT_DEVICE:
|
||||||
usbi_dbg(DEVICE_CTX(dev), "LIBUSB_DT_DEVICE");
|
usbi_dbg(DEVICE_CTX(dev), "LIBUSB_DT_DEVICE");
|
||||||
return _hid_get_device_descriptor(priv->hid, data, size);
|
return _hid_get_device_descriptor(dev, priv->hid, data, size);
|
||||||
case LIBUSB_DT_CONFIG:
|
case LIBUSB_DT_CONFIG:
|
||||||
usbi_dbg(DEVICE_CTX(dev), "LIBUSB_DT_CONFIG");
|
usbi_dbg(DEVICE_CTX(dev), "LIBUSB_DT_CONFIG");
|
||||||
if (!_index)
|
if (!_index)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
#define LIBUSB_NANO 11931
|
#define LIBUSB_NANO 11932
|
||||||
|
|
Loading…
Reference in a new issue