Skip to content

Fill in the usage page and usage id on linux with hidraw #6

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

djpnewton
Copy link

No description provided.

@klali
Copy link

klali commented Aug 14, 2014

I'd very much like to be able to get usage page and usage through the hidraw backend.

Would an updated patch of this be acceptable for merging?
Or some other tactic for implementing it?

@signal11
Copy link
Owner

So that first commit has a couple problems:

  1. It's a copy/paste/edit my uses_numbered_reports(). Those would need to be merged into one implementation.
  2. The patch does more than one thing, eg:
    a. refactoring retrieval of the report descriptor into a function
    b. calling this new function from hid_open_path() and hid_enumerate() (why not just hid_enumerate()?)
    c. whitespace changes.
    These changes will need to each be evaluated, and if applicable, be split into separate commits.
  3. It introduces a dependency on C99. I like C99, but some users running on ancient versions of Linux (and there are more than it seems like there ought to be) will scream.

@amadsen
Copy link

amadsen commented Nov 13, 2016

I'm curious, 2 years further on, if this is getting any attention (mostly because U2F expects the implementer to find devices by their usage page and usage.)

Yubico's libu2f-host library appears to have essentially patched this code in outside the hidapi library, but it seems like it would be a lot cleaner if there is a way to get an acceptable version of this branch merged in.

@hyperb1iss
Copy link

