summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2010-02-02 19:42:27 +0000
committerPete Batard <pbatard@gmail.com>2010-02-02 19:42:27 +0000
commit3bb808f3980e8df4fa85b5bb1b0b3f9e0de25adb (patch)
tree57b029ffe912ac615db57fb3b32599f71bb7d3be /examples
parentc8b4ec4c6ddd78d1c56874dfaae8e53d3e728321 (diff)
downloadlibusb-3bb808f3980e8df4fa85b5bb1b0b3f9e0de25adb.tar.gz
r132: harmonized compatibility layer function names (_libusb prefix always, rather than _for_poll suffix)r132
additional minor xusb improvements.
Diffstat (limited to 'examples')
-rw-r--r--examples/xusb.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/examples/xusb.c b/examples/xusb.c
index 9925f07..fbe8f07 100644
--- a/examples/xusb.c
+++ b/examples/xusb.c
@@ -136,6 +136,19 @@ enum test_type {
} test_mode;
uint16_t VID, PID;
+void display_buffer_hex(unsigned char *buffer, unsigned size)
+{
+ unsigned i;
+
+ for (i=0; i<size; i++) {
+ if (!(i%0x10))
+ printf("\n ");
+ printf(" %02X", buffer[i]);
+ }
+ printf("\n");
+}
+
+
// The XBOX Controller is really a HID device that got its HID Report Descriptors
// removed by Microsoft.
// Input/Output reports described at http://euc.jp/periphs/xbox-controller.ja.html
@@ -261,7 +274,7 @@ int get_mass_storage_status(libusb_device_handle *handle, uint8_t endpoint, uint
expected_tag, csw.dCSWTag);
return -1;
}
- // Strictly speaking, we should also should check dCSWSignature for validity, which we don't.
+ // For this test, we ignore the dCSWSignature check for validity...
printf(" Mass Storage Status: %02X (%s)\n", csw.bCSWStatus, csw.bCSWStatus?"FAILED":"Success");
if (csw.dCSWTag != expected_tag)
return -1;
@@ -395,12 +408,7 @@ int test_mass_storage(libusb_device_handle *handle, uint8_t endpoint_in, uint8_t
if (get_mass_storage_status(handle, endpoint_in, expected_tag) == -2) {
get_sense(handle, endpoint_in, endpoint_out);
} else {
- for (i=0; i<size; i++) {
- if (!(i%0x10))
- printf("\n ");
- printf(" %02X", data[i]);
- }
- printf("\n");
+ display_buffer_hex(data, size);
}
return 0;
@@ -434,6 +442,8 @@ int display_sidewinder_status(libusb_device_handle *handle)
{
int r;
uint8_t input_report[6];
+ unsigned char buffer[8];
+ int size;
printf("\nReading SideWinder 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, 6, 5000);
@@ -449,6 +459,14 @@ int display_sidewinder_status(libusb_device_handle *handle)
break;
}
}
+ // Attempt a bulk read from endpoint 0 (this should just return a raw input report)
+ printf("\nTesting bulk read (raw input report)...\n");
+ r = libusb_bulk_transfer(handle, 0x81, buffer, 8, &size, 5000);
+ if (r >= 0) {
+ display_buffer_hex(buffer, size);
+ } else {
+ printf(" %s\n", libusb_strerror(r));
+ }
return 0;
}