summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorPete Batard <pete@akeo.ie>2013-09-29 21:39:26 +0100
committerPete Batard <pete@akeo.ie>2013-09-29 21:39:26 +0100
commit16692c825e6f55548b28738dcf2f9b6157b9daf1 (patch)
tree636677ad026c5e3ff0c6968de92c7000e2e1758f /examples
parent28d5514e61ca7f7459c200b187b8cc3ebeda9274 (diff)
downloadlibusb-16692c825e6f55548b28738dcf2f9b6157b9daf1.tar.gz
examples: add an option to force a device request for WCID descriptors
* Add option 'w' to force the use of a Device Request rather than an Interface Request when querying the WCID OS Extended Properties descriptor. * This is due to a WinUSB limitation where all Interface Requests have the wIndex set to the interface number. * This assumes that the WCID firmware answers both Device and Interface requests equally.
Diffstat (limited to 'examples')
-rw-r--r--examples/xusb.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/examples/xusb.c b/examples/xusb.c
index 829ce41..56386df 100644
--- a/examples/xusb.c
+++ b/examples/xusb.c
@@ -50,6 +50,7 @@
// Global variables
static bool binary_dump = false;
static bool extra_info = false;
+static bool force_device_request = false; // For WCID descriptor queries
static const char* binary_name = NULL;
static int perr(char const *format, ...)
@@ -713,6 +714,11 @@ static void read_ms_winsub_feature_descriptors(libusb_device_handle *handle, uin
};
if (iface_number < 0) return;
+ // WinUSB has a limitation that forces wIndex to the interface number when issuing
+ // an Interface Request. To work around that, we can force a Device Request for
+ // the Extended Properties, assuming the device answers both equally.
+ if (force_device_request)
+ os_fd[1].recipient = LIBUSB_RECIPIENT_DEVICE;
for (i=0; i<2; i++) {
printf("\nReading %s OS Feature Descriptor (wIndex = 0x%04d):\n", os_fd[i].desc, os_fd[i].index);
@@ -991,6 +997,9 @@ int main(int argc, char** argv)
case 'i':
extra_info = true;
break;
+ case 'w':
+ force_device_request = true;
+ break;
case 'b':
if ((j+1 >= argc) || (argv[j+1][0] == '-') || (argv[j+1][0] == '/')) {
printf(" Option -b requires a file name\n");
@@ -1063,7 +1072,7 @@ int main(int argc, char** argv)
}
if ((show_help) || (argc == 1) || (argc > 7)) {
- printf("usage: %s [-h] [-d] [-i] [-k] [-b file] [-l lang] [-j] [-x] [-s] [-p] [vid:pid]\n", argv[0]);
+ printf("usage: %s [-h] [-d] [-i] [-k] [-b file] [-l lang] [-j] [-x] [-s] [-p] [-w] [vid:pid]\n", argv[0]);
printf(" -h : display usage\n");
printf(" -d : enable debug output\n");
printf(" -i : print topology and speed info\n");
@@ -1074,6 +1083,7 @@ int main(int argc, char** argv)
printf(" -s : test Microsoft Sidewinder Precision Pro (HID)\n");
printf(" -x : test Microsoft XBox Controller Type S\n");
printf(" -l lang : language to report errors in (ISO 639-1)\n");
+ printf(" -w : force the use of device requests when querying WCID descriptors\n");
printf("If only the vid:pid is provided, xusb attempts to run the most appropriate test\n");
return 0;
}