Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hid_device_info->interface_number zero on macOS 13.3 #531

Closed
mcuee opened this issue Apr 15, 2023 Discussed in #527 · 17 comments · Fixed by #534 or BitBoxSwiss/bitbox02-firmware#1073
Closed

hid_device_info->interface_number zero on macOS 13.3 #531

mcuee opened this issue Apr 15, 2023 Discussed in #527 · 17 comments · Fixed by #534 or BitBoxSwiss/bitbox02-firmware#1073
Labels
macOS Related to macOS backend

Comments

@mcuee
Copy link
Member

mcuee commented Apr 15, 2023

Discussed in #527

Originally posted by dingsijie-nreal April 11, 2023
I've noticed comment here: https://github.com/libusb/hidapi/blob/master/mac/hid.c#L543
The interesting thing is: macOS Monterey(12.6.3) works perfectly with my usb gadget, I got expected interface numbers.
the output of test.c is shown below:

hidapi test/example tool. Compiled with hidapi version 0.14.0, runtime ve
Compile-time version matches runtime version of hidapi.

Device Found
  type: 3318 0424
  path: DevSrvsID:4298350859
  serial_number: A00016:33:33
  Manufacturer: xxxx
  Product:    xxxx
  Release:      1
  Interface:    3
  Usage (page): 0x0 (0x41)
  Bus type: 1

  Report Descriptor: (27 bytes)
0x05, 0x41, 0x09, 0x00, 0xa1, 0x01, 0x15, 0x00, 0x25, 0xff, 
0x19, 0x01, 0x29, 0x08, 0x95, 0x40, 0x75, 0x08, 0x81, 0x02, 
0x19, 0x01, 0x29, 0x08, 0x91, 0x02, 0xc0, 
Device Found
  type: 3318 0424
  path: DevSrvsID:4298350872
  serial_number: A00016:33:33
  Manufacturer: xxxx
  Product:      xxxxx
  Release:      1
  Interface:    5
  Usage (page): 0x0 (0x41)
  Bus type: 1

  Report Descriptor: (27 bytes)
0x05, 0x41, 0x09, 0x00, 0xa1, 0x01, 0x15, 0x00, 0x25, 0xff, 
0x19, 0x01, 0x29, 0x08, 0x95, 0x40, 0x75, 0x08, 0x81, 0x02, 
0x19, 0x01, 0x29, 0x08, 0x91, 0x02, 0xc0, 
Device Found
  type: 3318 0424
  path: DevSrvsID:4298350862
  serial_number: A00016:33:33
  Manufacturer: xxxx
  Product:      xxxxx
  Release:      1
  Interface:    4
  Usage (page): 0x0 (0x41)
  Bus type: 1

  Report Descriptor: (27 bytes)
0x05, 0x41, 0x09, 0x00, 0xa1, 0x01, 0x15, 0x00, 0x25, 0xff, 
0x19, 0x01, 0x29, 0x08, 0x95, 0x40, 0x75, 0x08, 0x81, 0x02, 
0x19, 0x01, 0x29, 0x08, 0x91, 0x02, 0xc0, 

But, after upgrading to macOS 13.3 the result changes to flowing:

hidapi test/example tool. Compiled with hidapi version 0.14.0, runtime version 0.14.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 3318 0424
  path: DevSrvsID:4294984005
  serial_number: A00016:33:33
  Manufacturer: xxxxx
  Product:      xxxxx
  Release:      1
  Interface:    0
  Usage (page): 0x0 (0x41)
  Bus type: 1

  Report Descriptor: (27 bytes)
0x05, 0x41, 0x09, 0x00, 0xa1, 0x01, 0x15, 0x00, 0x25, 0xff, 
0x19, 0x01, 0x29, 0x08, 0x95, 0x40, 0x75, 0x08, 0x81, 0x02, 
0x19, 0x01, 0x29, 0x08, 0x91, 0x02, 0xc0, 
Device Found
  type: 3318 0424
  path: DevSrvsID:4294984010
  serial_number: A00016:33:33
  Manufacturer: xxxxx
  Product:      xxxxx
  Release:      1
  Interface:    0
  Usage (page): 0x0 (0x41)
  Bus type: 1

  Report Descriptor: (27 bytes)
0x05, 0x41, 0x09, 0x00, 0xa1, 0x01, 0x15, 0x00, 0x25, 0xff, 
0x19, 0x01, 0x29, 0x08, 0x95, 0x40, 0x75, 0x08, 0x81, 0x02, 
0x19, 0x01, 0x29, 0x08, 0x91, 0x02, 0xc0, 
Device Found
  type: 3318 0424
  path: DevSrvsID:4294984008
  serial_number: A00016:33:33
  Manufacturer: xxxxx
  Product:      xxxxx
  Release:      1
  Interface:    0
  Usage (page): 0x0 (0x41)
  Bus type: 1

  Report Descriptor: (27 bytes)
0x05, 0x41, 0x09, 0x00, 0xa1, 0x01, 0x15, 0x00, 0x25, 0xff, 
0x19, 0x01, 0x29, 0x08, 0x95, 0x40, 0x75, 0x08, 0x81, 0x02, 
0x19, 0x01, 0x29, 0x08, 0x91, 0x02, 0xc0, 

My mission it to discriminate 3 different components on my USB gadget, and the interface number was the key that I rely on.
But with 0 interfaces numbers, I don't know how to do my job.
Any one get any ideas? Thanks a lot.

@mcuee mcuee added the macOS Related to macOS backend label Apr 15, 2023
@mcuee
Copy link
Member Author

mcuee commented Apr 15, 2023

I think this is a real issue.

Last time I can get proper interface number on my Mac Mini M1.
#249 (comment)

With the latest macOS Ventura 13.3.1 on my Mac Mini M1, interface number becomes 0 for the Logitech USB receiver (046d:c52b).

