Skip to content

Commit d2ff66a

Browse files
authored
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
1 parent 7260fc3 commit d2ff66a

File tree

451 files changed

+1651
-1477
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

451 files changed

+1651
-1477
lines changed

Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,21 @@ define PARSE_SUBPROJECT
314314
ifneq ($$(CURRENT_SP),allsp)
315315
# get a list of all keymaps
316316
KEYMAPS := $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/keymaps/*/.)))
317+
LAYOUTS :=
318+
$$(eval -include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/rules.mk)
319+
KEYBOARD_LAYOUTS := $$(LAYOUTS)
317320
ifneq ($$(CURRENT_SP),)
318321
# if the subproject is defined, then also look for keymaps inside the subproject folder
319322
SP_KEYMAPS := $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/$$(CURRENT_SP)/keymaps/*/.)))
320323
KEYMAPS := $$(sort $$(KEYMAPS) $$(SP_KEYMAPS))
324+
# $$(eval -include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/$$(CURRENT_SP)/rules.mk)
325+
# KEYBOARD_LAYOUTS := $$(sort $$(KEYBOARD_LAYOUTS) $$(LAYOUTS))
321326
endif
327+
328+
LAYOUT_KEYMAPS :=
329+
$$(foreach LAYOUT,$$(KEYBOARD_LAYOUTS),$$(eval LAYOUT_KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/layouts/*/$$(LAYOUT)/*/.)))))
330+
331+
KEYMAPS := $$(sort $$(KEYMAPS) $$(LAYOUT_KEYMAPS))
322332
# if the rule after removing the start of it is empty (we haven't specified a kemap or target)
323333
# compile all the keymaps
324334
ifeq ($$(RULE),)

build_keyboard.mk

+9-3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ ifneq ("$(wildcard $(KEYBOARD_C))","")
3939
else
4040
$(error "$(KEYBOARD_C)" does not exist)
4141
endif
42+
OPT_DEFS += -DKEYBOARD_$(KEYBOARD)
4243

4344
ifneq ($(SUBPROJECT),)
4445
SUBPROJECT_PATH := keyboards/$(KEYBOARD)/$(SUBPROJECT)
@@ -97,11 +98,13 @@ else ifneq ("$(wildcard $(MAIN_KEYMAP_C))","")
9798
-include $(MAIN_KEYMAP_PATH)/Makefile
9899
KEYMAP_C := $(MAIN_KEYMAP_C)
99100
KEYMAP_PATH := $(MAIN_KEYMAP_PATH)
101+
else ifneq ($(LAYOUTS),)
102+
include build_layout.mk
100103
else
101-
$(error "$(MAIN_KEYMAP_C)/keymap.c" does not exist)
104+
$(error Could not find keymap)
105+
# this state should never be reached
102106
endif
103107

104-
105108
# Object files directory
106109
# To put object files in current directory, use a dot (.), do NOT make
107110
# this an empty or blank macro!
@@ -157,7 +160,10 @@ endif
157160

158161
OUTPUTS := $(KEYMAP_OUTPUT) $(KEYBOARD_OUTPUT)
159162
$(KEYMAP_OUTPUT)_SRC := $(SRC)
160-
$(KEYMAP_OUTPUT)_DEFS := $(OPT_DEFS) $(GFXDEFS) -DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYMAP=\"$(KEYMAP)\"
163+
$(KEYMAP_OUTPUT)_DEFS := $(OPT_DEFS) $(GFXDEFS) \
164+
-DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYBOARD_H=\"$(KEYBOARD).h\" -DQMK_KEYBOARD_CONFIG_H=\"$(KEYBOARD_PATH)/config.h\" \
165+
-DQMK_KEYMAP=\"$(KEYMAP)\" -DQMK_KEYMAP_H=\"$(KEYMAP).h\" -DQMK_KEYMAP_CONFIG_H=\"$(KEYMAP_PATH)/config.h\" \
166+
-DQMK_SUBPROJECT=\"$(SUBPROJECT)\" -DQMK_SUBPROJECT_H=\"$(SUBPROJECT).h\" -DQMK_SUBPROJECT_CONFIG_H=\"$(SUBPROJECT_PATH)/config.h\"
161167
$(KEYMAP_OUTPUT)_INC := $(VPATH) $(EXTRAINCDIRS)
162168
$(KEYMAP_OUTPUT)_CONFIG := $(CONFIG_H)
163169
$(KEYBOARD_OUTPUT)_SRC := $(CHIBISRC) $(GFXSRC)