Just banged my head against the wall for a few hours after running into this issue myself :( Would be really nice to have this working. I'll take a swing at improving the patch if necessary.

@limpkin
Copy link

limpkin commented Mar 14, 2017

our device (mooltipass) is a composite HID/HID. having this feature would be great.

@thealexbaron
Copy link

+1

haata added a commit to haata/hidapi that referenced this pull request Jan 13, 2020
Adapted from ApeironTuska's PR to PastaJ36/hidapi (PastaJ36/hidapi#1)
Which was adapted from djpnewton's PR to signal11/hidapi (signal11/hidapi#6)

Also addresses some of the issues mentioned in (signal11/hidapi#6)
* hid_open_path and hid_enumerate both need to retrieve the usage page
as the user may call hid_open_path directly without using hid_enumerate
* Now using uses_numbered_reports() instead of duplicated code

Includes additional interface fields that are useful in Linux when it's
not possible (undesireable) to unbind the HID interface during a scan.
* iInterface (only some devices use this, but can be very useful)
* bInterfaceClass
* bInterfaceSubClass
* bInterfaceProtocol
* bNumEndpoints

TODO - macOS and Windows
TODO - Test hid and libusb usage and usage page
haata added a commit to haata/hidapi that referenced this pull request Jan 19, 2020
Adapted from ApeironTuska's PR to PastaJ36/hidapi (PastaJ36/hidapi#1)
Which was adapted from djpnewton's PR to signal11/hidapi (signal11/hidapi#6)

Also addresses some of the issues mentioned in (signal11/hidapi#6)
* hid_open_path and hid_enumerate both need to retrieve the usage page
as the user may call hid_open_path directly without using hid_enumerate
* Now using uses_numbered_reports() instead of duplicated code

Includes additional interface fields that are useful in Linux when it's
not possible (undesireable) to unbind the HID interface during a scan.
* iInterface (only some devices use this, but can be very useful)
* bInterfaceClass
* bInterfaceSubClass
* bInterfaceProtocol
* bNumEndpoints

TODO - macOS and Windows
TODO - Test hid and libusb usage and usage page
haata added a commit to haata/hidapi that referenced this pull request Jan 21, 2020
Adapted from ApeironTuska's PR to PastaJ36/hidapi (PastaJ36/hidapi#1)
Which was adapted from djpnewton's PR to signal11/hidapi (signal11/hidapi#6)

Also addresses some of the issues mentioned in (signal11/hidapi#6)
* hid_open_path and hid_enumerate both need to retrieve the usage page
as the user may call hid_open_path directly without using hid_enumerate
* Added get_hid_item_size() for hid parsing, used in both uses_numbered_reports() and get_usage()
haata added a commit to haata/hidapi that referenced this pull request Jan 22, 2020
Adapted from ApeironTuska's PR to PastaJ36/hidapi (PastaJ36/hidapi#1)
Which was adapted from djpnewton's PR to signal11/hidapi (signal11/hidapi#6)

Also addresses some of the issues mentioned in (signal11/hidapi#6)
* hid_open_path and hid_enumerate both need to retrieve the usage page
as the user may call hid_open_path directly without using hid_enumerate
* Added get_hid_item_size() for hid parsing, used in both uses_numbered_reports() and get_usage()

- hidtest-hidraw test -

Device Found
  type: 308f 0015
  path: /dev/hidraw10
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    0
  Usage (page): 0x6 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw11
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    1
  Usage (page): 0x6 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw12
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    2
  Usage (page): 0x1 (0xc)

Device Found
  type: 308f 0015
  path: /dev/hidraw13
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    3
  Usage (page): 0x2 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw14
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    4
  Usage (page): 0x1100 (0xff1c)
haata added a commit to haata/hidapi that referenced this pull request Jan 22, 2020
Adapted from ApeironTuska's PR to PastaJ36/hidapi (PastaJ36/hidapi#1)
Which was adapted from djpnewton's PR to signal11/hidapi (signal11/hidapi#6)

Also addresses some of the issues mentioned in (signal11/hidapi#6)
* hid_open_path and hid_enumerate both need to retrieve the usage page
as the user may call hid_open_path directly without using hid_enumerate
* Added get_hid_item_size() for hid parsing, used in both uses_numbered_reports() and get_usage()

NOTE: This commit does not handle composite HID descriptors
I am interested in adding support for composite descriptors though I still need to find a
device with a composite descriptor to test it correctly

- hidtest-hidraw test -

Device Found
  type: 308f 0015
  path: /dev/hidraw10
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    0
  Usage (page): 0x6 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw11
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    1
  Usage (page): 0x6 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw12
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    2
  Usage (page): 0x1 (0xc)

Device Found
  type: 308f 0015
  path: /dev/hidraw13
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    3
  Usage (page): 0x2 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw14
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    4
  Usage (page): 0x1100 (0xff1c)
haata added a commit to haata/hidapi that referenced this pull request Jan 22, 2020
Adapted from ApeironTuska's PR to PastaJ36/hidapi (PastaJ36/hidapi#1)
Which was adapted from djpnewton's PR to signal11/hidapi (signal11/hidapi#6)

Also addresses some of the issues mentioned in (signal11/hidapi#6)
* hid_open_path and hid_enumerate both need to retrieve the usage page
as the user may call hid_open_path directly without using hid_enumerate
* Added get_hid_item_size() for hid parsing, used in both uses_numbered_reports() and get_usage()

NOTE: This commit does not handle composite HID descriptors
I am interested in adding support for composite descriptors though I still need to find a
device with a composite descriptor to test it correctly

- hidtest-hidraw test -

Device Found
  type: 308f 0015
  path: /dev/hidraw10
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    0
  Usage (page): 0x6 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw11
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    1
  Usage (page): 0x6 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw12
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    2
  Usage (page): 0x1 (0xc)

Device Found
  type: 308f 0015
  path: /dev/hidraw13
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    3
  Usage (page): 0x2 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw14
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    4
  Usage (page): 0x1100 (0xff1c)
haata added a commit to haata/hidapi that referenced this pull request Jan 22, 2020
Adapted from ApeironTuska's PR to PastaJ36/hidapi (PastaJ36/hidapi#1)
Which was adapted from djpnewton's PR to signal11/hidapi (signal11/hidapi#6)

Also addresses some of the issues mentioned in (signal11/hidapi#6)
* hid_open_path and hid_enumerate both need to retrieve the usage page
as the user may call hid_open_path directly without using hid_enumerate
* Added get_hid_item_size() for hid parsing, used in both uses_numbered_reports() and get_hid_usage()

NOTE: This commit does not handle composite HID descriptors
I am interested in adding support for composite descriptors though I still need to find a
device with a composite descriptor to test it correctly

- hidtest-hidraw test -

Device Found
  type: 308f 0015
  path: /dev/hidraw10
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    0
  Usage (page): 0x6 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw11
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    1
  Usage (page): 0x6 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw12
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    2
  Usage (page): 0x1 (0xc)

Device Found
  type: 308f 0015
  path: /dev/hidraw13
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    3
  Usage (page): 0x2 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw14
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    4
  Usage (page): 0x1100 (0xff1c)
haata added a commit to haata/hidapi that referenced this pull request Jan 27, 2020
Adapted from ApeironTuska's PR to PastaJ36/hidapi (PastaJ36/hidapi#1)
Which was adapted from djpnewton's PR to signal11/hidapi (signal11/hidapi#6)

Also addresses some of the issues mentioned in (signal11/hidapi#6)
* hid_open_path and hid_enumerate both need to retrieve the usage page
as the user may call hid_open_path directly without using hid_enumerate
* Added get_hid_item_size() for hid parsing, used in both uses_numbered_reports() and get_hid_usage()

NOTE: This commit does not handle composite HID descriptors
I am interested in adding support for composite descriptors though I still need to find a
device with a composite descriptor to test it correctly

- hidtest-hidraw test -

Device Found
  type: 308f 0015
  path: /dev/hidraw10
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    0
  Usage (page): 0x6 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw11
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    1
  Usage (page): 0x6 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw12
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    2
  Usage (page): 0x1 (0xc)

Device Found
  type: 308f 0015
  path: /dev/hidraw13
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    3
  Usage (page): 0x2 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw14
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    4
  Usage (page): 0x1100 (0xff1c)
haata added a commit to haata/hidapi that referenced this pull request Mar 13, 2020
Adapted from ApeironTuska's PR to PastaJ36/hidapi (PastaJ36/hidapi#1)
Which was adapted from djpnewton's PR to signal11/hidapi (signal11/hidapi#6)

Also addresses some of the issues mentioned in (signal11/hidapi#6)
* hid_open_path and hid_enumerate both need to retrieve the usage page
as the user may call hid_open_path directly without using hid_enumerate
* Added get_hid_item_size() for hid parsing, used in both uses_numbered_reports() and get_hid_usage()

NOTE: This commit does not handle composite HID descriptors
I am interested in adding support for composite descriptors though I still need to find a
device with a composite descriptor to test it correctly

- hidtest-hidraw test -

Device Found
  type: 308f 0015
  path: /dev/hidraw10
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    0
  Usage (page): 0x6 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw11
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    1
  Usage (page): 0x6 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw12
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    2
  Usage (page): 0x1 (0xc)

Device Found
  type: 308f 0015
  path: /dev/hidraw13
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    3
  Usage (page): 0x2 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw14
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    4
  Usage (page): 0x1100 (0xff1c)
haata added a commit to haata/hidapi that referenced this pull request May 24, 2020
Adapted from ApeironTuska's PR to PastaJ36/hidapi (PastaJ36/hidapi#1)
Which was adapted from djpnewton's PR to signal11/hidapi (signal11/hidapi#6)

Also addresses some of the issues mentioned in (signal11/hidapi#6)
* hid_open_path and hid_enumerate both need to retrieve the usage page
as the user may call hid_open_path directly without using hid_enumerate
* Added get_hid_item_size() for hid parsing, used in both uses_numbered_reports() and get_hid_usage()

NOTE: This commit does not handle composite HID descriptors
I am interested in adding support for composite descriptors though I still need to find a
device with a composite descriptor to test it correctly

- hidtest-hidraw test -

Device Found
  type: 308f 0015
  path: /dev/hidraw10
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    0
  Usage (page): 0x6 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw11
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    1
  Usage (page): 0x6 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw12
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    2
  Usage (page): 0x1 (0xc)

Device Found
  type: 308f 0015
  path: /dev/hidraw13
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    3
  Usage (page): 0x2 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw14
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    4
  Usage (page): 0x1100 (0xff1c)
haata added a commit to haata/hidapi that referenced this pull request Nov 18, 2020
Adapted from ApeironTuska's PR to PastaJ36/hidapi (PastaJ36/hidapi#1)
Which was adapted from djpnewton's PR to signal11/hidapi (signal11/hidapi#6)

Also addresses some of the issues mentioned in (signal11/hidapi#6)
* hid_open_path and hid_enumerate both need to retrieve the usage page
as the user may call hid_open_path directly without using hid_enumerate
* Added get_hid_item_size() for hid parsing, used in both uses_numbered_reports() and get_hid_usage()

NOTE: This commit does not handle composite HID descriptors
I am interested in adding support for composite descriptors though I still need to find a
device with a composite descriptor to test it correctly

- hidtest-hidraw test -

Device Found
  type: 308f 0015
  path: /dev/hidraw10
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    0
  Usage (page): 0x6 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw11
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    1
  Usage (page): 0x6 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw12
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    2
  Usage (page): 0x1 (0xc)

Device Found
  type: 308f 0015
  path: /dev/hidraw13
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    3
  Usage (page): 0x2 (0x1)

Device Found
  type: 308f 0015
  path: /dev/hidraw14
  serial_number: 53373100323943353230353139363032 - sam4s2
  Manufacturer: Kiibohd
  Product:      Keyboard - None PartialMap USBxUART
  Release:      4ac
  Interface:    4
  Usage (page): 0x1100 (0xff1c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants