hidapi icon indicating copy to clipboard operation
hidapi copied to clipboard

RFC: Add HID bus type in hid_device_info

Open DJm00n opened this issue 4 years ago • 48 comments

It happens that Bluetooth HID gamepads are having the same VID/PID as when connected via USB (DualShock4 and DualSense for example). But they have different report descriptors and thus input/output reports. We need a way to differentiate them.

To address this I have added a new hid_bus_type enum and hid_bus_type bus_type field to hid_device_info struct:

typedef enum {
	/* Unknown bus type */
	HID_API_BUS_UNKNOWN = 0x00,

	/* USB bus
	   Specifications:
	   https://usb.org/hid */
	HID_API_BUS_USB = 0x01,

	/* Bluetooth or Bluetooth LE bus
	   Specifications:
	   https://www.bluetooth.com/specifications/specs/human-interface-device-profile-1-1-1/
	   https://www.bluetooth.com/specifications/specs/hid-service-1-0/
	   https://www.bluetooth.com/specifications/specs/hid-over-gatt-profile-1-0/ */
	HID_API_BUS_BLUETOOTH = 0x02,

	/* I2C bus
	   Specifications:
	   https://docs.microsoft.com/previous-versions/windows/hardware/design/dn642101(v=vs.85) */
	HID_API_BUS_I2C = 0x03,

	/* SPI bus
	   Specifications:
	   https://www.microsoft.com/download/details.aspx?id=103325 */
	HID_API_BUS_SPI = 0x04,
} hid_bus_type;

Implemented it for Windows, libusb, hidraw and MacOS backends.

DJm00n avatar Jul 22 '21 11:07 DJm00n

Sony DualSense controller example.

Before:

Device Found
  type: 054c 0ce6
  path: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}_vid&0002054c_pid&0ce6#8&3265df1c&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: a0ab518cf90a
  Manufacturer: Sony Interactive Entertainment
  Product:      Wireless Controller
  Release:      0
  Interface:    -1
  Usage (page): 0x5 (0x1)

Device Found
  type: 054c 0ce6
  path: \\?\hid#vid_054c&pid_0ce6&mi_03#7&2a5e324d&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Sony Interactive Entertainment
  Product:      Wireless Controller
  Release:      100
  Interface:    3
  Usage (page): 0x5 (0x1)

After:

Device Found
  type: 054c 0ce6
  path: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}_vid&0002054c_pid&0ce6#8&3265df1c&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: a0ab518cf90a
  Manufacturer: Sony Interactive Entertainment
  Product:      Wireless Controller
  Release:      0
  Interface:    -1
  Usage (page): 0x5 (0x1)
  Bus type: 2
  
Device Found
  type: 054c 0ce6
  path: \\?\hid#vid_054c&pid_0ce6&mi_03#7&2a5e324d&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Sony Interactive Entertainment
  Product:      Wireless Controller
  Release:      100
  Interface:    3
  Usage (page): 0x5 (0x1)
  Bus type: 1

DJm00n avatar Jul 22 '21 13:07 DJm00n

I didn't test Linux version yet.

DJm00n avatar Jul 22 '21 13:07 DJm00n

@mcuee @Youw can you test it on Linux?

DJm00n avatar Jul 23 '21 19:07 DJm00n

Technically I could, but right now I'm a little short on time regarding everything, so I can only ask not to make any expectations when I'll do it I can only promice that I will, and I'm also going to see if this can be implemented for macOS as well

Youw avatar Jul 23 '21 21:07 Youw

Here is the test results on my Raspberry Pi 400 running 64bit Ubuntu Linux.

click to expand for the run log
hidapi_djm on  hid_bus_type via △ v3.18.4 took 3s ❯ ./hidtest/hidtest-libusb 
hidapi test/example tool. Compiled with hidapi version 0.11.0, runtime version 0.11.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 04d9 0007
  path: 1-1.4:1.0
  serial_number: (null)
  Manufacturer: (null)
  Product:      (null)
  Release:      161
  Interface:    0
  Usage (page): 0x0 (0x0)
  Bus type: 1

Device Found
  type: 04d9 0007
  path: 1-1.4:1.1
  serial_number: (null)
  Manufacturer: (null)
  Product:      (null)
  Release:      161
  Interface:    1
  Usage (page): 0x0 (0x0)
  Bus type: 1

Device Found
  type: 047f c025
  path: 1-1.2.1.2.6:1.3
  serial_number: (null)
  Manufacturer: (null)
  Product:      (null)
  Release:      135
  Interface:    3
  Usage (page): 0x0 (0x0)
  Bus type: 1

Device Found
  type: 046d c52b
  path: 1-1.2.1.2.4:1.0
  serial_number: (null)
  Manufacturer: (null)
  Product:      (null)
  Release:      2410
  Interface:    0
  Usage (page): 0x0 (0x0)
  Bus type: 1

Device Found
  type: 046d c52b
  path: 1-1.2.1.2.4:1.1
  serial_number: (null)
  Manufacturer: (null)
  Product:      (null)
  Release:      2410
  Interface:    1
  Usage (page): 0x0 (0x0)
  Bus type: 1

