summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2017-08-24 04:29:07 +0200
committerGitHub <noreply@github.com>2017-08-24 04:29:07 +0200
commitd2ff66a985b938e87fffe55c1d9f1dc55e356f91 (patch)
tree561b3e203033849573a17f5ac6248077ab687676 /docs
parent7260fc3eef98fb7b0e2ed24d3d0d14cf2e613000 (diff)
downloadqmk_firmware-d2ff66a985b938e87fffe55c1d9f1dc55e356f91.tar.gz
qmk_firmware-d2ff66a985b938e87fffe55c1d9f1dc55e356f91.tar.xz
Creates a layouts/ folder for keymaps shared between keyboards (#1609)
* include variables and .h files as pp directives * start layout compilation * split ergodoxes up * don't compile all layouts for everything * might seg fault * reset layouts variable * actually reset layouts * include rules.mk instead * remove includes from rules.mk * update variable setting * load visualizer from path * adds some more examples * adds more layouts * more boards added * more boards added * adds documentation for layouts * use lowercase names for LAYOUT_ * add layout.json files for each layout * add community folder, default keymaps for layouts * touch-up default layouts * touch-up layouts, some keyboard rules.mk * update documentation for layouts * fix up serial/i2c switches
Diffstat (limited to 'docs')
-rw-r--r--docs/_summary.md1
-rw-r--r--docs/feature_layouts.md77
2 files changed, 78 insertions, 0 deletions
diff --git a/docs/_summary.md b/docs/_summary.md
index e32548f5b..77d208fc3 100644
--- a/docs/_summary.md
+++ b/docs/_summary.md
@@ -12,6 +12,7 @@
* [Keymap](faq_keymap.md)
* [Features](features.md)
+ * [Layouts](feature_layouts.md)
* [Common Shortcuts](feature_common_shortcuts.md)
* [Backlight](feature_backlight.md)
* [Bootmagic](feature_bootmagic.md)
diff --git a/docs/feature_layouts.md b/docs/feature_layouts.md
new file mode 100644
index 000000000..4d75270dc
--- /dev/null
+++ b/docs/feature_layouts.md
@@ -0,0 +1,77 @@
+# Layouts: Using a keymap with multiple keyboards
+
+The `layouts/` folder contains different physical key layouts that can apply to different keyboards.
+
+```
+layouts/
++ default/
+| + 60_ansi/
+| | + readme.md
+| | + layout.json
+| | + a_good_keymap/
+| | | + keymap.c
+| | | + readme.md
+| | | + config.h
+| | | + rules.mk
+| | + <keymap folder>/
+| | + ...
+| + <layout folder>/
++ community/
+| + <layout folder>/
+| + ...
+```
+
+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 reposistories here.
+
+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:
+
+```md
+# 60_ansi
+
+ LAYOUT_60_ansi
+```
+
+New names should try to stick to the standards set by existing layouts, and can be discussed in the PR/Issue.
+
+## Supporting a layout
+
+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 preferrably the physical layout):
+
+ #define LAYOUT_60_ansi KEYMAP_ANSI
+
+The folder name must be added to the keyboard's `rules.mk`:
+
+ LAYOUTS = 60_ansi
+
+`LAYOUTS` can be appended in the subproject's `rules.mk`:
+
+ LAYOUTS += 60_iso
+
+but the `LAYOUT_<layout>` variable must be defined in `<subproject>.h` as well.
+
+## Tips for making layouts keyboard-agnostic
+
+Instead of using `#include "planck.h"`, you can use this line to include whatever `<keyboard>.h` (`<subproject>.h` should not be included here) file that is being compiled:
+
+ #include QMK_KEYBOARD_H
+
+In your config.h, you can also use this variable to include the keyboard's `config.h`:
+
+ #include QMK_KEYBOARD_CONFIG_H
+
+If you want to keep some keyboard-specific code, you can use these variables to escape it with an `#ifdef` statement:
+
+* `KEYBOARD_<keyboard>`
+* `SUBPROJECT_<subproject>`
+
+For example:
+
+```c
+#ifdef KEYBOARD_planck
+ #ifdef SUBPROJECT_rev4
+ planck_rev4_function();
+ #endif
+#endif
+```
+
+Note that the names are lowercase and match the folder/file names for the keyboard/subproject exactly. \ No newline at end of file