build_layout.mk

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
LAYOUTS_PATH := layouts
2+
LAYOUTS_REPOS := $(patsubst %/,%,$(sort $(dir $(wildcard $(LAYOUTS_PATH)/*/))))
3+
4+
define SEARCH_LAYOUTS_REPO
5+
LAYOUT_KEYMAP_PATH := $$(LAYOUTS_REPO)/$$(LAYOUT)/$$(KEYMAP)
6+
LAYOUT_KEYMAP_C := $$(LAYOUT_KEYMAP_PATH)/keymap.c
7+
ifneq ("$$(wildcard $$(LAYOUT_KEYMAP_C))","")
8+
-include $$(LAYOUT_KEYMAP_PATH)/rules.mk
9+
KEYMAP_C := $$(LAYOUT_KEYMAP_C)
10+
KEYMAP_PATH := $$(LAYOUT_KEYMAP_PATH)
11+
endif
12+
endef
13+
14+
define SEARCH_LAYOUTS
15+
$$(foreach LAYOUTS_REPO,$$(LAYOUTS_REPOS),$$(eval $$(call SEARCH_LAYOUTS_REPO)))
16+
endef
17+
18+
$(foreach LAYOUT,$(LAYOUTS),$(eval $(call SEARCH_LAYOUTS)))

docs/_summary.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* [Keymap](faq_keymap.md)
1313

1414
* [Features](features.md)
15+
* [Layouts](feature_layouts.md)
1516
* [Common Shortcuts](feature_common_shortcuts.md)
1617
* [Backlight](feature_backlight.md)
1718
* [Bootmagic](feature_bootmagic.md)

docs/feature_layouts.md

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Layouts: Using a keymap with multiple keyboards
2+
3+
The `layouts/` folder contains different physical key layouts that can apply to different keyboards.
4+
5+
```
6+
layouts/
7+
+ default/
8+
| + 60_ansi/
9+
| | + readme.md
10+
| | + layout.json
11+
| | + a_good_keymap/
12+
| | | + keymap.c
13+
| | | + readme.md
14+
| | | + config.h
15+
| | | + rules.mk
16+
| | + <keymap folder>/
17+
| | + ...
18+
| + <layout folder>/
19+
+ community/
20+
| + <layout folder>/
21+
| + ...
22+
```
23+
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 reposistories here.
25+
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:
27+
28+
```md
29+
# 60_ansi
30+
31+
LAYOUT_60_ansi
32+
```
33+
34+
New names should try to stick to the standards set by existing layouts, and can be discussed in the PR/Issue.
35+
36+
## Supporting a layout
37+
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 preferrably the physical layout):
39+
40+
#define LAYOUT_60_ansi KEYMAP_ANSI
41+
42+
The folder name must be added to the keyboard's `rules.mk`:
43+
44+
LAYOUTS = 60_ansi
45+
46+
`LAYOUTS` can be appended in the subproject's `rules.mk`:
47+
48+
LAYOUTS += 60_iso
49+
50+
but the `LAYOUT_<layout>` variable must be defined in `<subproject>.h` as well.
51+
52+
## Tips for making layouts keyboard-agnostic
53+
54+
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:
55+
56+
#include QMK_KEYBOARD_H
57+
58+
In your config.h, you can also use this variable to include the keyboard's `config.h`:
59+
60+
#include QMK_KEYBOARD_CONFIG_H
61+
62+
If you want to keep some keyboard-specific code, you can use these variables to escape it with an `#ifdef` statement:
63+
64+
* `KEYBOARD_<keyboard>`
65+
* `SUBPROJECT_<subproject>`
66+
67+
For example:
68+
69+
```c
70+
#ifdef KEYBOARD_planck
71+
#ifdef SUBPROJECT_rev4
72+
planck_rev4_function();
73+
#endif
74+
#endif
75+
```
76+
77+
Note that the names are lowercase and match the folder/file names for the keyboard/subproject exactly.

keyboards/alps64/alps64.h

+18
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2020
#include "quantum.h"
2121

2222
/* Alps64 keymap definition macro */
23+
2324
#define KEYMAP( \
2425
K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, K26, K27, \
2526
K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \
2627
K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \
2728
K31, K41, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, K22, \
2829
K30, K40, K50, K60, K70, K00, K10, K20 \
30+
) { \
31+
{ K00, K01, K02, K03, K04, K05, K06, K07 }, \
32+
{ K10, K11, K12, K13, K14, K15, K16, K17 }, \
33+
{ K20, K21, K22, K23, K24, K25, K26, K27 }, \
34+
{ K30, K31, K32, K33, K34, K35, K36, K37 }, \
35+
{ K40, K41, K42, K43, K44, K45, K46, K47 }, \
36+
{ K50, K51, K52, K53, K54, K55, K56, K57 }, \
37+
{ K60, K61, K62, K63, K64, K65, K66, K67 }, \
38+
{ K70, K71, K72, K73, K74, K75, K76, K77 } \
39+
}
40+
41+
#define KC_KEYMAP( \
42+
K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, K26, K27, \
43+
K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \
44+
K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \
45+
K31, K41, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, K22, \
46+
K30, K40, K50, K60, K70, K00, K10, K20 \
2947
) { \
3048
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
3149
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \

keyboards/alps64/keymaps/default/keymap.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
44
/* 0: qwerty */
5-
KEYMAP( \
5+
KC_KEYMAP( \
66
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, NUHS, BSPC, \
77
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \
88
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, \

keyboards/amj60/amj60.h

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363
{k40, k41, k42, XXX, XXX, k45, XXX, XXX, XXX, XXX, k4a, k4b, k4c, k4d} \
6464
}
6565

66+
#define LAYOUT_60_ansi KEYMAP_ANSI
67+
6668
/* AMJ60 HHKB matrix layout
6769
* ,------------------------------------------------------------.
6870
* | 00 |01| 02| 03| 04| 05| 06| 07| 08| 09| 0a| 0b| 0c| 0d| 49 |
@@ -119,6 +121,7 @@
119121
{k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, XXX}, \
120122
{k40, k41, k42, XXX, XXX, k45, XXX, XXX, XXX, XXX, k4a, k4b, k4c, k4d} \
121123
}
124+
122125
/* ISO w/ split right shift key matrix layout
123126
* ,-----------------------------------------------------------.
124127
* | 00 |01| 02| 03| 04| 05| 06| 07| 08| 09| 0a| 0b| 0c| 0d |

keyboards/amj60/rules.mk

+2
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ MIDI_ENABLE = no # MIDI controls
6464
AUDIO_ENABLE = no
6565
UNICODE_ENABLE = no # Unicode
6666
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
67+
68+
LAYOUTS = 60_ansi

keyboards/atomic/atomic.h

+16
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,20 @@
2424
{ K40, K41, KC_NO, K43, KC_NO, KC_NO, K46, KC_NO, KC_NO, KC_NO, K4A, K4B, K4C, K4D, K4E } \
2525
}
2626

27+
#define KEYMAP_GRID( \
28+
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E,\
29+
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E,\
30+
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E,\
31+
K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E,\
32+
K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4B, K4C, K4D, K4E \
33+
) { \
34+
{ K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E }, \
35+
{ K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E }, \
36+
{ K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E }, \
37+
{ K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E }, \
38+
{ K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4B, K4C, K4D, K4E } \
39+
}
40+
41+
#define LAYOUT_ortho_5x15 KEYMAP_GRID
42+
2743
#endif

keyboards/atomic/rules.mk

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,6 @@ BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
6666
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
6767

6868
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
69-
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
69+
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
70+
71+
LAYOUTS = ortho_5x15

keyboards/atreus/rules.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,5 @@ UNICODE_ENABLE = YES # Unicode
7878

7979
USB = /dev/cu.usbmodem1411
8080

81-
upload: build
82-
$(ATREUS_UPLOAD_COMMAND)
81+
# upload: build
82+
# $(ATREUS_UPLOAD_COMMAND)

keyboards/chibios_test/stm32_f072_onekey/rules.mk

+1-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,4 @@ ARMV = 6
3535

3636
# Build Options
3737
# comment out to disable the options.
38-
#
39-
ifndef QUANTUM_DIR
40-
include ../../../Makefile
41-
endif
38+
#

keyboards/chibios_test/stm32_f103_onekey/rules.mk

+1-6
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,4 @@ ARMV = 7
4444
# http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf
4545
# This also requires a patch to chibios:
4646
# <tmk_dir>/tmk_core/tool/chibios/ch-bootloader-jump.patch
47-
#STM32_BOOTLOADER_ADDRESS = 0x1FFFC800
48-
49-
50-
ifndef QUANTUM_DIR
51-
include ../../../Makefile
52-
endif
47+
#STM32_BOOTLOADER_ADDRESS = 0x1FFFC800

keyboards/chibios_test/teensy_lc_onekey/rules.mk

+1-5
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,4 @@ MCU = cortex-m0plus
4242

4343
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
4444
# I.e. 6 for Teensy LC; 7 for Teensy 3.x
45-
ARMV = 6
46-
47-
ifndef QUANTUM_DIR
48-
include ../../../Makefile
49-
endif
45+
ARMV = 6

keyboards/clueboard/rev1/rules.mk

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
BACKLIGHT_ENABLE = no
2-
3-
ifndef QUANTUM_DIR
4-
include ../../../Makefile
5-
endif
1+
BACKLIGHT_ENABLE = no

keyboards/clueboard/rev2/rules.mk

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
BACKLIGHT_ENABLE = yes
2-
3-
ifndef QUANTUM_DIR
4-
include ../../../Makefile
5-
endif
1+
BACKLIGHT_ENABLE = yes

keyboards/eco/rev1/rules.mk

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
BACKLIGHT_ENABLE = no
2-
3-
ifndef QUANTUM_DIR
4-
include ../../../Makefile
5-
endif
1+
BACKLIGHT_ENABLE = no

keyboards/eco/rev2/rules.mk

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
BACKLIGHT_ENABLE = no
2-
3-
ifndef QUANTUM_DIR
4-
include ../../../Makefile
5-
endif
1+
BACKLIGHT_ENABLE = no
File renamed without changes.

keyboards/ergodox/ergodone/config.h renamed to keyboards/ergodone/config.h

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef ERGODOX_ERGODONE_CONFIG_H
22
#define ERGODOX_ERGODONE_CONFIG_H
33

4-
#include "../config.h"
5-
64
#include "config_common.h"
75

86
/* USB Device descriptor parameter */
@@ -17,6 +15,31 @@
1715
#define MATRIX_ROWS 6
1816
#define MATRIX_COLS 14
1917

18+
#define MOUSEKEY_INTERVAL 20
19+
#define MOUSEKEY_DELAY 0
20+
#define MOUSEKEY_TIME_TO_MAX 60
21+
#define MOUSEKEY_MAX_SPEED 7
22+
#define MOUSEKEY_WHEEL_DELAY 0
23+
24+
#define TAPPING_TOGGLE 1
25+
26+
/* define if matrix has ghost */
27+
//#define MATRIX_HAS_GHOST
28+
29+
#define TAPPING_TERM 200
30+
#define IGNORE_MOD_TAP_INTERRUPT // this makes it possible to do rolling combos (zx) with keys that convert to other keys on hold (z becomes ctrl when you hold it, and when this option isn't enabled, z rapidly followed by x actually sends Ctrl-x. That's bad.)
31+
32+
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
33+
#define LOCKING_SUPPORT_ENABLE
34+
/* Locking resynchronize hack */
35+
#define LOCKING_RESYNC_ENABLE
36+
37+
/* key combination for command */
38+
#define IS_COMMAND() ( \
39+
keyboard_report->mods == (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) || \
40+
keyboard_report->mods == (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) \
41+
)
42+
2043
/* number of backlight levels */
2144
#define BACKLIGHT_LEVELS 3
2245

File renamed without changes.

keyboards/ergodox/ergodone/ergodone.h renamed to keyboards/ergodone/ergodone.h

+2
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,6 @@ inline void ergodox_led_all_set(uint8_t n) {}
6060
{ KC_NO, k51, k52, k53, k54, k55, k56, k57, k58, k59, k5A, k5B, k5C, KC_NO } \
6161
}
6262

63+
#define LAYOUT_ergodox KEYMAP
64+
6365
#endif
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)