| 694 | } |
| 695 | |
| 696 | static struct hid_device_info *hid_internal_get_device_info(const wchar_t *path, HANDLE handle) |
| 697 | { |
| 698 | struct hid_device_info *dev = NULL; /* return object */ |
| 699 | HIDD_ATTRIBUTES attrib; |
| 700 | PHIDP_PREPARSED_DATA pp_data = NULL; |
| 701 | HIDP_CAPS caps; |
| 702 | wchar_t string[MAX_STRING_WCHARS]; |
| 703 | |
| 704 | /* Create the record. */ |
| 705 | dev = (struct hid_device_info*)calloc(1, sizeof(struct hid_device_info)); |
| 706 | |
| 707 | if (dev == NULL) { |
| 708 | return NULL; |
| 709 | } |
| 710 | |
| 711 | /* Fill out the record */ |
| 712 | dev->next = NULL; |
| 713 | dev->path = hid_internal_UTF16toUTF8(path); |
| 714 | dev->interface_number = -1; |
| 715 | |
| 716 | attrib.Size = sizeof(HIDD_ATTRIBUTES); |
| 717 | if (HidD_GetAttributes(handle, &attrib)) { |
| 718 | /* VID/PID */ |
| 719 | dev->vendor_id = attrib.VendorID; |
| 720 | dev->product_id = attrib.ProductID; |
| 721 | |
| 722 | /* Release Number */ |
| 723 | dev->release_number = attrib.VersionNumber; |
| 724 | } |
| 725 | |
| 726 | /* Get the Usage Page and Usage for this device. */ |
| 727 | if (HidD_GetPreparsedData(handle, &pp_data)) { |
| 728 | if (HidP_GetCaps(pp_data, &caps) == HIDP_STATUS_SUCCESS) { |
| 729 | dev->usage_page = caps.UsagePage; |
| 730 | dev->usage = caps.Usage; |
| 731 | } |
| 732 | |
| 733 | HidD_FreePreparsedData(pp_data); |
| 734 | } |
| 735 | |
| 736 | /* Serial Number */ |
| 737 | string[0] = L'\0'; |
| 738 | HidD_GetSerialNumberString(handle, string, sizeof(string)); |
| 739 | string[MAX_STRING_WCHARS - 1] = L'\0'; |
| 740 | dev->serial_number = _wcsdup(string); |
| 741 | |
| 742 | /* Manufacturer String */ |
| 743 | string[0] = L'\0'; |
| 744 | HidD_GetManufacturerString(handle, string, sizeof(string)); |
| 745 | string[MAX_STRING_WCHARS - 1] = L'\0'; |
| 746 | dev->manufacturer_string = _wcsdup(string); |
| 747 | |
| 748 | /* Product String */ |
| 749 | string[0] = L'\0'; |
| 750 | HidD_GetProductString(handle, string, sizeof(string)); |
| 751 | string[MAX_STRING_WCHARS - 1] = L'\0'; |
| 752 | dev->product_string = _wcsdup(string); |
| 753 |
no test coverage detected