HIDRAW(4)
β¨ HIDRAW(4) β¨
okay so bestie, welcome to the HIDRAW(4) glow-up π
this is the Kernel Interfaces Manual tea, and we're about to spill it.
πΈ NAME πΈ
hidraw β Raw Access to HID devices. literally the VIP pass to your Human Interface Devices, no cap π
π¦ SYNOPSIS π¦
so if you wanna compile this driver into the kernel (main character energy), you drop these lines into your kernel config file:
device hidraw
device hid
device hidbus
OR, if you'd rather load it as a module at boot time (lowkey more flexible), you put this line in loader.conf(5):
hidraw_load="YES"
slay, moving on β¨
π DESCRIPTION π
The hidraw driver gives you a raw interface to Human Interface Devices (HIDs). The reports go to and from the device unmodified β no processing, no filter, just pure vibes. π¦
The device handles 2 sets of ioctl(2) calls:
π FreeBSD uhid(4)-compatible calls:
HIDRAW_GET_REPORT_ID(int) β Grabs the report identifier this HID report is using. It's giving "what's your number?" energy πHIDRAW_GET_REPORT_DESC(struct hidraw_gen_descriptor) β Gets the HID report descriptor. Copies a maximum ofhgd_maxlenbytes of the report descriptor data into the memory specified byhgd_data. Upon return,hgd_actlenis 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 β raw and unfiltered, periodt. π₯
struct hidraw_gen_descriptor {
void *hgd_data;
uint16_t hgd_maxlen;
uint16_t hgd_actlen;
uint8_t hgd_report_type;
...
};
HIDRAW_SET_IMMED(int) β Sets the device into a mode where eachread(2)returns the current value of the input report. Normally aread(2)only returns data the device reports on its interrupt pipe. ngl this call may fail if the device doesn't support this feature πHIDRAW_GET_REPORT(struct hidraw_gen_descriptor) β Gets a report from the device without waiting for data on the interrupt pipe. Copies a maximum ofhgd_maxlenbytes of report data into the memory specified byhgd_data. Upon return,hgd_actlenis set to the number of bytes copied. Thehgd_report_typefield tells it which report you want β it should beHID_INPUT_REPORT,HID_OUTPUT_REPORT, orHID_FEATURE_REPORT. On a device using numbered reports, the first byte of returned data is the report number, and report data begins from the second byte. For devices without numbered reports, report data begins at the first byte. This call may fail if the device doesn't support it πHIDRAW_SET_REPORT(struct hidraw_gen_descriptor) β Sets a report in the device. Thehgd_report_typefield indicates which report is to be set β should beHID_INPUT_REPORT,HID_OUTPUT_REPORT, orHID_FEATURE_REPORT. The value is specified byhgd_dataandhgd_maxlenfields. On devices with numbered reports, the first byte of data sent is the report number, and report data begins from the second byte. For devices without numbered reports, report data begins at the first byte. May fail if the device doesn't support this feature πHIDRAW_GET_DEVICEINFO(struct hidraw_device_info) β Returns info about the device, like vendor ID and product ID. This call will not issue any hardware transfers β it's all vibes, no hardware drama β¨
π§ Linux hidraw-compatible calls:
HIDIOCGRDESCSIZE(int) β Gets the HID report descriptor size. Returns the size of the device report descriptor to use withHIDIOCGRDESCioctl(2). iconic πHIDIOCGRDESC(struct hidraw_report_descriptor) β Gets the HID report descriptor. Copies a maximum ofsizebytes of report descriptor data into the memory specified byvalue. π
struct hidraw_report_descriptor {
uint32_t size;
uint8_t value[HID_MAX_DESCRIPTOR_SIZE];
};
HIDIOCGRAWINFO(struct hidraw_devinfo) β Gets a structure containing the bus type, vendor ID (VID), and product ID (PID) of the device. Bus type can beBUS_USBorBUS_I2C, which are defined indev/evdev/input.h. π¦
struct hidraw_devinfo {
uint32_t bustype;
int16_t vendor;
int16_t product;
};
HIDIOCGRAWNAME(len)(char[] buf) β Gets device description. Copies a maximum oflenbytes of the device description (previously set withdevice_set_desc(9)procedure) into the memory specified bybuf. πHIDIOCGRAWPHYS(len)(char[] buf) β Gets the newbus path to the device. Copies a maximum oflenbytes of the newbus device path into the memory specified bybuf. slay πΈHIDIOCGFEATURE(len)(void[] buf)HIDIOCGINPUT(len)(void[] buf)HIDIOCGOUTPUT(len)(void[] buf)
Get respectively a feature, input, or output report from the device. Copies a maximum of len bytes of report data into the memory specified by buf. The first byte of the supplied buffer should be set to the report number of the requested report. For devices without numbered reports, set the first byte to 0. The report will be returned starting at the first byte of the buffer (ie: the report number is not returned). This call may fail if the device doesn't support this feature π
HIDIOCSFEATURE(len)(void[] buf)HIDIOCSINPUT(len)(void[] buf)HIDIOCSOUTPUT(len)(void[] buf)
Set respectively a feature, input, or output report in the device. Value of the report is specified by the buf and len parameters. Set the first byte of the supplied buffer to the report number. For devices without numbered reports, set the first byte to 0. Report data begins in the second byte. Make sure to set len accordingly, to one more than the length of the report (to account for the report number). This call may fail if the device doesn't support this feature. fr fr π
Use read(2) to get data from the device. Data should be read in chunks of the size prescribed by the report descriptor. On devices using numbered reports, the first byte of returned data is the report number, and report data begins from the second byte. For devices without numbered reports, report data begins at the first byte. π«Ά
Use write(2) to send data to the device. Data should be written in chunks of the size prescribed by the report descriptor. The first byte of the buffer passed to write(2) should be set to the report number. If the device doesn't use numbered reports, there are 2 operation modes: hidraw mode and uhid(4) mode. In hidraw mode, the first byte should be set to 0 and report data itself should begin at the second byte. In uhid(4) mode, report data should begin at the first byte. The modes can be switched by issuing one of HIDIOCGRDESC or HID_GET_REPORT_DESC ioctl(2) accordingly. Default mode is hidraw. periodt. β¨
π SYSCTL VARIABLES π
The following variables are available as both sysctl(8) variables and loader(8) tunables:
hw.hid.hidraw.debugβ Debug output level, where 0 is debugging disabled and larger values increase debug message verbosity. Default is0. ngl this is the "how much tea do you want in your logs" dial π
π FILES π
/dev/hidraw? β that's the spot, bestie π
β SEE ALSO β
usbhidctl(1), hid(4), hidbus(4), uhid(4) β go read these too, they're iconic in their own right π¦
π HISTORY π
The uhid(4) driver appeared in NetBSD 1.4. hidraw protocol support was added in FreeBSD 13 by Vladimir Kondratyev <wulf@FreeBSD.org>. This manual page was adopted from NetBSD by Tom Rhodes <trhodes@FreeBSD.org> in April 2002. we stan the OGs π
okay that's the whole tea, bestie π«Ά this HIDRAW(4) page is from the Debian manual, dated April 27, 2025 β go forth and slay your HID game π
β¨πΈ
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 1999, 2001 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms