Support for Usage Page and Usage for each device in the hid_device_info struct.

This commit is contained in:
Alan Ott
2011-01-11 23:38:15 -05:00
parent 897c45f360
commit 64daa8adbc
3 changed files with 23 additions and 0 deletions
+4
View File
@@ -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;
+3
View File
@@ -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);
+16
View File
@@ -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;