Add hid_get_device_info #432

Merged
Julusian merged 28 commits from feat/hid_get_device_info into master 2022-08-13 11:01:57 -05:00
Julusian commented 2022-06-20 17:30:22 -05:00 (Migrated from github.com)

Resolves: #431
Closes: #164
Closes: #163

I don't like the signature of get_device_info_for_device in linux, and Im unsure about fill_device_info_for_device in libusb.

The mac, linux and libusb implementations appear to work fine with hidtest.
I havent tested the other backends yet

Resolves: #431 Closes: #164 Closes: #163 I don't like the signature of `get_device_info_for_device` in linux, and Im unsure about `fill_device_info_for_device` in libusb. The mac, linux and libusb implementations appear to work fine with hidtest. I havent tested the other backends yet
Youw commented 2022-06-20 17:33:14 -05:00 (Migrated from github.com)

lets have it against a feature branch for now: https://github.com/libusb/hidapi/tree/hid_get_device_info

lets have it against a feature branch for now: https://github.com/libusb/hidapi/tree/hid_get_device_info
Julusian commented 2022-06-20 17:44:48 -05:00 (Migrated from github.com)

This could replace #164, as it will be possible to get the path from the device_info struct.
I can see there you were wondering about lazily initialising the path. Would you want that to be done here? It doesnt look like it would be too hard to do for most backends. It looks like the only extra data some backends may need is the path. Nothing too bad to persist until the device_info is generated

This could replace #164, as it will be possible to get the path from the device_info struct. I can see there you were wondering about lazily initialising the path. Would you want that to be done here? It doesnt look like it would be too hard to do for most backends. It looks like the only extra data some backends may need is the path. Nothing too bad to persist until the device_info is generated
Youw commented 2022-06-20 17:54:16 -05:00 (Migrated from github.com)

Would you want that to be done here?

Yes, lazy initialization of the device info should be beneficial, specially for those who never use it.

> Would you want that to be done here? Yes, lazy initialization of the device info should be beneficial, specially for those who never use it.
Julusian commented 2022-06-20 18:14:08 -05:00 (Migrated from github.com)

Would you want that to be done here?

Yes, lazy initialization of the device info should be beneficial, specially for those who never use it.

The calls to get the serial number and other strings are now all copying off the device_info, so I would guess it to be rare that it won't get loaded, but I have no problem making it lazy and caching it

> > Would you want that to be done here? > > Yes, lazy initialization of the device info should be beneficial, specially for those who never use it. The calls to get the serial number and other strings are now all copying off the device_info, so I would guess it to be rare that it won't get loaded, but I have no problem making it lazy and caching it
Youw (Migrated from github.com) reviewed 2022-06-21 17:06:31 -05:00
Youw (Migrated from github.com) commented 2022-06-21 17:06:31 -05:00
				This struct is valid until the device is closed with hid_close().
```suggestion This struct is valid until the device is closed with hid_close(). ```
Youw (Migrated from github.com) reviewed 2022-06-21 17:12:33 -05:00
Youw (Migrated from github.com) commented 2022-06-21 17:12:33 -05:00

not needed since you're using calloc

not needed since you're using `calloc` ```suggestion ```
Youw (Migrated from github.com) reviewed 2022-06-21 17:19:44 -05:00
Youw (Migrated from github.com) commented 2022-06-21 17:19:43 -05:00

I don't like that we're passing the ownership inside here
lets initialize this field at the same place, where we call hidapi_initialize_device - where the ownership of path is hold

I don't like that we're passing the ownership inside here lets initialize this field at the same place, where we call `hidapi_initialize_device` - where the ownership of `path` is hold
Youw (Migrated from github.com) reviewed 2022-06-21 17:21:09 -05:00
Youw (Migrated from github.com) commented 2022-06-21 17:21:08 -05:00

this block has extra indentation - should remain at the same level as res = libusb_open(dev, &handle);

this block has extra indentation - should remain at the same level as `res = libusb_open(dev, &handle);`
Youw (Migrated from github.com) reviewed 2022-06-21 17:21:16 -05:00
Youw (Migrated from github.com) commented 2022-06-21 17:21:16 -05:00
#ifdef __ANDROID__
```suggestion #ifdef __ANDROID__ ```
Youw (Migrated from github.com) reviewed 2022-06-21 17:21:25 -05:00
Youw (Migrated from github.com) commented 2022-06-21 17:21:24 -05:00
#endif
```suggestion #endif ```
Youw commented 2022-06-21 17:41:07 -05:00 (Migrated from github.com)

Rebase to master, when you have a chance - got some conflicting changes in there.

Rebase to master, when you have a chance - got some conflicting changes in there.
Julusian (Migrated from github.com) reviewed 2022-06-23 13:13:08 -05:00
Julusian (Migrated from github.com) commented 2022-06-23 13:13:08 -05:00

This was copied from elsewhere. There are many other places doing a calloc then setting their pointer values to null

This was copied from elsewhere. There are many other places doing a calloc then setting their pointer values to null
Youw (Migrated from github.com) reviewed 2022-06-23 13:23:56 -05:00
Youw (Migrated from github.com) commented 2022-06-23 13:23:56 -05:00

Oh no, developers copy-paste code 😱

Oh no, developers copy-paste code 😱
mcuee commented 2022-07-16 00:42:39 -05:00 (Migrated from github.com)

Mac Mini M1 (macOS 12.4) output. The output seems to be fine.


mcuee@mcuees-Mac-mini hidapi_pr432 % ./build_darwin/hidtest/hidtest       
hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 0000 0000
  path: DevSrvsID:4294969138
  serial_number: 
  Manufacturer: Apple
  Product:      
  Release:      0
  Interface:    -1
  Usage (page): 0xff (0xff00)

Device Found
  type: 1915 1025
  path: DevSrvsID:4294969659
  serial_number: 
  Manufacturer: ZY.Ltd
  Product:      ZY Control Mic
  Release:      173
  Interface:    3
  Usage (page): 0x2 (0x1)

Device Found
  type: 1915 1025
  path: DevSrvsID:4294969659
  serial_number: 
  Manufacturer: ZY.Ltd
  Product:      ZY Control Mic
  Release:      173
  Interface:    3
  Usage (page): 0x1 (0x1)

Device Found
  type: 1915 1025
  path: DevSrvsID:4294969659
  serial_number: 
  Manufacturer: ZY.Ltd
  Product:      ZY Control Mic
  Release:      173
  Interface:    3
  Usage (page): 0x1 (0xc)

Device Found
  type: 1915 1025
  path: DevSrvsID:4294969659
  serial_number: 
  Manufacturer: ZY.Ltd
  Product:      ZY Control Mic
  Release:      173
  Interface:    3
  Usage (page): 0x80 (0x1)

Device Found
  type: 1915 1025
  path: DevSrvsID:4294969659
  serial_number: 
  Manufacturer: ZY.Ltd
  Product:      ZY Control Mic
  Release:      173
  Interface:    3
  Usage (page): 0x0 (0xff00)

Device Found
  type: 1915 1025
  path: DevSrvsID:4294969661
  serial_number: 
  Manufacturer: ZY.Ltd
  Product:      ZY Control Mic
  Release:      173
  Interface:    2
  Usage (page): 0x6 (0x1)

Device Found
  type: 045e 082f
  path: DevSrvsID:4294969867
  serial_number: 734762612322
  Manufacturer: Microsoft
  Product:      Microsoft Bluetooth Mouse
  Release:      212
  Interface:    -1
  Usage (page): 0x2 (0x1)

Device Found
  type: 045e 082f
  path: DevSrvsID:4294969867
  serial_number: 734762612322
  Manufacturer: Microsoft
  Product:      Microsoft Bluetooth Mouse
  Release:      212
  Interface:    -1
  Usage (page): 0x1 (0x1)

Device Found
  type: 045e 082f
  path: DevSrvsID:4294969867
  serial_number: 734762612322
  Manufacturer: Microsoft
  Product:      Microsoft Bluetooth Mouse
  Release:      212
  Interface:    -1
  Usage (page): 0x6 (0x1)

Device Found
  type: 045e 082f
  path: DevSrvsID:4294969867
  serial_number: 734762612322
  Manufacturer: Microsoft
  Product:      Microsoft Bluetooth Mouse
  Release:      212
  Interface:    -1
  Usage (page): 0x212 (0xff07)

Device Found
  type: 046d b33d
  path: DevSrvsID:4294969883
  serial_number: f4-73-35-4b-c5-aa
  Manufacturer: Unknown
  Product:      Keyboard K480
  Release:      2803
  Interface:    -1
  Usage (page): 0x6 (0x1)

Device Found
  type: 046d b33d
  path: DevSrvsID:4294969883
  serial_number: f4-73-35-4b-c5-aa
  Manufacturer: Unknown
  Product:      Keyboard K480
  Release:      2803
  Interface:    -1
  Usage (page): 0x1 (0xc)

Device Found
  type: 046d b33d
  path: DevSrvsID:4294969883
  serial_number: f4-73-35-4b-c5-aa
  Manufacturer: Unknown
  Product:      Keyboard K480
  Release:      2803
  Interface:    -1
  Usage (page): 0x80 (0x1)

Device Found
  type: 046d b33d
  path: DevSrvsID:4294969883
  serial_number: f4-73-35-4b-c5-aa
  Manufacturer: Unknown
  Product:      Keyboard K480
  Release:      2803
  Interface:    -1
  Usage (page): 0x1 (0xff00)

Device Found
  type: 046d b33d
  path: DevSrvsID:4294969883
  serial_number: f4-73-35-4b-c5-aa
  Manufacturer: Unknown
  Product:      Keyboard K480
  Release:      2803
  Interface:    -1
  Usage (page): 0x2 (0xff00)

Device Found
  type: 0000 0000
  path: DevSrvsID:4294968515
  serial_number: 
  Manufacturer: Apple
  Product:      Headset
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0xc)

Device Found
  type: 0000 0000
  path: DevSrvsID:4294968878
  serial_number: 
  Manufacturer: APPL
  Product:      BTM
  Release:      0
  Interface:    -1
  Usage (page): 0x48 (0xff00)

unable to open device

