[LayerLock] Ignores Toggled Layers? Only works on highest layer? #80
-
|
While playing with the Layer Lock library, I found that it is not working as I expected for layers that were toggled. Proposal / Question 1:I see in the code that it handles MO and TO which work great, but any time I toggle a layer, it doesn't consider it locked. I am thinking this is done on purpose, but wanted to propose that toggled layers should be considered locked. By doing this, we can use the layer lock key to I was able to get the desired effect by adding: bool process_layer_lock(uint16_t keycode, keyrecord_t* record, uint16_t lock_keycode) {
// .... code removed to show new stuff only
case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX: // `TG(layer)` keys.
if (record->event.pressed) { // On press, toggle the lock
layer_lock_invert(QK_TOGGLE_LAYER_GET_LAYER(keycode));
}
return false;
break;Proposal / Question 2:That got me thinking about the other part of the code: if (keycode == lock_keycode) {
if (record->event.pressed) { // The layer lock key was pressed.
layer_lock_invert(get_highest_layer(layer_state));
}
return false;
}this code only considers the highest layer, not the layer from which the key came. Scenario 1: By considering the layer that sent the Scenario 2: This would also work if we use the same row and column on multiple layers, only considering the highest layer since that would match the row and column. I was able to get functionality by changing the above code to: if (keycode == lock_keycode) {
if (record->event.pressed) { // The layer lock key was pressed.
// we need to determine what layer we are on, and then change current state
uint8_t current_layer = layer_switch_get_layer(record->event.key);
// original
// layer_lock_invert(get_highest_layer(layer_state));
// DV edit
layer_lock_invert(current_layer);
}
return false;
}I'm still playing with the code, but it seems to give more flexibility. What do you think? Is there value in adding those features? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
@iamdanielv this is a nice idea, thanks for the suggestion! You're right that layer-toggle The QMK maintainers usually push to look for a way of applying existing features where possible over introducing new behavior. From that mindset, I'd say the "layer lock key has to be pressed twice" problem is solvable by placing a |
Beta Was this translation helpful? Give feedback.
@iamdanielv this is a nice idea, thanks for the suggestion! You're right that layer-toggle
TGkeys were excluded on purpose, or more accurately, I hadn't thought of how Layer Lock could be beneficial withTGkeys, so it ignores them. You're right though thatTGkeys do work conceptually like locking the layer, and as in your example the layer lock key could work to toggle off the layer. It's satisfying when features integrate in a predictable way like that.The QMK maintainers usually push to look for a way of applying ex…