Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ device spec. Writing data (`hid_write`) at random to your HID devices can break

```c
#include <stdio.h> // printf
#include <wchar.h> // wprintf
#include <wchar.h> // wchar_t

#include <hidapi.h>

Expand All @@ -117,22 +117,28 @@ int main(int argc, char* argv[])
// Open the device using the VID, PID,
// and optionally the Serial number.
handle = hid_open(0x4d8, 0x3f, NULL);
if (!handle) {
printf("Unable to open device\n");

hid_exit()
return 1;
}

// Read the Manufacturer String
res = hid_get_manufacturer_string(handle, wstr, MAX_STR);
wprintf(L"Manufacturer String: %s\n", wstr);
printf("Manufacturer String: %ls\n", wstr);

// Read the Product String
res = hid_get_product_string(handle, wstr, MAX_STR);
wprintf(L"Product String: %s\n", wstr);
printf("Product String: %ls\n", wstr);

// Read the Serial Number String
res = hid_get_serial_number_string(handle, wstr, MAX_STR);
wprintf(L"Serial Number String: (%d) %s\n", wstr[0], wstr);
printf("Serial Number String: (%d) %ls\n", wstr[0], wstr);

// Read Indexed String 1
res = hid_get_indexed_string(handle, 1, wstr, MAX_STR);
wprintf(L"Indexed String 1: %s\n", wstr);
printf("Indexed String 1: %ls\n", wstr);

// Toggle LED (cmd 0x80). The first byte is the report number (0x0).
buf[0] = 0x0;
Expand Down