forked from forks/qmk_firmware
Align TO() max layers with other keycodes (#17989)
This commit is contained in:
parent
ac31e42974
commit
ba04ecfabd
|
@ -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_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_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_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_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_ON_OFF(layer) ACTION_LAYER_TAP((layer), OP_ON_OFF)
|
||||||
#define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON)
|
#define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON)
|
||||||
|
|
|
@ -47,10 +47,9 @@ action_t action_for_keycode(uint16_t keycode) {
|
||||||
keycode = keycode_config(keycode);
|
keycode = keycode_config(keycode);
|
||||||
|
|
||||||
action_t action = {};
|
action_t action = {};
|
||||||
uint8_t action_layer, when, mod;
|
uint8_t action_layer, mod;
|
||||||
|
|
||||||
(void)action_layer;
|
(void)action_layer;
|
||||||
(void)when;
|
|
||||||
(void)mod;
|
(void)mod;
|
||||||
|
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
|
@ -85,9 +84,8 @@ action_t action_for_keycode(uint16_t keycode) {
|
||||||
break;
|
break;
|
||||||
case QK_TO ... QK_TO_MAX:;
|
case QK_TO ... QK_TO_MAX:;
|
||||||
// Layer set "GOTO"
|
// Layer set "GOTO"
|
||||||
when = (keycode >> 0x4) & 0x3;
|
action_layer = keycode & 0xFF;
|
||||||
action_layer = keycode & 0xF;
|
action.code = ACTION_LAYER_GOTO(action_layer);
|
||||||
action.code = ACTION_LAYER_SET(action_layer, when);
|
|
||||||
break;
|
break;
|
||||||
case QK_MOMENTARY ... QK_MOMENTARY_MAX:;
|
case QK_MOMENTARY ... QK_MOMENTARY_MAX:;
|
||||||
// Momentary action_layer
|
// Momentary action_layer
|
||||||
|
|
|
@ -797,15 +797,8 @@ enum quantum_keycodes {
|
||||||
#define EH_LEFT MAGIC_EE_HANDS_LEFT
|
#define EH_LEFT MAGIC_EE_HANDS_LEFT
|
||||||
#define EH_RGHT MAGIC_EE_HANDS_RIGHT
|
#define EH_RGHT MAGIC_EE_HANDS_RIGHT
|
||||||
|
|
||||||
// GOTO layer - 16 layers max
|
// GOTO layer - 256 layer max
|
||||||
// when:
|
#define TO(layer) (QK_TO | ((layer)&0xFF))
|
||||||
// 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))
|
|
||||||
|
|
||||||
// Momentary switch layer - 256 layer max
|
// Momentary switch layer - 256 layer max
|
||||||
#define MO(layer) (QK_MOMENTARY | ((layer)&0xFF))
|
#define MO(layer) (QK_MOMENTARY | ((layer)&0xFF))
|
||||||
|
|
Loading…
Reference in a new issue