Mac Mini M1 (macOS 12.4) output. The output seems to be fine. ``` mcuee@mcuees-Mac-mini hidapi_pr432 % ./build_darwin/hidtest/hidtest hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0. Compile-time version matches runtime version of hidapi. Device Found type: 0000 0000 path: DevSrvsID:4294969138 serial_number: Manufacturer: Apple Product: Release: 0 Interface: -1 Usage (page): 0xff (0xff00) Device Found type: 1915 1025 path: DevSrvsID:4294969659 serial_number: Manufacturer: ZY.Ltd Product: ZY Control Mic Release: 173 Interface: 3 Usage (page): 0x2 (0x1) Device Found type: 1915 1025 path: DevSrvsID:4294969659 serial_number: Manufacturer: ZY.Ltd Product: ZY Control Mic Release: 173 Interface: 3 Usage (page): 0x1 (0x1) Device Found type: 1915 1025 path: DevSrvsID:4294969659 serial_number: Manufacturer: ZY.Ltd Product: ZY Control Mic Release: 173 Interface: 3 Usage (page): 0x1 (0xc) Device Found type: 1915 1025 path: DevSrvsID:4294969659 serial_number: Manufacturer: ZY.Ltd Product: ZY Control Mic Release: 173 Interface: 3 Usage (page): 0x80 (0x1) Device Found type: 1915 1025 path: DevSrvsID:4294969659 serial_number: Manufacturer: ZY.Ltd Product: ZY Control Mic Release: 173 Interface: 3 Usage (page): 0x0 (0xff00) Device Found type: 1915 1025 path: DevSrvsID:4294969661 serial_number: Manufacturer: ZY.Ltd Product: ZY Control Mic Release: 173 Interface: 2 Usage (page): 0x6 (0x1) Device Found type: 045e 082f path: DevSrvsID:4294969867 serial_number: 734762612322 Manufacturer: Microsoft Product: Microsoft Bluetooth Mouse Release: 212 Interface: -1 Usage (page): 0x2 (0x1) Device Found type: 045e 082f path: DevSrvsID:4294969867 serial_number: 734762612322 Manufacturer: Microsoft Product: Microsoft Bluetooth Mouse Release: 212 Interface: -1 Usage (page): 0x1 (0x1) Device Found type: 045e 082f path: DevSrvsID:4294969867 serial_number: 734762612322 Manufacturer: Microsoft Product: Microsoft Bluetooth Mouse Release: 212 Interface: -1 Usage (page): 0x6 (0x1) Device Found type: 045e 082f path: DevSrvsID:4294969867 serial_number: 734762612322 Manufacturer: Microsoft Product: Microsoft Bluetooth Mouse Release: 212 Interface: -1 Usage (page): 0x212 (0xff07) Device Found type: 046d b33d path: DevSrvsID:4294969883 serial_number: f4-73-35-4b-c5-aa Manufacturer: Unknown Product: Keyboard K480 Release: 2803 Interface: -1 Usage (page): 0x6 (0x1) Device Found type: 046d b33d path: DevSrvsID:4294969883 serial_number: f4-73-35-4b-c5-aa Manufacturer: Unknown Product: Keyboard K480 Release: 2803 Interface: -1 Usage (page): 0x1 (0xc) Device Found type: 046d b33d path: DevSrvsID:4294969883 serial_number: f4-73-35-4b-c5-aa Manufacturer: Unknown Product: Keyboard K480 Release: 2803 Interface: -1 Usage (page): 0x80 (0x1) Device Found type: 046d b33d path: DevSrvsID:4294969883 serial_number: f4-73-35-4b-c5-aa Manufacturer: Unknown Product: Keyboard K480 Release: 2803 Interface: -1 Usage (page): 0x1 (0xff00) Device Found type: 046d b33d path: DevSrvsID:4294969883 serial_number: f4-73-35-4b-c5-aa Manufacturer: Unknown Product: Keyboard K480 Release: 2803 Interface: -1 Usage (page): 0x2 (0xff00) Device Found type: 0000 0000 path: DevSrvsID:4294968515 serial_number: Manufacturer: Apple Product: Headset Release: 0 Interface: -1 Usage (page): 0x1 (0xc) Device Found type: 0000 0000 path: DevSrvsID:4294968878 serial_number: Manufacturer: APPL Product: BTM Release: 0 Interface: -1 Usage (page): 0x48 (0xff00) unable to open device ```
mcuee commented 2022-07-16 00:53:24 -05:00 (Migrated from github.com)

Windows MSYS2 mingw64 output. Seems to be fine.

MINGW64 /c/work/libusb/hidapi_pr432
$ ./build_mingw64/hidtest/hidtest.exe
hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 8087 0a1e
  path: \\?\HID#INTC816#3&d2322f2&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      200
  Interface:    -1
  Usage (page): 0xd (0x1)

Device Found
  type: 06cb cd40
  path: \\?\HID#SYNA7DAB&Col01#5&2f64dfea&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      501
  Interface:    -1
  Usage (page): 0x2 (0x1)

Device Found
  type: 06cb cd40
  path: \\?\HID#SYNA7DAB&Col02#5&2f64dfea&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      501
  Interface:    -1
  Usage (page): 0x5 (0xd)

Device Found
  type: 06cb cd40
  path: \\?\HID#SYNA7DAB&Col03#5&2f64dfea&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      501
  Interface:    -1
  Usage (page): 0xe (0xd)

Device Found
  type: 06cb cd40
  path: \\?\HID#SYNA7DAB&Col04#5&2f64dfea&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      501
  Interface:    -1
  Usage (page): 0x1 (0xff00)

Device Found
  type: 046d c52b
  path: \\?\HID#VID_046D&PID_C52B&MI_01&Col01#7&1119bfb4&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    1
  Usage (page): 0x2 (0x1)

Device Found
  type: 045e 0000
  path: \\?\HID#ConvertedDevice&Col02#5&32cf90e6&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0xc)

Device Found
  type: 046d c52b
  path: \\?\HID#VID_046D&PID_C52B&MI_01&Col02#7&1119bfb4&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    1
  Usage (page): 0x1 (0xc)

Device Found
  type: 045e 0000
  path: \\?\HID#ConvertedDevice&Col03#5&32cf90e6&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      0
  Interface:    -1
  Usage (page): 0x80 (0x1)

Device Found
  type: 046d c52b
  path: \\?\HID#VID_046D&PID_C52B&MI_01&Col03#7&1119bfb4&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    1
  Usage (page): 0x80 (0x1)

Device Found
  type: deed feed
  path: \\?\HID#10251229#3&9d5d338&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Acer Inc
  Product:      Acer Airplane Mode Controller
  Release:      101
  Interface:    -1
  Usage (page): 0xc (0x1)

Device Found
  type: 045e 0000
  path: \\?\HID#ConvertedDevice&Col01#5&32cf90e6&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\KBD
  serial_number:
  Manufacturer:
  Product:
  Release:      0
  Interface:    -1
  Usage (page): 0x6 (0x1)

Device Found
  type: 046d c52b
  path: \\?\HID#VID_046D&PID_C52B&MI_01&Col04#7&1119bfb4&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    1
  Usage (page): 0x88 (0xffbc)

Device Found
  type: 046d c52b
  path: \\?\HID#VID_046D&PID_C52B&MI_02&Col01#7&12bd7e0e&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    2
  Usage (page): 0x1 (0xff00)

Device Found
  type: 046d c52b
  path: \\?\HID#VID_046D&PID_C52B&MI_02&Col02#7&12bd7e0e&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    2
  Usage (page): 0x2 (0xff00)

Device Found
  type: 046d c52b
  path: \\?\HID#VID_046D&PID_C52B&MI_02&Col03#7&12bd7e0e&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    2
  Usage (page): 0x4 (0xff00)

Device Found
  type: 046d c52b
  path: \\?\HID#VID_046D&PID_C52B&MI_00#7&34f0fd76&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\KBD
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    0
  Usage (page): 0x6 (0x1)

unable to open device
Windows MSYS2 mingw64 output. Seems to be fine. ``` MINGW64 /c/work/libusb/hidapi_pr432 $ ./build_mingw64/hidtest/hidtest.exe hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0. Compile-time version matches runtime version of hidapi. Device Found type: 8087 0a1e path: \\?\HID#INTC816#3&d2322f2&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Product: Release: 200 Interface: -1 Usage (page): 0xd (0x1) Device Found type: 06cb cd40 path: \\?\HID#SYNA7DAB&Col01#5&2f64dfea&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 9999 Manufacturer: Microsoft Product: HIDI2C Device Release: 501 Interface: -1 Usage (page): 0x2 (0x1) Device Found type: 06cb cd40 path: \\?\HID#SYNA7DAB&Col02#5&2f64dfea&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 9999 Manufacturer: Microsoft Product: HIDI2C Device Release: 501 Interface: -1 Usage (page): 0x5 (0xd) Device Found type: 06cb cd40 path: \\?\HID#SYNA7DAB&Col03#5&2f64dfea&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 9999 Manufacturer: Microsoft Product: HIDI2C Device Release: 501 Interface: -1 Usage (page): 0xe (0xd) Device Found type: 06cb cd40 path: \\?\HID#SYNA7DAB&Col04#5&2f64dfea&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 9999 Manufacturer: Microsoft Product: HIDI2C Device Release: 501 Interface: -1 Usage (page): 0x1 (0xff00) Device Found type: 046d c52b path: \\?\HID#VID_046D&PID_C52B&MI_01&Col01#7&1119bfb4&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 1 Usage (page): 0x2 (0x1) Device Found type: 045e 0000 path: \\?\HID#ConvertedDevice&Col02#5&32cf90e6&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Product: Release: 0 Interface: -1 Usage (page): 0x1 (0xc) Device Found type: 046d c52b path: \\?\HID#VID_046D&PID_C52B&MI_01&Col02#7&1119bfb4&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 1 Usage (page): 0x1 (0xc) Device Found type: 045e 0000 path: \\?\HID#ConvertedDevice&Col03#5&32cf90e6&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Product: Release: 0 Interface: -1 Usage (page): 0x80 (0x1) Device Found type: 046d c52b path: \\?\HID#VID_046D&PID_C52B&MI_01&Col03#7&1119bfb4&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 1 Usage (page): 0x80 (0x1) Device Found type: deed feed path: \\?\HID#10251229#3&9d5d338&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Acer Inc Product: Acer Airplane Mode Controller Release: 101 Interface: -1 Usage (page): 0xc (0x1) Device Found type: 045e 0000 path: \\?\HID#ConvertedDevice&Col01#5&32cf90e6&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\KBD serial_number: Manufacturer: Product: Release: 0 Interface: -1 Usage (page): 0x6 (0x1) Device Found type: 046d c52b path: \\?\HID#VID_046D&PID_C52B&MI_01&Col04#7&1119bfb4&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 1 Usage (page): 0x88 (0xffbc) Device Found type: 046d c52b path: \\?\HID#VID_046D&PID_C52B&MI_02&Col01#7&12bd7e0e&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 2 Usage (page): 0x1 (0xff00) Device Found type: 046d c52b path: \\?\HID#VID_046D&PID_C52B&MI_02&Col02#7&12bd7e0e&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 2 Usage (page): 0x2 (0xff00) Device Found type: 046d c52b path: \\?\HID#VID_046D&PID_C52B&MI_02&Col03#7&12bd7e0e&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 2 Usage (page): 0x4 (0xff00) Device Found type: 046d c52b path: \\?\HID#VID_046D&PID_C52B&MI_00#7&34f0fd76&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\KBD serial_number: Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 0 Usage (page): 0x6 (0x1) unable to open device ```
Youw commented 2022-07-16 07:18:38 -05:00 (Migrated from github.com)

@Julusian do you consider this as still a draft?

@Julusian do you consider this as still a draft?
Julusian commented 2022-07-17 06:23:04 -05:00 (Migrated from github.com)

Sorry, I got distracted on other things
Yeah I am happy with this. I havent made it lazy initialize yet though

@mcuee you haven't really tested my changes much there. You have for the refactoring, but the unable to open device at the end means that it didnt open a device and use the new method

Sorry, I got distracted on other things Yeah I am happy with this. I havent made it lazy initialize yet though @mcuee you haven't really tested my changes much there. You have for the refactoring, but the `unable to open device` at the end means that it didnt open a device and use the new method
mcuee commented 2022-07-17 06:35:49 -05:00 (Migrated from github.com)

Sorry, I got distracted on other things Yeah I am happy with this. I havent made it lazy initialize yet though

@mcuee you haven't really tested my changes much there. You have for the refactoring, but the unable to open device at the end means that it didnt open a device and use the new method

I see. Unfortunately the one used in hidtest is not a common device but rather a modified Microchip generic HID FW example from Alan Ott. So maybe I need to use other codes to test this pull request.

Will hidapitester be good enought?

> Sorry, I got distracted on other things Yeah I am happy with this. I havent made it lazy initialize yet though > > @mcuee you haven't really tested my changes much there. You have for the refactoring, but the `unable to open device` at the end means that it didnt open a device and use the new method I see. Unfortunately the one used in hidtest is not a common device but rather a modified Microchip generic HID FW example from Alan Ott. So maybe I need to use other codes to test this pull request. Will hidapitester be good enought?
Julusian commented 2022-07-17 06:41:21 -05:00 (Migrated from github.com)

I see. Unfortunately the one used in hidtest is not a common device but rather a modified Microchip generic HID FW example from Alan Ott. So maybe I need to use other programms to test this pull request.

I have been changing the ids to be for a device I have, then stopping the application when it starts on the read/write tests

> I see. Unfortunately the one used in hidtest is not a common device but rather a modified Microchip generic HID FW example from Alan Ott. So maybe I need to use other programms to test this pull request. I have been changing the ids to be for a device I have, then stopping the application when it starts on the read/write tests
mcuee commented 2022-07-17 06:58:21 -05:00 (Migrated from github.com)

I see. Unfortunately the one used in hidtest is not a common device but rather a modified Microchip generic HID FW example from Alan Ott. So maybe I need to use other programms to test this pull request.

I have been changing the ids to be for a device I have, then stopping the application when it starts on the read/write tests

This is the output from my Microchip Custom Demo (original Microchip FW). It is probably good enough for this testing.

...
PS C:\work\libusb\hidapi_pr432> .\build_mingw64\hidtest\hidtest.exe
hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0.
Compile-time version matches runtime version of hidapi.
....
...
...
Device Found
  type: 04d8 003f
  path: \\?\HID#VID_04D8&PID_003F#7&aebbb81&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Microchip Technology Inc.
  Product:      Simple HID Device Demo
  Release:      2
  Interface:    -1
  Usage (page): 0x1 (0xff00)

Manufacturer String: Microchip Technology Inc.
Product String: Simple HID Device Demo
Serial Number String: (0)
Device Found
  type: 04d8 003f
  path: \\?\HID#VID_04D8&PID_003F#7&aebbb81&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Microchip Technology Inc.
  Product:      Simple HID Device Demo
  Release:      2
  Interface:    -1
  Usage (page): 0x1 (0xff00)

Indexed String 1: Microchip Technology Inc.
Unable to send a feature report.
Unable to get a feature report.
Get Input/Feature Report DeviceIoControl: (0x00000001) Incorrect function.Data read:
   81 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Press any key to continue . . .
> > I see. Unfortunately the one used in hidtest is not a common device but rather a modified Microchip generic HID FW example from Alan Ott. So maybe I need to use other programms to test this pull request. > > I have been changing the ids to be for a device I have, then stopping the application when it starts on the read/write tests This is the output from my Microchip Custom Demo (original Microchip FW). It is probably good enough for this testing. ``` ... PS C:\work\libusb\hidapi_pr432> .\build_mingw64\hidtest\hidtest.exe hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0. Compile-time version matches runtime version of hidapi. .... ... ... Device Found type: 04d8 003f path: \\?\HID#VID_04D8&PID_003F#7&aebbb81&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Microchip Technology Inc. Product: Simple HID Device Demo Release: 2 Interface: -1 Usage (page): 0x1 (0xff00) Manufacturer String: Microchip Technology Inc. Product String: Simple HID Device Demo Serial Number String: (0) Device Found type: 04d8 003f path: \\?\HID#VID_04D8&PID_003F#7&aebbb81&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Microchip Technology Inc. Product: Simple HID Device Demo Release: 2 Interface: -1 Usage (page): 0x1 (0xff00) Indexed String 1: Microchip Technology Inc. Unable to send a feature report. Unable to get a feature report. Get Input/Feature Report DeviceIoControl: (0x00000001) Incorrect function.Data read: 81 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Press any key to continue . . . ```
mcuee commented 2022-07-17 07:09:11 -05:00 (Migrated from github.com)

Output under Linux.

mcuee@UbuntuSwift3:~/build/hidapi_pr432$ sudo ./build_linux/hidtest/hidtest_hidraw 
hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 04d8 003f
  path: /dev/hidraw3
  serial_number: 
  Manufacturer: Microchip Technology Inc.
  Product:      Simple HID Device Demo
  Release:      2
  Interface:    0
  Usage (page): 0x1 (0xff00)

....
....
....
Manufacturer String: Microchip Technology Inc.
Product String: Simple HID Device Demo
Serial Number String: (0) 
Device Found
  type: 04d8 003f
  path: /dev/hidraw3
  serial_number: 
  Manufacturer: Microchip Technology Inc.
  Product:      Simple HID Device Demo
  Release:      2
  Interface:    0
  Usage (page): 0x1 (0xff00)

Unable to read indexed string 1
Indexed String 1: 
Unable to send a feature report.
Unable to get a feature report.
ioctl (GFEATURE): Broken pipewaiting...
waiting...
waiting...
waiting...
waiting...
waiting...
waiting...
^C

mcuee@UbuntuSwift3:~/build/hidapi_pr432$ sudo ./build_linux/hidtest/hidtest_libusb 
hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 046d c52b
  path: 3-3:1.0
  serial_number: (null)
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    0
  Usage (page): 0x0 (0x0)

Device Found
  type: 046d c52b
  path: 3-3:1.1
  serial_number: (null)
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    1
  Usage (page): 0x0 (0x0)

Device Found
  type: 046d c52b
  path: 3-3:1.2
  serial_number: (null)
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    2
  Usage (page): 0x0 (0x0)

Device Found
  type: 04d8 003f
  path: 3-2.3:1.0
  serial_number: (null)
  Manufacturer: Microchip Technology Inc.
  Product:      Simple HID Device Demo
  Release:      2
  Interface:    0
  Usage (page): 0x0 (0x0)

Manufacturer String: Microchip Technology Inc.
Product String: Simple HID Device Demo
Serial Number String: (1033) 
Device Found
  type: 04d8 003f
  path: 3-2.3:1.0
  serial_number: (null)
  Manufacturer: Microchip Technology Inc.
  Product:      Simple HID Device Demo
  Release:      2
  Interface:    0
  Usage (page): 0x0 (0x0)

Indexed String 1: Microchip Technology Inc.
Unable to send a feature report.
Unable to get a feature report.
hid_error is not implemented yetwaiting...
waiting...
waiting...
waiting...
waiting...
^C

Output under Linux. ``` mcuee@UbuntuSwift3:~/build/hidapi_pr432$ sudo ./build_linux/hidtest/hidtest_hidraw hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0. Compile-time version matches runtime version of hidapi. Device Found type: 04d8 003f path: /dev/hidraw3 serial_number: Manufacturer: Microchip Technology Inc. Product: Simple HID Device Demo Release: 2 Interface: 0 Usage (page): 0x1 (0xff00) .... .... .... Manufacturer String: Microchip Technology Inc. Product String: Simple HID Device Demo Serial Number String: (0) Device Found type: 04d8 003f path: /dev/hidraw3 serial_number: Manufacturer: Microchip Technology Inc. Product: Simple HID Device Demo Release: 2 Interface: 0 Usage (page): 0x1 (0xff00) Unable to read indexed string 1 Indexed String 1: Unable to send a feature report. Unable to get a feature report. ioctl (GFEATURE): Broken pipewaiting... waiting... waiting... waiting... waiting... waiting... waiting... ^C mcuee@UbuntuSwift3:~/build/hidapi_pr432$ sudo ./build_linux/hidtest/hidtest_libusb hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0. Compile-time version matches runtime version of hidapi. Device Found type: 046d c52b path: 3-3:1.0 serial_number: (null) Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 0 Usage (page): 0x0 (0x0) Device Found type: 046d c52b path: 3-3:1.1 serial_number: (null) Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 1 Usage (page): 0x0 (0x0) Device Found type: 046d c52b path: 3-3:1.2 serial_number: (null) Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 2 Usage (page): 0x0 (0x0) Device Found type: 04d8 003f path: 3-2.3:1.0 serial_number: (null) Manufacturer: Microchip Technology Inc. Product: Simple HID Device Demo Release: 2 Interface: 0 Usage (page): 0x0 (0x0) Manufacturer String: Microchip Technology Inc. Product String: Simple HID Device Demo Serial Number String: (1033) Device Found type: 04d8 003f path: 3-2.3:1.0 serial_number: (null) Manufacturer: Microchip Technology Inc. Product: Simple HID Device Demo Release: 2 Interface: 0 Usage (page): 0x0 (0x0) Indexed String 1: Microchip Technology Inc. Unable to send a feature report. Unable to get a feature report. hid_error is not implemented yetwaiting... waiting... waiting... waiting... waiting... ^C ```
mcuee commented 2022-07-17 07:16:49 -05:00 (Migrated from github.com)

Output under macOS 12.4 (Mac Mini M1 2020).

mcuee@mcuees-Mac-mini hidapi_pr432 % ./build_darwin/hidtest/hidtest 
hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0.
Compile-time version matches runtime version of hidapi.
...
...
Device Found
  type: 04d8 003f
  path: DevSrvsID:4294969665
  serial_number: 
  Manufacturer: Microchip Technology Inc.
  Product:      Simple HID Device Demo
  Release:      2
  Interface:    0
  Usage (page): 0x1 (0xff00)
...
...
Manufacturer String: Microchip Technology Inc.
Product String: Simple HID Device Demo
Serial Number String: (0) 
Device Found
  type: 04d8 003f
  path: DevSrvsID:4294969665
  serial_number: 
  Manufacturer: Microchip Technology Inc.
  Product:      Simple HID Device Demo
  Release:      2
  Interface:    0
  Usage (page): 0x1 (0xff00)

Indexed String 1: 
Unable to send a feature report.
Unable to get a feature report.
hid_error is not implemented yetwaiting...
waiting...
waiting...
waiting...
waiting...
waiting...
^C

Output under macOS 12.4 (Mac Mini M1 2020). ``` mcuee@mcuees-Mac-mini hidapi_pr432 % ./build_darwin/hidtest/hidtest hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0. Compile-time version matches runtime version of hidapi. ... ... Device Found type: 04d8 003f path: DevSrvsID:4294969665 serial_number: Manufacturer: Microchip Technology Inc. Product: Simple HID Device Demo Release: 2 Interface: 0 Usage (page): 0x1 (0xff00) ... ... Manufacturer String: Microchip Technology Inc. Product String: Simple HID Device Demo Serial Number String: (0) Device Found type: 04d8 003f path: DevSrvsID:4294969665 serial_number: Manufacturer: Microchip Technology Inc. Product: Simple HID Device Demo Release: 2 Interface: 0 Usage (page): 0x1 (0xff00) Indexed String 1: Unable to send a feature report. Unable to get a feature report. hid_error is not implemented yetwaiting... waiting... waiting... waiting... waiting... waiting... ^C ```
mcuee commented 2022-07-17 21:45:08 -05:00 (Migrated from github.com)

I have been changing the ids to be for a device I have, then stopping the application when it starts on the read/write tests

Good idea. So I just modified test.c to open different device.

Here is the output for Logitech Bluetooth mouse.

...
Device Found
  type: 046d b010
  path: \\?\HID#{00001124-0000-1000-8000-00805f9b34fb}_VID&0002046d_PID&b010&Col02#8&1cf1c1b9&5&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 34885dab0c12
  Manufacturer: Logitech
  Product:      Logitech Bluetooth Wireless Mouse
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0xc)

Manufacturer String: Logitech
Product String: Logitech Bluetooth Wireless Mouse
Serial Number String: (51) 34885dab0c12
Device Found
  type: 046d b010
  path: \\?\HID#{00001124-0000-1000-8000-00805f9b34fb}_VID&0002046d_PID&b010&Col03#8&1cf1c1b9&5&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 34885dab0c12
  Manufacturer: Logitech
  Product:      Logitech Bluetooth Wireless Mouse
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0xff00)

Indexed String 1: Bluetooth Mouse
Press any key to continue . . .
> I have been changing the ids to be for a device I have, then stopping the application when it starts on the read/write tests Good idea. So I just modified test.c to open different device. Here is the output for Logitech Bluetooth mouse. ``` ... Device Found type: 046d b010 path: \\?\HID#{00001124-0000-1000-8000-00805f9b34fb}_VID&0002046d_PID&b010&Col02#8&1cf1c1b9&5&0001#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 34885dab0c12 Manufacturer: Logitech Product: Logitech Bluetooth Wireless Mouse Release: 0 Interface: -1 Usage (page): 0x1 (0xc) Manufacturer String: Logitech Product String: Logitech Bluetooth Wireless Mouse Serial Number String: (51) 34885dab0c12 Device Found type: 046d b010 path: \\?\HID#{00001124-0000-1000-8000-00805f9b34fb}_VID&0002046d_PID&b010&Col03#8&1cf1c1b9&5&0002#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 34885dab0c12 Manufacturer: Logitech Product: Logitech Bluetooth Wireless Mouse Release: 0 Interface: -1 Usage (page): 0x1 (0xff00) Indexed String 1: Bluetooth Mouse Press any key to continue . . . ```
mcuee commented 2022-07-17 21:49:13 -05:00 (Migrated from github.com)

For Logitech USB Receiver:

C:\work\hid\hidapi_pr432\windows\x64\Release [feat/hid_get_device_info ≡ +0 ~1 -0 !]> .\hidtest.exe
hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 046d b010
  path: \\?\HID#{00001124-0000-1000-8000-00805f9b34fb}_VID&0002046d_PID&b010&Col03#8&1cf1c1b9&5&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 34885dab0c12
  Manufacturer: Logitech
  Product:      Logitech Bluetooth Wireless Mouse
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0xff00)

Device Found
  type: 046d b010
  path: \\?\HID#{00001124-0000-1000-8000-00805f9b34fb}_VID&0002046d_PID&b010&Col04#8&1cf1c1b9&5&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 34885dab0c12
  Manufacturer: Logitech
  Product:      Logitech Bluetooth Wireless Mouse
  Release:      0
  Interface:    -1
  Usage (page): 0x2 (0xff00)

Device Found
  type: 046d c534
  path: \\?\HID#VID_046D&PID_C534&MI_01&Col03#7&7e9f97e&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x80 (0x1)

Device Found
  type: 0488 121f
  path: \\?\HID#DELL091A&Col01#5&99b72d3&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      40d
  Interface:    -1
  Usage (page): 0x2 (0x1)

Device Found
  type: 046d b010
  path: \\?\HID#{00001124-0000-1000-8000-00805f9b34fb}_VID&0002046d_PID&b010&Col05#8&1cf1c1b9&5&0004#{4d1e55b2-f16f-11cf-88cb-001111000030}\KBD
  serial_number: 34885dab0c12
  Manufacturer: Logitech
  Product:      Logitech Bluetooth Wireless Mouse
  Release:      0
  Interface:    -1
  Usage (page): 0x6 (0x1)

Device Found
  type: 046d b010
  path: \\?\HID#{00001124-0000-1000-8000-00805f9b34fb}_VID&0002046d_PID&b010&Col06#8&1cf1c1b9&5&0005#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 34885dab0c12
  Manufacturer: Logitech
  Product:      Logitech Bluetooth Wireless Mouse
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0xc)

Device Found
  type: 8087 0a1e
  path: \\?\HID#INTC816&Col01#3&36a7043c&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      200
  Interface:    -1
  Usage (page): 0xc (0x1)

Device Found
  type: 044e 1212
  path: \\?\HID#Vid_044E&Pid_1212&Col01&Col02#7&290aacae&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}\KBD
  serial_number:
  Manufacturer:
  Product:
  Release:      0
  Interface:    -1
  Usage (page): 0x6 (0x1)

Device Found
  type: 8087 0a1e
  path: \\?\HID#INTC816&Col02#3&36a7043c&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      200
  Interface:    -1
  Usage (page): 0xd (0x1)

Device Found
  type: 044e 1212
  path: \\?\HID#Vid_044E&Pid_1212&Col01&Col01#7&290aacae&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      0
  Interface:    -1
  Usage (page): 0x2 (0x1)

Device Found
  type: 046d c534
  path: \\?\HID#VID_046D&PID_C534&MI_01&Col04#7&7e9f97e&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x1 (0xff00)

Device Found
  type: 0488 121f
  path: \\?\HID#DELL091A&Col02#5&99b72d3&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      40d
  Interface:    -1
  Usage (page): 0x5 (0xd)

Device Found
  type: 413c b06e
  path: \\?\HID#VID_413C&PID_B06E#c&37ff1248&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      101
  Interface:    -1
  Usage (page): 0xda (0xffda)

Device Found
  type: 047f c056
  path: \\?\HID#VID_047F&PID_C056&MI_03&Col01#f&39e6f119&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: D1CEC32927974D5F9BD6B2AEBF2EA8E3
  Manufacturer: Plantronics
  Product:      Plantronics Blackwire 3220 Series
  Release:      210
  Interface:    3
  Usage (page): 0x1 (0xc)

Device Found
  type: 045e 0000
  path: \\?\HID#ConvertedDevice&Col02#5&379854aa&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0xc)

Device Found
  type: 047f c056
  path: \\?\HID#VID_047F&PID_C056&MI_03&Col02#f&39e6f119&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: D1CEC32927974D5F9BD6B2AEBF2EA8E3
  Manufacturer: Plantronics
  Product:      Plantronics Blackwire 3220 Series
  Release:      210
  Interface:    3
  Usage (page): 0x5 (0xb)

Device Found
  type: 045e 0000
  path: \\?\HID#ConvertedDevice&Col03#5&379854aa&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      0
  Interface:    -1
  Usage (page): 0x80 (0x1)

Device Found
  type: 047f c056
  path: \\?\HID#VID_047F&PID_C056&MI_03&Col03#f&39e6f119&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: D1CEC32927974D5F9BD6B2AEBF2EA8E3
  Manufacturer: Plantronics
  Product:      Plantronics Blackwire 3220 Series
  Release:      210
  Interface:    3
  Usage (page): 0x3 (0xffa0)

Device Found
  type: 046d c534
  path: \\?\HID#VID_046D&PID_C534&MI_01&Col05#7&7e9f97e&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x2 (0xff00)

Device Found
  type: 0488 121f
  path: \\?\HID#DELL091A&Col03#5&99b72d3&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      40d
  Interface:    -1
  Usage (page): 0x1 (0xff01)

Device Found
  type: 046d c534
  path: \\?\HID#VID_046D&PID_C534&MI_00#7&32158c2f&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\KBD
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    0
  Usage (page): 0x6 (0x1)

Device Found
  type: 413c 2107
  path: \\?\HID#VID_413C&PID_2107#e&1de7f0c0&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\KBD
  serial_number:
  Manufacturer: DELL
  Product:      Dell USB Entry Keyboard
  Release:      178
  Interface:    -1
  Usage (page): 0x6 (0x1)

Device Found
  type: 0488 121f
  path: \\?\HID#DELL091A&Col04#5&99b72d3&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      40d
  Interface:    -1
  Usage (page): 0x1 (0xff02)

Device Found
  type: 046d c534
  path: \\?\HID#VID_046D&PID_C534&MI_01&Col01#7&7e9f97e&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x2 (0x1)

Device Found
  type: 046d c077
  path: \\?\HID#VID_046D&PID_C077#e&fde55df&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Optical Mouse
  Release:      7200
  Interface:    -1
  Usage (page): 0x2 (0x1)

Device Found
  type: 0488 121f
  path: \\?\HID#DELL091A&Col05#5&99b72d3&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      40d
  Interface:    -1
  Usage (page): 0xe (0xd)

Device Found
  type: 046d b010
  path: \\?\HID#{00001124-0000-1000-8000-00805f9b34fb}_VID&0002046d_PID&b010&Col01#8&1cf1c1b9&5&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 34885dab0c12
  Manufacturer: Logitech
  Product:      Logitech Bluetooth Wireless Mouse
  Release:      0
  Interface:    -1
  Usage (page): 0x2 (0x1)

