From 60412cb33f733b3b0c8e4e931185c818f7d04420 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Thu, 18 Feb 2010 00:22:50 +0000 Subject: xusb improvements (feature reports) --- examples/xusb.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/xusb.c b/examples/xusb.c index 15dc126..6ebaa17 100644 --- a/examples/xusb.c +++ b/examples/xusb.c @@ -497,6 +497,17 @@ int test_hid(libusb_device_handle *handle, uint8_t endpoint_in) return -1; } + printf("\nReading Feature Report...\n"); + r = libusb_control_transfer(handle, LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE, + HID_GET_REPORT, (HID_REPORT_TYPE_FEATURE<<8)|0, 0, input_report, (uint16_t)size, 5000); + if (r >= 0) { + display_buffer_hex(input_report, size); + } else if (r == LIBUSB_ERROR_NOT_FOUND) { + printf(" No Feature Report available for this device\n"); + } else { + printf(" Error: %s\n", libusb_strerror(r)); + } + printf("\nReading Input Report...\n"); r = libusb_control_transfer(handle, LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE, HID_GET_REPORT, (HID_REPORT_TYPE_INPUT<<8)|0x00, 0, input_report, (uint16_t)size, 5000); @@ -508,7 +519,7 @@ int test_hid(libusb_device_handle *handle, uint8_t endpoint_in) printf(" Timeout! Please make sure you act on the device within the 5 seconds allocated...\n"); break; default: - printf(" Error: %d\n", r); + printf(" Error: %s\n", libusb_strerror(r)); break; } } @@ -614,10 +625,10 @@ int test_device(uint16_t vid, uint16_t pid) } #endif + printf("\nReading string descriptors:\n"); r = libusb_get_string_descriptor(handle, 0, 0, string, 128); if (r > 0) { nb_strings = string[0]; - printf("\nReading string descriptors:\n"); for (i=1; i= 0) { printf(" String (%d/%d): \"%s\"\n", i, nb_strings-1, string); -- cgit v1.2.1