1 # Layouts: Using a Keymap with Multiple Keyboards
3 The `layouts/` folder contains different physical key layouts that can apply to different keyboards.
16 | | + <keymap folder>/
24 The `layouts/default/` and `layouts/community/` are two examples of layout "repositories" - currently `default` will contain all of the information concerning the layout, and one default keymap named `default_<layout>`, for users to use as a reference. `community` contains all of the community keymaps, with the eventual goal of being split-off into a separate repo for users to clone into `layouts/`. QMK searches through all folders in `layouts/`, so it's possible to have multiple repositories here.
26 Each layout folder is named (`[a-z0-9_]`) after the physical aspects of the layout, in the most generic way possible, and contains a `readme.md` with the layout to be defined by the keyboard:
34 New names should try to stick to the standards set by existing layouts, and can be discussed in the PR/Issue.
36 ## Supporting a Layout
38 For a keyboard to support a layout, the variable (`[a-z0-9_]`) must be defined in it's `<keyboard>.h`, and match the number of arguments/keys (and preferably the physical layout):
40 #define LAYOUT_60_ansi KEYMAP_ANSI
42 The folder name must be added to the keyboard's `rules.mk`:
46 `LAYOUTS` can be set in any keyboard folder level's `rules.mk`:
50 but the `LAYOUT_<layout>` variable must be defined in `<folder>.h` as well.
52 ## Tips for Making Layouts Keyboard-Agnostic
54 Instead of using `#include "planck.h"`, you can use this line to include whatever `<keyboard>.h` (`<folder>.h` should not be included here) file that is being compiled:
56 #include QMK_KEYBOARD_H
58 If you want to keep some keyboard-specific code, you can use these variables to escape it with an `#ifdef` statement:
60 * `KEYBOARD_<folder1>_<folder2>`
65 #ifdef KEYBOARD_planck
66 #ifdef KEYBOARD_planck_rev4
67 planck_rev4_function();
72 Note that the names are lowercase and match the folder/file names for the keyboard/revision exactly.