Device Found
  type: 413c b06f
  path: \\?\HID#VID_413C&PID_B06F#d&3624b04c&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      101
  Interface:    -1
  Usage (page): 0xda (0xffda)

Device Found
  type: 046d c534
  path: \\?\HID#VID_046D&PID_C534&MI_01&Col02#7&7e9f97e&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x1 (0xc)

Device Found
  type: 045e 0000
  path: \\?\HID#ConvertedDevice&Col01#5&379854aa&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\KBD
  serial_number:
  Manufacturer:
  Product:
  Release:      0
  Interface:    -1
  Usage (page): 0x6 (0x1)

Device Found
  type: 046d b010
  path: \\?\HID#{00001124-0000-1000-8000-00805f9b34fb}_VID&0002046d_PID&b010&Col02#8&1cf1c1b9&5&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 34885dab0c12
  Manufacturer: Logitech
  Product:      Logitech Bluetooth Wireless Mouse
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0xc)

Manufacturer String: Logitech
Product String: USB Receiver
Serial Number String: (0)
Device Found
  type: 046d c534
  path: \\?\HID#VID_046D&PID_C534&MI_01&Col03#7&7e9f97e&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x80 (0x1)

Indexed String 1: Logitech
Press any key to continue . . .

For Logitech USB Receiver: ``` C:\work\hid\hidapi_pr432\windows\x64\Release [feat/hid_get_device_info ≡ +0 ~1 -0 !]> .\hidtest.exe hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0. Compile-time version matches runtime version of hidapi. Device Found type: 046d b010 path: \\?\HID#{00001124-0000-1000-8000-00805f9b34fb}_VID&0002046d_PID&b010&Col03#8&1cf1c1b9&5&0002#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 34885dab0c12 Manufacturer: Logitech Product: Logitech Bluetooth Wireless Mouse Release: 0 Interface: -1 Usage (page): 0x1 (0xff00) Device Found type: 046d b010 path: \\?\HID#{00001124-0000-1000-8000-00805f9b34fb}_VID&0002046d_PID&b010&Col04#8&1cf1c1b9&5&0003#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 34885dab0c12 Manufacturer: Logitech Product: Logitech Bluetooth Wireless Mouse Release: 0 Interface: -1 Usage (page): 0x2 (0xff00) Device Found type: 046d c534 path: \\?\HID#VID_046D&PID_C534&MI_01&Col03#7&7e9f97e&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Logitech Product: USB Receiver Release: 2901 Interface: 1 Usage (page): 0x80 (0x1) Device Found type: 0488 121f path: \\?\HID#DELL091A&Col01#5&99b72d3&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 9999 Manufacturer: Microsoft Product: HIDI2C Device Release: 40d Interface: -1 Usage (page): 0x2 (0x1) Device Found type: 046d b010 path: \\?\HID#{00001124-0000-1000-8000-00805f9b34fb}_VID&0002046d_PID&b010&Col05#8&1cf1c1b9&5&0004#{4d1e55b2-f16f-11cf-88cb-001111000030}\KBD serial_number: 34885dab0c12 Manufacturer: Logitech Product: Logitech Bluetooth Wireless Mouse Release: 0 Interface: -1 Usage (page): 0x6 (0x1) Device Found type: 046d b010 path: \\?\HID#{00001124-0000-1000-8000-00805f9b34fb}_VID&0002046d_PID&b010&Col06#8&1cf1c1b9&5&0005#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 34885dab0c12 Manufacturer: Logitech Product: Logitech Bluetooth Wireless Mouse Release: 0 Interface: -1 Usage (page): 0x1 (0xc) Device Found type: 8087 0a1e path: \\?\HID#INTC816&Col01#3&36a7043c&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Product: Release: 200 Interface: -1 Usage (page): 0xc (0x1) Device Found type: 044e 1212 path: \\?\HID#Vid_044E&Pid_1212&Col01&Col02#7&290aacae&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}\KBD serial_number: Manufacturer: Product: Release: 0 Interface: -1 Usage (page): 0x6 (0x1) Device Found type: 8087 0a1e path: \\?\HID#INTC816&Col02#3&36a7043c&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Product: Release: 200 Interface: -1 Usage (page): 0xd (0x1) Device Found type: 044e 1212 path: \\?\HID#Vid_044E&Pid_1212&Col01&Col01#7&290aacae&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Product: Release: 0 Interface: -1 Usage (page): 0x2 (0x1) Device Found type: 046d c534 path: \\?\HID#VID_046D&PID_C534&MI_01&Col04#7&7e9f97e&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Logitech Product: USB Receiver Release: 2901 Interface: 1 Usage (page): 0x1 (0xff00) Device Found type: 0488 121f path: \\?\HID#DELL091A&Col02#5&99b72d3&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 9999 Manufacturer: Microsoft Product: HIDI2C Device Release: 40d Interface: -1 Usage (page): 0x5 (0xd) Device Found type: 413c b06e path: \\?\HID#VID_413C&PID_B06E#c&37ff1248&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Product: Release: 101 Interface: -1 Usage (page): 0xda (0xffda) Device Found type: 047f c056 path: \\?\HID#VID_047F&PID_C056&MI_03&Col01#f&39e6f119&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: D1CEC32927974D5F9BD6B2AEBF2EA8E3 Manufacturer: Plantronics Product: Plantronics Blackwire 3220 Series Release: 210 Interface: 3 Usage (page): 0x1 (0xc) Device Found type: 045e 0000 path: \\?\HID#ConvertedDevice&Col02#5&379854aa&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Product: Release: 0 Interface: -1 Usage (page): 0x1 (0xc) Device Found type: 047f c056 path: \\?\HID#VID_047F&PID_C056&MI_03&Col02#f&39e6f119&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: D1CEC32927974D5F9BD6B2AEBF2EA8E3 Manufacturer: Plantronics Product: Plantronics Blackwire 3220 Series Release: 210 Interface: 3 Usage (page): 0x5 (0xb) Device Found type: 045e 0000 path: \\?\HID#ConvertedDevice&Col03#5&379854aa&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Product: Release: 0 Interface: -1 Usage (page): 0x80 (0x1) Device Found type: 047f c056 path: \\?\HID#VID_047F&PID_C056&MI_03&Col03#f&39e6f119&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: D1CEC32927974D5F9BD6B2AEBF2EA8E3 Manufacturer: Plantronics Product: Plantronics Blackwire 3220 Series Release: 210 Interface: 3 Usage (page): 0x3 (0xffa0) Device Found type: 046d c534 path: \\?\HID#VID_046D&PID_C534&MI_01&Col05#7&7e9f97e&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Logitech Product: USB Receiver Release: 2901 Interface: 1 Usage (page): 0x2 (0xff00) Device Found type: 0488 121f path: \\?\HID#DELL091A&Col03#5&99b72d3&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 9999 Manufacturer: Microsoft Product: HIDI2C Device Release: 40d Interface: -1 Usage (page): 0x1 (0xff01) Device Found type: 046d c534 path: \\?\HID#VID_046D&PID_C534&MI_00#7&32158c2f&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\KBD serial_number: Manufacturer: Logitech Product: USB Receiver Release: 2901 Interface: 0 Usage (page): 0x6 (0x1) Device Found type: 413c 2107 path: \\?\HID#VID_413C&PID_2107#e&1de7f0c0&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\KBD serial_number: Manufacturer: DELL Product: Dell USB Entry Keyboard Release: 178 Interface: -1 Usage (page): 0x6 (0x1) Device Found type: 0488 121f path: \\?\HID#DELL091A&Col04#5&99b72d3&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 9999 Manufacturer: Microsoft Product: HIDI2C Device Release: 40d Interface: -1 Usage (page): 0x1 (0xff02) Device Found type: 046d c534 path: \\?\HID#VID_046D&PID_C534&MI_01&Col01#7&7e9f97e&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Logitech Product: USB Receiver Release: 2901 Interface: 1 Usage (page): 0x2 (0x1) Device Found type: 046d c077 path: \\?\HID#VID_046D&PID_C077#e&fde55df&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Logitech Product: USB Optical Mouse Release: 7200 Interface: -1 Usage (page): 0x2 (0x1) Device Found type: 0488 121f path: \\?\HID#DELL091A&Col05#5&99b72d3&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 9999 Manufacturer: Microsoft Product: HIDI2C Device Release: 40d Interface: -1 Usage (page): 0xe (0xd) Device Found type: 046d b010 path: \\?\HID#{00001124-0000-1000-8000-00805f9b34fb}_VID&0002046d_PID&b010&Col01#8&1cf1c1b9&5&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 34885dab0c12 Manufacturer: Logitech Product: Logitech Bluetooth Wireless Mouse Release: 0 Interface: -1 Usage (page): 0x2 (0x1) Device Found type: 413c b06f path: \\?\HID#VID_413C&PID_B06F#d&3624b04c&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Product: Release: 101 Interface: -1 Usage (page): 0xda (0xffda) Device Found type: 046d c534 path: \\?\HID#VID_046D&PID_C534&MI_01&Col02#7&7e9f97e&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Logitech Product: USB Receiver Release: 2901 Interface: 1 Usage (page): 0x1 (0xc) Device Found type: 045e 0000 path: \\?\HID#ConvertedDevice&Col01#5&379854aa&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\KBD serial_number: Manufacturer: Product: Release: 0 Interface: -1 Usage (page): 0x6 (0x1) Device Found type: 046d b010 path: \\?\HID#{00001124-0000-1000-8000-00805f9b34fb}_VID&0002046d_PID&b010&Col02#8&1cf1c1b9&5&0001#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: 34885dab0c12 Manufacturer: Logitech Product: Logitech Bluetooth Wireless Mouse Release: 0 Interface: -1 Usage (page): 0x1 (0xc) Manufacturer String: Logitech Product String: USB Receiver Serial Number String: (0) Device Found type: 046d c534 path: \\?\HID#VID_046D&PID_C534&MI_01&Col03#7&7e9f97e&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030} serial_number: Manufacturer: Logitech Product: USB Receiver Release: 2901 Interface: 1 Usage (page): 0x80 (0x1) Indexed String 1: Logitech Press any key to continue . . . ```
Julusian commented 2022-07-26 13:41:02 -05:00 (Migrated from github.com)

@Youw I think I am done on this now.
I have made it lazy-load the device_info struct on linux&mac backends, both libusb and windows use some additional properties which arent persisted on the struct.

@Youw I think I am done on this now. I have made it lazy-load the device_info struct on linux&mac backends, both libusb and windows use some additional properties which arent persisted on the struct.
Youw commented 2022-07-26 16:10:09 -05:00 (Migrated from github.com)

I'll have to find some time to go over it again to review. I'll try to do so shortly.
Thanks for the contribution!

