matrix_keypad_build_keymap(9)
π matrix_keypad_build_keymap β¨
okay so you're reading the Kernel API Manual, section 9, and the star of the show is matrix_keypad_build_keymap β the little function that takes your platform keymap and turns it into a matrix keymap. bestie, it's giving "glow-up for keycodes" and honestly? iconic. π
πΈ NAME πΈ
matrix_keypad_build_keymap β convert platform keymap into matrix keymap π
β¨ SYNOPSIS β¨
int matrix_keypad_build_keymap (const struct matrix_keymap_data
*keymap_data , const char *keymap_name , unsigned int rows , unsigned
int cols , unsigned short *keymap , struct input_dev *input_dev );
like, look at all those args. she's thriving. π¦
π«Ά ARGUMENTS π«Ά
keymap_dataβ the keymap your platform code hands over. the source material, the blueprint, the moment. β¨keymap_nameβ the name of the device tree property that contains the keymap (only if device tree support is enabled, iykyk). πrowsβ how many rows the target keymap array has. math but make it cute. π’colsβ how many cols the target keymap array has. yes queen, dimensions. πkeymapβ the expanded version of the keymap, suitable for use by a matrix keyboard driver. the glow-up result! πinput_devβ the input device we're setting up the keymap for. main character energy fr fr. π§
π DESCRIPTION π
so what she does is: this function converts the platform keymap (encoded with the KEY macro) into an array of keycodes that's suitable for using in a standard matrix keyboard driver that uses row and col as indices. no cap, that's the whole vibe. π¦
if keymap_data is not supplied and device tree support is enabled, she'll attempt to load the keymap from the property specified by the keymap_name argument β or "linux,keymap" if keymap_name is NULL. fallback queen behavior. π
if keymap is NULL, the function will automatically allocate a managed block of memory to store the keymap. that memory gets associated with the parent device and is automatically freed when the device unbinds from the driver. literal self-care. β¨
β οΈ real talk: callers are expected to set up input_dev->dev.parent before calling this function. do that first or it's gonna be a mess, bestie. π
π₯ SEE ALSO π₯
- Kernel file
./drivers/input/matrix-keymap.cβ go read the source, it's lowkey fascinating π matrix_keypad_parse_properties(9)β her bestie, obviously π«Ά
and that's the whole page, bestie! π this one shipped out of ./drivers/input, dated October 2026, and it's your girl matrix_keypad_build_keymap(9) signing off β slay, stay keyed, and don't forget your parent device πβ¨π
π¦ 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