windows: try to get USB device serial number if not provided by HidD_GetSerialNumberString #464

Merged
DJm00n merged 3 commits from xusb-serial-number into master 2023-03-13 17:50:58 -05:00
DJm00n commented 2022-10-15 08:27:27 -05:00 (Migrated from github.com)

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:

Device Found
  type: 045e 02ff
  path: \\?\HID#VID_045E&PID_02FF&IG_00#7&1912990&1&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:      Controller (Xbox One For Windows)
  Release:      0
  Interface:    -1
  Usage (page): 0x5 (0x1)
  Bus type: 1
  
Device Found
  type: 045e 02ff
  path: \\?\HID#VID_045E&PID_02FF&IG_00#7&f6ef908&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:      Controller (Xbox One For Windows)
  Release:      0
  Interface:    -1
  Usage (page): 0x5 (0x1)
  Bus type: 1

Device Found
  type: 045e 028e
  path: \\?\HID#VID_045E&PID_028E&IG_00#7&176b3b07&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:      Controller (XBOX 360 For Windows)
  Release:      0
  Interface:    -1
  Usage (page): 0x5 (0x1)
  Bus type: 1
  
Device Found
  type: 1949 041a
  path: \\?\HID#VID_1949&PID_041A&IG_03#8&3373dab9&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:      Controller (Amazon Game Controller)
  Release:      0
  Interface:    -1
  Usage (page): 0x5 (0x1)
  Bus type: 1

Device Found
  type: 045e 02a1
  path: \\?\HID#VID_045E&PID_02A1&IG_04#7&21ec0f93&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:      Controller (Xbox 360 Wireless Receiver for Windows)
  Release:      0
  Interface:    -1
  Usage (page): 0x5 (0x1)
  Bus type: 1

After:

Device Found
  type: 045e 02ff
  path: \\?\HID#VID_045E&PID_02FF&IG_00#7&1912990&1&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 7EED86C35B04
  Manufacturer:
  Product:      Controller (Xbox One For Windows)
  Release:      0
  Interface:    -1
  Usage (page): 0x5 (0x1)
  Bus type: 1

Device Found
  type: 045e 02ff
  path: \\?\HID#VID_045E&PID_02FF&IG_00#7&f6ef908&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 3032363330303437373233303433
  Manufacturer:
  Product:      Controller (Xbox One For Windows)
  Release:      0
  Interface:    -1
  Usage (page): 0x5 (0x1)
  Bus type: 1

Device Found
  type: 045e 028e
  path: \\?\HID#VID_045E&PID_028E&IG_00#7&176b3b07&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 04B229A
  Manufacturer:
  Product:      Controller (XBOX 360 For Windows)
  Release:      0
  Interface:    -1
  Usage (page): 0x5 (0x1)
  Bus type: 1

Device Found
  type: 1949 041a
  path: \\?\HID#VID_1949&PID_041A&IG_03#8&3373dab9&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: G0G159090273003V
  Manufacturer:
  Product:      Controller (Amazon Game Controller)
  Release:      0
  Interface:    0
  Usage (page): 0x5 (0x1)
  Bus type: 1

Device Found
  type: 045e 02a1
  path: \\?\HID#VID_045E&PID_02A1&IG_04#7&21ec0f93&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: E1A03E30
  Manufacturer:
  Product:      Controller (Xbox 360 Wireless Receiver for Windows)
  Release:      0
  Interface:    -1
  Usage (page): 0x5 (0x1)
  Bus type: 1
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: ``` Device Found type: 045e 02ff path: \\?\HID#VID_045E&PID_02FF&IG_00#7&1912990&1&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Product: Controller (Xbox One For Windows) Release: 0 Interface: -1 Usage (page): 0x5 (0x1) Bus type: 1 Device Found type: 045e 02ff path: \\?\HID#VID_045E&PID_02FF&IG_00#7&f6ef908&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Product: Controller (Xbox One For Windows) Release: 0 Interface: -1 Usage (page): 0x5 (0x1) Bus type: 1 Device Found type: 045e 028e path: \\?\HID#VID_045E&PID_028E&IG_00#7&176b3b07&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Product: Controller (XBOX 360 For Windows) Release: 0 Interface: -1 Usage (page): 0x5 (0x1) Bus type: 1 Device Found type: 1949 041a path: \\?\HID#VID_1949&PID_041A&IG_03#8&3373dab9&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Product: Controller (Amazon Game Controller) Release: 0 Interface: -1 Usage (page): 0x5 (0x1) Bus type: 1 Device Found type: 045e 02a1 path: \\?\HID#VID_045E&PID_02A1&IG_04#7&21ec0f93&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Product: Controller (Xbox 360 Wireless Receiver for Windows) Release: 0 Interface: -1 Usage (page): 0x5 (0x1) Bus type: 1 ``` After: ``` Device Found type: 045e 02ff path: \\?\HID#VID_045E&PID_02FF&IG_00#7&1912990&1&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 7EED86C35B04 Manufacturer: Product: Controller (Xbox One For Windows) Release: 0 Interface: -1 Usage (page): 0x5 (0x1) Bus type: 1 Device Found type: 045e 02ff path: \\?\HID#VID_045E&PID_02FF&IG_00#7&f6ef908&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 3032363330303437373233303433 Manufacturer: Product: Controller (Xbox One For Windows) Release: 0 Interface: -1 Usage (page): 0x5 (0x1) Bus type: 1 Device Found type: 045e 028e path: \\?\HID#VID_045E&PID_028E&IG_00#7&176b3b07&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 04B229A Manufacturer: Product: Controller (XBOX 360 For Windows) Release: 0 Interface: -1 Usage (page): 0x5 (0x1) Bus type: 1 Device Found type: 1949 041a path: \\?\HID#VID_1949&PID_041A&IG_03#8&3373dab9&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: G0G159090273003V Manufacturer: Product: Controller (Amazon Game Controller) Release: 0 Interface: 0 Usage (page): 0x5 (0x1) Bus type: 1 Device Found type: 045e 02a1 path: \\?\HID#VID_045E&PID_02A1&IG_04#7&21ec0f93&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: E1A03E30 Manufacturer: Product: Controller (Xbox 360 Wireless Receiver for Windows) Release: 0 Interface: -1 Usage (page): 0x5 (0x1) Bus type: 1 ```
Youw commented 2022-10-15 17:43:59 -05:00 (Migrated from github.com)

This looks good on a first glance, thanks.
I'd like to check closer before merging it. Hopefully somewhere this week.

