hid_bpf_hw_request(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… hid_bpf_hw_request (9) β€” the kernel API manual, bestie edition πŸŽ€

Okay so like, welcome to the hid_bpf_hw_request(9) page, which is literally your cheat code for talking to a HID device from BPF. Yes. Actual hardware. From a sandboxed program. Iconic behavior, no cap.


✨ NAME ✨

hid_bpf_hw_request β€” communicate with a HID device πŸ¦‹

Like, you're sliding into your keyboard's DMs. Respectfully. Through the kernel. πŸ’–


🌸 SYNOPSIS 🌸

__bpf_kfunc int hid_bpf_hw_request (struct hid_bpf_ctx *ctx , __u8 *buf
, size_t buf__sz , enum hid_report_type rtype , enum hid_class_request
reqtype );

Copy it exactly like that, don't get cute with the spacing, the compiler is not in a forgiving mood today. 😭


πŸ‘‘ ARGUMENTS πŸ‘‘

  • ctx β€” the HID-BPF context you already got from hid_bpf_allocate_context earlier. You can't just show up with no context, that's giving party-crasher energy. πŸ™ˆ
  • buf β€” a PTR_TO_MEM buffer. It's your little memory bag, the verifier is watching it, be normal about it.
  • buf__sz β€” the size of the data to transfer. It's the __sz twin of buf, they're a matching set, don't separate them. 🫢
  • rtype β€” the type of the report, and it's one of HID_INPUT_REPORT, HID_FEATURE_REPORT, or HID_OUTPUT_REPORT. Pick your fighter. ⭐
  • reqtype β€” the type of the request: HID_REQ_GET_REPORT, HID_REQ_SET_REPORT, ... β€” the ... is doing a lot of heavy lifting there but that's literally what the page says, iykyk. πŸ’…

πŸ”₯ DESCRIPTION πŸ”₯

It returns 0 on success. Literally that's the whole description. And if it doesn't work out? A negative error code. So like, lowkey just vibe-check the return value before you assume anything slayed. πŸ’€

Fr fr, 0 = we ate. Negative = we did not eat, go look at the error code and figure out why.

🌈 SEE ALSO 🌈

Kernel file ./drivers/hid/bpf/hid_bpf_dispatch.c β€” that's the source, main character document. πŸ“„

And the whole friend group of related calls:

Go read all of them, they're a package deal, don't leave anyone on read. πŸ§šπŸ’œ


<div align="center">

That's the whole page, bestie β€” written out of ./drivers/hid/bpf and dated October 2026, and yeah, it's still filed under hid_bpf_hw_request(9) because we do not rename things in this house. Goodbye, go poke a HID device. πŸ’…βœ¨

</div>

πŸ“¦ where this page comes from