STRUCT USB_KBD(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

okay so this is the manual page for struct usb_kbd β€” in the struct usb_kbd(9) Kernel API Manual, bestie β€” and it's literally just the state of each attached keyboard. that's it. that's the whole vibe. one struct holding everything a HID keyboard needs to keep track of about itself 🎹✨


✨ SYNOPSIS ✨

no cap, here's the whole thing, character for character:

struct usb_kbd {
    struct input_dev *dev;
    struct usb_device *usbdev;
    unsigned char old[8];
    struct urb *irq, *led;
    unsigned char newleds;
    char name[128];
    char phys[64];
    unsigned char *new;
    struct usb_ctrlrequest *cr;
    unsigned char *leds;
    dma_addr_t new_dma;
    dma_addr_t leds_dma;
    spinlock_t leds_lock;
    bool led_urb_submitted;
 };

like... she's got range. input dev, usb dev, buffers, DMA addresses, a spinlock, a bool. main character struct energy honestly πŸ‘‘


πŸŽ€ Members πŸŽ€

okay bestie, member-by-member tour, everybody gets their moment:

  • dev β€” the input device associated with this keyboard 🫢
  • usbdev β€” the usb device associated with this keyboard πŸ”Œ
  • old β€” data received in the past from the irq URB representing which keys were pressed. by comparing it with the current list of keys that are pressed, we're able to see key releases πŸ‘€ that's the trick, that's the whole trick β€” diff the old against the new and boom, you know what got let go.
  • irq β€” the URB for receiving a list of keys that are pressed when a new key is pressed or a key that was pressed is released 🎯
  • led β€” the URB for sending LEDs (e.g. numlock, ...) πŸ’‘βœ¨
  • newleds β€” data that will be sent with the led URB, representing which LEDs should be on 🌟
  • name β€” Name of the keyboard. dev's name field points to this buffer 🏷️
  • phys β€” Physical path of the keyboard. dev's phys field points to this buffer πŸ›€οΈ
  • new β€” Buffer for the irq URB 🧺
  • cr β€” Control request for led URB πŸŽ›οΈ
  • leds β€” Buffer for the led URB πŸ§ΊπŸ’‘
  • new_dma β€” DMA address for irq URB 🚚
  • leds_dma β€” DMA address for led URB πŸššπŸ’‘
  • leds_lock β€” spinlock that protects leds, newleds, and led_urb_submitted πŸ”’ like genuinely protects all three, don't be out here touching them unlocked, that's not the move
  • led_urb_submitted β€” indicates whether led is in progress, i.e. it has been submitted and its completion handler has not returned yet without resubmitting led ⏳ (read that one twice, it's doing a lot of work in one sentence, iykyk)

πŸ¦‹ SEE ALSO πŸ¦‹

  • Kernel file ./drivers/hid/usbhid/usbkbd.c β€” go read the source, bestie, it's right there πŸ“–πŸ’…

okay that's the whole page!! literally all of it, nothing skipped, no gatekeeping 🌈 the manual name is struct usb_kbd(9), the source/version bits are ./drivers/hid/usbhid and October 2026, and the date-ish stamp is struct usb_kbd(9) again β€” so bye bestie, go read usbkbd.c, mwah πŸ’œπŸŽ€πŸ¦‹

πŸ“¦ where this page comes from