windows: try to get USB device serial number if not provided by HidD_GetSerialNumberString #464
No reviewers
Labels
No labels
3rdparty
Android
API
Author does not respond
bsd
bug
build system/CI
ci-virtual-device
CMake
Contributions Welcome
Core
dependencies
device-specific
documentation
don't_merge
duplicate
enhancement
Example
Haiku
hidraw
hotplug
info required
invalid
libusb
macOS
Misc
Not an issue
question
Release
Test
Test GUI
Windows
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-libusb/hidapi!464
Loading…
Reference in a new issue
No description provided.
Delete branch "xusb-serial-number"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is efficient for Xbox Common Controller class (XUSB) devices like Xbox 360 or Xbox One controllers that are missing serial number via usual HID API.
Before:
After:
This looks good on a first glance, thanks.
I'd like to check closer before merging it. Hopefully somewhere this week.
@ -409,6 +408,132 @@ static void* hid_internal_get_device_interface_property(const wchar_t* interfacereturn property_value;}this has a side-effect:
interface_numberis not set to-1for non-USB devices anymorewe probably need to make
hid_internal_get_device_infoset it to-1by default@ -409,6 +408,132 @@ static void* hid_internal_get_device_interface_property(const wchar_t* interfacereturn property_value;}I have a game controller that has only one interface and
&MI_is not present in none of its HardwareIDs.At the end we end-up setting
interface_numberto-1for that device.Do you think we could add euristic to default it to
0for devices with only one interface?I didn't give it enough thought as of how to do so correctly.
@ -409,6 +408,132 @@ static void* hid_internal_get_device_interface_property(const wchar_t* interfacereturn property_value;}My device:
I'll do a fallback to
-1for non-usb devices but also seems this-1value is not documented properly inhidapi.h@ -409,6 +408,132 @@ static void* hid_internal_get_device_interface_property(const wchar_t* interfacereturn property_value;}Seems this device haven't reported proper serial number it its
iSerialNumberstring descriptor.@ -409,6 +408,132 @@ static void* hid_internal_get_device_interface_property(const wchar_t* interfacereturn property_value;}I think we should set
interface_numberto0for single-interface USB devices since this value is reported in its USB_INTERFACE_DESCRIPTOR.bInterfaceNumber in this case. This way we'll be consistent for all kinds of USB devices.I'll update this PR a bit later with these corrections.
I do not have a proper device to carry out the tests, at least it does not cause regressions.
There is one:
right, we better fix that
@ -412,0 +454,4 @@/* Get the hardware ids from devnode */hardware_ids = hid_internal_get_devnode_property(dev_node, &DEVPKEY_Device_HardwareIds, DEVPROP_TYPE_STRING_LIST);if (!hardware_ids)goto end;need normalize to upper case
@ -412,0 +486,4 @@wchar_t* manufacturer_string = hid_internal_get_devnode_property(dev_node, &DEVPKEY_Device_Manufacturer, DEVPROP_TYPE_STRING);if (manufacturer_string) {free(dev->manufacturer_string);dev->manufacturer_string = manufacturer_string;the check is redundant
@ -409,6 +408,132 @@ static void* hid_internal_get_device_interface_property(const wchar_t* interfacereturn property_value;}use similiar code instead of towupper/wcsstr calls?
https://stackoverflow.com/a/35674861/1795050
@ -409,6 +408,132 @@ static void* hid_internal_get_device_interface_property(const wchar_t* interfacereturn property_value;}sure
want to do it within this PR or later?
@ -409,6 +408,132 @@ static void* hid_internal_get_device_interface_property(const wchar_t* interfacereturn property_value;}I'll do it myself.
Hm. I have found DEVPKEY_Device_UINumber property. Maybe I can use it and Instance ID parsing wouldn't be needed. Need to check it.
@DJm00n I'm a bit lost in where our conversation ended.
Let me know - do you suggest having this merged as is, or should I wait for more of your changes.
Dang, so now there is a conflict, because of the last change.
@Youw rebased PR
@ -169,11 +169,9 @@ extern "C" {/** The USB interface which this logical deviceThanks