Device Found
  type: 046d c52b
  path: 1-1.2.1.2.4:1.2
  serial_number: (null)
  Manufacturer: (null)
  Product:      (null)
  Release:      2410
  Interface:    2
  Usage (page): 0x0 (0x0)
  Bus type: 1

unable to open device

hidapi_djm on  hid_bus_type via △ v3.18.4 ❯ ./hidtest/hidtest-hidraw 
hidapi test/example tool. Compiled with hidapi version 0.11.0, runtime version 0.11.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 046d 101b
  path: /dev/hidraw4
  serial_number: 101b-ae-8a-0c-8c
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x2 (0x1)
  Bus type: 1

Device Found
  type: 046d 101b
  path: /dev/hidraw4
  serial_number: 101b-ae-8a-0c-8c
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x1 (0x1)
  Bus type: 0

Device Found
  type: 046d 101b
  path: /dev/hidraw4
  serial_number: 101b-ae-8a-0c-8c
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x1 (0xff00)
  Bus type: 0

Device Found
  type: 046d 101b
  path: /dev/hidraw4
  serial_number: 101b-ae-8a-0c-8c
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x2 (0xff00)
  Bus type: 0

Device Found
  type: 046d 101b
  path: /dev/hidraw4
  serial_number: 101b-ae-8a-0c-8c
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x4 (0xff00)
  Bus type: 0

Device Found
  type: 046d 2008
  path: /dev/hidraw5
  serial_number: 2008-b6-b4-d3-96
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x6 (0x1)
  Bus type: 1

Device Found
  type: 046d 2008
  path: /dev/hidraw5
  serial_number: 2008-b6-b4-d3-96
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x1 (0xc)
  Bus type: 0

Device Found
  type: 046d 2008
  path: /dev/hidraw5
  serial_number: 2008-b6-b4-d3-96
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x80 (0x1)
  Bus type: 0

Device Found
  type: 046d 2008
  path: /dev/hidraw5
  serial_number: 2008-b6-b4-d3-96
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x88 (0xffbc)
  Bus type: 0

Device Found
  type: 046d 2008
  path: /dev/hidraw5
  serial_number: 2008-b6-b4-d3-96
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x1 (0xff00)
  Bus type: 0

Device Found
  type: 046d 2008
  path: /dev/hidraw5
  serial_number: 2008-b6-b4-d3-96
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x2 (0xff00)
  Bus type: 0

Device Found
  type: 046d 2008
  path: /dev/hidraw5
  serial_number: 2008-b6-b4-d3-96
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x4 (0xff00)
  Bus type: 0

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

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

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

Device Found
  type: 046d b010
  path: /dev/hidraw6
  serial_number: 34:88:5d:ab:0c:12
  Manufacturer: 
  Product:      Bluetooth Mouse M557
  Release:      0
  Interface:    -1
  Usage (page): 0x2 (0x1)
  Bus type: 2

Device Found
  type: 046d b010
  path: /dev/hidraw6
  serial_number: 34:88:5d:ab:0c:12
  Manufacturer: 
  Product:      Bluetooth Mouse M557
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0x1)
  Bus type: 0

Device Found
  type: 046d b010
  path: /dev/hidraw6
  serial_number: 34:88:5d:ab:0c:12
  Manufacturer: 
  Product:      Bluetooth Mouse M557
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0xc)
  Bus type: 0

Device Found
  type: 046d b010
  path: /dev/hidraw6
  serial_number: 34:88:5d:ab:0c:12
  Manufacturer: 
  Product:      Bluetooth Mouse M557
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0xff00)
  Bus type: 0

Device Found
  type: 046d b010
  path: /dev/hidraw6
  serial_number: 34:88:5d:ab:0c:12
  Manufacturer: 
  Product:      Bluetooth Mouse M557
  Release:      0
  Interface:    -1
  Usage (page): 0x2 (0xff00)
  Bus type: 0

Device Found
  type: 046d b010
  path: /dev/hidraw6
  serial_number: 34:88:5d:ab:0c:12
  Manufacturer: 
  Product:      Bluetooth Mouse M557
  Release:      0
  Interface:    -1
  Usage (page): 0x6 (0x1)
  Bus type: 0

Device Found
  type: 046d b010
  path: /dev/hidraw6
  serial_number: 34:88:5d:ab:0c:12
  Manufacturer: 
  Product:      Bluetooth Mouse M557
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0xc)
  Bus type: 0

Device Found
  type: 047f c025
  path: /dev/hidraw3
  serial_number: CB13A3E40E8E47D6A40769C27E90A38E
  Manufacturer: Plantronics
  Product:      Plantronics C320-M
  Release:      135
  Interface:    3
  Usage (page): 0x1 (0xc)
  Bus type: 1

Device Found
  type: 047f c025
  path: /dev/hidraw3
  serial_number: CB13A3E40E8E47D6A40769C27E90A38E
  Manufacturer: Plantronics
  Product:      Plantronics C320-M
  Release:      135
  Interface:    3
  Usage (page): 0x5 (0xb)
  Bus type: 0

Device Found
  type: 047f c025
  path: /dev/hidraw3
  serial_number: CB13A3E40E8E47D6A40769C27E90A38E
  Manufacturer: Plantronics
  Product:      Plantronics C320-M
  Release:      135
  Interface:    3
  Usage (page): 0x1 (0xffa0)
  Bus type: 0

