Merge branch 'master' of github.com:signal11/hidapi

This commit is contained in:
Alan Ott
2010-07-22 19:37:22 -04:00
6 changed files with 19 additions and 9 deletions
+9
View File
@@ -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) {
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+10 -9
View File
@@ -19,7 +19,7 @@
#include "hidapi.h"
// Headers needed for sleeping.
#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
@@ -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;