summaryrefslogtreecommitdiff
path: root/libusb
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2010-01-23 23:28:55 +0000
committerPete Batard <pbatard@gmail.com>2010-01-23 23:28:55 +0000
commit628bd43bc24319f82a6ca63265b55adce438c9b5 (patch)
treea45f752fdc0d9b3cc034bc437dbcc7dcf20ef819 /libusb
parent6b34ff4ed72e3c52b4c927946b4fb0a233c24044 (diff)
downloadlibusb-628bd43bc24319f82a6ca63265b55adce438c9b5.tar.gz
r105: added MS Sidewinder HID test in xusb.c + minor changes/improvements
Diffstat (limited to 'libusb')
-rw-r--r--libusb/os/windows_usb.c12
-rw-r--r--libusb/os/windows_usb.h2
2 files changed, 9 insertions, 5 deletions
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 3c8b7f6..9f38fbc 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -2774,14 +2774,16 @@ static int _hid_get_report(struct hid_device_priv* dev, HANDLE hid_handle, int i
*size += 1;
// Use ReadFile instead of HidD_GetInputReport for async I/O
+ // NB: HidD_GetInputReport returns the last Input Report read whereas ReadFile
+ // waits for input to be generated => in case your HID device requires human
+ // action to generate a report, it may wait indefinitely
+ // TODO: give users a choice?
if (!ReadFile(hid_handle, buf, *size, NULL, overlapped)) {
- if(GetLastError() != ERROR_IO_PENDING) {
- usbi_dbg("READFILE FAILED");
+ if (GetLastError() != ERROR_IO_PENDING) {
+ usbi_dbg("Failed to Read HID Input Report: %s", windows_error_str(0));
return LIBUSB_ERROR_IO;
}
- usbi_dbg("IO_PENDING");
} else {
- usbi_dbg("IO_SYNC");
return LIBUSB_COMPLETED;
}
@@ -2803,6 +2805,7 @@ static int _hid_set_report(struct hid_device_priv* dev, HANDLE hid_handle, int i
// Une WriteFile instead of HidD_SetOutputReport for async I/O
if (!WriteFile(hid_handle, buf, *size, NULL, overlapped)) {
if (GetLastError() != ERROR_IO_PENDING) {
+ usbi_dbg("Failed to Write HID Output Report: %s", windows_error_str(0));
return LIBUSB_ERROR_IO;
}
} else {
@@ -2936,6 +2939,7 @@ static int hid_open(struct libusb_device_handle *dev_handle)
&& (priv->usb_interface[i].apib->id == USB_API_HID) ) {
hid_handle = CreateFileA(priv->usb_interface[i].path, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
+ usbi_dbg("hid_handle = %p", hid_handle);
/*
* http://www.lvr.com/hidfaq.htm: Why do I receive "Access denied" when attempting to access my HID?
* "Windows 2000 and later have exclusive read/write access to HIDs that are configured as a system
diff --git a/libusb/os/windows_usb.h b/libusb/os/windows_usb.h
index 58fc9b2..582605f 100644
--- a/libusb/os/windows_usb.h
+++ b/libusb/os/windows_usb.h
@@ -83,7 +83,7 @@ inline void upperize(char* str) {
// Handle code for HID interface that have been claimed ("dibs")
#define INTERFACE_CLAIMED ((HANDLE)0xD1B5)
// Additional return code for HID operations that completed synchronously
-#define LIBUSB_COMPLETED (LIBUSB_SUCCESS + 1)
+#define LIBUSB_COMPLETED (LIBUSB_SUCCESS + 1)
#define wchar_to_utf8_ms(wstr, str, strlen) WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, strlen, NULL, NULL)