Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creates a layouts/ folder for keymaps shared between keyboards #1609

Merged
merged 25 commits into from
Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9791919
include variables and .h files as pp directives
jackhumbert Aug 13, 2017
f5a8053
start layout compilation
jackhumbert Aug 17, 2017
29a85ec
start to add layouts
jackhumbert Aug 17, 2017
b43fd74
split ergodoxes up
jackhumbert Aug 18, 2017
cdfa7d4
don't compile all layouts for everything
jackhumbert Aug 18, 2017
4d49744
might seg fault
jackhumbert Aug 18, 2017
5317dd6
reset layouts variable
jackhumbert Aug 18, 2017
0e91339
actually reset layouts
jackhumbert Aug 18, 2017
bd40013
include rules.mk instead
jackhumbert Aug 18, 2017
88cabe5
remove includes from rules.mk
jackhumbert Aug 18, 2017
e10897f
update variable setting
jackhumbert Aug 18, 2017
ab4fc42
load visualizer from path
jackhumbert Aug 18, 2017
0af6a8d
adds some more examples
jackhumbert Aug 19, 2017
b043f3c
adds more layouts
jackhumbert Aug 19, 2017
505595c
more boards added
jackhumbert Aug 19, 2017
40f573f
more boards added
jackhumbert Aug 19, 2017
dc5b915
adds documentation for layouts
jackhumbert Aug 19, 2017
769ed17
use lowercase names for LAYOUT_
jackhumbert Aug 19, 2017
d88e8c9
add layout.json files for each layout
jackhumbert Aug 20, 2017
cf5dcc4
add community folder, default keymaps for layouts
jackhumbert Aug 21, 2017
8fd5348
touch-up default layouts
jackhumbert Aug 21, 2017
3e586d8
touch-up layouts, some keyboard rules.mk
jackhumbert Aug 21, 2017
eca285a
update documentation for layouts
jackhumbert Aug 21, 2017
cdede25
fix up serial/i2c switches
jackhumbert Aug 21, 2017
2402ac5
merge from master
jackhumbert Aug 22, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,21 @@ define PARSE_SUBPROJECT
ifneq ($$(CURRENT_SP),allsp)
# get a list of all keymaps
KEYMAPS := $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/keymaps/*/.)))
LAYOUTS :=
$$(eval -include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/rules.mk)
KEYBOARD_LAYOUTS := $$(LAYOUTS)
ifneq ($$(CURRENT_SP),)
# if the subproject is defined, then also look for keymaps inside the subproject folder
SP_KEYMAPS := $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/$$(CURRENT_SP)/keymaps/*/.)))
KEYMAPS := $$(sort $$(KEYMAPS) $$(SP_KEYMAPS))
# $$(eval -include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/$$(CURRENT_SP)/rules.mk)
# KEYBOARD_LAYOUTS := $$(sort $$(KEYBOARD_LAYOUTS) $$(LAYOUTS))
endif

LAYOUT_KEYMAPS :=
$$(foreach LAYOUT,$$(KEYBOARD_LAYOUTS),$$(eval LAYOUT_KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/layouts/*/$$(LAYOUT)/*/.)))))

KEYMAPS := $$(sort $$(KEYMAPS) $$(LAYOUT_KEYMAPS))
# if the rule after removing the start of it is empty (we haven't specified a kemap or target)
# compile all the keymaps
ifeq ($$(RULE),)
Expand Down
12 changes: 9 additions & 3 deletions build_keyboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ifneq ("$(wildcard $(KEYBOARD_C))","")
else
$(error "$(KEYBOARD_C)" does not exist)
endif
OPT_DEFS += -DKEYBOARD_$(KEYBOARD)

ifneq ($(SUBPROJECT),)
SUBPROJECT_PATH := keyboards/$(KEYBOARD)/$(SUBPROJECT)
Expand Down Expand Up @@ -97,11 +98,13 @@ else ifneq ("$(wildcard $(MAIN_KEYMAP_C))","")
-include $(MAIN_KEYMAP_PATH)/Makefile
KEYMAP_C := $(MAIN_KEYMAP_C)
KEYMAP_PATH := $(MAIN_KEYMAP_PATH)
else ifneq ($(LAYOUTS),)
include build_layout.mk
else
$(error "$(MAIN_KEYMAP_C)/keymap.c" does not exist)
$(error Could not find keymap)
# this state should never be reached
endif


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