This looks good on a first glance, thanks. I'd like to check closer before merging it. Hopefully somewhere this week.
Youw (Migrated from github.com) reviewed 2022-10-24 05:49:37 -05:00
@ -409,6 +408,132 @@ static void* hid_internal_get_device_interface_property(const wchar_t* interface
return property_value;
}
Youw (Migrated from github.com) commented 2022-10-24 05:49:18 -05:00
static int hid_internal_extract_int_token_value(const wchar_t* string, const wchar_t* token)
```suggestion static int hid_internal_extract_int_token_value(const wchar_t* string, const wchar_t* token) ```
Youw (Migrated from github.com) commented 2022-10-24 05:49:24 -05:00
	if (hid_internal_extract_int_token_value(device_id, L"IG_") != -1) {
```suggestion if (hid_internal_extract_int_token_value(device_id, L"IG_") != -1) { ```
Youw (Migrated from github.com) commented 2022-10-24 05:49:31 -05:00
		dev->interface_number = hid_internal_extract_int_token_value(hardware_id, L"MI_");
```suggestion dev->interface_number = hid_internal_extract_int_token_value(hardware_id, L"MI_"); ```
Youw (Migrated from github.com) reviewed 2022-10-24 06:25:58 -05:00
Youw (Migrated from github.com) commented 2022-10-24 06:25:57 -05:00

this has a side-effect: interface_number is not set to -1 for non-USB devices anymore
we probably need to make hid_internal_get_device_info set it to -1 by default

this has a side-effect: `interface_number` is not set to `-1` for non-USB devices anymore we probably need to make `hid_internal_get_device_info` set it to `-1` by default
Youw (Migrated from github.com) reviewed 2022-10-24 06:29:35 -05:00
@ -409,6 +408,132 @@ static void* hid_internal_get_device_interface_property(const wchar_t* interface
return property_value;
}
Youw (Migrated from github.com) commented 2022-10-24 06:29:35 -05:00

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_number to -1 for that device.
Do you think we could add euristic to default it to 0 for devices with only one interface?
I didn't give it enough thought as of how to do so correctly.

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_number` to `-1` for that device. Do you think we could add euristic to default it to `0` for devices with only one interface? I didn't give it enough thought as of how to do so correctly.
Youw (Migrated from github.com) reviewed 2022-10-24 06:41:19 -05:00
@ -409,6 +408,132 @@ static void* hid_internal_get_device_interface_property(const wchar_t* interface
return property_value;
}
Youw (Migrated from github.com) commented 2022-10-24 06:41:18 -05:00

My device:

        +++++++++++++++++ Device Information ++++++++++++++++++
Device Description       : Xbox 360 Controller for Windows
Device Path 1            : \\?\USB#VID_045E&PID_028E#6&328b81da&1&2#{a5dcbf10-6530-11d2-901f-00c04fb951ed} (GUID_DEVINTERFACE_USB_DEVICE)
Device Path 2            : \\?\USB#VID_045E&PID_028E#6&328b81da&1&2#{ec87f1e3-c13b-4100-b5f7-8b84d54260cb}
Kernel Name              : \Device\USBPDO-9
Device ID                : USB\VID_045E&PID_028E\6&328B81DA&1&2
Hardware IDs             : USB\VID_045E&PID_028E&REV_2020 USB\VID_045E&PID_028E
Driver KeyName           : {d61ca365-5af4-4486-998b-9db4734c6ca3}\0001
Driver                   : \SystemRoot\System32\drivers\xusb22.sys (Version: 10.0.22000.653  Date: 2022-05-13)
Driver Inf               : C:\WINDOWS\inf\xusb22.inf
Legacy BusType           : PNPBus
Class                    : XnaComposite
Class GUID               : {d61ca365-5af4-4486-998b-9db4734c6ca3}
Service                  : xusb22
Enumerator               : USB
Location Info            : Port_#0002.Hub_#0008
Location IDs             : PCIROOT(0)#PCI(1400)#USBROOT(0)#USB(10)#USB(2), ACPI(_SB_)#ACPI(PC00)#ACPI(XHCI)#ACPI(RHUB)#ACPI(HS10)#USB(2)
Container ID             : {d12ad581-3b3d-11ed-9df4-40b076a530b2}
Manufacturer Info        : Microsoft
Capabilities             : 0x84 (Removable, SurpriseRemovalOK)
Status                   : 0x0180600A (DN_DRIVER_LOADED, DN_STARTED, DN_DISABLEABLE, DN_REMOVABLE, DN_NT_ENUMERATOR, DN_NT_DRIVER)
Problem Code             : 0
HcDisableSelectiveSuspend: 0
EnableSelectiveSuspend   : 0
SelectiveSuspendEnabled  : 0
EnhancedPowerMgmtEnabled : 0
IdleInWorkingState       : 0
WakeFromSleepState       : 0
Power State              : D0 (supported: D0, D2, D3, wake from D0, wake from D2)
 Child Device 1          : USB Input Device
  Device ID              : USB\VID_045E&PID_028E&IG_00\7&C002879&0&00
  Class                  : HIDClass
  Driver KeyName         : {745a17a0-74d3-11d0-b6fe-00a0c90f57da}\0124 (GUID_DEVCLASS_HIDCLASS)
  Service                : HidUsb
  Location               : XBOX_360_DEVICE_00:00
   Child Device 1        : HID-compliant game controller
    Device Path          : \\?\HID#VID_045E&PID_028E&IG_00#8&3e51efe&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} (GUID_DEVINTERFACE_HID)
    Kernel Name          : \Device\00000156
    Device ID            : HID\VID_045E&PID_028E&IG_00\8&3E51EFE&0&0000
    Class                : HIDClass
    Driver KeyName       : {745a17a0-74d3-11d0-b6fe-00a0c90f57da}\0125 (GUID_DEVCLASS_HIDCLASS)

    ---------------------- Device Descriptor ----------------------
bLength                  : 0x12 (18 bytes)
bDescriptorType          : 0x01 (Device Descriptor)
bcdUSB                   : 0x200 (USB Version 2.0) -> but device is Full-Speed only
bDeviceClass             : 0xFF (Vendor Specific)
bDeviceSubClass          : 0xFF
bDeviceProtocol          : 0xFF
bMaxPacketSize0          : 0x08 (8 bytes)
idVendor                 : 0x045E (Microsoft Corporation)
idProduct                : 0x028E
bcdDevice                : 0x2020
iManufacturer            : 0x01 (String Descriptor 1)
 *!*ERROR  String descriptor not found
iProduct                 : 0x02 (String Descriptor 2)
 Language 0x0409         : "XEOX Gamepad"
iSerialNumber            : 0x03 (String Descriptor 3)
 *!*ERROR  String descriptor not found
bNumConfigurations       : 0x01 (1 Configuration)
Data (HexDump)           : 12 01 00 02 FF FF FF 08 5E 04 8E 02 20 20 01 02   ........^...  ..
                           03 01    
My device: ``` +++++++++++++++++ Device Information ++++++++++++++++++ Device Description : Xbox 360 Controller for Windows Device Path 1 : \\?\USB#VID_045E&PID_028E#6&328b81da&1&2#{a5dcbf10-6530-11d2-901f-00c04fb951ed} (GUID_DEVINTERFACE_USB_DEVICE) Device Path 2 : \\?\USB#VID_045E&PID_028E#6&328b81da&1&2#{ec87f1e3-c13b-4100-b5f7-8b84d54260cb} Kernel Name : \Device\USBPDO-9 Device ID : USB\VID_045E&PID_028E\6&328B81DA&1&2 Hardware IDs : USB\VID_045E&PID_028E&REV_2020 USB\VID_045E&PID_028E Driver KeyName : {d61ca365-5af4-4486-998b-9db4734c6ca3}\0001 Driver : \SystemRoot\System32\drivers\xusb22.sys (Version: 10.0.22000.653 Date: 2022-05-13) Driver Inf : C:\WINDOWS\inf\xusb22.inf Legacy BusType : PNPBus Class : XnaComposite Class GUID : {d61ca365-5af4-4486-998b-9db4734c6ca3} Service : xusb22 Enumerator : USB Location Info : Port_#0002.Hub_#0008 Location IDs : PCIROOT(0)#PCI(1400)#USBROOT(0)#USB(10)#USB(2), ACPI(_SB_)#ACPI(PC00)#ACPI(XHCI)#ACPI(RHUB)#ACPI(HS10)#USB(2) Container ID : {d12ad581-3b3d-11ed-9df4-40b076a530b2} Manufacturer Info : Microsoft Capabilities : 0x84 (Removable, SurpriseRemovalOK) Status : 0x0180600A (DN_DRIVER_LOADED, DN_STARTED, DN_DISABLEABLE, DN_REMOVABLE, DN_NT_ENUMERATOR, DN_NT_DRIVER) Problem Code : 0 HcDisableSelectiveSuspend: 0 EnableSelectiveSuspend : 0 SelectiveSuspendEnabled : 0 EnhancedPowerMgmtEnabled : 0 IdleInWorkingState : 0 WakeFromSleepState : 0 Power State : D0 (supported: D0, D2, D3, wake from D0, wake from D2) Child Device 1 : USB Input Device Device ID : USB\VID_045E&PID_028E&IG_00\7&C002879&0&00 Class : HIDClass Driver KeyName : {745a17a0-74d3-11d0-b6fe-00a0c90f57da}\0124 (GUID_DEVCLASS_HIDCLASS) Service : HidUsb Location : XBOX_360_DEVICE_00:00 Child Device 1 : HID-compliant game controller Device Path : \\?\HID#VID_045E&PID_028E&IG_00#8&3e51efe&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} (GUID_DEVINTERFACE_HID) Kernel Name : \Device\00000156 Device ID : HID\VID_045E&PID_028E&IG_00\8&3E51EFE&0&0000 Class : HIDClass Driver KeyName : {745a17a0-74d3-11d0-b6fe-00a0c90f57da}\0125 (GUID_DEVCLASS_HIDCLASS) ---------------------- Device Descriptor ---------------------- bLength : 0x12 (18 bytes) bDescriptorType : 0x01 (Device Descriptor) bcdUSB : 0x200 (USB Version 2.0) -> but device is Full-Speed only bDeviceClass : 0xFF (Vendor Specific) bDeviceSubClass : 0xFF bDeviceProtocol : 0xFF bMaxPacketSize0 : 0x08 (8 bytes) idVendor : 0x045E (Microsoft Corporation) idProduct : 0x028E bcdDevice : 0x2020 iManufacturer : 0x01 (String Descriptor 1) *!*ERROR String descriptor not found iProduct : 0x02 (String Descriptor 2) Language 0x0409 : "XEOX Gamepad" iSerialNumber : 0x03 (String Descriptor 3) *!*ERROR String descriptor not found bNumConfigurations : 0x01 (1 Configuration) Data (HexDump) : 12 01 00 02 FF FF FF 08 5E 04 8E 02 20 20 01 02 ........^... .. 03 01 ```
DJm00n (Migrated from github.com) reviewed 2022-11-27 13:11:44 -06:00
DJm00n (Migrated from github.com) commented 2022-11-27 13:11:44 -06:00

I'll do a fallback to -1 for non-usb devices but also seems this -1 value is not documented properly in hidapi.h

I'll do a fallback to `-1` for non-usb devices but also seems this `-1` value is not documented properly in `hidapi.h`
DJm00n (Migrated from github.com) reviewed 2022-11-27 13:13:25 -06:00
@ -409,6 +408,132 @@ static void* hid_internal_get_device_interface_property(const wchar_t* interface
return property_value;
}
DJm00n (Migrated from github.com) commented 2022-11-27 13:13:25 -06:00

Device ID : USB\VID_045E&PID_028E&IG_00\7&C002879&0&00
iSerialNumber : 0x03 (String Descriptor 3)
*!*ERROR String descriptor not found

Seems this device haven't reported proper serial number it its iSerialNumber string descriptor.

>Device ID : USB\VID_045E&PID_028E&IG_00\7&C002879&0&00 >iSerialNumber : 0x03 (String Descriptor 3) >*!*ERROR String descriptor not found Seems this device haven't reported proper serial number it its `iSerialNumber` string descriptor.
DJm00n (Migrated from github.com) reviewed 2022-11-27 13:17:49 -06:00
@ -409,6 +408,132 @@ static void* hid_internal_get_device_interface_property(const wchar_t* interface
return property_value;
}
DJm00n (Migrated from github.com) commented 2022-11-27 13:17:48 -06:00

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_number to -1 for that device. Do you think we could add euristic to default it to 0 for devices with only one interface? I didn't give it enough thought as of how to do so correctly.

I think we should set interface_number to 0 for 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 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_number` to `-1` for that device. Do you think we could add euristic to default it to `0` for devices with only one interface? I didn't give it enough thought as of how to do so correctly. I think we should set `interface_number` to `0` for single-interface USB devices since this value is reported in its [USB_INTERFACE_DESCRIPTOR.bInterfaceNumber](https://learn.microsoft.com/windows-hardware/drivers/ddi/usbspec/ns-usbspec-_usb_interface_descriptor) 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.
mcuee commented 2023-01-25 21:05:21 -06:00 (Migrated from github.com)

I do not have a proper device to carry out the tests, at least it does not cause regressions.

I do not have a proper device to carry out the tests, at least it does not cause regressions.
Youw commented 2023-01-26 05:28:57 -06:00 (Migrated from github.com)

at least it does not cause regressions

There is one:

interface_number is not set to -1 for non-USB devices anymore


this -1 value is not documented properly in hidapi.h

right, we better fix that

> at least it does not cause regressions There is one: > interface_number is not set to -1 for non-USB devices anymore --- > this -1 value is not documented properly in hidapi.h right, we better fix that
DJm00n (Migrated from github.com) reviewed 2023-01-26 16:45:43 -06:00
@ -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;
DJm00n (Migrated from github.com) commented 2023-01-26 16:45:43 -06:00

need normalize to upper case

need normalize to upper case
Youw (Migrated from github.com) approved these changes 2023-02-01 12:37:56 -06:00
@ -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;
Youw (Migrated from github.com) commented 2023-02-01 12:31:04 -06:00

the check is redundant

			dev->interface_number = hid_internal_extract_int_token_value(hardware_id, L"MI_");
the check is redundant ```suggestion dev->interface_number = hid_internal_extract_int_token_value(hardware_id, L"MI_"); ```
DJm00n (Migrated from github.com) reviewed 2023-02-06 14:05:33 -06:00
@ -409,6 +408,132 @@ static void* hid_internal_get_device_interface_property(const wchar_t* interface
return property_value;
}
DJm00n (Migrated from github.com) commented 2023-02-06 14:05:33 -06:00

use similiar code instead of towupper/wcsstr calls?

   size_t i;
    unsigned char c0 = *pattern, c1, c2;

    if (c0 == '\0')
        return (char *)str;

    c0 = toupper(c0);
    for (; (c1 = *str) != '\0'; str++) {
        if (toupper(c1) == c0) {
            for (i = 1;; i++) {
                c2 = pattern[i];
                if (c2 != '\0')
                    return (char *)str;
                c1 = str[i];
                if (toupper(c1) != toupper(c2))
                    break;
            }
        }
    }

https://stackoverflow.com/a/35674861/1795050

use similiar code instead of towupper/wcsstr calls? ```cpp size_t i; unsigned char c0 = *pattern, c1, c2; if (c0 == '\0') return (char *)str; c0 = toupper(c0); for (; (c1 = *str) != '\0'; str++) { if (toupper(c1) == c0) { for (i = 1;; i++) { c2 = pattern[i]; if (c2 != '\0') return (char *)str; c1 = str[i]; if (toupper(c1) != toupper(c2)) break; } } } ``` https://stackoverflow.com/a/35674861/1795050
Youw (Migrated from github.com) reviewed 2023-02-06 18:49:10 -06:00
@ -409,6 +408,132 @@ static void* hid_internal_get_device_interface_property(const wchar_t* interface
return property_value;
}
Youw (Migrated from github.com) commented 2023-02-06 18:49:10 -06:00

sure
want to do it within this PR or later?

sure want to do it within this PR or later?
DJm00n (Migrated from github.com) reviewed 2023-02-08 11:38:40 -06:00
@ -409,6 +408,132 @@ static void* hid_internal_get_device_interface_property(const wchar_t* interface
return property_value;
}
DJm00n (Migrated from github.com) commented 2023-02-08 11:38:40 -06:00

I'll do it myself.

I'll do it myself.
DJm00n commented 2023-02-08 11:40:37 -06:00 (Migrated from github.com)

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.

Hm. I have found [DEVPKEY_Device_UINumber](https://learn.microsoft.com/windows-hardware/drivers/install/devpkey-device-uinumber) property. Maybe I can use it and Instance ID parsing wouldn't be needed. Need to check it.
Youw commented 2023-02-21 18:08:12 -06:00 (Migrated from github.com)

@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.

@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.
Youw commented 2023-03-13 05:36:42 -05:00 (Migrated from github.com)

Dang, so now there is a conflict, because of the last change.

Dang, so now there is a conflict, because of the last change.
DJm00n commented 2023-03-13 16:45:28 -05:00 (Migrated from github.com)

@Youw rebased PR

@Youw rebased PR
Youw (Migrated from github.com) reviewed 2023-03-13 17:49:49 -05:00
@ -169,11 +169,9 @@ extern "C" {
/** The USB interface which this logical device
Youw (Migrated from github.com) commented 2023-03-13 17:49:48 -05:00
			    Valid only if the device is a USB HID device.
			    Set to -1 in all other cases.
			*/
```suggestion Valid only if the device is a USB HID device. Set to -1 in all other cases. */ ```
Youw commented 2023-03-13 17:51:11 -05:00 (Migrated from github.com)

Thanks

Thanks
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-libusb/hidapi!464
No description provided.