Align TO() max layers with other keycodes (#17989)

master
Joel Challis 2022-08-14 12:25:46 +01:00 committed by GitHub
parent ac31e42974
commit ba04ecfabd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 14 deletions

View File

@ -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)

View File

@ -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) {
@ -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

View File

@ -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))