OUTPUTS := $(KEYMAP_OUTPUT) $(KEYBOARD_OUTPUT)
$(KEYMAP_OUTPUT)_SRC := $(SRC)
$(KEYMAP_OUTPUT)_DEFS := $(OPT_DEFS) $(GFXDEFS) -DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYMAP=\"$(KEYMAP)\"
$(KEYMAP_OUTPUT)_DEFS := $(OPT_DEFS) $(GFXDEFS) \
-DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYBOARD_H=\"$(KEYBOARD).h\" -DQMK_KEYBOARD_CONFIG_H=\"$(KEYBOARD_PATH)/config.h\" \
-DQMK_KEYMAP=\"$(KEYMAP)\" -DQMK_KEYMAP_H=\"$(KEYMAP).h\" -DQMK_KEYMAP_CONFIG_H=\"$(KEYMAP_PATH)/config.h\" \
-DQMK_SUBPROJECT=\"$(SUBPROJECT)\" -DQMK_SUBPROJECT_H=\"$(SUBPROJECT).h\" -DQMK_SUBPROJECT_CONFIG_H=\"$(SUBPROJECT_PATH)/config.h\"
$(KEYMAP_OUTPUT)_INC := $(VPATH) $(EXTRAINCDIRS)
$(KEYMAP_OUTPUT)_CONFIG := $(CONFIG_H)
$(KEYBOARD_OUTPUT)_SRC := $(CHIBISRC) $(GFXSRC)
Expand Down
18 changes: 18 additions & 0 deletions build_layout.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
LAYOUTS_PATH := layouts
LAYOUTS_REPOS := $(patsubst %/,%,$(sort $(dir $(wildcard $(LAYOUTS_PATH)/*/))))

define SEARCH_LAYOUTS_REPO
LAYOUT_KEYMAP_PATH := $$(LAYOUTS_REPO)/$$(LAYOUT)/$$(KEYMAP)
LAYOUT_KEYMAP_C := $$(LAYOUT_KEYMAP_PATH)/keymap.c
ifneq ("$$(wildcard $$(LAYOUT_KEYMAP_C))","")
-include $$(LAYOUT_KEYMAP_PATH)/rules.mk
KEYMAP_C := $$(LAYOUT_KEYMAP_C)
KEYMAP_PATH := $$(LAYOUT_KEYMAP_PATH)
endif
endef

define SEARCH_LAYOUTS
$$(foreach LAYOUTS_REPO,$$(LAYOUTS_REPOS),$$(eval $$(call SEARCH_LAYOUTS_REPO)))
endef

$(foreach LAYOUT,$(LAYOUTS),$(eval $(call SEARCH_LAYOUTS)))
1 change: 1 addition & 0 deletions docs/_summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
77 changes: 77 additions & 0 deletions docs/feature_layouts.md
Original file line number Diff line number Diff line change
@@ -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.
18 changes: 18 additions & 0 deletions keyboards/alps64/alps64.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "quantum.h"

/* Alps64 keymap definition macro */

#define KEYMAP( \
K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, K26, K27, \
K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \
K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \
K31, K41, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, K22, \
K30, K40, K50, K60, K70, K00, K10, K20 \
) { \
{ K00, K01, K02, K03, K04, K05, K06, K07 }, \
{ K10, K11, K12, K13, K14, K15, K16, K17 }, \
{ K20, K21, K22, K23, K24, K25, K26, K27 }, \
{ K30, K31, K32, K33, K34, K35, K36, K37 }, \
{ K40, K41, K42, K43, K44, K45, K46, K47 }, \
{ K50, K51, K52, K53, K54, K55, K56, K57 }, \
{ K60, K61, K62, K63, K64, K65, K66, K67 }, \
{ K70, K71, K72, K73, K74, K75, K76, K77 } \
}

#define KC_KEYMAP( \
K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, K26, K27, \
K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \
K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \
K31, K41, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, K22, \
K30, K40, K50, K60, K70, K00, K10, K20 \
) { \
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
Expand Down
2 changes: 1 addition & 1 deletion keyboards/alps64/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* 0: qwerty */
KEYMAP( \
KC_KEYMAP( \
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, NUHS, BSPC, \
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, \
Expand Down
3 changes: 3 additions & 0 deletions keyboards/amj60/amj60.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
{k40, k41, k42, XXX, XXX, k45, XXX, XXX, XXX, XXX, k4a, k4b, k4c, k4d} \
}

#define LAYOUT_60_ansi KEYMAP_ANSI

/* AMJ60 HHKB matrix layout
* ,------------------------------------------------------------.
* | 00 |01| 02| 03| 04| 05| 06| 07| 08| 09| 0a| 0b| 0c| 0d| 49 |
Expand Down Expand Up @@ -119,6 +121,7 @@
{k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, XXX}, \
{k40, k41, k42, XXX, XXX, k45, XXX, XXX, XXX, XXX, k4a, k4b, k4c, k4d} \
}

/* ISO w/ split right shift key matrix layout
* ,-----------------------------------------------------------.
* | 00 |01| 02| 03| 04| 05| 06| 07| 08| 09| 0a| 0b| 0c| 0d |
Expand Down
2 changes: 2 additions & 0 deletions keyboards/amj60/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ MIDI_ENABLE = no # MIDI controls
AUDIO_ENABLE = no
UNICODE_ENABLE = no # Unicode
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID

LAYOUTS = 60_ansi
16 changes: 16 additions & 0 deletions keyboards/atomic/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,20 @@
{ K40, K41, KC_NO, K43, KC_NO, KC_NO, K46, KC_NO, KC_NO, KC_NO, K4A, K4B, K4C, K4D, K4E } \
}

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

#define LAYOUT_ortho_5x15 KEYMAP_GRID

#endif
4 changes: 3 additions & 1 deletion keyboards/atomic/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@ BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.

# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend

LAYOUTS = ortho_5x15
4 changes: 2 additions & 2 deletions keyboards/atreus/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@ UNICODE_ENABLE = YES # Unicode

USB = /dev/cu.usbmodem1411

upload: build
$(ATREUS_UPLOAD_COMMAND)
# upload: build
# $(ATREUS_UPLOAD_COMMAND)
5 changes: 1 addition & 4 deletions keyboards/chibios_test/stm32_f072_onekey/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,4 @@ ARMV = 6

# Build Options
# comment out to disable the options.
#
ifndef QUANTUM_DIR
include ../../../Makefile
endif
#
7 changes: 1 addition & 6 deletions keyboards/chibios_test/stm32_f103_onekey/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,4 @@ ARMV = 7
# http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf
# This also requires a patch to chibios:
# <tmk_dir>/tmk_core/tool/chibios/ch-bootloader-jump.patch
#STM32_BOOTLOADER_ADDRESS = 0x1FFFC800


ifndef QUANTUM_DIR
include ../../../Makefile
endif
#STM32_BOOTLOADER_ADDRESS = 0x1FFFC800
6 changes: 1 addition & 5 deletions keyboards/chibios_test/teensy_lc_onekey/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,4 @@ MCU = cortex-m0plus

# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
# I.e. 6 for Teensy LC; 7 for Teensy 3.x
ARMV = 6

ifndef QUANTUM_DIR
include ../../../Makefile
endif
ARMV = 6
6 changes: 1 addition & 5 deletions keyboards/clueboard/rev1/rules.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
BACKLIGHT_ENABLE = no

ifndef QUANTUM_DIR
include ../../../Makefile
endif
BACKLIGHT_ENABLE = no
6 changes: 1 addition & 5 deletions keyboards/clueboard/rev2/rules.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
BACKLIGHT_ENABLE = yes

ifndef QUANTUM_DIR
include ../../../Makefile
endif
BACKLIGHT_ENABLE = yes
6 changes: 1 addition & 5 deletions keyboards/eco/rev1/rules.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
BACKLIGHT_ENABLE = no

ifndef QUANTUM_DIR
include ../../../Makefile
endif
BACKLIGHT_ENABLE = no
6 changes: 1 addition & 5 deletions keyboards/eco/rev2/rules.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
BACKLIGHT_ENABLE = no

ifndef QUANTUM_DIR
include ../../../Makefile
endif
BACKLIGHT_ENABLE = no
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef ERGODOX_ERGODONE_CONFIG_H
#define ERGODOX_ERGODONE_CONFIG_H

#include "../config.h"

#include "config_common.h"

/* USB Device descriptor parameter */
Expand All @@ -17,6 +15,31 @@
#define MATRIX_ROWS 6
#define MATRIX_COLS 14

#define MOUSEKEY_INTERVAL 20
#define MOUSEKEY_DELAY 0
#define MOUSEKEY_TIME_TO_MAX 60
#define MOUSEKEY_MAX_SPEED 7
#define MOUSEKEY_WHEEL_DELAY 0

#define TAPPING_TOGGLE 1

/* define if matrix has ghost */
//#define MATRIX_HAS_GHOST

#define TAPPING_TERM 200
#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.)

/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE

/* key combination for command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) || \
keyboard_report->mods == (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) \
)

/* number of backlight levels */
#define BACKLIGHT_LEVELS 3

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ inline void ergodox_led_all_set(uint8_t n) {}
{ KC_NO, k51, k52, k53, k54, k55, k56, k57, k58, k59, k5A, k5B, k5C, KC_NO } \
}

#define LAYOUT_ergodox KEYMAP

#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading