diff options
author | Pete Batard <pete@akeo.ie> | 2011-11-02 11:25:42 +0000 |
---|---|---|
committer | Pete Batard <pete@akeo.ie> | 2011-11-02 11:25:42 +0000 |
commit | f63e7bbf6b177c27d04af65717381428ed859681 (patch) | |
tree | 41a63415a1234e65dc174804d8af14cce79eebe6 | |
parent | 54244d1e396db533c057b21c44fcdeb3581a1a4e (diff) | |
download | libusb-f63e7bbf6b177c27d04af65717381428ed859681.tar.gz |
[xusb] added recipient for WCID device control request
* note that WinUSB prevents proper use of LIBUSB_RECIPIENT_INTERFACE
for Extended Properties: http://www.lvr.com/forum/index.php?topic=331
-rw-r--r-- | examples/xusb.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/examples/xusb.c b/examples/xusb.c index 1a42cab..26ce017 100644 --- a/examples/xusb.c +++ b/examples/xusb.c @@ -536,11 +536,17 @@ void read_ms_winsub_feature_descriptors(libusb_device_handle *handle, uint8_t bR void* le_type_punning_IS_fine; struct { char* desc; + uint8_t recipient; uint16_t index; uint16_t header_size; } os_fd[2] = { - {"Extended Compat ID", 0x0004, 0x10}, - {"Extended Properties", 0x0005, 0x0A} + {"Extended Compat ID", LIBUSB_RECIPIENT_DEVICE, 0x0004, 0x10}, + {"Extended Properties", LIBUSB_RECIPIENT_DEVICE, 0x0005, 0x0A} + // NB: LIBUSB_RECIPIENT_INTERFACE should be used for the Extended Properties. + // However, for Interface requests, the WinUSB DLL forces the low byte of wIndex + // to the interface number, regardless of what you set it to, so we have to + // fallback to Device and hope the firmware answers both equally. + // See http://www.lvr.com/forum/index.php?topic=331 }; if (iface_number < 0) return; @@ -549,7 +555,7 @@ void read_ms_winsub_feature_descriptors(libusb_device_handle *handle, uint8_t bR printf("\nReading %s OS Feature Descriptor (wIndex = 0x%04d):\n", os_fd[i].desc, os_fd[i].index); // Read the header part - r = libusb_control_transfer(handle, LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_VENDOR, + r = libusb_control_transfer(handle, LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_VENDOR|os_fd[i].recipient, bRequest, ((iface_number)<< 8)|0x00, os_fd[i].index, os_desc, os_fd[i].header_size, 1000); if (r < os_fd[i].header_size) { perr(" Failed: %s", (r<0)?libusb_strerror(r):"header size is too small"); @@ -562,7 +568,7 @@ void read_ms_winsub_feature_descriptors(libusb_device_handle *handle, uint8_t bR } // Read the full feature descriptor - r = libusb_control_transfer(handle, LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_VENDOR, + r = libusb_control_transfer(handle, LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_VENDOR|os_fd[i].recipient, bRequest, ((iface_number)<< 8)|0x00, os_fd[i].index, os_desc, (uint16_t)length, 1000); if (r < 0) { perr(" Failed: %s", libusb_strerror(r)); |