I'll have to find some time to go over it again to review. I'll try to do so shortly. Thanks for the contribution!
Youw (Migrated from github.com) reviewed 2022-08-01 04:41:37 -05:00
@ -473,0 +477,4 @@
@returns
This function returns a pointer to the struct #hid_device_info
for this hid_device, or NULL in the case of failure.
Youw (Migrated from github.com) commented 2022-08-01 04:41:37 -05:00
				for this hid_device, or NULL in the case of failure.
				Call hid_error(dev) to get the failure reason.
```suggestion for this hid_device, or NULL in the case of failure. Call hid_error(dev) to get the failure reason. ```
Youw (Migrated from github.com) reviewed 2022-08-01 04:44:19 -05:00
@ -1199,6 +1199,16 @@ int HID_API_EXPORT_CALL HID_API_CALL hid_get_serial_number_string(hid_device *de
return 0;
Youw (Migrated from github.com) commented 2022-08-01 04:44:18 -05:00
		register_string_error(dev, L"NULL device info");
```suggestion register_string_error(dev, L"NULL device info"); ```
Youw (Migrated from github.com) reviewed 2022-08-01 04:46:43 -05:00
@ -1161,17 +1164,74 @@ void HID_API_EXPORT hid_close(hid_device *dev)
Youw (Migrated from github.com) commented 2022-08-01 04:46:43 -05:00

ideally - this check should go before calling hid_get_device_info

ideally - this check should go before calling `hid_get_device_info`
Youw (Migrated from github.com) reviewed 2022-08-01 04:50:44 -05:00
@ -154,6 +155,7 @@ static hid_device *new_hid_device(void)
dev->source = NULL;
dev->input_report_buf = NULL;
Youw (Migrated from github.com) commented 2022-08-01 04:50:43 -05:00
	dev->input_reports = NULL;
	dev->device_info = NULL;
	dev->shutdown_thread = 0;
```suggestion dev->input_reports = NULL; dev->device_info = NULL; dev->shutdown_thread = 0; ```
Youw (Migrated from github.com) reviewed 2022-08-01 05:37:17 -05:00
Youw (Migrated from github.com) commented 2022-08-01 05:37:17 -05:00

I always recommend not to have large (most) of the function body under an if condition, i.e. in this case:

if (!handle)
    return;

so the rest of the body doesn't have an extra indentation


yes, that is another holy war about function early returns, and if that bothers you a lot - just place the content of the if branch body into another function
the point - avoid extra indentation of the large amount of code


and yes - its been even worse before, but this time we're doing curated refactoring of this part, and not just "different people adding random things"

I always recommend not to have large (most) of the function body under an `if` condition, i.e. in this case: ``` if (!handle) return; ``` so the rest of the body doesn't have an extra indentation --- yes, that is another holy war about function early returns, and if that bothers you a lot - just place the content of the `if` branch body into another function the point - avoid extra indentation of the large amount of code --- and yes - its been even worse before, but this time we're doing curated refactoring of this part, and not just "different people adding random things"
Youw (Migrated from github.com) reviewed 2022-08-01 05:38:04 -05:00
Youw (Migrated from github.com) commented 2022-08-01 05:38:03 -05:00

this is specifically 3 spaces, and not a tab, to align the text (content of the comment)

					/* Parse the usage and usage page
					   out of the report descriptor. */
this is specifically 3 spaces, and not a tab, to align the text (content of the comment) ```suggestion /* Parse the usage and usage page out of the report descriptor. */ ```
Youw (Migrated from github.com) reviewed 2022-08-01 05:39:06 -05:00
Youw (Migrated from github.com) commented 2022-08-01 05:39:06 -05:00

try to keep the original alignment

try to keep the original alignment
Youw (Migrated from github.com) reviewed 2022-08-01 05:39:54 -05:00
Youw (Migrated from github.com) commented 2022-08-01 05:39:53 -05:00
	libusb_get_device_descriptor(libusb_get_device(dev->device_handle), &desc);
```suggestion libusb_get_device_descriptor(libusb_get_device(dev->device_handle), &desc); ```
Youw (Migrated from github.com) reviewed 2022-08-01 05:56:37 -05:00
Youw (Migrated from github.com) commented 2022-08-01 05:56:36 -05:00
	if (!hidapi_initialize_device(dev, selected_intf_desc))
```suggestion if (!hidapi_initialize_device(dev, selected_intf_desc)) ```
Youw (Migrated from github.com) reviewed 2022-08-01 06:01:32 -05:00
Youw (Migrated from github.com) commented 2022-08-01 06:01:31 -05:00

general comment: can we make it in the same form as on macOS?
I.e.:
static struct hid_device_info * fill_device_info_for_device(libusb_device_handle *handle, struct libusb_device_descriptor *desc)
This way it would make the usage a bit simpler:

  • no need to allocate hid_device_info at every usage (2 places);
  • simpler future development: libusb backend should probably report multiple devices for multiple usages as it is done for other backends;
general comment: can we make it in the same form as on macOS? I.e.: `static struct hid_device_info * fill_device_info_for_device(libusb_device_handle *handle, struct libusb_device_descriptor *desc)` This way it would make the usage a bit simpler: - no need to allocate `hid_device_info` at every usage (2 places); - simpler future development: libusb backend should probably report multiple devices for multiple usages as it is done for other backends;
Youw (Migrated from github.com) reviewed 2022-08-01 06:09:29 -05:00
Youw (Migrated from github.com) commented 2022-08-01 06:09:29 -05:00

I believe this way it will be possible to make the lazy initialisation with simple implementation

I believe this way it will be possible to make the lazy initialisation with simple implementation
Youw (Migrated from github.com) reviewed 2022-08-01 06:11:03 -05:00
@ -438,0 +492,4 @@
return parse_hid_vid_pid_from_uevent(buf, bus_type, vendor_id, product_id);
}
/* return non-zero if successfully read/parsed */
Youw (Migrated from github.com) commented 2022-08-01 06:11:03 -05:00

this is filtering logic - should be a part of hid_enumerate only, and not a part of get_device_info_for_device

this is filtering logic - should be a part of `hid_enumerate` only, and not a part of `get_device_info_for_device`
Youw (Migrated from github.com) reviewed 2022-08-01 06:12:30 -05:00
@ -438,0 +492,4 @@
return parse_hid_vid_pid_from_uevent(buf, bus_type, vendor_id, product_id);
}
/* return non-zero if successfully read/parsed */
Youw (Migrated from github.com) commented 2022-08-01 06:12:30 -05:00

this looks unnecessarily complicated, I expect to have something like:
static struct hid_device_info * get_device_info_for_device(struct udev_device *raw_dev)

this looks unnecessarily complicated, I expect to have something like: `static struct hid_device_info * get_device_info_for_device(struct udev_device *raw_dev)`
Youw (Migrated from github.com) reviewed 2022-08-01 06:13:49 -05:00
@ -438,0 +492,4 @@
return parse_hid_vid_pid_from_uevent(buf, bus_type, vendor_id, product_id);
}
/* return non-zero if successfully read/parsed */
Youw (Migrated from github.com) commented 2022-08-01 06:13:48 -05:00

maybe even: create_device_info_for_device - note: create_, not get_

maybe even: `create_device_info_for_device` - note: *create_*, not *get_*
Youw commented 2022-08-01 06:17:30 -05:00 (Migrated from github.com)

Windows and macOS is fine.
Libusb and Hidraw - I see multuple improvements to perform before it is ready as far as I can tell.

@Julusian do you feel comfortable performing all changes as part of this PR? I could make a feature branch and accept changes there iteratively instead.

Windows and macOS is fine. Libusb and Hidraw - I see multuple improvements to perform before it is ready as far as I can tell. @Julusian do you feel comfortable performing all changes as part of this PR? I could make a feature branch and accept changes there iteratively instead.
Julusian (Migrated from github.com) reviewed 2022-08-01 13:57:53 -05:00
@ -438,0 +492,4 @@
return parse_hid_vid_pid_from_uevent(buf, bus_type, vendor_id, product_id);
}
/* return non-zero if successfully read/parsed */
Julusian (Migrated from github.com) commented 2022-08-01 13:57:53 -05:00

I ended up with this because it can return any number of devices. So it was either this, or immediately afterwards it would have to loop through the returned device to find last_dev. It didnt feel good to be iterating through a return value like that.

struct hid_device_info * last_dev = first_dev->next;
while (last_dev->next) {
  last_dev = last_dev->next;
}

Something like that. I did do this initially, but after it got into an infinite loop a couple of times I decided to change it.

I suppose first_dev could be returned instead of being passed out like this, but this felt a bit better for consistency.

I ended up with this because it can return any number of devices. So it was either this, or immediately afterwards it would have to loop through the returned device to find `last_dev`. It didnt feel good to be iterating through a return value like that. ``` struct hid_device_info * last_dev = first_dev->next; while (last_dev->next) { last_dev = last_dev->next; } ``` Something like that. I did do this initially, but after it got into an infinite loop a couple of times I decided to change it. I suppose `first_dev` could be returned instead of being passed out like this, but this felt a bit better for consistency.
Julusian (Migrated from github.com) reviewed 2022-08-01 14:04:19 -05:00
@ -438,0 +492,4 @@
return parse_hid_vid_pid_from_uevent(buf, bus_type, vendor_id, product_id);
}
/* return non-zero if successfully read/parsed */
Julusian (Migrated from github.com) commented 2022-08-01 14:04:19 -05:00

To get the vendor_id and product_id from raw_dev, it requires 2 calls to udev methods, and some string parsing (parse_uevent_info).
Having to repeat that much logic doesnt feel good, but I do appreciate that this is also not great

To get the vendor_id and product_id from `raw_dev`, it requires 2 calls to udev methods, and some string parsing (`parse_uevent_info`). Having to repeat that much logic doesnt feel good, but I do appreciate that this is also not great
Julusian (Migrated from github.com) reviewed 2022-08-01 14:09:10 -05:00
Julusian (Migrated from github.com) commented 2022-08-01 14:09:10 -05:00

Good point. I have made those changes.
Lazy initialisation is still tricky, as I don't see where interface_num and bConfigurationValue are being stored, which are both needed to reform the path. It is possible they are there and I havent spotted them, or maybe they can be retrieved from the open libusb handle?

Good point. I have made those changes. Lazy initialisation is still tricky, as I don't see where `interface_num` and `bConfigurationValue` are being stored, which are both needed to reform the path. It is possible they are there and I havent spotted them, or maybe they can be retrieved from the open libusb handle?
Julusian commented 2022-08-01 14:25:38 -05:00 (Migrated from github.com)

I think this is as far as I feel I can go on this myself.

The remaining couple of points are ones that I think need to be experimented with to see how close it can get to what you want, and consider the cost/benefit of the result. So this would probably be better to do separately.

