sparse_keymap_setup(9)
π 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 ofkey_entrystructures, and the very last one has to be aKE_ENDtype 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 beNULLβ 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 π
- Kernel file
./drivers/input/sparse-keymap.c sparse_keymap_entry_from_scancode(9)sparse_keymap_entry_from_keycode(9)sparse_keymap_report_entry(9)sparse_keymap_report_event(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms