sticky cleanup

master
Stefan Dorn 2016-06-14 11:45:57 +01:00
parent 270feb968a
commit 2498833488
1 changed files with 3 additions and 10 deletions

View File

@ -229,7 +229,7 @@ void layer_enable_upto(layer max_layer) {
// ----------------------------------------------------------------------------
void init_sticky() {
for (layer l=0; l < KB_LAYERS; l++) {
for (layer l=1; l < KB_LAYERS; l++) {
layer_sticky[l] = false;
}
for (keycode mod=0; mod < MODIFIERS; mod++) {
@ -240,16 +240,14 @@ void init_sticky() {
}
void sticky_disable() {
for (layer l = 1; l < KB_LAYERS; l++) {
for (layer l=1; l < KB_LAYERS; l++) {
if (layer_sticky[l]) {
layer_disable(l);
layer_sticky[l] = false;
debug_printf("sticky %d up\n", l);
}
}
if (modifier_sticky) {
debug_printf("mod %d up\n", modifier_sticky);
keyboard_modifier_keys &= ~modifier_sticky;
modifier_sticky = 0;
}
@ -374,6 +372,7 @@ void kbfun_layer_disable() {
// letting go off a key releases *all* layers on that key
for (layer l=0; l <= KB_LAYERS; l++) {
// FIXME this is broken with sticky
void (*key_function)(void) = kb_keyfunc_release(l, current_row, current_col);
if (is_layer_disable(key_function)) {
@ -390,16 +389,13 @@ void kbfun_layer_sticky() {
if (current_is_pressed) {
layer_enable(l);
sticky_done = false;
debug_printf("sticky %d down\n", l);
} else {
if (sticky_done) {
layer_disable(l);
debug_printf("sticky %d up and done\n", l);
} else {
layer_sticky[l] = true;
sticky_on = true;
sticky_done = false;
debug_printf("sticky %d up, but still on\n", l);
}
}
}
@ -413,16 +409,13 @@ void kbfun_modifier_sticky() {
if (current_is_pressed) {
kbfun_modifier_press_release();
sticky_done = false;
debug_printf("mod %d down\n", mod);
} else {
if (sticky_done) {
kbfun_modifier_press_release();
debug_printf("mod %d up and done\n", mod);
} else {
modifier_sticky |= 1<<mod;
sticky_on = true;
sticky_done = false;
debug_printf("mod %d up, but still on\n", mod);
}
}
}