mcuee@mcuees-Mac-mini hidapi % ./hidtest/hidtest
Password:
hidapi test/example tool. Compiled with hidapi version 0.14.0, runtime version 0.14.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 046d c52b
  path: DevSrvsID:4294970451
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    0
  Usage (page): 0x2 (0x1)
  Bus type: 1

  Report Descriptor: (148 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 
0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x10, 0x15, 0x00, 
0x25, 0x01, 0x95, 0x10, 0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 
0x09, 0x30, 0x09, 0x31, 0x81, 0x06, 0x15, 0x81, 0x25, 0x7f, 
0x75, 0x08, 0x95, 0x01, 0x09, 0x38, 0x81, 0x06, 0x05, 0x0c, 
0x0a, 0x38, 0x02, 0x95, 0x01, 0x81, 0x06, 0xc0, 0xc0, 0x05, 
0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x75, 0x10, 0x95, 
0x02, 0x15, 0x01, 0x26, 0xff, 0x02, 0x19, 0x01, 0x2a, 0xff, 
0x02, 0x81, 0x00, 0xc0, 0x05, 0x01, 0x09, 0x80, 0xa1, 0x01, 
0x85, 0x04, 0x75, 0x02, 0x95, 0x01, 0x15, 0x01, 0x25, 0x03, 
0x09, 0x82, 0x09, 0x81, 0x09, 0x83, 0x81, 0x60, 0x75, 0x06, 
0x81, 0x03, 0xc0, 0x06, 0xbc, 0xff, 0x09, 0x88, 0xa1, 0x01, 
0x85, 0x08, 0x19, 0x01, 0x29, 0xff, 0x15, 0x01, 0x26, 0xff, 
0x00, 0x75, 0x08, 0x95, 0x01, 0x81, 0x00, 0xc0, 
Device Found
  type: 046d c52b
  path: DevSrvsID:4294970451
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    0
  Usage (page): 0x1 (0x1)
  Bus type: 1

  Report Descriptor: (148 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 
0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x10, 0x15, 0x00, 
0x25, 0x01, 0x95, 0x10, 0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 
0x09, 0x30, 0x09, 0x31, 0x81, 0x06, 0x15, 0x81, 0x25, 0x7f, 
0x75, 0x08, 0x95, 0x01, 0x09, 0x38, 0x81, 0x06, 0x05, 0x0c, 
0x0a, 0x38, 0x02, 0x95, 0x01, 0x81, 0x06, 0xc0, 0xc0, 0x05, 
0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x75, 0x10, 0x95, 
0x02, 0x15, 0x01, 0x26, 0xff, 0x02, 0x19, 0x01, 0x2a, 0xff, 
0x02, 0x81, 0x00, 0xc0, 0x05, 0x01, 0x09, 0x80, 0xa1, 0x01, 
0x85, 0x04, 0x75, 0x02, 0x95, 0x01, 0x15, 0x01, 0x25, 0x03, 
0x09, 0x82, 0x09, 0x81, 0x09, 0x83, 0x81, 0x60, 0x75, 0x06, 
0x81, 0x03, 0xc0, 0x06, 0xbc, 0xff, 0x09, 0x88, 0xa1, 0x01, 
0x85, 0x08, 0x19, 0x01, 0x29, 0xff, 0x15, 0x01, 0x26, 0xff, 
0x00, 0x75, 0x08, 0x95, 0x01, 0x81, 0x00, 0xc0, 
Device Found
  type: 046d c52b
  path: DevSrvsID:4294970451
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    0
  Usage (page): 0x1 (0xc)
  Bus type: 1

  Report Descriptor: (148 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 
0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x10, 0x15, 0x00, 
0x25, 0x01, 0x95, 0x10, 0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 
0x09, 0x30, 0x09, 0x31, 0x81, 0x06, 0x15, 0x81, 0x25, 0x7f, 
0x75, 0x08, 0x95, 0x01, 0x09, 0x38, 0x81, 0x06, 0x05, 0x0c, 
0x0a, 0x38, 0x02, 0x95, 0x01, 0x81, 0x06, 0xc0, 0xc0, 0x05, 
0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x75, 0x10, 0x95, 
0x02, 0x15, 0x01, 0x26, 0xff, 0x02, 0x19, 0x01, 0x2a, 0xff, 
0x02, 0x81, 0x00, 0xc0, 0x05, 0x01, 0x09, 0x80, 0xa1, 0x01, 
0x85, 0x04, 0x75, 0x02, 0x95, 0x01, 0x15, 0x01, 0x25, 0x03, 
0x09, 0x82, 0x09, 0x81, 0x09, 0x83, 0x81, 0x60, 0x75, 0x06, 
0x81, 0x03, 0xc0, 0x06, 0xbc, 0xff, 0x09, 0x88, 0xa1, 0x01, 
0x85, 0x08, 0x19, 0x01, 0x29, 0xff, 0x15, 0x01, 0x26, 0xff, 
0x00, 0x75, 0x08, 0x95, 0x01, 0x81, 0x00, 0xc0, 
Device Found
  type: 046d c52b
  path: DevSrvsID:4294970451
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    0
  Usage (page): 0x80 (0x1)
  Bus type: 1

  Report Descriptor: (148 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 
0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x10, 0x15, 0x00, 
0x25, 0x01, 0x95, 0x10, 0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 
0x09, 0x30, 0x09, 0x31, 0x81, 0x06, 0x15, 0x81, 0x25, 0x7f, 
0x75, 0x08, 0x95, 0x01, 0x09, 0x38, 0x81, 0x06, 0x05, 0x0c, 
0x0a, 0x38, 0x02, 0x95, 0x01, 0x81, 0x06, 0xc0, 0xc0, 0x05, 
0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x75, 0x10, 0x95, 
0x02, 0x15, 0x01, 0x26, 0xff, 0x02, 0x19, 0x01, 0x2a, 0xff, 
0x02, 0x81, 0x00, 0xc0, 0x05, 0x01, 0x09, 0x80, 0xa1, 0x01, 
0x85, 0x04, 0x75, 0x02, 0x95, 0x01, 0x15, 0x01, 0x25, 0x03, 
0x09, 0x82, 0x09, 0x81, 0x09, 0x83, 0x81, 0x60, 0x75, 0x06, 
0x81, 0x03, 0xc0, 0x06, 0xbc, 0xff, 0x09, 0x88, 0xa1, 0x01, 
0x85, 0x08, 0x19, 0x01, 0x29, 0xff, 0x15, 0x01, 0x26, 0xff, 
0x00, 0x75, 0x08, 0x95, 0x01, 0x81, 0x00, 0xc0, 
Device Found
  type: 046d c52b
  path: DevSrvsID:4294970451
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    0
  Usage (page): 0x88 (0xffbc)
  Bus type: 1

  Report Descriptor: (148 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 
0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x10, 0x15, 0x00, 
0x25, 0x01, 0x95, 0x10, 0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 
0x09, 0x30, 0x09, 0x31, 0x81, 0x06, 0x15, 0x81, 0x25, 0x7f, 
0x75, 0x08, 0x95, 0x01, 0x09, 0x38, 0x81, 0x06, 0x05, 0x0c, 
0x0a, 0x38, 0x02, 0x95, 0x01, 0x81, 0x06, 0xc0, 0xc0, 0x05, 
0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x75, 0x10, 0x95, 
0x02, 0x15, 0x01, 0x26, 0xff, 0x02, 0x19, 0x01, 0x2a, 0xff, 
0x02, 0x81, 0x00, 0xc0, 0x05, 0x01, 0x09, 0x80, 0xa1, 0x01, 
0x85, 0x04, 0x75, 0x02, 0x95, 0x01, 0x15, 0x01, 0x25, 0x03, 
0x09, 0x82, 0x09, 0x81, 0x09, 0x83, 0x81, 0x60, 0x75, 0x06, 
0x81, 0x03, 0xc0, 0x06, 0xbc, 0xff, 0x09, 0x88, 0xa1, 0x01, 
0x85, 0x08, 0x19, 0x01, 0x29, 0xff, 0x15, 0x01, 0x26, 0xff, 
0x00, 0x75, 0x08, 0x95, 0x01, 0x81, 0x00, 0xc0, 
Device Found
  type: 046d c52b
  path: DevSrvsID:4294970444
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    0
  Usage (page): 0x6 (0x1)
  Bus type: 1

  Report Descriptor: (59 bytes)
0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07, 0x19, 0xe0, 
0x29, 0xe7, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 
0x81, 0x02, 0x81, 0x03, 0x95, 0x05, 0x05, 0x08, 0x19, 0x01, 
0x29, 0x05, 0x91, 0x02, 0x95, 0x01, 0x75, 0x03, 0x91, 0x01, 
0x95, 0x06, 0x75, 0x08, 0x15, 0x00, 0x26, 0xa4, 0x00, 0x05, 
0x07, 0x19, 0x00, 0x2a, 0xa4, 0x00, 0x81, 0x00, 0xc0, 

Device Found
  type: 046d c52b
  path: DevSrvsID:4294970448
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    -1
  Usage (page): 0x1 (0xff00)
  Bus type: 1

  Report Descriptor: (98 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x10, 0x75, 
0x08, 0x95, 0x06, 0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 0x01, 
0x81, 0x00, 0x09, 0x01, 0x91, 0x00, 0xc0, 0x06, 0x00, 0xff, 
0x09, 0x02, 0xa1, 0x01, 0x85, 0x11, 0x75, 0x08, 0x95, 0x13, 
0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 0x02, 0x81, 0x00, 0x09, 
0x02, 0x91, 0x00, 0xc0, 0x06, 0x00, 0xff, 0x09, 0x04, 0xa1, 
0x01, 0x85, 0x20, 0x75, 0x08, 0x95, 0x0e, 0x15, 0x00, 0x26, 
0xff, 0x00, 0x09, 0x41, 0x81, 0x00, 0x09, 0x41, 0x91, 0x00, 
0x85, 0x21, 0x95, 0x1f, 0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 
0x42, 0x81, 0x00, 0x09, 0x42, 0x91, 0x00, 0xc0, 
Device Found
  type: 046d c52b
  path: DevSrvsID:4294970448
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    -1
  Usage (page): 0x2 (0xff00)
  Bus type: 1

  Report Descriptor: (98 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x10, 0x75, 
0x08, 0x95, 0x06, 0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 0x01, 
0x81, 0x00, 0x09, 0x01, 0x91, 0x00, 0xc0, 0x06, 0x00, 0xff, 
0x09, 0x02, 0xa1, 0x01, 0x85, 0x11, 0x75, 0x08, 0x95, 0x13, 
0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 0x02, 0x81, 0x00, 0x09, 
0x02, 0x91, 0x00, 0xc0, 0x06, 0x00, 0xff, 0x09, 0x04, 0xa1, 
0x01, 0x85, 0x20, 0x75, 0x08, 0x95, 0x0e, 0x15, 0x00, 0x26, 
0xff, 0x00, 0x09, 0x41, 0x81, 0x00, 0x09, 0x41, 0x91, 0x00, 
0x85, 0x21, 0x95, 0x1f, 0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 
0x42, 0x81, 0x00, 0x09, 0x42, 0x91, 0x00, 0xc0, 
Device Found
  type: 046d c52b
  path: DevSrvsID:4294970448
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    -1
  Usage (page): 0x4 (0xff00)
  Bus type: 1

  Report Descriptor: (98 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x10, 0x75, 
0x08, 0x95, 0x06, 0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 0x01, 
0x81, 0x00, 0x09, 0x01, 0x91, 0x00, 0xc0, 0x06, 0x00, 0xff, 
0x09, 0x02, 0xa1, 0x01, 0x85, 0x11, 0x75, 0x08, 0x95, 0x13, 
0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 0x02, 0x81, 0x00, 0x09, 
0x02, 0x91, 0x00, 0xc0, 0x06, 0x00, 0xff, 0x09, 0x04, 0xa1, 
0x01, 0x85, 0x20, 0x75, 0x08, 0x95, 0x0e, 0x15, 0x00, 0x26, 
0xff, 0x00, 0x09, 0x41, 0x81, 0x00, 0x09, 0x41, 0x91, 0x00, 
0x85, 0x21, 0x95, 0x1f, 0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 
0x42, 0x81, 0x00, 0x09, 0x42, 0x91, 0x00, 0xc0,

Device Found
  type: 046d 1000
  path: DevSrvsID:4294971188
  serial_number: 
  Manufacturer: Logitech
  Product:      LogiVirtualHIDDevice
  Release:      1
  Interface:    -1
  Usage (page): 0x2 (0x1)
  Bus type: 0

  Report Descriptor: (69 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 
0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x10, 0x15, 0x00, 
0x25, 0x01, 0x95, 0x10, 0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 
0x09, 0x30, 0x09, 0x31, 0x81, 0x06, 0x15, 0x81, 0x25, 0x7f, 
0x75, 0x08, 0x95, 0x01, 0x09, 0x38, 0x81, 0x06, 0x05, 0x0c, 
0x0a, 0x38, 0x02, 0x95, 0x01, 0x81, 0x06, 0xc0, 0xc0, 
Device Found
  type: 046d 1000
  path: DevSrvsID:4294971188
  serial_number: 
  Manufacturer: Logitech
  Product:      LogiVirtualHIDDevice
  Release:      1
  Interface:    -1
  Usage (page): 0x1 (0x1)
  Bus type: 0

  Report Descriptor: (69 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 
0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x10, 0x15, 0x00, 
0x25, 0x01, 0x95, 0x10, 0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 
0x09, 0x30, 0x09, 0x31, 0x81, 0x06, 0x15, 0x81, 0x25, 0x7f, 
0x75, 0x08, 0x95, 0x01, 0x09, 0x38, 0x81, 0x06, 0x05, 0x0c, 
0x0a, 0x38, 0x02, 0x95, 0x01, 0x81, 0x06, 0xc0, 0xc0, 
unable to open device

@mcuee
Copy link
Member Author

mcuee commented Apr 15, 2023

From @dingsijie-nreal

Well, I noticed this PR #530 It was submitted by one of my coworkers. The PR is a workaround we found. For now I think

cur_dev->interface_number = get_int_property(dev, CFSTR(kUSBInterfaceNumber));

is the
only "proper" way to get the interface number. But it just doesn't work on the latest macOS.
We've posted a question at https://developer.apple.com/forums/thread/728001.
No one replys... Maybe you can also have a look at the post, and say something there.

@mcuee
Copy link
Member Author

mcuee commented Apr 15, 2023

@Youw @dingsijie-nreal @pengxianheng-nreal

Somehow libusb is able to print the interface number.

mcuee@mcuees-Mac-mini libusb % ./examples/xusb 046d:c52b
Using libusb v1.0.26.11791

Opening device 046D:C52B...

Reading device descriptor:
            length: 18
      device class: 0
               S/N: 0
           VID:PID: 046D:C52B
         bcdDevice: 2410
   iMan:iProd:iSer: 1:2:0
          nb confs: 1

Reading BOS descriptor: no descriptor

Reading first configuration descriptor:
              total length: 84
         descriptor length: 9
             nb interfaces: 3
              interface[0]: id = 0
interface[0].altsetting[0]: num endpoints = 1
   Class.SubClass.Protocol: 03.01.01
       endpoint[0].address: 81
           max packet size: 0008
          polling interval: 08
              interface[1]: id = 1
interface[1].altsetting[0]: num endpoints = 1
   Class.SubClass.Protocol: 03.01.02
       endpoint[0].address: 82
           max packet size: 0008
          polling interval: 02
              interface[2]: id = 2
interface[2].altsetting[0]: num endpoints = 1
   Class.SubClass.Protocol: 03.00.00
       endpoint[0].address: 83
           max packet size: 0020
          polling interval: 02

Kernel driver attached for interface 0: yes

Claiming interface 0...
libusb: info [darwin_detach_kernel_driver] no capture entitlements. may not be able to detach the kernel driver for this device
libusb: warning [darwin_detach_kernel_driver] USB device capture requires either an entitlement (com.apple.vm.device-access) or root privilege
libusb: info [darwin_capture_claim_interface] failed to auto-detach the kernel driver for this device, ret=-3
libusb: info [darwin_claim_interface] USBInterfaceOpen: another process has device opened for exclusive access
   Failed (error 1) Other error

Kernel driver attached for interface 1: yes

Claiming interface 1...
libusb: info [darwin_detach_kernel_driver] no capture entitlements. may not be able to detach the kernel driver for this device
libusb: warning [darwin_detach_kernel_driver] USB device capture requires either an entitlement (com.apple.vm.device-access) or root privilege
libusb: info [darwin_capture_claim_interface] failed to auto-detach the kernel driver for this device, ret=-3
libusb: info [darwin_claim_interface] USBInterfaceOpen: another process has device opened for exclusive access
   Failed (error 1) Other error

Kernel driver attached for interface 2: yes

Claiming interface 2...
libusb: info [darwin_detach_kernel_driver] no capture entitlements. may not be able to detach the kernel driver for this device
libusb: warning [darwin_detach_kernel_driver] USB device capture requires either an entitlement (com.apple.vm.device-access) or root privilege
libusb: info [darwin_capture_claim_interface] failed to auto-detach the kernel driver for this device, ret=-3
libusb: info [darwin_claim_interface] USBInterfaceOpen: another process has device opened for exclusive access
   Failed (error 1) Other error

Reading string descriptors:
   String (0x01): "Logitech"
   String (0x02): "USB Receiver"

Reading OS string descriptor: no descriptor

Reading interface association descriptors (IADs) for first configuration:
    nb IADs: 0

Releasing interface 0...
Releasing interface 1...
Releasing interface 2...
Closing device...
mcuee@mcuees-Mac-mini hidapi % lsusb -v -d 046d:c52b

Bus 002 Device 020: ID 046d:c52b  
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        32
  idVendor           0x046d 
  idProduct          0xc52b 
  bcdDevice           24.10
  iManufacturer           1 
  iProduct                2 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0054
    bNumInterfaces          3
    bConfigurationValue     1
    iConfiguration          4 RQR24.10_B0036
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower               98mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 
      bInterfaceSubClass      1 
      bInterfaceProtocol      1 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      59
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               8
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 
      bInterfaceSubClass      1 
      bInterfaceProtocol      2 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     148
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               2
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      98
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval               2
can't get device qualifier: No such file or directory
can't get debug descriptor: No such file or directory
Device Status:     0x0002
  (Bus Powered)
  Remote Wakeup Enabled

mcuee@mcuees-Mac-mini libusb % sudo usbhid-dump -d 046d:c52b
Password:
libusb: info [darwin_detach_kernel_driver] no capture entitlements. may not be able to detach the kernel driver for this device
002:020:002:DESCRIPTOR         1681539895.627480
 06 00 FF 09 01 A1 01 85 10 75 08 95 06 15 00 26
 FF 00 09 01 81 00 09 01 91 00 C0 06 00 FF 09 02
 A1 01 85 11 75 08 95 13 15 00 26 FF 00 09 02 81
 00 09 02 91 00 C0 06 00 FF 09 04 A1 01 85 20 75
 08 95 0E 15 00 26 FF 00 09 41 81 00 09 41 91 00
 85 21 95 1F 15 00 26 FF 00 09 42 81 00 09 42 91
 00 C0

002:020:001:DESCRIPTOR         1681539895.629868
 05 01 09 02 A1 01 85 02 09 01 A1 00 05 09 19 01
 29 10 15 00 25 01 95 10 75 01 81 02 05 01 16 01
 F8 26 FF 07 75 0C 95 02 09 30 09 31 81 06 15 81
 25 7F 75 08 95 01 09 38 81 06 05 0C 0A 38 02 95
 01 81 06 C0 C0 05 0C 09 01 A1 01 85 03 75 10 95
 02 15 01 26 FF 02 19 01 2A FF 02 81 00 C0 05 01
 09 80 A1 01 85 04 75 02 95 01 15 01 25 03 09 82
 09 81 09 83 81 60 75 06 81 03 C0 06 BC FF 09 88
 A1 01 85 08 19 01 29 FF 15 01 26 FF 00 75 08 95
 01 81 00 C0

002:020:000:DESCRIPTOR         1681539895.630954
 05 01 09 06 A1 01 05 07 19 E0 29 E7 15 00 25 01
 75 01 95 08 81 02 81 03 95 05 05 08 19 01 29 05
 91 02 95 01 75 03 91 01 95 06 75 08 15 00 26 A4
 00 05 07 19 00 2A A4 00 81 00 C0

@mcuee
Copy link
Member Author

mcuee commented Apr 15, 2023

PR #530 is a workaround and it seems to work. However, I believe there is a better solution.

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

Device Found
  type: 046d 1000
  path: DevSrvsID:4294971188
  serial_number: 
  Manufacturer: Logitech
  Product:      LogiVirtualHIDDevice
  Release:      1
  Interface:    2
  Usage (page): 0x2 (0x1)
  Bus type: 0

  Report Descriptor: (69 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 
0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x10, 0x15, 0x00, 
0x25, 0x01, 0x95, 0x10, 0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 
0x09, 0x30, 0x09, 0x31, 0x81, 0x06, 0x15, 0x81, 0x25, 0x7f, 
0x75, 0x08, 0x95, 0x01, 0x09, 0x38, 0x81, 0x06, 0x05, 0x0c, 
0x0a, 0x38, 0x02, 0x95, 0x01, 0x81, 0x06, 0xc0, 0xc0, 
Device Found
  type: 046d 1000
  path: DevSrvsID:4294971188
  serial_number: 
  Manufacturer: Logitech
  Product:      LogiVirtualHIDDevice
  Release:      1
  Interface:    2
  Usage (page): 0x1 (0x1)
  Bus type: 0

  Report Descriptor: (69 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 
0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x10, 0x15, 0x00, 
0x25, 0x01, 0x95, 0x10, 0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 
0x09, 0x30, 0x09, 0x31, 0x81, 0x06, 0x15, 0x81, 0x25, 0x7f, 
0x75, 0x08, 0x95, 0x01, 0x09, 0x38, 0x81, 0x06, 0x05, 0x0c, 
0x0a, 0x38, 0x02, 0x95, 0x01, 0x81, 0x06, 0xc0, 0xc0, 
Device Found
  type: 046d c52b
  path: DevSrvsID:4294971164
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x1 (0xff00)
  Bus type: 1

  Report Descriptor: (98 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x10, 0x75, 
0x08, 0x95, 0x06, 0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 0x01, 
0x81, 0x00, 0x09, 0x01, 0x91, 0x00, 0xc0, 0x06, 0x00, 0xff, 
0x09, 0x02, 0xa1, 0x01, 0x85, 0x11, 0x75, 0x08, 0x95, 0x13, 
0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 0x02, 0x81, 0x00, 0x09, 
0x02, 0x91, 0x00, 0xc0, 0x06, 0x00, 0xff, 0x09, 0x04, 0xa1, 
0x01, 0x85, 0x20, 0x75, 0x08, 0x95, 0x0e, 0x15, 0x00, 0x26, 
0xff, 0x00, 0x09, 0x41, 0x81, 0x00, 0x09, 0x41, 0x91, 0x00, 
0x85, 0x21, 0x95, 0x1f, 0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 
0x42, 0x81, 0x00, 0x09, 0x42, 0x91, 0x00, 0xc0, 
Device Found
  type: 046d c52b
  path: DevSrvsID:4294971164
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x2 (0xff00)
  Bus type: 1

  Report Descriptor: (98 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x10, 0x75, 
0x08, 0x95, 0x06, 0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 0x01, 
0x81, 0x00, 0x09, 0x01, 0x91, 0x00, 0xc0, 0x06, 0x00, 0xff, 
0x09, 0x02, 0xa1, 0x01, 0x85, 0x11, 0x75, 0x08, 0x95, 0x13, 
0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 0x02, 0x81, 0x00, 0x09, 
0x02, 0x91, 0x00, 0xc0, 0x06, 0x00, 0xff, 0x09, 0x04, 0xa1, 
0x01, 0x85, 0x20, 0x75, 0x08, 0x95, 0x0e, 0x15, 0x00, 0x26, 
0xff, 0x00, 0x09, 0x41, 0x81, 0x00, 0x09, 0x41, 0x91, 0x00, 
0x85, 0x21, 0x95, 0x1f, 0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 
0x42, 0x81, 0x00, 0x09, 0x42, 0x91, 0x00, 0xc0, 
Device Found
  type: 046d c52b
  path: DevSrvsID:4294971164
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x4 (0xff00)
  Bus type: 1

  Report Descriptor: (98 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x10, 0x75, 
0x08, 0x95, 0x06, 0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 0x01, 
0x81, 0x00, 0x09, 0x01, 0x91, 0x00, 0xc0, 0x06, 0x00, 0xff, 
0x09, 0x02, 0xa1, 0x01, 0x85, 0x11, 0x75, 0x08, 0x95, 0x13, 
0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 0x02, 0x81, 0x00, 0x09, 
0x02, 0x91, 0x00, 0xc0, 0x06, 0x00, 0xff, 0x09, 0x04, 0xa1, 
0x01, 0x85, 0x20, 0x75, 0x08, 0x95, 0x0e, 0x15, 0x00, 0x26, 
0xff, 0x00, 0x09, 0x41, 0x81, 0x00, 0x09, 0x41, 0x91, 0x00, 
0x85, 0x21, 0x95, 0x1f, 0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 
0x42, 0x81, 0x00, 0x09, 0x42, 0x91, 0x00, 0xc0, 
Device Found
  type: 046d c52b
  path: DevSrvsID:4294971160
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    0
  Usage (page): 0x6 (0x1)
  Bus type: 1

  Report Descriptor: (59 bytes)
0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07, 0x19, 0xe0, 
0x29, 0xe7, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 
0x81, 0x02, 0x81, 0x03, 0x95, 0x05, 0x05, 0x08, 0x19, 0x01, 
0x29, 0x05, 0x91, 0x02, 0x95, 0x01, 0x75, 0x03, 0x91, 0x01, 
0x95, 0x06, 0x75, 0x08, 0x15, 0x00, 0x26, 0xa4, 0x00, 0x05, 
0x07, 0x19, 0x00, 0x2a, 0xa4, 0x00, 0x81, 0x00, 0xc0, 
Device Found
  type: 046d c52b
  path: DevSrvsID:4294971158
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    1
  Usage (page): 0x2 (0x1)
  Bus type: 1

  Report Descriptor: (148 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 
0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x10, 0x15, 0x00, 
0x25, 0x01, 0x95, 0x10, 0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 
0x09, 0x30, 0x09, 0x31, 0x81, 0x06, 0x15, 0x81, 0x25, 0x7f, 
0x75, 0x08, 0x95, 0x01, 0x09, 0x38, 0x81, 0x06, 0x05, 0x0c, 
0x0a, 0x38, 0x02, 0x95, 0x01, 0x81, 0x06, 0xc0, 0xc0, 0x05, 
0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x75, 0x10, 0x95, 
0x02, 0x15, 0x01, 0x26, 0xff, 0x02, 0x19, 0x01, 0x2a, 0xff, 
0x02, 0x81, 0x00, 0xc0, 0x05, 0x01, 0x09, 0x80, 0xa1, 0x01, 
0x85, 0x04, 0x75, 0x02, 0x95, 0x01, 0x15, 0x01, 0x25, 0x03, 
0x09, 0x82, 0x09, 0x81, 0x09, 0x83, 0x81, 0x60, 0x75, 0x06, 
0x81, 0x03, 0xc0, 0x06, 0xbc, 0xff, 0x09, 0x88, 0xa1, 0x01, 
0x85, 0x08, 0x19, 0x01, 0x29, 0xff, 0x15, 0x01, 0x26, 0xff, 
0x00, 0x75, 0x08, 0x95, 0x01, 0x81, 0x00, 0xc0, 
Device Found
  type: 046d c52b
  path: DevSrvsID:4294971158
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    1
  Usage (page): 0x1 (0x1)
  Bus type: 1

  Report Descriptor: (148 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 
0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x10, 0x15, 0x00, 
0x25, 0x01, 0x95, 0x10, 0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 
0x09, 0x30, 0x09, 0x31, 0x81, 0x06, 0x15, 0x81, 0x25, 0x7f, 
0x75, 0x08, 0x95, 0x01, 0x09, 0x38, 0x81, 0x06, 0x05, 0x0c, 
0x0a, 0x38, 0x02, 0x95, 0x01, 0x81, 0x06, 0xc0, 0xc0, 0x05, 
0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x75, 0x10, 0x95, 
0x02, 0x15, 0x01, 0x26, 0xff, 0x02, 0x19, 0x01, 0x2a, 0xff, 
0x02, 0x81, 0x00, 0xc0, 0x05, 0x01, 0x09, 0x80, 0xa1, 0x01, 
0x85, 0x04, 0x75, 0x02, 0x95, 0x01, 0x15, 0x01, 0x25, 0x03, 
0x09, 0x82, 0x09, 0x81, 0x09, 0x83, 0x81, 0x60, 0x75, 0x06, 
0x81, 0x03, 0xc0, 0x06, 0xbc, 0xff, 0x09, 0x88, 0xa1, 0x01, 
0x85, 0x08, 0x19, 0x01, 0x29, 0xff, 0x15, 0x01, 0x26, 0xff, 
0x00, 0x75, 0x08, 0x95, 0x01, 0x81, 0x00, 0xc0, 
Device Found
  type: 046d c52b
  path: DevSrvsID:4294971158
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    1
  Usage (page): 0x1 (0xc)
  Bus type: 1

  Report Descriptor: (148 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 
0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x10, 0x15, 0x00, 
0x25, 0x01, 0x95, 0x10, 0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 
0x09, 0x30, 0x09, 0x31, 0x81, 0x06, 0x15, 0x81, 0x25, 0x7f, 
0x75, 0x08, 0x95, 0x01, 0x09, 0x38, 0x81, 0x06, 0x05, 0x0c, 
0x0a, 0x38, 0x02, 0x95, 0x01, 0x81, 0x06, 0xc0, 0xc0, 0x05, 
0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x75, 0x10, 0x95, 
0x02, 0x15, 0x01, 0x26, 0xff, 0x02, 0x19, 0x01, 0x2a, 0xff, 
0x02, 0x81, 0x00, 0xc0, 0x05, 0x01, 0x09, 0x80, 0xa1, 0x01, 
0x85, 0x04, 0x75, 0x02, 0x95, 0x01, 0x15, 0x01, 0x25, 0x03, 
0x09, 0x82, 0x09, 0x81, 0x09, 0x83, 0x81, 0x60, 0x75, 0x06, 
0x81, 0x03, 0xc0, 0x06, 0xbc, 0xff, 0x09, 0x88, 0xa1, 0x01, 
0x85, 0x08, 0x19, 0x01, 0x29, 0xff, 0x15, 0x01, 0x26, 0xff, 
0x00, 0x75, 0x08, 0x95, 0x01, 0x81, 0x00, 0xc0, 
Device Found
  type: 046d c52b
  path: DevSrvsID:4294971158
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    1
  Usage (page): 0x80 (0x1)
  Bus type: 1

  Report Descriptor: (148 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 
0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x10, 0x15, 0x00, 
0x25, 0x01, 0x95, 0x10, 0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 
0x09, 0x30, 0x09, 0x31, 0x81, 0x06, 0x15, 0x81, 0x25, 0x7f, 
0x75, 0x08, 0x95, 0x01, 0x09, 0x38, 0x81, 0x06, 0x05, 0x0c, 
0x0a, 0x38, 0x02, 0x95, 0x01, 0x81, 0x06, 0xc0, 0xc0, 0x05, 
0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x75, 0x10, 0x95, 
0x02, 0x15, 0x01, 0x26, 0xff, 0x02, 0x19, 0x01, 0x2a, 0xff, 
0x02, 0x81, 0x00, 0xc0, 0x05, 0x01, 0x09, 0x80, 0xa1, 0x01, 
0x85, 0x04, 0x75, 0x02, 0x95, 0x01, 0x15, 0x01, 0x25, 0x03, 
0x09, 0x82, 0x09, 0x81, 0x09, 0x83, 0x81, 0x60, 0x75, 0x06, 
0x81, 0x03, 0xc0, 0x06, 0xbc, 0xff, 0x09, 0x88, 0xa1, 0x01, 
0x85, 0x08, 0x19, 0x01, 0x29, 0xff, 0x15, 0x01, 0x26, 0xff, 
0x00, 0x75, 0x08, 0x95, 0x01, 0x81, 0x00, 0xc0, 
Device Found
  type: 046d c52b
  path: DevSrvsID:4294971158
  serial_number: 
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    1
  Usage (page): 0x88 (0xffbc)
  Bus type: 1

  Report Descriptor: (148 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 
0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x10, 0x15, 0x00, 
0x25, 0x01, 0x95, 0x10, 0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 
0x09, 0x30, 0x09, 0x31, 0x81, 0x06, 0x15, 0x81, 0x25, 0x7f, 
0x75, 0x08, 0x95, 0x01, 0x09, 0x38, 0x81, 0x06, 0x05, 0x0c, 
0x0a, 0x38, 0x02, 0x95, 0x01, 0x81, 0x06, 0xc0, 0xc0, 0x05, 
0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x75, 0x10, 0x95, 
0x02, 0x15, 0x01, 0x26, 0xff, 0x02, 0x19, 0x01, 0x2a, 0xff, 
0x02, 0x81, 0x00, 0xc0, 0x05, 0x01, 0x09, 0x80, 0xa1, 0x01, 
0x85, 0x04, 0x75, 0x02, 0x95, 0x01, 0x15, 0x01, 0x25, 0x03, 
0x09, 0x82, 0x09, 0x81, 0x09, 0x83, 0x81, 0x60, 0x75, 0x06, 
0x81, 0x03, 0xc0, 0x06, 0xbc, 0xff, 0x09, 0x88, 0xa1, 0x01, 
0x85, 0x08, 0x19, 0x01, 0x29, 0xff, 0x15, 0x01, 0x26, 0xff, 
0x00, 0x75, 0x08, 0x95, 0x01, 0x81, 0x00, 0xc0, 

@mcuee
Copy link
Member Author

mcuee commented Apr 15, 2023

Just a quick test using my mod hidapi-libusb under macOS.
#319 (comment)

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

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

  Report Descriptor: Unable to open device by path
Device Found
  type: 046d c52b
  path: 2-2.4.4:1.1
  serial_number: (null)
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    1
  Usage (page): 0x0 (0x0)
  Bus type: 1

  Report Descriptor: Unable to open device by path
Device Found
  type: 046d c52b
  path: 2-2.4.4:1.2
  serial_number: (null)
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x0 (0x0)
  Bus type: 1

  Report Descriptor: Unable to open device by path
unable to open device

mcuee@mcuees-Mac-mini libusb % sudo ./hidtest-libusb
Password:
hidapi test/example tool. Compiled with hidapi version 0.14.0, runtime version 0.14.0.
Compile-time version matches runtime version of hidapi.

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

  Report Descriptor: (59 bytes)
0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07, 0x19, 0xe0, 
0x29, 0xe7, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 
0x81, 0x02, 0x81, 0x03, 0x95, 0x05, 0x05, 0x08, 0x19, 0x01, 
0x29, 0x05, 0x91, 0x02, 0x95, 0x01, 0x75, 0x03, 0x91, 0x01, 
0x95, 0x06, 0x75, 0x08, 0x15, 0x00, 0x26, 0xa4, 0x00, 0x05, 
0x07, 0x19, 0x00, 0x2a, 0xa4, 0x00, 0x81, 0x00, 0xc0, 
Device Found
  type: 046d c52b
  path: 2-2.4.4:1.1
  serial_number: (null)
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    1
  Usage (page): 0x0 (0x0)
  Bus type: 1

  Report Descriptor: (148 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01, 
0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x10, 0x15, 0x00, 
0x25, 0x01, 0x95, 0x10, 0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 
0x16, 0x01, 0xf8, 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 
0x09, 0x30, 0x09, 0x31, 0x81, 0x06, 0x15, 0x81, 0x25, 0x7f, 
0x75, 0x08, 0x95, 0x01, 0x09, 0x38, 0x81, 0x06, 0x05, 0x0c, 
0x0a, 0x38, 0x02, 0x95, 0x01, 0x81, 0x06, 0xc0, 0xc0, 0x05, 
0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x75, 0x10, 0x95, 
0x02, 0x15, 0x01, 0x26, 0xff, 0x02, 0x19, 0x01, 0x2a, 0xff, 
0x02, 0x81, 0x00, 0xc0, 0x05, 0x01, 0x09, 0x80, 0xa1, 0x01, 
0x85, 0x04, 0x75, 0x02, 0x95, 0x01, 0x15, 0x01, 0x25, 0x03, 
0x09, 0x82, 0x09, 0x81, 0x09, 0x83, 0x81, 0x60, 0x75, 0x06, 
0x81, 0x03, 0xc0, 0x06, 0xbc, 0xff, 0x09, 0x88, 0xa1, 0x01, 
0x85, 0x08, 0x19, 0x01, 0x29, 0xff, 0x15, 0x01, 0x26, 0xff, 
0x00, 0x75, 0x08, 0x95, 0x01, 0x81, 0x00, 0xc0, 
Device Found
  type: 046d c52b
  path: 2-2.4.4:1.2
  serial_number: (null)
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2410
  Interface:    2
  Usage (page): 0x0 (0x0)
  Bus type: 1

  Report Descriptor: (98 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x10, 0x75, 
0x08, 0x95, 0x06, 0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 0x01, 
0x81, 0x00, 0x09, 0x01, 0x91, 0x00, 0xc0, 0x06, 0x00, 0xff, 
0x09, 0x02, 0xa1, 0x01, 0x85, 0x11, 0x75, 0x08, 0x95, 0x13, 
0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 0x02, 0x81, 0x00, 0x09, 
0x02, 0x91, 0x00, 0xc0, 0x06, 0x00, 0xff, 0x09, 0x04, 0xa1, 
0x01, 0x85, 0x20, 0x75, 0x08, 0x95, 0x0e, 0x15, 0x00, 0x26, 
0xff, 0x00, 0x09, 0x41, 0x81, 0x00, 0x09, 0x41, 0x91, 0x00, 
0x85, 0x21, 0x95, 0x1f, 0x15, 0x00, 0x26, 0xff, 0x00, 0x09, 
0x42, 0x81, 0x00, 0x09, 0x42, 0x91, 0x00, 0xc0, 
unable to open device

@mcuee
Copy link
Member Author

mcuee commented Apr 15, 2023

@Youw

I am thinking that libusb codes may be of some reference to sort out the issue here.[
https://github.com/libusb/libusb/blob/master/libusb/os/darwin_usb.c#L1342-L1377

@Youw
Copy link
Member

Youw commented Apr 15, 2023

Somehow libusb is able to print the interface number.

Yeah, libusb and HIDAPI using different API/subsystems to get the information about USB device.
libusb gets it directly from USB subsystem, which would be broken all at once if the interface number wasn't availale.
HIDAPI uses HidManager macOS API which is either changed or broken in the latest macOS 13.3.1.

BTW: I'm still using 12.6 so I'm unable to debug/fix it localy as of yet...

@dingsijie-nreal
Copy link

Yeah, I've noticed that libusb is able to fetch the correct interface number, but as @Youw has pointed out, hidapi doesn't use libusb on mac. Our app code currently uses hidapi API because it is easier and nicer to use than libusb. Maybe it is a real bug on macOS 13.3?
Now what I'm thinking more about is that shouldn't apple already received reports about this issue? Is @mcuee 's logitech USB receiver working fine on macOS 13.3? Or, maybe a usb device with none zero interface number itself is a less common design?

@mcuee
Copy link
Member Author

mcuee commented Apr 16, 2023

The USB receiver works fine (together with the mouse and keyboard). In fact yesterday I tried hidpp macOS fork and it works fine.

It is probably just the paticual macOS API is broken. Sometimes Apple will fix it in the future updates. Sometimes it may take time. Let's see if you will get some reply here. Better way is to submit a bug report to Apple.
Ref: https://developer.apple.com/forums/thread/728001

@mcuee
Copy link
Member Author

mcuee commented Apr 16, 2023

Better way is to submit a bug report to Apple.

@dingsijie-nreal
It will be good to file a feedback to Apple.
https://developer.apple.com/bug-reporting/

You can see from the following libusb issue that Apple fixed the issue pretty fast in the paticular case. But sometimes it takes time.
Ref: libusb/libusb#1156

@dingsijie-nreal
Copy link

@Youw
Copy link
Member

Youw commented Apr 17, 2023

Is there some kind of visibility configuration for the feedback? I'm unable to open/see it.

@mcuee
Copy link
Member Author

mcuee commented Apr 17, 2023

Is there some kind of visibility configuration for the feedback? I'm unable to open/see it.

Same here. Probably it is not visible for unconfirmed issue.

@dingsijie-nreal
Copy link

Only apple can see it according to:
https://developer.apple.com/forums/thread/700518
Also, I didn't notice any visibility setting when I was posting the feedback.

@Youw
Copy link
Member

Youw commented Apr 30, 2023

After digging deeper into the problem in the context of #534 - I'm starting to think that this is not a bug in macOS.
It looks like HIDAPI used an undocumented property of the IOHIDDevice registry entry, and Apple finally cleaned (some?/all?) undocumented properties from the IOHIDDevice registry.

But it is still a clear statement that IOHIDDevice entry in the registry is one of the child entries of the IOUSBHostInterface entry for USB HID devices, which definitely has the InterfaceNumber property (otherwise at least libusb would break completely).

@Youw
Copy link
Member

Youw commented Apr 30, 2023

@dingsijie-nreal see if you (or you colleague?) could check the #534 fix.

@mcuee
Copy link
Member Author

mcuee commented May 1, 2023

PR #534 works fine for me.

@Youw Youw closed this as completed in #534 May 5, 2023
benma added a commit to benma/bitbox02-firmware that referenced this issue May 29, 2023
Fixing trezor/cython-hidapi#151, which
includes the fix libusb/hidapi#531, which
fixes a bug where on macOS, the interface number of all hid interfaces
would be 0. This lead to one BitBox02 multi being listed twice instead
of once (as it exposes a second interface for U2F).
benma added a commit to benma/bitbox02-firmware that referenced this issue May 29, 2023
Fixing trezor/cython-hidapi#151, which
includes the fix libusb/hidapi#531, which
fixes a bug where on macOS, the interface number of all hid interfaces
would be 0. This lead to one BitBox02 multi being listed twice instead
of once (as it exposes a second interface for U2F).
benma added a commit to benma/HWI that referenced this issue May 30, 2023
6.2.0 was released to put a minimum requirement on hidapi 0.14.0,
which includes the fix for this issue:

libusb/hidapi#531

That bug caused hidapi on macOS 13.3 to report 0 as the interface
number for all hid devices, which led to the bitbox02 being listed
twice instead of once. This breaks some downstream integrations like
Sparrow: sparrowwallet/sparrow#972
SomberNight pushed a commit to spesmilo/electrum that referenced this issue May 30, 2023
6.2.0 was released to put a minimum requirement on hidapi 0.14.0,
which includes the fix for this issue:

libusb/hidapi#531

That bug caused hidapi on macOS 13.3 to report 0 as the interface
number for all hid devices, which led to the bitbox02 multi edition being listed
twice instead of once - once for the main HW wallet interface and once erroneously
For the U2F interface (which should not be listed).
benma added a commit to benma/bitbox-wallet-app that referenced this issue Mar 13, 2024
When building the BBApp on an updated XCode, the BitBox02 can't
connect anymore on macOS, most likely due to
libusb/hidapi#531.

In
BitBoxSwiss@bef0672
we switched from karalabe/hid to karalabe/usb, because karalabe/usb
go-ethereum switched to it, and both libs cannot (or could not) be
linked at once.

Then in
BitBoxSwiss@63dbb28
we abandoned karalabe/usb and made our own
fork (https://github.com/digitalbitbox/usb/), because it seemed
unmaintained/dead, and we needed important fixes to keep working.  The
original and the fork had a very old version of
https://github.com/libusb/hidapi/.

This fork, like the original, bundled a very old version of the hidapi
C library.

The above issue is with the connection on macOS is fixed by uprading
it, but that is not super easy (hidapi requires libusb, and upgrading
and compiling both in cgo is hard).

Luckily just last week, go-ethereum switched back to karalabe/hid, and
karalabe/hid finally got some love from the maintainers and they
upgraded hidapi:
karalabe/hid@80d2c4b

Switching back to this the hid lib fixes the macOS issue and it means
we can archive our own fork.
benma added a commit to benma/bitbox-wallet-app that referenced this issue Mar 13, 2024
When building the BBApp on an updated XCode, the BitBox02 can't
connect anymore on macOS, most likely due to
libusb/hidapi#531.

In
BitBoxSwiss@bef0672
we switched from karalabe/hid to karalabe/usb, because karalabe/usb
go-ethereum switched to it, and both libs cannot (or could not) be
linked at once.

Then in
BitBoxSwiss@63dbb28
we abandoned karalabe/usb and made our own
fork (https://github.com/digitalbitbox/usb/), because it seemed
unmaintained/dead, and we needed important fixes to keep working.  The
original and the fork had a very old version of
https://github.com/libusb/hidapi/.

This fork, like the original, bundled a very old version of the hidapi
C library.

The above issue is with the connection on macOS is fixed by uprading
it, but that is not super easy (hidapi requires libusb, and upgrading
and compiling both in cgo is hard).

Luckily just last week, go-ethereum switched back to karalabe/hid, and
karalabe/hid finally got some love from the maintainers and they
upgraded hidapi:
karalabe/hid@80d2c4b

Switching back to this the hid lib fixes the macOS issue and it means
we can archive our own fork.

The golangci linter `gomoddirectives` is disabled b/c it complains
about `replace` directives in the go.mod file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
macOS Related to macOS backend
Projects
None yet
3 participants