Skip to content

Commit

Permalink
Align TO() max layers with other keycodes (qmk#17989)
Browse files Browse the repository at this point in the history
  • Loading branch information
zvecr authored and nolanseaton committed Jan 23, 2023
1 parent 816cd50 commit 6bf21d2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
1 change: 1 addition & 0 deletions quantum/action_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ enum layer_param_tap_op {
#define ACTION_LAYER_INVERT(layer, on) ACTION_LAYER_BIT_XOR((layer) / 4, 1 << ((layer) % 4), (on))
#define ACTION_LAYER_ON(layer, on) ACTION_LAYER_BIT_OR((layer) / 4, 1 << ((layer) % 4), (on))
#define ACTION_LAYER_OFF(layer, on) ACTION_LAYER_BIT_AND((layer) / 4, ~(1 << ((layer) % 4)), (on))
#define ACTION_LAYER_GOTO(layer) ACTION_LAYER_SET(layer, ON_PRESS)
#define ACTION_LAYER_SET(layer, on) ACTION_LAYER_BIT_SET((layer) / 4, 1 << ((layer) % 4), (on))
#define ACTION_LAYER_ON_OFF(layer) ACTION_LAYER_TAP((layer), OP_ON_OFF)
#define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON)
Expand Down
8 changes: 3 additions & 5 deletions quantum/keymap_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ action_t action_for_keycode(uint16_t keycode) {
keycode = keycode_config(keycode);

action_t action = {};
uint8_t action_layer, when, mod;
uint8_t action_layer, mod;

(void)action_layer;
(void)when;
(void)mod;

switch (keycode) {
Expand Down Expand Up @@ -85,9 +84,8 @@ action_t action_for_keycode(uint16_t keycode) {
break;
case QK_TO ... QK_TO_MAX:;
// Layer set "GOTO"
when = (keycode >> 0x4) & 0x3;
action_layer = keycode & 0xF;
action.code = ACTION_LAYER_SET(action_layer, when);
action_layer = keycode & 0xFF;
action.code = ACTION_LAYER_GOTO(action_layer);
break;
case QK_MOMENTARY ... QK_MOMENTARY_MAX:;
// Momentary action_layer
Expand Down
11 changes: 2 additions & 9 deletions quantum/quantum_keycodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -797,15 +797,8 @@ enum quantum_keycodes {
#define EH_LEFT MAGIC_EE_HANDS_LEFT
#define EH_RGHT MAGIC_EE_HANDS_RIGHT

// GOTO layer - 16 layers max
// when:
// ON_PRESS = 1
// ON_RELEASE = 2
// Unless you have a good reason not to do so, prefer ON_PRESS (1) as your default.
// In fact, we changed it to assume ON_PRESS for sanity/simplicity. If needed, you can add your own
// keycode modeled after the old version, kept below for this.
/* #define TO(layer, when) (QK_TO | (when << 0x4) | (layer & 0xFF)) */
#define TO(layer) (QK_TO | (ON_PRESS << 0x4) | ((layer)&0xFF))
// GOTO layer - 256 layer max
#define TO(layer) (QK_TO | ((layer)&0xFF))

// Momentary switch layer - 256 layer max
#define MO(layer) (QK_MOMENTARY | ((layer)&0xFF))
Expand Down

0 comments on commit 6bf21d2

Please sign in to comment.