Device Found
  type: 04d9 0007
  path: /dev/hidraw0
  serial_number: 
  Manufacturer:  
  Product:      Raspberry Pi Internal Keyboard
  Release:      161
  Interface:    0
  Usage (page): 0x6 (0x1)
  Bus type: 1

Device Found
  type: 04d9 0007
  path: /dev/hidraw1
  serial_number: 
  Manufacturer:  
  Product:      Raspberry Pi Internal Keyboard
  Release:      161
  Interface:    1
  Usage (page): 0x1 (0xc)
  Bus type: 1

unable to open device

mcuee avatar Jul 24 '21 01:07 mcuee

@DJm00n You can see that libusb backend output is expected. As for the hidraw backend, on one hand it seems to work, but on the other hand, many reports bus type "0". Is this expected by your design? Take note hidraw backend has the feature of ""split by usage_page/usage" as per https://github.com/libusb/hidapi/issues/287 .

mcuee avatar Jul 24 '21 01:07 mcuee

Under my Windows 10 laptop (Windows 10 Enterprise x64 20H2), it seems to me Microsoft HIDI2C device is not listed correctly.

click to expand
C:\work\hid\hidapi_djm\windows\x64\Release [ble_device_info ≡]> .\hidtest.exe
hidapi test/example tool. Compiled with hidapi version 0.11.0, runtime version 0.11.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col03#7&1ebb799e&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x80 (0x1)
  Bus type: 1

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col04#7&1ebb799e&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x1 (0xff00)
  Bus type: 1

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col05#7&1ebb799e&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x2 (0xff00)
  Bus type: 1

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 1

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)
  Bus type: 255

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)
  Bus type: 1

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)
  Bus type: 255

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)
  Bus type: 1

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)
  Bus type: 255

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)
  Bus type: 255

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_00#7&51bc424&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    0
  Usage (page): 0x6 (0x1)
  Bus type: 1

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)
  Bus type: 255

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col01#7&1ebb799e&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x2 (0x1)
  Bus type: 1

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col02#7&1ebb799e&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x1 (0xc)
  Bus type: 1

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)
  Bus type: 255

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

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

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

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

Device Found
  type: 046d b010
  path: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}_vid&0002046d_pid&b010&col05#8&1cf1c1b9&2&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)
  Bus type: 2

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

unable to open device

mcuee avatar Jul 24 '21 08:07 mcuee

@DJm00n For the I2C HID device, you have the following codes for Windows.

	/* I2C HID devices have a special ACPI ID
	   https://docs.microsoft.com/windows-hardware/drivers/hid/plug-and-play-support-and-power-management */
	if (wcsstr(device_id, L"ACPI\\PNP0C50") != 0) {
		dev->bus_type = HID_BUS_I2C;
		goto close;
	}

And I checked the Microsoft I2CHID device in Device Manager "Human Interface Devices" section and indeed it has a "Compatible device id" and "Matching device id" value of "ACPI\PNP0C50".

mcuee avatar Jul 24 '21 08:07 mcuee

@DJm00n And for those "\?\hid#converteddevice", I am not exactly sure if 255 is the right one to use. I tend to think they are more like "virtual hid bus type". But I am okay as well if you use 255 if there are no better ways.

mcuee avatar Jul 24 '21 08:07 mcuee

@DJm00n From what I see, the following Windows codes are not good enough (just using "Device_InstanceId"). On the other hand, for the purpose of HIDAPI, maybe it is still okay. I do not think we can do much with the "Microsoft I2CHID device" anyway.

	/* Get the device id from parent devnode */
	len = 0;
	cr = CM_Get_DevNode_PropertyW(dev_node, &DEVPKEY_Device_InstanceId, &property_type, NULL, &len, 0);
	if (cr == CR_BUFFER_SMALL && property_type == DEVPROP_TYPE_STRING) {
		free(device_id);
		device_id = (wchar_t*)calloc(len, sizeof(BYTE));
		cr = CM_Get_DevNode_PropertyW(dev_node, &DEVPKEY_Device_InstanceId, &property_type, (PBYTE)device_id, &len, 0);
	}

mcuee avatar Jul 24 '21 08:07 mcuee

@mcuee Thank you for testing it!

I don't have such I2C or SPI HID devices in person. So I need some further help.

Can you debug the code a bit and look what exact device_id (acquired with DEVPKEY_Device_InstanceId property) your devices are having?

For example you can add:

wprintf(L"DEVPKEY_Device_InstanceId: %s\n", device_id);

before if (wcsstr(...)) checks.

DJm00n avatar Jul 24 '21 10:07 DJm00n

@DJm00n This is what I get.

click to expand
C:\work\hid\hidapi_djm\windows\x64\Debug [ble_device_info ≡ +0 ~1 -0 !]> .\hidtest.exe
hidapi test/example tool. Compiled with hidapi version 0.11.0, runtime version 0.11.0.
Compile-time version matches runtime version of hidapi.

DEVPKEY_Device_InstanceId: USB\VID_046D&PID_C534&MI_01\6&1CFA36F4&0&0001
DEVPKEY_Device_InstanceId: USB\VID_046D&PID_C534&MI_01\6&1CFA36F4&0&0001
DEVPKEY_Device_InstanceId: USB\VID_046D&PID_C534&MI_01\6&1CFA36F4&0&0001
DEVPKEY_Device_InstanceId: ACPI\DELL091A\4&27F2A591&0
DEVPKEY_Device_InstanceId: ACPI\INT33D5\2&DABA3FF&0
DEVPKEY_Device_InstanceId: HID\VID_044E&PID_1212&COL01\6&298C10D6&0&0000
DEVPKEY_Device_InstanceId: ACPI\INT33D5\2&DABA3FF&0
DEVPKEY_Device_InstanceId: HID\VID_044E&PID_1212&COL01\6&298C10D6&0&0000
DEVPKEY_Device_InstanceId: ACPI\DELL091A\4&27F2A591&0
DEVPKEY_Device_InstanceId: USB\VID_047F&PID_C056&MI_03\E&3A27DC9B&0&0003
DEVPKEY_Device_InstanceId: BUTTONCONVERTER\CONVERTEDDEVICE\4&32F8A6A3&0&0
DEVPKEY_Device_InstanceId: USB\VID_047F&PID_C056&MI_03\E&3A27DC9B&0&0003
DEVPKEY_Device_InstanceId: BUTTONCONVERTER\CONVERTEDDEVICE\4&32F8A6A3&0&0
DEVPKEY_Device_InstanceId: USB\VID_047F&PID_C056&MI_03\E&3A27DC9B&0&0003
DEVPKEY_Device_InstanceId: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}_VID&0002046D_PID&B010\7&31D658D&0&34885DAB0C12_C00000000
DEVPKEY_Device_InstanceId: ACPI\DELL091A\4&27F2A591&0
DEVPKEY_Device_InstanceId: ACPI\DELL091A\4&27F2A591&0
DEVPKEY_Device_InstanceId: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}_VID&0002046D_PID&B010\7&31D658D&0&34885DAB0C12_C00000000
DEVPKEY_Device_InstanceId: USB\VID_046D&PID_C534&MI_00\6&1CFA36F4&0&0000
DEVPKEY_Device_InstanceId: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}_VID&0002046D_PID&B010\7&31D658D&0&34885DAB0C12_C00000000
DEVPKEY_Device_InstanceId: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}_VID&0002046D_PID&B010\7&31D658D&0&34885DAB0C12_C00000000
DEVPKEY_Device_InstanceId: ACPI\DELL091A\4&27F2A591&0
DEVPKEY_Device_InstanceId: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}_VID&0002046D_PID&B010\7&31D658D&0&34885DAB0C12_C00000000
DEVPKEY_Device_InstanceId: USB\VID_046D&PID_C534&MI_01\6&1CFA36F4&0&0001
DEVPKEY_Device_InstanceId: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}_VID&0002046D_PID&B010\7&31D658D&0&34885DAB0C12_C00000000
DEVPKEY_Device_InstanceId: USB\VID_046D&PID_C534&MI_01\6&1CFA36F4&0&0001
DEVPKEY_Device_InstanceId: BUTTONCONVERTER\CONVERTEDDEVICE\4&32F8A6A3&0&0
Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col03#7&1ebb799e&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x80 (0x1)
  Bus type: 1

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col04#7&1ebb799e&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x1 (0xff00)
  Bus type: 1

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col05#7&1ebb799e&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x2 (0xff00)
  Bus type: 1

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 1

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)
  Bus type: 255

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)
  Bus type: 1

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)
  Bus type: 255

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)
  Bus type: 1

Device Found
  type: 046d b010
  path: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}_vid&0002046d_pid&b010&col05#8&1cf1c1b9&2&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)
  Bus type: 2

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)
  Bus type: 255

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)
  Bus type: 255

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

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_00#7&51bc424&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    0
  Usage (page): 0x6 (0x1)
  Bus type: 1

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

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

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)
  Bus type: 255

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

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col01#7&1ebb799e&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x2 (0x1)
  Bus type: 1

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

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col02#7&1ebb799e&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x1 (0xc)
  Bus type: 1

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)
  Bus type: 255

unable to open device

mcuee avatar Jul 24 '21 12:07 mcuee

@DJm00n The Microsoft I2C HID device has the following

DEVPKEY_Device_InstanceId: ACPI\DELL091A\4&27F2A591&0.

If I look at the Device Manager "Human Device Interface" entries, Device_InstanceId printed out is the same as what is listed as "Device Instance Path" in Device Manager.

The one you want to get here is "Compatible IDs" which has two values, "ACPI\PNP0C50" and "PNP0C50".

mcuee avatar Jul 24 '21 12:07 mcuee

@DJm00n From the link in your code, https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/plug-and-play-support-and-power-management

The ACPI 5.0 Specification includes support for HID Class Devices. the ACPI definitions for HID I²C are as follows.

Field Value ACPI object Format Comments
Compatible ID PNP0C50 _CID String in the format of ACPI0C50 or PNP0C50 CompatibleID

mcuee avatar Jul 24 '21 13:07 mcuee

Same for SPI HID device. https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/plug-and-play-for-spi

The ACPI 5.0 Specification includes support for HID Class Devices. the ACPI definitions for HID SPI are as follows.

Field Value ACPI object Format Comments
Hardware ID Vendor Specific _HID String in the format of VVVVdddd (e.g. MSFT0011) VendorID + DeviceID
Compatible ID PNP0C51 _CID String in the format of ACPIxxxx or PNPxxxx CompatibleID

mcuee avatar Jul 24 '21 13:07 mcuee

Compatible ID should work for your purpose, no matter it is USB, Bluetooth, I2C or SPI. https://docs.microsoft.com/en-us/windows-hardware/drivers/install/compatible-ids

mcuee avatar Jul 24 '21 13:07 mcuee

More info about HID Transport under Windows https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/hid-transports

mcuee avatar Jul 24 '21 13:07 mcuee

Built-in device for my Dell Laptop (without any external USB/Bluetooth devices).

click to expand
C:\work\hid\hidapi_djm\windows\x64\Debug [ble_device_info ≡ +0 ~1 -0 !]> .\hidtest.exe
hidapi test/example tool. Compiled with hidapi version 0.11.0, runtime version 0.11.0.
Compile-time version matches runtime version of hidapi.

DEVPKEY_Device_InstanceId: ACPI\DELL091A\4&27F2A591&0
DEVPKEY_Device_InstanceId: ACPI\INT33D5\2&DABA3FF&0
DEVPKEY_Device_InstanceId: HID\VID_044E&PID_1212&COL01\6&298C10D6&0&0000
DEVPKEY_Device_InstanceId: ACPI\INT33D5\2&DABA3FF&0
DEVPKEY_Device_InstanceId: HID\VID_044E&PID_1212&COL01\6&298C10D6&0&0000
DEVPKEY_Device_InstanceId: ACPI\DELL091A\4&27F2A591&0
DEVPKEY_Device_InstanceId: BUTTONCONVERTER\CONVERTEDDEVICE\4&32F8A6A3&0&0
DEVPKEY_Device_InstanceId: BUTTONCONVERTER\CONVERTEDDEVICE\4&32F8A6A3&0&0
DEVPKEY_Device_InstanceId: ACPI\DELL091A\4&27F2A591&0
DEVPKEY_Device_InstanceId: ACPI\DELL091A\4&27F2A591&0
DEVPKEY_Device_InstanceId: ACPI\DELL091A\4&27F2A591&0
DEVPKEY_Device_InstanceId: BUTTONCONVERTER\CONVERTEDDEVICE\4&32F8A6A3&0&0
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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 255

unable to open device

mcuee avatar Jul 24 '21 14:07 mcuee

@mcuee Thank you! I’ll try to do a fix.

DJm00n avatar Jul 24 '21 14:07 DJm00n

@DJm00n Yes the latest update seems to work fine.


C:\work\hid\hidapi_djm\windows\x64\Release [hid_bus_type ≡]> .\hidtest.exe
hidapi test/example tool. Compiled with hidapi version 0.11.0, runtime version 0.11.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col01#7&383a3a17&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x2 (0x1)
  Bus type: 1

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col02#7&383a3a17&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x1 (0xc)
  Bus type: 1

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col03#7&383a3a17&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x80 (0x1)
  Bus type: 1

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col04#7&383a3a17&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x1 (0xff00)
  Bus type: 1

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)
  Bus type: 3

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)
  Bus type: 255

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)
  Bus type: 255

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col05#7&383a3a17&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x2 (0xff00)
  Bus type: 1

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 3

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)
  Bus type: 255

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)
  Bus type: 255

Device Found
  type: 046d b010
  path: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}_vid&0002046d_pid&b010&col05#8&1cf1c1b9&2&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)
  Bus type: 2

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)
  Bus type: 3

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_00#7&1c54b96&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    0
  Usage (page): 0x6 (0x1)
  Bus type: 1

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)
  Bus type: 3

Device Found
  type: 1915 1025
  path: \\?\hid#vid_1915&pid_1025&mi_03&col01#8&33bf0c65&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: ZY.Ltd
  Product:      ZY Control Mic
  Release:      173
  Interface:    3
  Usage (page): 0x2 (0x1)
  Bus type: 1

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

Device Found
  type: 1915 1025
  path: \\?\hid#vid_1915&pid_1025&mi_03&col02#8&33bf0c65&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: ZY.Ltd
  Product:      ZY Control Mic
  Release:      173
  Interface:    3
  Usage (page): 0x1 (0xc)
  Bus type: 1

Device Found
  type: 1915 1025
  path: \\?\hid#vid_1915&pid_1025&mi_02#8&b545e9c&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd
  serial_number:
  Manufacturer: ZY.Ltd
  Product:      ZY Control Mic
  Release:      173
  Interface:    2
  Usage (page): 0x6 (0x1)
  Bus type: 1

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

Device Found
  type: 1915 1025
  path: \\?\hid#vid_1915&pid_1025&mi_03&col03#8&33bf0c65&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: ZY.Ltd
  Product:      ZY Control Mic
  Release:      173
  Interface:    3
  Usage (page): 0x80 (0x1)
  Bus type: 1

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

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)
  Bus type: 3

Device Found
  type: 1915 1025
  path: \\?\hid#vid_1915&pid_1025&mi_03&col04#8&33bf0c65&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: ZY.Ltd
  Product:      ZY Control Mic
  Release:      173
  Interface:    3
  Usage (page): 0x0 (0xff00)
  Bus type: 1

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

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

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)
  Bus type: 255

unable to open device

mcuee avatar Jul 25 '21 01:07 mcuee

With added debug print, so I think the latest update is good.


diff --git a/windows/hid.c b/windows/hid.c
index 2631382..23d2acf 100644
--- a/windows/hid.c
+++ b/windows/hid.c
@@ -417,7 +417,7 @@ static void hid_internal_get_info(struct hid_device_info* dev)
        {
                /* Normalize to upper case */
                for (wchar_t* p = compatible_id; *p; ++p) *p = towupper(*p);
-
+               wprintf(L"DEVPKEY_Device_CompatibleId: %s\n", compatible_id);
                /* USB devices
                   https://docs.microsoft.com/windows-hardware/drivers/hid/plug-and-play-support
                   https://docs.microsoft.com/windows-hardware/drivers/install/standard-usb-identifiers *
click to expand
C:\work\hid\hidapi_djm\windows\x64\Release [hid_bus_type ≡]> .\hidtest.exe
hidapi test/example tool. Compiled with hidapi version 0.11.0, runtime version 0.11.0.
Compile-time version matches runtime version of hidapi.

DEVPKEY_Device_CompatibleId: USB\CLASS_03&SUBCLASS_01&PROT_02
DEVPKEY_Device_CompatibleId: USB\CLASS_03&SUBCLASS_01&PROT_02
DEVPKEY_Device_CompatibleId: USB\CLASS_03&SUBCLASS_01&PROT_02
DEVPKEY_Device_CompatibleId: USB\CLASS_03&SUBCLASS_01&PROT_02
DEVPKEY_Device_CompatibleId: ACPI\PNP0C50
DEVPKEY_Device_CompatibleId: PTP_HID_DEVICE
DEVPKEY_Device_CompatibleId: USB\CLASS_03&SUBCLASS_01&PROT_02
DEVPKEY_Device_CompatibleId: PTP_HID_DEVICE
DEVPKEY_Device_CompatibleId: ACPI\PNP0C50
DEVPKEY_Device_CompatibleId: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}
DEVPKEY_Device_CompatibleId: ACPI\PNP0C50
DEVPKEY_Device_CompatibleId: USB\CLASS_03&SUBCLASS_01&PROT_01
DEVPKEY_Device_CompatibleId: ACPI\PNP0C50
DEVPKEY_Device_CompatibleId: USB\CLASS_03&SUBCLASS_00&PROT_00
DEVPKEY_Device_CompatibleId: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}
DEVPKEY_Device_CompatibleId: USB\CLASS_03&SUBCLASS_00&PROT_00
DEVPKEY_Device_CompatibleId: USB\CLASS_03&SUBCLASS_01&PROT_01
DEVPKEY_Device_CompatibleId: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}
DEVPKEY_Device_CompatibleId: USB\CLASS_03&SUBCLASS_00&PROT_00
DEVPKEY_Device_CompatibleId: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}
DEVPKEY_Device_CompatibleId: ACPI\PNP0C50
DEVPKEY_Device_CompatibleId: USB\CLASS_03&SUBCLASS_00&PROT_00
DEVPKEY_Device_CompatibleId: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}
DEVPKEY_Device_CompatibleId: BTHENUM\{00001124-0000-1000-8000-00805F9B34FB}
Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col01#7&383a3a17&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x2 (0x1)
  Bus type: 1

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col02#7&383a3a17&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x1 (0xc)
  Bus type: 1

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col03#7&383a3a17&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x80 (0x1)
  Bus type: 1

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col04#7&383a3a17&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x1 (0xff00)
  Bus type: 1

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)
  Bus type: 3

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)
  Bus type: 255

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)
  Bus type: 255

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col05#7&383a3a17&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x2 (0xff00)
  Bus type: 1

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)
  Bus type: 255

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)
  Bus type: 255

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)
  Bus type: 3

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)
  Bus type: 255

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)
  Bus type: 255

Device Found
  type: 046d b010
  path: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}_vid&0002046d_pid&b010&col05#8&1cf1c1b9&2&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)
  Bus type: 2

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)
  Bus type: 3

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_00#7&1c54b96&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    0
  Usage (page): 0x6 (0x1)
  Bus type: 1

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)
  Bus type: 3

Device Found
  type: 1915 1025
  path: \\?\hid#vid_1915&pid_1025&mi_03&col01#8&33bf0c65&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: ZY.Ltd
  Product:      ZY Control Mic
  Release:      173
  Interface:    3
  Usage (page): 0x2 (0x1)
  Bus type: 1

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

Device Found
  type: 1915 1025
  path: \\?\hid#vid_1915&pid_1025&mi_03&col02#8&33bf0c65&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: ZY.Ltd
  Product:      ZY Control Mic
  Release:      173
  Interface:    3
  Usage (page): 0x1 (0xc)
  Bus type: 1

Device Found
  type: 1915 1025
  path: \\?\hid#vid_1915&pid_1025&mi_02#8&b545e9c&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd
  serial_number:
  Manufacturer: ZY.Ltd
  Product:      ZY Control Mic
  Release:      173
  Interface:    2
  Usage (page): 0x6 (0x1)
  Bus type: 1

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

Device Found
  type: 1915 1025
  path: \\?\hid#vid_1915&pid_1025&mi_03&col03#8&33bf0c65&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: ZY.Ltd
  Product:      ZY Control Mic
  Release:      173
  Interface:    3
  Usage (page): 0x80 (0x1)
  Bus type: 1

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

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)
  Bus type: 3

Device Found
  type: 1915 1025
  path: \\?\hid#vid_1915&pid_1025&mi_03&col04#8&33bf0c65&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: ZY.Ltd
  Product:      ZY Control Mic
  Release:      173
  Interface:    3
  Usage (page): 0x0 (0xff00)
  Bus type: 1

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

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

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)
  Bus type: 255

unable to open device

mcuee avatar Jul 25 '21 01:07 mcuee

It is also good for BLE device.

Device Found
  type: 16c0 05df
  path: \\?\hid#{00001812-0000-1000-8000-00805f9b34fb}_dev_vid&0216c0_pid&05df_rev&0100_30aea44c4efa#9&38bb9e5a&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      100
  Interface:    -1
  Usage (page): 0x100 (0xff00)
  Bus type: 2

Device Found
  type: 16c0 05df
  path: \\?\hid#{00001812-0000-1000-8000-00805f9b34fb}_dev_vid&0216c0_pid&05df_rev&0100_30aea44c4efa#9&f97cf65&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      100
  Interface:    -1
  Usage (page): 0x1 (0xc)
  Bus type: 2

mcuee avatar Jul 25 '21 06:07 mcuee

@mcuee

As for the hidraw backend, on one hand it seems to work, but on the other hand, many reports bus type "0". Is this expected by your design?

I have fixed it. Please check when you have a time.

DJm00n avatar Jul 26 '21 08:07 DJm00n

@DJm00n Yes the latest git is okay for Linux (tested with my Raspberry Pi 400 running Ubuntu 64bit Linux).

hidapi_djm/build on  hid_bus_type [?] via △ v3.18.4 ❯ ./hidtest/hidtest_hidraw
hidapi test/example tool. Compiled with hidapi version 0.11.0, runtime version 0.11.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 046d 101b
  path: /dev/hidraw3
  serial_number: 101b-ae-8a-0c-8c
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x2 (0x1)
  Bus type: 1

Device Found
  type: 046d 101b
  path: /dev/hidraw3
  serial_number: 101b-ae-8a-0c-8c
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x1 (0x1)
  Bus type: 1

Device Found
  type: 046d 101b
  path: /dev/hidraw3
  serial_number: 101b-ae-8a-0c-8c
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x1 (0xff00)
  Bus type: 1

Device Found
  type: 046d 101b
  path: /dev/hidraw3
  serial_number: 101b-ae-8a-0c-8c
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x2 (0xff00)
  Bus type: 1

Device Found
  type: 046d 101b
  path: /dev/hidraw3
  serial_number: 101b-ae-8a-0c-8c
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x4 (0xff00)
  Bus type: 1

Device Found
  type: 046d 2008
  path: /dev/hidraw4
  serial_number: 2008-b6-b4-d3-96
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x6 (0x1)
  Bus type: 1

Device Found
  type: 046d 2008
  path: /dev/hidraw4
  serial_number: 2008-b6-b4-d3-96
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x1 (0xc)
  Bus type: 1

Device Found
  type: 046d 2008
  path: /dev/hidraw4
  serial_number: 2008-b6-b4-d3-96
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x80 (0x1)
  Bus type: 1

Device Found
  type: 046d 2008
  path: /dev/hidraw4
  serial_number: 2008-b6-b4-d3-96
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x88 (0xffbc)
  Bus type: 1

Device Found
  type: 046d 2008
  path: /dev/hidraw4
  serial_number: 2008-b6-b4-d3-96
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x1 (0xff00)
  Bus type: 1

Device Found
  type: 046d 2008
  path: /dev/hidraw4
  serial_number: 2008-b6-b4-d3-96
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x2 (0xff00)
  Bus type: 1

Device Found
  type: 046d 2008
  path: /dev/hidraw4
  serial_number: 2008-b6-b4-d3-96
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x4 (0xff00)
  Bus type: 1

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

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

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

Device Found
  type: 04d9 0007
  path: /dev/hidraw0
  serial_number: 
  Manufacturer:  
  Product:      Raspberry Pi Internal Keyboard
  Release:      161
  Interface:    0
  Usage (page): 0x6 (0x1)
  Bus type: 1

Device Found
  type: 04d9 0007
  path: /dev/hidraw1
  serial_number: 
  Manufacturer:  
  Product:      Raspberry Pi Internal Keyboard
  Release:      161
  Interface:    1
  Usage (page): 0x1 (0xc)
  Bus type: 1

unable to open device

mcuee avatar Jul 26 '21 13:07 mcuee

@Youw could you please review the code?

DJm00n avatar Jul 26 '21 13:07 DJm00n

@DJm00n You may want to disable the following warnings.

1>C:\work\hid\hidapi_bustype\windows\hid.c(423,6): warning C4996: 'mbstowcs': This function or variable may be unsafe. Consider using mbstowcs_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>C:\work\hid\hidapi_bustype\windows\hid.c(1169,2): warning C4996: 'wcsncpy': This function or variable may be unsafe. Consider using wcsncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>C:\work\hid\hidapi_bustype\windows\hid.c(1179,2): warning C4996: 'wcsncpy': This function or variable may be unsafe. Consider using wcsncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>C:\work\hid\hidapi_bustype\windows\hid.c(1189,2): warning C4996: 'wcsncpy': This function or variable may be unsafe. Consider using wcsncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

mcuee avatar Aug 06 '21 05:08 mcuee

Maybe this one can be considered for next release 0.12? Or maybe 0.13?

mcuee avatar Feb 06 '22 03:02 mcuee

Hey @Youw!

I have added MacOS implementation (KUDOS @JoergAtGithub) and updated this PR. Need someone who can test MacOS implementation.

DJm00n avatar Jul 14 '22 19:07 DJm00n

Sample on my mac machine:

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: 05ac 0341
  path: DevSrvsID:4294969267
  serial_number: FM714170104N4Q8BG+EMN
  Manufacturer: Apple Inc.
  Product:      Apple Internal Keyboard / Trackpad
  Release:      175
  Interface:    -1
  Usage (page): 0x2 (0x1)
  Bus type: 4

Device Found
  type: 05ac 0341
  path: DevSrvsID:4294969267
  serial_number: FM714170104N4Q8BG+EMN
  Manufacturer: Apple Inc.
  Product:      Apple Internal Keyboard / Trackpad
  Release:      175
  Interface:    -1
  Usage (page): 0x1 (0x1)
  Bus type: 4

Device Found
  type: 05ac 0341
  path: DevSrvsID:4294969267
  serial_number: FM714170104N4Q8BG+EMN
  Manufacturer: Apple Inc.
  Product:      Apple Internal Keyboard / Trackpad
  Release:      175
  Interface:    -1
  Usage (page): 0x5 (0xd)
  Bus type: 4

Device Found
  type: 05ac 0341
  path: DevSrvsID:4294969267
  serial_number: FM714170104N4Q8BG+EMN
  Manufacturer: Apple Inc.
  Product:      Apple Internal Keyboard / Trackpad
  Release:      175
  Interface:    -1
  Usage (page): 0xc (0xff00)
  Bus type: 4

Device Found
  type: 0000 0000
  path: DevSrvsID:4294968672
  serial_number: 
  Manufacturer: Apple
  Product:      
  Release:      0
  Interface:    -1
  Usage (page): 0x4 (0xff00)
  Bus type: 255

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

Device Found
  type: 05ac 0341
  path: DevSrvsID:4294970482
  serial_number: 
  Manufacturer: 
  Product:      Keyboard Backlight
  Release:      0
  Interface:    -1
  Usage (page): 0xf (0xff00)
  Bus type: 1

Device Found
  type: 05ac 0341
  path: DevSrvsID:4294969269
  serial_number: FM714170104N4Q8BG+EMN
  Manufacturer: Apple Inc.
  Product:      Apple Internal Keyboard / Trackpad
  Release:      175
  Interface:    -1
  Usage (page): 0xd (0xff00)
  Bus type: 4

Device Found
  type: 05ac 0341
  path: DevSrvsID:4294969271
  serial_number: FM714170104N4Q8BG+EMN
  Manufacturer: Apple Inc.
  Product:      Apple Internal Keyboard / Trackpad
  Release:      175
  Interface:    -1
  Usage (page): 0x3 (0xff00)
  Bus type: 4

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

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

Device Found
  type: 05ac 8600
  path: DevSrvsID:4294970620
  serial_number: 
  Manufacturer: 
  Product:      TouchBarUserDevice
  Release:      0
  Interface:    -1
  Usage (page): 0x6 (0x1)
  Bus type: 255

Device Found
  type: 05ac 0341
  path: DevSrvsID:4294969264
  serial_number: FM714170104N4Q8BG+EMN
  Manufacturer: Apple Inc.
  Product:      Apple Internal Keyboard / Trackpad
  Release:      175
  Interface:    -1
  Usage (page): 0x6 (0x1)
  Bus type: 4

Device Found
  type: 0000 0000
  path: DevSrvsID:4294969290
  serial_number: 
  Manufacturer: Apple
  Product:      
  Release:      0
  Interface:    -1
  Usage (page): 0x4 (0xd)
  Bus type: 4

Device Found
  type: 05ac 0341
  path: DevSrvsID:4294969259
  serial_number: FM714170104N4Q8BG+EMN
  Manufacturer: Apple Inc.
  Product:      Apple Internal Keyboard / Trackpad
  Release:      175
  Interface:    -1
  Usage (page): 0xb (0xff00)
  Bus type: 4

unable to open device

Youw avatar Jul 14 '22 22:07 Youw

How is the headset connected?

JoergAtGithub avatar Jul 14 '22 22:07 JoergAtGithub