diff options
| author | Joel Challis <git@zvecr.com> | 2022-08-14 12:25:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-14 21:25:46 +1000 |
| commit | ba04ecfabd4f254bb89ccd7d1de9ac7fb228ce5b (patch) | |
| tree | 4198d6b70f683529a19d699a79dcd082e0b71cd2 | |
| parent | ac31e429741a640b0d03d2ebd76554b7fe9247e0 (diff) | |
Align TO() max layers with other keycodes (#17989)
| -rw-r--r-- | quantum/action_code.h | 1 | ||||
| -rw-r--r-- | quantum/keymap_common.c | 8 | ||||
| -rw-r--r-- | quantum/quantum_keycodes.h | 11 |
3 files changed, 6 insertions, 14 deletions
diff --git a/quantum/action_code.h b/quantum/action_code.h index 20b3e459d2..e107f0a740 100644 --- a/quantum/action_code.h +++ b/quantum/action_code.h | |||
| @@ -234,6 +234,7 @@ enum layer_param_tap_op { | |||
| 234 | #define ACTION_LAYER_INVERT(layer, on) ACTION_LAYER_BIT_XOR((layer) / 4, 1 << ((layer) % 4), (on)) | 234 | #define ACTION_LAYER_INVERT(layer, on) ACTION_LAYER_BIT_XOR((layer) / 4, 1 << ((layer) % 4), (on)) |
| 235 | #define ACTION_LAYER_ON(layer, on) ACTION_LAYER_BIT_OR((layer) / 4, 1 << ((layer) % 4), (on)) | 235 | #define ACTION_LAYER_ON(layer, on) ACTION_LAYER_BIT_OR((layer) / 4, 1 << ((layer) % 4), (on)) |
| 236 | #define ACTION_LAYER_OFF(layer, on) ACTION_LAYER_BIT_AND((layer) / 4, ~(1 << ((layer) % 4)), (on)) | 236 | #define ACTION_LAYER_OFF(layer, on) ACTION_LAYER_BIT_AND((layer) / 4, ~(1 << ((layer) % 4)), (on)) |
| 237 | #define ACTION_LAYER_GOTO(layer) ACTION_LAYER_SET(layer, ON_PRESS) | ||
| 237 | #define ACTION_LAYER_SET(layer, on) ACTION_LAYER_BIT_SET((layer) / 4, 1 << ((layer) % 4), (on)) | 238 | #define ACTION_LAYER_SET(layer, on) ACTION_LAYER_BIT_SET((layer) / 4, 1 << ((layer) % 4), (on)) |
| 238 | #define ACTION_LAYER_ON_OFF(layer) ACTION_LAYER_TAP((layer), OP_ON_OFF) | 239 | #define ACTION_LAYER_ON_OFF(layer) ACTION_LAYER_TAP((layer), OP_ON_OFF) |
| 239 | #define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON) | 240 | #define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON) |
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index c1940f0fd3..8d7a8bda9a 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c | |||
| @@ -47,10 +47,9 @@ action_t action_for_keycode(uint16_t keycode) { | |||
| 47 | keycode = keycode_config(keycode); | 47 | keycode = keycode_config(keycode); |
| 48 | 48 | ||
| 49 | action_t action = {}; | 49 | action_t action = {}; |
| 50 | uint8_t action_layer, when, mod; | 50 | uint8_t action_layer, mod; |
| 51 | 51 | ||
| 52 | (void)action_layer; | 52 | (void)action_layer; |
| 53 | (void)when; | ||
| 54 | (void)mod; | 53 | (void)mod; |
| 55 | 54 | ||
| 56 | switch (keycode) { | 55 | switch (keycode) { |
| @@ -85,9 +84,8 @@ action_t action_for_keycode(uint16_t keycode) { | |||
| 85 | break; | 84 | break; |
| 86 | case QK_TO ... QK_TO_MAX:; | 85 | case QK_TO ... QK_TO_MAX:; |
| 87 | // Layer set "GOTO" | 86 | // Layer set "GOTO" |
| 88 | when = (keycode >> 0x4) & 0x3; | 87 | action_layer = keycode & 0xFF; |
| 89 | action_layer = keycode & 0xF; | 88 | action.code = ACTION_LAYER_GOTO(action_layer); |
| 90 | action.code = ACTION_LAYER_SET(action_layer, when); | ||
| 91 | break; | 89 | break; |
| 92 | case QK_MOMENTARY ... QK_MOMENTARY_MAX:; | 90 | case QK_MOMENTARY ... QK_MOMENTARY_MAX:; |
| 93 | // Momentary action_layer | 91 | // Momentary action_layer |
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 456fad6f1b..7228ee9e08 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
| @@ -797,15 +797,8 @@ enum quantum_keycodes { | |||
| 797 | #define EH_LEFT MAGIC_EE_HANDS_LEFT | 797 | #define EH_LEFT MAGIC_EE_HANDS_LEFT |
| 798 | #define EH_RGHT MAGIC_EE_HANDS_RIGHT | 798 | #define EH_RGHT MAGIC_EE_HANDS_RIGHT |
| 799 | 799 | ||
| 800 | // GOTO layer - 16 layers max | 800 | // GOTO layer - 256 layer max |
| 801 | // when: | 801 | #define TO(layer) (QK_TO | ((layer)&0xFF)) |
| 802 | // ON_PRESS = 1 | ||
| 803 | // ON_RELEASE = 2 | ||
| 804 | // Unless you have a good reason not to do so, prefer ON_PRESS (1) as your default. | ||
| 805 | // In fact, we changed it to assume ON_PRESS for sanity/simplicity. If needed, you can add your own | ||
| 806 | // keycode modeled after the old version, kept below for this. | ||
| 807 | /* #define TO(layer, when) (QK_TO | (when << 0x4) | (layer & 0xFF)) */ | ||
| 808 | #define TO(layer) (QK_TO | (ON_PRESS << 0x4) | ((layer)&0xFF)) | ||
| 809 | 802 | ||
| 810 | // Momentary switch layer - 256 layer max | 803 | // Momentary switch layer - 256 layer max |
| 811 | #define MO(layer) (QK_MOMENTARY | ((layer)&0xFF)) | 804 | #define MO(layer) (QK_MOMENTARY | ((layer)&0xFF)) |
