diff --git a/hidapi/hid.cpp b/hidapi/hid.cpp index a7139ff..792be75 100644 --- a/hidapi/hid.cpp +++ b/hidapi/hid.cpp @@ -426,6 +426,15 @@ int HID_API_EXPORT hid_read(int device, unsigned char *data, size_t length) // we are in non-blocking mode. Get the number of bytes read. The actual // data has been copied to the data[] array which was passed to ReadFile(). res = GetOverlappedResult(dev->device_handle, &ol, &bytes_read, TRUE/*wait*/); + + if (bytes_read > 0 && data[0] == 0x0) { + /* If report numbers aren't being used, but Windows sticks a report + number (0x0) on the beginning of the report anyway. To make this + work like the other platforms, and to make it work more like the + HID spec, we'll skip over this byte. */ + bytes_read--; + memmove(data, data+1, bytes_read); + } end_of_function: if (!res) { diff --git a/hidapi/objfre_wxp_x86/i386/hidapi.dll b/hidapi/objfre_wxp_x86/i386/hidapi.dll index eef8adb..8b1e946 100644 Binary files a/hidapi/objfre_wxp_x86/i386/hidapi.dll and b/hidapi/objfre_wxp_x86/i386/hidapi.dll differ diff --git a/hidapi/objfre_wxp_x86/i386/hidapi.lib b/hidapi/objfre_wxp_x86/i386/hidapi.lib index 7473cda..022c796 100644 Binary files a/hidapi/objfre_wxp_x86/i386/hidapi.lib and b/hidapi/objfre_wxp_x86/i386/hidapi.lib differ diff --git a/hidtest/Debug/hidtest.exe b/hidtest/Debug/hidtest.exe index 8b8e42b..6e7be14 100644 Binary files a/hidtest/Debug/hidtest.exe and b/hidtest/Debug/hidtest.exe differ diff --git a/hidtest/Release/hidtest.exe b/hidtest/Release/hidtest.exe index e3d2dd8..0a19a67 100644 Binary files a/hidtest/Release/hidtest.exe and b/hidtest/Release/hidtest.exe differ diff --git a/hidtest/hidtest.cpp b/hidtest/hidtest.cpp index 1849df5..fbb2072 100644 --- a/hidtest/hidtest.cpp +++ b/hidtest/hidtest.cpp @@ -19,7 +19,7 @@ #include "hidapi.h" // Headers needed for sleeping. -#ifdef WIN32 +#ifdef _WIN32 #include #else #include @@ -28,7 +28,7 @@ int main(int argc, char* argv[]) { int res; - unsigned char buf[65]; + unsigned char buf[256]; #define MAX_STR 255 wchar_t wstr[MAX_STR]; int handle; @@ -121,17 +121,18 @@ int main(int argc, char* argv[]) res = hid_get_feature_report(handle, buf, sizeof(buf)); if (res < 0) { printf("Unable to get a feature report.\n"); + printf("%s", hid_error(handle)); + } + else { + // Print out the returned buffer. + printf("Feature Report\n "); + for (i = 0; i < 17; i++) + printf("%02hhx ", buf[i]); + printf("\n"); } - // Print out the returned buffer. - printf("Feature Report\n "); - for (i = 0; i < 17; i++) - printf("%02hhx ", buf[i]); - printf("\n"); - memset(buf,0,sizeof(buf)); - // Toggle LED (cmd 0x80). The first byte is the report number (0x1). buf[0] = 0x1; buf[1] = 0x80;