UHID(4)

πŸ“¦
version 15.1 Β· 3 versions
, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

✨ NAME ✨

okay bestie, welcome to the uhid(4) page β€” USB generic HID support πŸ’– (yes, the kernel interfaces manual cutie). It's the driver that has your back for all HID (Human Interface Device) interfaces in USB devices that don't have a special driver. No cap. 🫢

🌸 SYNOPSIS 🌸

To compile this driver into the kernel, drop the following line into your kernel configuration file:

device uhid
device hid
device usb

Or, to load the driver as a module at boot time, put this line in loader.conf(5):

uhid_load="YES"

πŸŽ€ DESCRIPTION πŸŽ€

The uhid driver provides support for all HID (Human Interface Device) interfaces in USB devices that do not have a special driver. Literally its whole job, and it ate. πŸ’…

The device handles these ioctl(2) calls, bestie:

  • USB_GET_REPORT_ID (int) β€” grabs the report identifier used by this HID report. Cute little ID check ✨
  • USB_GET_REPORT_DESC (struct usb_gen_descriptor) β€” pulls the HID report descriptor. It copies a maximum of ugd_maxlen bytes of the report descriptor data into the memory specified by ugd_data, and when it comes back ugd_actlen is set to the number of bytes copied. Using this descriptor you can find the exact layout and meaning of data to/from the device. The report descriptor is delivered without any processing β€” no extra spin, no edits, just the raw thing 🫢

Here's the struct, exactly as it appears:

struct usb_gen_descriptor {
        void   *ugd_data;
        uint16_t ugd_maxlen;
        uint16_t ugd_actlen;
        uint8_t ugd_report_type;
        ...
};
  • USB_SET_IMMED (int) β€” flips the device into a mode where each read(2) will return the current value of the input report. Normally a read(2) will only return the data that the device reports on its interrupt pipe. Heads up: this call may fail if the device does not support this feature. πŸ’€
  • USB_GET_REPORT (struct usb_gen_descriptor) β€” gets a report from the device without waiting for data on the interrupt pipe. It copies a maximum of ugd_maxlen bytes of the report data into the memory specified by ugd_data; upon return ugd_actlen is set to the number of bytes copied. The ugd_report_type field tells it which report is requested β€” it should be UHID_INPUT_REPORT, UHID_OUTPUT_REPORT, or UHID_FEATURE_REPORT. This call may fail if the device does not support this feature. 😭
  • USB_SET_REPORT (struct usb_gen_descriptor) β€” sets a report in the device. The ugd_report_type field tells it which report is to be set β€” it should be UHID_INPUT_REPORT, UHID_OUTPUT_REPORT, or UHID_FEATURE_REPORT. The value of the report is specified by the ugd_data and ugd_maxlen fields. This call may fail if the device does not support this feature. πŸ™ˆ
  • USB_GET_DEVICEINFO (struct usb_device_info) β€” returns information about the device, like USB vendor ID and USB product ID. This call will not issue any USB transactions β€” zero USB traffic, just info. Also refer to ugen(4). πŸ‘‘

Use read(2) to get data from the device. Data should be read in chunks of the size prescribed by the report descriptor.

Use write(2) to send data to the device. Data should be written in chunks of the size prescribed by the report descriptor.

πŸ’… SYSCTL VARIABLES πŸ’…

The following variables are available as both sysctl(8) variables and loader(8) tunables:

  • hw.usb.uhid.debug β€” debug output level, where 0 is debugging disabled and larger values increase debug message verbosity. Default is 0. Periodt ✨

πŸ¦‹ FILES πŸ¦‹

  • /dev/uhid? β€” the device node, bestie πŸ¦‹

🌈 SEE ALSO 🌈

go check these cuties too πŸ’œ

πŸ‘‘ HISTORY πŸ‘‘

The uhid driver appeared in NetBSD 1.4. This manual page was adopted from NetBSD by Tom Rhodes <trhodes@FreeBSD.org> in April 2002. πŸ‘‘


okay that's the whole uhid(4) page, bestie πŸ’– this one is from Debian, dated Oct 31, 2020, and it's the UHID(4) manual through and through ✨🫢 periodt.

πŸ“¦ where this page comes from