fix latch bug

master
Stefan Dorn 2016-02-06 14:31:54 +00:00
parent 9da1313e70
commit b5f88d06f4
3 changed files with 23 additions and 15 deletions

View File

@ -171,16 +171,15 @@ void kbfun_layer_sticky() {
main_arg_any_non_trans_key_pressed = false;
}
} else {
if (topLayer == layer) {
if (topSticky == eStickyOnceDown) {
// When releasing this sticky key, pop the layer always
main_layers_disable(layer);
if (!main_arg_any_non_trans_key_pressed) {
// If no key defined for this layer (a non-transparent key)
// was pressed, push the layer again, but in the
// StickyOnceUp state
main_layers_enable(layer, eStickyOnceUp);
}
if (main_layers_sticky(layer) == eStickyOnceDown) {
// When releasing this sticky key, pop the layer always
main_layers_disable(layer);
if (!main_arg_any_non_trans_key_pressed) {
// If no key defined for this layer (a non-transparent key)
// was pressed, push the layer again, but in the
// StickyOnceUp state
main_layers_enable(layer, eStickyOnceUp);
}
}
}

View File

@ -148,7 +148,14 @@ uint8_t main_layers_top_layer() {
// return if highest active layer is sticky
uint8_t main_layers_top_sticky() {
return layers[layers_top].sticky;
return main_layers_sticky(layers_top);
}
// return if layer is sticky
uint8_t main_layers_sticky(uint8_t layer) {
if (layer < KB_LAYERS) {
return layers[layer].sticky;
}
}
// enable a layer
@ -168,7 +175,11 @@ void main_layers_disable(uint8_t layer) {
if (layer >= KB_LAYERS) { return; }
// base layer stays always on
if (layer > 0) { layers[layer].active = false; }
if (layer > 0) {
layers[layer].active = false;
layers[layer].sticky = eStickyNone;
}
if (layer >= layers_top) {
layers_top = _highest_active_layer(1);
}

View File

@ -43,11 +43,9 @@ void main_exec_key (void);
uint8_t main_layers_top_layer (void);
uint8_t main_layers_top_sticky (void);
uint8_t main_layers_sticky (uint8_t layer);
void main_layers_enable (uint8_t layer, uint8_t sticky);
void main_layers_disable (uint8_t layer);
void main_layers_disable_top (void);
#endif