Trying a tri-layer for the NUM layer

This commit is contained in:
Drew Whitney 2025-11-23 16:23:19 -07:00
commit a1df29acd7
2 changed files with 31 additions and 28 deletions

View file

@ -119,12 +119,12 @@ const uint16_t PROGMEM num_layer_combo[] = {NAV_TAB, SYM_BSPC, COMBO_END};
const uint16_t PROGMEM win_swap_combo[] = {TAB_LEFT, TAB_RIGHT, COMBO_END};
combo_t key_combos[] = {
[NumCombo] = COMBO(num_layer_combo, NUM),
// [NumCombo] = COMBO(num_layer_combo, NUM),
[WinSwapCombo] = COMBO(win_swap_combo, WIN_SWAP),
};
bool process_record_user(uint16_t keycode, keyrecord_t* record) {
static bool NAV_is_on = false;
// static bool NAV_is_on = false;
switch (keycode) {
// allow NAV and SYM to override each other
@ -133,9 +133,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t* record) {
// if NAV is on, turn it off when SYM is turned on, then restore it when SYM is
// turned off
// if we're NUM-latched, don't interfere with the states
if (NAV_is_on) {
record->event.pressed && !NUM_latched ? layer_off(_NAV) : layer_on(_NAV);
}
// if (NAV_is_on) {
// record->event.pressed && !NUM_latched ? layer_off(_NAV) : layer_on(_NAV);
// }
} else {
// backspace -> obliterate line
if (record->event.pressed) {
@ -153,11 +153,11 @@ bool process_record_user(uint16_t keycode, keyrecord_t* record) {
}
break;
case NAV_TAB:
if (!record->tap.count) {
NAV_is_on = record->event.pressed;
}
break;
// case NAV_TAB:
// if (!record->tap.count) {
// NAV_is_on = record->event.pressed;
// }
// break;
case WIN_SWAP: // easy Alt-Tab
if (record->event.pressed) {

View file

@ -3,23 +3,26 @@
bool NUM_latched = false;
layer_state_t layer_state_set_user(layer_state_t state) {
// NUM latching
if (NUM_latched) {
if (IS_LAYER_ON_STATE(state, _SYM) && IS_LAYER_ON_STATE(state, _NAV)) {
state |= 1 << _NUM; // turn on NUM
} else {
// if both NAV and SYM are off, de-latch NUM
if (!IS_LAYER_ON_STATE(state, _SYM) && !IS_LAYER_ON_STATE(state, _NAV)) {
NUM_latched = false;
}
// since both layers aren't held, turn off NUM
state &= ~(1 << _NUM);
}
} else if (IS_LAYER_ON_STATE(state, _NUM)) {
NUM_latched = true;
// turn on NAV and SYM too, since the layer keys were consumed by the combo activation
state |= 1 << _NAV | 1 << _SYM;
}
// // NUM latching
// if (NUM_latched) {
// if (IS_LAYER_ON_STATE(state, _SYM) && IS_LAYER_ON_STATE(state, _NAV)) {
// state |= 1 << _NUM; // turn on NUM
// } else {
// // if both NAV and SYM are off, de-latch NUM
// if (!IS_LAYER_ON_STATE(state, _SYM) && !IS_LAYER_ON_STATE(state, _NAV)) {
// NUM_latched = false;
// }
// // since both layers aren't held, turn off NUM
// state &= ~(1 << _NUM);
// }
// } else if (IS_LAYER_ON_STATE(state, _NUM)) {
// NUM_latched = true;
// // turn on NAV and SYM too, since the layer keys were consumed by the combo activation
// state |= 1 << _NAV | 1 << _SYM;
// }
return state;
// return state;
return update_tri_layer_state(state, _SYM, _NAV, _NUM);
}