UHID(4)
π UHID(4) β the Kernel Interfaces Manual page, but make it cute π
okay bestie, welcome to the uhid page, straight out of the Kernel Interfaces Manual. sit down, grab a boba, we're learning about USB generic HID support π¦
β¨ NAME β¨
uhid β USB generic HID support. that's it, that's the name. slay.
πΈ SYNOPSIS πΈ
ok so if you wanna bake this driver into the kernel, you drop this line into your kernel configuration file:
device uhid
or, alternatively β if you'd rather load it as a module at boot time (very valid, very low-effort queen behavior) β put this line in loader.conf(5):
uhid_load="YES"
π DESCRIPTION π
the uhid driver has your back for all HID (Human Interface Device) interfaces in USB devices that don't have a special driver of their own. like, if nobody else claimed it, uhid is stepping up. main character energy fr fr π
the device handles these ioctl(2) calls:
USB_GET_REPORT_ID(int) β gets the report identifier that this HID report uses. cute little ID, no notes.USB_GET_REPORT_DESC(struct usb_gen_descriptor) β gets the HID report descriptor. it copies a max ofugd_maxlenbytes of the report descriptor data into the memory thatugd_datapoints at. when it comes back,ugd_actlenis set to the number of bytes it actually copied. using this descriptor you can find the exact layout and meaning of data going to/from the device. and listen β the report descriptor is delivered without any processing. raw. unedited. no filter. π
struct usb_gen_descriptor {
void *ugd_data;
uint16_t ugd_maxlen;
uint16_t ugd_actlen;
uint8_t ugd_report_type;
...
};
USB_SET_IMMED(int) β sets the device into a mode where every singleread(2)returns the current value of the input report. normally aread(2)only gives you the data the device reports on its interrupt pipe. heads up tho β this call may fail if the device doesn't support this feature. not every device is that girl, and that's okay πUSB_GET_REPORT(struct usb_gen_descriptor) β gets a report from the device without waiting around for data on the interrupt pipe. copies a max ofugd_maxlenbytes of the report data into the memoryugd_datapoints at. on return,ugd_actlenis set to the number of bytes copied. theugd_report_typefield tells it which report you're asking for, and it should be one ofUHID_INPUT_REPORT,UHID_OUTPUT_REPORT, orUHID_FEATURE_REPORT. and yep β this call may fail if the device doesn't support the feature. πUSB_SET_REPORT(struct usb_gen_descriptor) β sets a report in the device. theugd_report_typefield says which report is getting set, and it should beUHID_INPUT_REPORT,UHID_OUTPUT_REPORT, orUHID_FEATURE_REPORT. the actual value of the report is specified by theugd_dataandugd_maxlenfields. and yes, again β this call may fail if the device doesn't support this feature. it's giving "we tried our best" π
use read(2) to get data from the device β and bestie, read it in chunks of the size prescribed by the report descriptor, okay? don't freestyle it.
use write(2) to send data to the device β same deal, chunks of the size prescribed by the report descriptor. the descriptor is the blueprint, we respect the blueprint β¨
β SYSCTL VARIABLES β
these variables are available as both sysctl(8) variables and loader(8) tunables:
hw.usb.uhid.debugβ debug output level.0means debugging is disabled, and bigger values crank up the debug message verbosity. default is0. so if you're not debugging, you're at a cool zero, no chaos, we love a calm baseline π§
π FILES π
/dev/uhid?
π¦ SEE ALSO π¦
π HISTORY π
the uhid driver first appeared in NetBSD 1.4. this manual page was adopted from NetBSD by Tom Rhodes <trhodes@FreeBSD.org> in April 2002. iconic lineage, honestly π
and that's the whole page, bestie!! this version lives under the Debian source, dated July 1, 2018, and it's the UHID(4) page β so like, go forth and read your report descriptors in appropriately sized chunks π«Άπβ¨
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1999, 2001 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms