diff --git a/hidapi/hidapi.h b/hidapi/hidapi.h index 709b29f..7dfb571 100644 --- a/hidapi/hidapi.h +++ b/hidapi/hidapi.h @@ -59,6 +59,10 @@ extern "C" { wchar_t *manufacturer_string; /** Product string */ wchar_t *product_string; + /** Usage Page for this Device/Interface */ + unsigned short usage_page; + /** Usage for this Device/Interface */ + unsigned short usage; /** Pointer to the next device */ struct hid_device_info *next; diff --git a/testgui/test.cpp b/testgui/test.cpp index 72de070..e3e0cb9 100644 --- a/testgui/test.cpp +++ b/testgui/test.cpp @@ -275,9 +275,12 @@ MainWindow::onRescan(FXObject *sender, FXSelector sel, void *ptr) while (cur_dev) { // Add it to the List Box. FXString s; + FXString usage_str; s.format("%04hx:%04hx -", cur_dev->vendor_id, cur_dev->product_id); s += FXString(" ") + cur_dev->manufacturer_string; s += FXString(" ") + cur_dev->product_string; + usage_str.format(" (usage: %04hx:%04hx) ", cur_dev->usage_page, cur_dev->usage); + s += usage_str; FXListItem *li = new FXListItem(s, NULL, cur_dev); device_list->appendItem(li); diff --git a/windows/hid.cpp b/windows/hid.cpp index dc58394..0b7ccd3 100644 --- a/windows/hid.cpp +++ b/windows/hid.cpp @@ -291,6 +291,10 @@ struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned shor #define WSTR_LEN 512 const char *str; struct hid_device_info *tmp; + HIDP_PREPARSED_DATA *pp_data = NULL; + HIDP_CAPS caps; + BOOLEAN res; + NTSTATUS nt_res; wchar_t wstr[WSTR_LEN]; // TODO: Determine Size size_t len; @@ -303,6 +307,18 @@ struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned shor root = tmp; } cur_dev = tmp; + + // Get the Usage Page and Usage for this device. + res = HidD_GetPreparsedData(write_handle, &pp_data); + if (res) { + nt_res = HidP_GetCaps(pp_data, &caps); + if (nt_res == HIDP_STATUS_SUCCESS) { + cur_dev->usage_page = caps.UsagePage; + cur_dev->usage = caps.Usage; + } + + HidD_FreePreparsedData(pp_data); + } /* Fill out the record */ cur_dev->next = NULL;