I think this is as far as I feel I can go on this myself. The remaining couple of points are ones that I think need to be experimented with to see how close it can get to what you want, and consider the cost/benefit of the result. So this would probably be better to do separately.
Youw commented 2022-08-06 11:51:35 -05:00 (Migrated from github.com)

Updated the implementation to have lazy initialisation for libusb backend.
During the refactoring, found a bug: hidapi_initialize_device hasn't been filling up the device_info->interface_number field.
With new implementation such kind of issues are eliminated.

Updated the implementation to have lazy initialisation for libusb backend. During the refactoring, found a bug: `hidapi_initialize_device` hasn't been filling up the `device_info->interface_number` field. With new implementation such kind of issues are eliminated.
Youw commented 2022-08-07 04:38:53 -05:00 (Migrated from github.com)

Another libusb update: sorted out the "get usage_page/usage". It has to be handled differently during the enumeration and when the device is fully opened.

Another libusb update: sorted out the "get usage_page/usage". It has to be handled differently during the enumeration and when the device is fully opened.
Youw commented 2022-08-07 05:23:29 -05:00 (Migrated from github.com)

Now I'm happy with libusb implementation.

Now I'm happy with libusb implementation.
Youw (Migrated from github.com) approved these changes 2022-08-07 11:43:38 -05:00
Youw (Migrated from github.com) left a comment

Updated hidraw implementation too.

Dependency on libudev has been a major blocker for me, from using hidraw backend on Android, for a while. Today I made a tiny step to using sysfs directly instead of libudev (hid_enumerate/filter over VID/PID).

Second major improvement - hid_get_*_string functions: wcsncpy crashes of the source string is NULL. Add explicit check.


If anyone can additionally test libusb and hidraw backends - I'd highly appreciate it.

Updated hidraw implementation too. Dependency on libudev has been a major blocker for me, from using hidraw backend on Android, for a while. Today I made a tiny step to using sysfs directly instead of libudev (hid_enumerate/filter over VID/PID). Second major improvement - `hid_get_*_string` functions: `wcsncpy` crashes of the source string is NULL. Add explicit check. --- If anyone can additionally test libusb and hidraw backends - I'd highly appreciate it.
Youw commented 2022-08-13 06:20:47 -05:00 (Migrated from github.com)

Since no one complains about my latest changes - either everything works as expecter or no one had a chance to look :)

Since no one complains about my latest changes - either everything works as expecter or no one had a chance to look :)
mcuee commented 2022-08-13 06:40:54 -05:00 (Migrated from github.com)

@Youw
The hidraw backend seems to have some issues with my Microchip Custom Demo device.

No issue with the libusb backend under Ubuntu 20.04.

mcuee@UbuntuSwift3:~/build/hidapi_pr432/build_linux$ ./hidtest/hidtest_libusb
hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 046d c52b
  path: 3-3:1.0
  serial_number: (null)
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    0
  Usage (page): 0x0 (0x0)

Device Found
  type: 046d c52b
  path: 3-3:1.1
  serial_number: (null)
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    1
  Usage (page): 0x0 (0x0)

Device Found
  type: 046d c52b
  path: 3-3:1.2
  serial_number: (null)
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    2
  Usage (page): 0x0 (0x0)

Device Found
  type: 04d8 003f
  path: 3-2.3:1.0
  serial_number: (null)
  Manufacturer: Microchip Technology Inc.
  Product:      Simple HID Device Demo
  Release:      2
  Interface:    0
  Usage (page): 0x0 (0x0)

Device Found
  type: 16c0 05dc
  path: 3-1:1.1
  serial_number: 0001
  Manufacturer: www.fischl.de
  Product:      USBasp
  Release:      110
  Interface:    1
  Usage (page): 0x0 (0x0)

Manufacturer String: Microchip Technology Inc.
Product String: Simple HID Device Demo
Serial Number String: (1033) 
Device Found
  type: 04d8 003f
  path: 3-2.3:1.0
  serial_number: (null)
  Manufacturer: Microchip Technology Inc.
  Product:      Simple HID Device Demo
  Release:      2
  Interface:    0
  Usage (page): 0x1 (0xff00)

Indexed String 1: Microchip Technology Inc.
Unable to send a feature report.
Unable to get a feature report.
hid_error is not implemented yetwaiting...
waiting...
waiting...
waiting...
waiting...
^C

But there is no way to open the device using the hidraw backend. It can not even find the device after the above. Maybe it does not work with hidraw driver.

mcuee@UbuntuSwift3:~/build/hidapi_pr432/build_linux$ ./hidtest/hidtest_hidraw
hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 16c0 05dc
  path: /dev/hidraw1
  serial_number: 0001
  Manufacturer: www.fischl.de
  Product:      USBasp
  Release:      110
  Interface:    1
  Usage (page): 0x1 (0xff00)
...

unable to open device


@Youw The hidraw backend seems to have some issues with my Microchip Custom Demo device. No issue with the libusb backend under Ubuntu 20.04. ``` mcuee@UbuntuSwift3:~/build/hidapi_pr432/build_linux$ ./hidtest/hidtest_libusb hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0. Compile-time version matches runtime version of hidapi. Device Found type: 046d c52b path: 3-3:1.0 serial_number: (null) Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 0 Usage (page): 0x0 (0x0) Device Found type: 046d c52b path: 3-3:1.1 serial_number: (null) Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 1 Usage (page): 0x0 (0x0) Device Found type: 046d c52b path: 3-3:1.2 serial_number: (null) Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 2 Usage (page): 0x0 (0x0) Device Found type: 04d8 003f path: 3-2.3:1.0 serial_number: (null) Manufacturer: Microchip Technology Inc. Product: Simple HID Device Demo Release: 2 Interface: 0 Usage (page): 0x0 (0x0) Device Found type: 16c0 05dc path: 3-1:1.1 serial_number: 0001 Manufacturer: www.fischl.de Product: USBasp Release: 110 Interface: 1 Usage (page): 0x0 (0x0) Manufacturer String: Microchip Technology Inc. Product String: Simple HID Device Demo Serial Number String: (1033) Device Found type: 04d8 003f path: 3-2.3:1.0 serial_number: (null) Manufacturer: Microchip Technology Inc. Product: Simple HID Device Demo Release: 2 Interface: 0 Usage (page): 0x1 (0xff00) Indexed String 1: Microchip Technology Inc. Unable to send a feature report. Unable to get a feature report. hid_error is not implemented yetwaiting... waiting... waiting... waiting... waiting... ^C ``` But there is no way to open the device using the hidraw backend. It can not even find the device after the above. Maybe it does not work with hidraw driver. ``` mcuee@UbuntuSwift3:~/build/hidapi_pr432/build_linux$ ./hidtest/hidtest_hidraw hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0. Compile-time version matches runtime version of hidapi. Device Found type: 16c0 05dc path: /dev/hidraw1 serial_number: 0001 Manufacturer: www.fischl.de Product: USBasp Release: 110 Interface: 1 Usage (page): 0x1 (0xff00) ... unable to open device ```
mcuee commented 2022-08-13 06:45:17 -05:00 (Migrated from github.com)

@Youw
Sorry but the above is a false alarm. The libusb backend will detach the hidraw driver so that hidraw backend will not be able to find the device. There will be no issue running the hidtest-hidraw first.

mcuee@UbuntuSwift3:~/build/hidapi_pr432/build_linux$ sudo ./hidtest/hidtest_hidraw
hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 16c0 05dc
  path: /dev/hidraw1
  serial_number: 0001
  Manufacturer: www.fischl.de
  Product:      USBasp
  Release:      110
  Interface:    1
  Usage (page): 0x1 (0xff00)

Device Found
  type: 04d8 003f
  path: /dev/hidraw4
  serial_number: 
  Manufacturer: Microchip Technology Inc.
  Product:      Simple HID Device Demo
  Release:      2
  Interface:    0
  Usage (page): 0x1 (0xff00)
...

Manufacturer String: Microchip Technology Inc.
Product String: Simple HID Device Demo
Serial Number String: (0) 
Device Found
  type: 04d8 003f
  path: /dev/hidraw4
  serial_number: 
  Manufacturer: Microchip Technology Inc.
  Product:      Simple HID Device Demo
  Release:      2
  Interface:    0
  Usage (page): 0x1 (0xff00)

Unable to read indexed string 1
Indexed String 1: 
Unable to send a feature report.
Unable to get a feature report.
ioctl (GFEATURE): Broken pipewaiting...
waiting...
waiting...
waiting...
waiting...
^C

@Youw Sorry but the above is a false alarm. The libusb backend will detach the hidraw driver so that hidraw backend will not be able to find the device. There will be no issue running the hidtest-hidraw first. ``` mcuee@UbuntuSwift3:~/build/hidapi_pr432/build_linux$ sudo ./hidtest/hidtest_hidraw hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0. Compile-time version matches runtime version of hidapi. Device Found type: 16c0 05dc path: /dev/hidraw1 serial_number: 0001 Manufacturer: www.fischl.de Product: USBasp Release: 110 Interface: 1 Usage (page): 0x1 (0xff00) Device Found type: 04d8 003f path: /dev/hidraw4 serial_number: Manufacturer: Microchip Technology Inc. Product: Simple HID Device Demo Release: 2 Interface: 0 Usage (page): 0x1 (0xff00) ... Manufacturer String: Microchip Technology Inc. Product String: Simple HID Device Demo Serial Number String: (0) Device Found type: 04d8 003f path: /dev/hidraw4 serial_number: Manufacturer: Microchip Technology Inc. Product: Simple HID Device Demo Release: 2 Interface: 0 Usage (page): 0x1 (0xff00) Unable to read indexed string 1 Indexed String 1: Unable to send a feature report. Unable to get a feature report. ioctl (GFEATURE): Broken pipewaiting... waiting... waiting... waiting... waiting... ^C ```
mcuee commented 2022-08-13 06:54:05 -05:00 (Migrated from github.com)

Results of the Logitech USB Receiver under Linux.

mcuee@UbuntuSwift3:~/build/hidapi_pr432/build_linux$ sudo ./hidtest/hidtest_hidraw
hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 16c0 05dc
  path: /dev/hidraw1
  serial_number: 0001
  Manufacturer: www.fischl.de
  Product:      USBasp
  Release:      110
  Interface:    1
  Usage (page): 0x1 (0xff00)

Device Found
  type: 04d8 003f
  path: /dev/hidraw4
  serial_number: 
  Manufacturer: Microchip Technology Inc.
  Product:      Simple HID Device Demo
  Release:      2
  Interface:    0
  Usage (page): 0x1 (0xff00)
...

Device Found
  type: 046d c52b
  path: /dev/hidraw2
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    2
  Usage (page): 0x1 (0xff00)

Device Found
  type: 046d c52b
  path: /dev/hidraw2
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    2
  Usage (page): 0x2 (0xff00)

