summaryrefslogtreecommitdiffstats
path: root/quantum
diff options
context:
space:
mode:
authorsnyman <snyman@users.noreply.github.com>2018-03-21 03:59:54 +0100
committerJack Humbert <jack.humb@gmail.com>2018-03-21 03:59:54 +0100
commit7a5ce36f23624b29b548f9e8f8e3a0b165cdf2a4 (patch)
treeb3d9a72244a49f08b9ef12a1a8376fd05954c67b /quantum
parent4ec03111cc0dd8cb365aaa43a6aaf2c626d72a61 (diff)
downloadqmk_firmware-7a5ce36f23624b29b548f9e8f8e3a0b165cdf2a4.tar.gz
qmk_firmware-7a5ce36f23624b29b548f9e8f8e3a0b165cdf2a4.tar.xz
Add macro for momentarily switching to a layer while some mods are active (#2460)
* Macro for a momentary layer switch with mods Passes through to the existing ACTION_LAYER_MODS macro, albeit with more limited options due to lack of space in the quantum_keycodes enum. * Add documentation for LM layer-mod macro * Clean up Tap Toggle documentation
Diffstat (limited to 'quantum')
-rw-r--r--quantum/keymap_common.c5
-rw-r--r--quantum/quantum_keycodes.h5
2 files changed, 10 insertions, 0 deletions
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
index 8b09f93fc..9a412b66a 100644
--- a/quantum/keymap_common.c
+++ b/quantum/keymap_common.c
@@ -122,6 +122,11 @@ action_t action_for_key(uint8_t layer, keypos_t key)
case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX:
action.code = ACTION_LAYER_TAP_TOGGLE(keycode & 0xFF);
break;
+ case QK_LAYER_MOD ... QK_LAYER_MOD_MAX:
+ mod = keycode & 0xF;
+ action_layer = (keycode >> 4) & 0xF;
+ action.code = ACTION_LAYER_MODS(action_layer, mod);
+ break;
case QK_MOD_TAP ... QK_MOD_TAP_MAX:
mod = mod_config((keycode >> 0x8) & 0x1F);
action.code = ACTION_MODS_TAP_KEY(mod, keycode & 0xFF);
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index 4a5681c7e..8122bfe73 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -71,6 +71,8 @@ enum quantum_keycodes {
QK_TAP_DANCE_MAX = 0x57FF,
QK_LAYER_TAP_TOGGLE = 0x5800,
QK_LAYER_TAP_TOGGLE_MAX = 0x58FF,
+ QK_LAYER_MOD = 0x5900,
+ QK_LAYER_MOD_MAX = 0x59FF,
#ifdef STENO_ENABLE
QK_STENO = 0x5A00,
QK_STENO_BOLT = 0x5A30,
@@ -597,6 +599,9 @@ enum quantum_keycodes {
// One-shot layer - 256 layer max
#define OSL(layer) (layer | QK_ONE_SHOT_LAYER)
+// L-ayer M-od: Momentary switch layer with modifiers active - 16 layer max, left mods only
+#define LM(layer, mod) (QK_LAYER_MOD | (((layer) & 0xF) << 4) | ((mod) & 0xF))
+
// One-shot mod
#define OSM(mod) ((mod) | QK_ONE_SHOT_MOD)