sparse_keymap_setup(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… sparse_keymap_setup πŸ’…

okay so bestie, you know how this page is from the Kernel API Manual and it's literally all about sparse_keymap_setup? yeah. that's the one. pull up a chair πŸŽ€


✨ NAME ✨

sparse_keymap_setup β€” set up a sparse keymap for an input device. that's it, that's the whole vibe πŸ¦‹


🌸 SYNOPSIS 🌸

int sparse_keymap_setup (struct input_dev *dev , const struct key_entry
*keymap , int (*setup)(struct input_dev *, struct key_entry *) );

like, no cap, that's the whole signature. three arguments, one int coming back at you πŸ’–


πŸŽ€ ARGUMENTS πŸŽ€

  • dev β€” the input device. your main character, basically πŸ‘‘
  • keymap β€” the keymap, and the way it's shaped is an array of key_entry structures, and the very last one has to be a KE_END type entry. that last bit is not optional, it's the periodt of the array πŸ”₯
  • setup β€” a function you can use to adjust keymap entries depending on what the device needs. and hey, it may be NULL β€” yes queen, optional, we love that for you πŸ™ˆ

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's what happens, and it's actually iconic:

the function calculates the size and then allocates a copy of the original keymap β€” a copy, not your array, don't come for her β€” after which it sets up the input device event bits appropriately. slay. ⭐

and the allocated copy of the keymap is automatically freed when it is no longer needed. so you literally don't have to worry about it. she manages herself. self-care fr fr 🧚

ngl the freeing part is the best part. no cleanup code, no leaks, just vibes πŸ’œ

🌈 SEE ALSO 🌈

go read those too, iykyk 🫢


okay that's the page!! mwah πŸ’‹ and for the little sign-off credit-y bit at the bottom: this one lives under ./drivers/input and it's dated October 2026 β€” so like, future icon behaviour honestly. bye bestie, go set up some keymaps πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from