30 int main(
int argc,
char* argv[])
35 unsigned char buf[256];
42 UNREFERENCED_PARAMETER(argc);
43 UNREFERENCED_PARAMETER(argv);
55 printf(
"Device Found\n type: %04hx %04hx\n path: %s\n serial_number: %ls", cur_dev->
vendor_id, cur_dev->
product_id,
63 cur_dev = cur_dev->
next;
68 memset(buf, 0x00,
sizeof(buf));
76 handle =
hid_open(0x4d8, 0x3f,
nullptr);
79 printf(
"unable to open device\n");
87 printf(
"Unable to read manufacturer string\n");
88 printf(
"Manufacturer String: %ls\n", wstr);
94 printf(
"Unable to read product string\n");
95 printf(
"Product String: %ls\n", wstr);
101 printf(
"Unable to read serial number string\n");
102 printf(
"Serial Number String: (%d) %ls", wstr[0], wstr);
109 printf(
"Unable to read indexed string 1\n");
110 printf(
"Indexed String 1: %ls\n", wstr);
128 printf(
"Unable to send a feature report.\n");
131 memset(buf, 0,
sizeof(buf));
138 printf(
"Unable to get a feature report.\n");
144 printf(
"Feature Report\n ");
145 for (i = 0; i < res; i++)
146 printf(
"%02hhx ", buf[i]);
150 memset(buf, 0,
sizeof(buf));
158 printf(
"Unable to write()\n");
159 printf(
"Error: %ls\n",
hid_error(handle));
168 printf(
"Unable to write() (2)\n");
176 res =
hid_read(handle, buf,
sizeof(buf));
178 printf(
"waiting...\n");
180 printf(
"Unable to read()\n");
188 printf(
"Data read:\n ");
190 for (i = 0; i < res; i++)
191 printf(
"%02hhx ", buf[i]);
int HID_API_EXPORT hid_read(hid_device *dev, unsigned char *data, size_t length)
Read an Input report from a HID device.
hid_device * hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number)
Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally a serial number.
int HID_API_EXPORT hid_init(void)
Initialize the HIDAPI library.
void HID_API_EXPORT hid_free_enumeration(struct hid_device_info *devs)
Free an enumeration Linked List.
int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *dev, int string_index, wchar_t *string, size_t maxlen)
Get a string from a HID device, based on its string index.
int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t length)
Write an Output report to a HID device.
int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *dev, wchar_t *string, size_t maxlen)
Get The Serial Number String from a HID device.
int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length)
Get a feature report from a HID device.
int HID_API_EXPORT_CALL hid_get_product_string(hid_device *dev, wchar_t *string, size_t maxlen)
Get The Product String from a HID device.
int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *dev, wchar_t *string, size_t maxlen)
Get The Manufacturer String from a HID device.
void HID_API_EXPORT hid_close(hid_device *dev)
Close a HID device.
int HID_API_EXPORT hid_send_feature_report(hid_device *dev, const unsigned char *data, size_t length)
Send a Feature report to the device.
HID_API_EXPORT const wchar_t *HID_API_CALL hid_error(hid_device *dev)
Get a string describing the last error which occurred.
int HID_API_EXPORT hid_set_nonblocking(hid_device *dev, int nonblock)
Set the device handle to be non-blocking.
int HID_API_EXPORT hid_exit(void)
Finalize the HIDAPI library.
struct hid_device_info HID_API_EXPORT * hid_enumerate(unsigned short vendor_id, unsigned short product_id)
Enumerate the HID Devices.
int main(int argc, char *argv[])
unsigned short product_id
struct hid_device_info * next
wchar_t * manufacturer_string
unsigned short release_number