Device Found
  type: 046d c52b
  path: /dev/hidraw2
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    2
  Usage (page): 0x4 (0xff00)

...

Manufacturer String: Logitech
Product String: USB Receiver
Serial Number String: (0) 
Device Found
  type: 046d c52b
  path: /dev/hidraw2
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    2
  Usage (page): 0x1 (0xff00)

Device Found
  type: 046d c52b
  path: /dev/hidraw2
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    2
  Usage (page): 0x2 (0xff00)

Device Found
  type: 046d c52b
  path: /dev/hidraw2
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    2
  Usage (page): 0x4 (0xff00)

Unable to read indexed string 1
Indexed String 1: 
Unable to send a feature report.
Unable to get a feature report.
ioctl (GFEATURE): Broken pipeUnable to write()
Error: Broken pipe
Unable to write() (2)
waiting...
waiting...
waiting...
waiting...
^C

mcuee@UbuntuSwift3:~/build/hidapi_pr432/build_linux$ ./hidtest/hidtest_libusb
hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 046d c52b
  path: 3-3:1.0
  serial_number: (null)
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    0
  Usage (page): 0x0 (0x0)

Device Found
  type: 046d c52b
  path: 3-3:1.1
  serial_number: (null)
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    1
  Usage (page): 0x0 (0x0)

Device Found
  type: 046d c52b
  path: 3-3:1.2
  serial_number: (null)
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    2
  Usage (page): 0x0 (0x0)

Device Found
  type: 04d8 003f
  path: 3-2.3:1.0
  serial_number: (null)
  Manufacturer: Microchip Technology Inc.
  Product:      Simple HID Device Demo
  Release:      2
  Interface:    0
  Usage (page): 0x0 (0x0)

Device Found
  type: 16c0 05dc
  path: 3-1:1.1
  serial_number: 0001
  Manufacturer: www.fischl.de
  Product:      USBasp
  Release:      110
  Interface:    1
  Usage (page): 0x0 (0x0)

Manufacturer String: Logitech
Product String: USB Receiver
Serial Number String: (1033) 
Device Found
  type: 046d c52b
  path: 3-3:1.0
  serial_number: (null)
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    0
  Usage (page): 0x6 (0x1)

Indexed String 1: Logitech
Unable to send a feature report.
Unable to get a feature report.
hid_error is not implemented yetUnable to write()
Error: hid_error is not implemented yet
Unable to write() (2)
waiting...
waiting...
waiting...
waiting...
^C



Results of the Logitech USB Receiver under Linux. ``` mcuee@UbuntuSwift3:~/build/hidapi_pr432/build_linux$ sudo ./hidtest/hidtest_hidraw hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0. Compile-time version matches runtime version of hidapi. Device Found type: 16c0 05dc path: /dev/hidraw1 serial_number: 0001 Manufacturer: www.fischl.de Product: USBasp Release: 110 Interface: 1 Usage (page): 0x1 (0xff00) Device Found type: 04d8 003f path: /dev/hidraw4 serial_number: Manufacturer: Microchip Technology Inc. Product: Simple HID Device Demo Release: 2 Interface: 0 Usage (page): 0x1 (0xff00) ... Device Found type: 046d c52b path: /dev/hidraw2 serial_number: Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 2 Usage (page): 0x1 (0xff00) Device Found type: 046d c52b path: /dev/hidraw2 serial_number: Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 2 Usage (page): 0x2 (0xff00) Device Found type: 046d c52b path: /dev/hidraw2 serial_number: Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 2 Usage (page): 0x4 (0xff00) ... Manufacturer String: Logitech Product String: USB Receiver Serial Number String: (0) Device Found type: 046d c52b path: /dev/hidraw2 serial_number: Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 2 Usage (page): 0x1 (0xff00) Device Found type: 046d c52b path: /dev/hidraw2 serial_number: Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 2 Usage (page): 0x2 (0xff00) Device Found type: 046d c52b path: /dev/hidraw2 serial_number: Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 2 Usage (page): 0x4 (0xff00) Unable to read indexed string 1 Indexed String 1: Unable to send a feature report. Unable to get a feature report. ioctl (GFEATURE): Broken pipeUnable to write() Error: Broken pipe Unable to write() (2) waiting... waiting... waiting... waiting... ^C mcuee@UbuntuSwift3:~/build/hidapi_pr432/build_linux$ ./hidtest/hidtest_libusb hidapi test/example tool. Compiled with hidapi version 0.12.0, runtime version 0.12.0. Compile-time version matches runtime version of hidapi. Device Found type: 046d c52b path: 3-3:1.0 serial_number: (null) Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 0 Usage (page): 0x0 (0x0) Device Found type: 046d c52b path: 3-3:1.1 serial_number: (null) Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 1 Usage (page): 0x0 (0x0) Device Found type: 046d c52b path: 3-3:1.2 serial_number: (null) Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 2 Usage (page): 0x0 (0x0) Device Found type: 04d8 003f path: 3-2.3:1.0 serial_number: (null) Manufacturer: Microchip Technology Inc. Product: Simple HID Device Demo Release: 2 Interface: 0 Usage (page): 0x0 (0x0) Device Found type: 16c0 05dc path: 3-1:1.1 serial_number: 0001 Manufacturer: www.fischl.de Product: USBasp Release: 110 Interface: 1 Usage (page): 0x0 (0x0) Manufacturer String: Logitech Product String: USB Receiver Serial Number String: (1033) Device Found type: 046d c52b path: 3-3:1.0 serial_number: (null) Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 0 Usage (page): 0x6 (0x1) Indexed String 1: Logitech Unable to send a feature report. Unable to get a feature report. hid_error is not implemented yetUnable to write() Error: hid_error is not implemented yet Unable to write() (2) waiting... waiting... waiting... waiting... ^C ```
Youw commented 2022-08-13 08:11:33 -05:00 (Migrated from github.com)

The libusb backend will detach the hidraw driver so that hidraw backend will not be able to find the device.

That is actually unexpected. LIBUSB backed should have re-attach the kernel (hidraw) driver back, once the device is closed.
Let me check.

> The libusb backend will detach the hidraw driver so that hidraw backend will not be able to find the device. That is actually unexpected. LIBUSB backed should have re-attach the kernel (hidraw) driver back, once the device is closed. Let me check.
Youw commented 2022-08-13 08:23:52 -05:00 (Migrated from github.com)

Let me check.

As far as I can tell - the driver was reattached (otherwise you wouldn't be able to enumerate it with hidraw after libusb).
Maybe there is adifferent issue - likely outside of this PR's scope.

> Let me check. As far as I can tell - the driver _was_ reattached (otherwise you wouldn't be able to enumerate it with hidraw after libusb). Maybe there is adifferent issue - likely outside of this PR's scope.
Youw commented 2022-08-13 09:19:43 -05:00 (Migrated from github.com)

There is an interesting side-effect/improvement in libusb backed:
Before this change, the only way to get (primary) usage_page/usage was to compile hidapi with INVASIVE_GET_USAGE.
Now - it is possible to to get it with hid_get_device_info with default compilation flags.
I.e. (default compilation flags):
hid_enumerate:

  type: 046d c52b
  path: 3-3:1.0
  serial_number: (null)
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    0
  Usage (page): 0x0 (0x0)

hid_get_device_info:

  type: 046d c52b
  path: 3-3:1.0
  serial_number: (null)
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      1203
  Interface:    0
  Usage (page): 0x6 (0x1)

But that works only if device supports GET LIBUSB_DT_REPORT - which is not always true. I have several devices that do not have this usb request implemented, even though HID Report Descriptor is still present among all USB descriptors.
UPD: see #438.

There is an interesting side-effect/improvement in libusb backed: Before this change, the only way to get (primary) usage_page/usage was to compile hidapi with `INVASIVE_GET_USAGE`. Now - it is possible to to get it with `hid_get_device_info` with default compilation flags. I.e. (default compilation flags): `hid_enumerate`: ``` type: 046d c52b path: 3-3:1.0 serial_number: (null) Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 0 Usage (page): 0x0 (0x0) ``` `hid_get_device_info`: ``` type: 046d c52b path: 3-3:1.0 serial_number: (null) Manufacturer: Logitech Product: USB Receiver Release: 1203 Interface: 0 Usage (page): 0x6 (0x1) ``` ~But that works only if device supports `GET` `LIBUSB_DT_REPORT` - which is not always true. I have several devices that do not have this usb request implemented, even though HID Report Descriptor is still present among all USB descriptors.~ UPD: see #438.
mcuee commented 2022-08-13 09:25:56 -05:00 (Migrated from github.com)

Let me check.

As far as I can tell - the driver was reattached (otherwise you wouldn't be able to enumerate it with hidraw after libusb). Maybe there is adifferent issue - likely outside of this PR's scope.

It can not enumerate with the hidraw after libusb. Therefore I think the re-attach does not work in this case, probably due to the use of CTRL-C to terminate the hidtest application. So I do not think this is a real issue.

> > Let me check. > > As far as I can tell - the driver _was_ reattached (otherwise you wouldn't be able to enumerate it with hidraw after libusb). Maybe there is adifferent issue - likely outside of this PR's scope. It can not enumerate with the hidraw after libusb. Therefore I think the re-attach does not work in this case, probably due to the use of CTRL-C to terminate the hidtest application. So I do not think this is a real issue.
Youw commented 2022-08-13 10:55:54 -05:00 (Migrated from github.com)

use of CTRL-C to terminate the hidtest application

Ah, right.

I do not think this is a real issue

Agree.

> use of CTRL-C to terminate the hidtest application Ah, right. > I do not think this is a real issue Agree.
mcuee commented 2022-08-14 20:48:37 -05:00 (Migrated from github.com)

There is an interesting side-effect/improvement in libusb backed: Before this change, the only way to get (primary) usage_page/usage was to compile hidapi with INVASIVE_GET_USAGE. Now - it is possible to to get it with hid_get_device_info with default compilation flags. I.e. (default compilation flags): hid_enumerate:

But that works only if device supports GET LIBUSB_DT_REPORT - which is not always true. I have several devices that do not have this usb request implemented, even though HID Report Descriptor is still present among all USB descriptors.

Thanks for the tip. I will try this on the Teensy HID device.

> There is an interesting side-effect/improvement in libusb backed: Before this change, the only way to get (primary) usage_page/usage was to compile hidapi with `INVASIVE_GET_USAGE`. Now - it is possible to to get it with `hid_get_device_info` with default compilation flags. I.e. (default compilation flags): `hid_enumerate`: > > But that works only if device supports `GET` `LIBUSB_DT_REPORT` - which is not always true. I have several devices that do not have this usb request implemented, even though HID Report Descriptor is still present among all USB descriptors. Thanks for the tip. I will try this on the Teensy HID device.
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!432
No description provided.