refactor (and minor sticky bug)

master
Stefan Dorn 2016-06-14 07:32:06 +01:00
parent 5dc33a30d0
commit 9c81274348
2 changed files with 25 additions and 23 deletions

View File

@ -133,23 +133,6 @@ void main_key_loop() {
}
}
// execute the keypress or keyrelease function (if it exists) of the key at the current possition
void exec_key(void) {
void (*key_function)(void) =
( (current_is_pressed)
? kb_keyfunc_press(current_layer, current_row, current_col)
: kb_keyfunc_release(current_layer, current_row, current_col) );
if (key_function) { (*key_function)(); }
// FIXME
// If the current layer is in the sticky once up state and a key defined
// for this layer (a non-transparent key) was pressed, pop the layer
if (layer_top_sticky() == StickyOnceUp && sticky_done) {
layer_disable_top();
}
}
// ----------------------------------------------------------------------------
// layer functions
// ----------------------------------------------------------------------------
@ -365,6 +348,23 @@ void _kbfun_mediakey_press_release(bool press, keycode key) {
// basic keyfuncs
// ----------------------------------------------------------------------------
// execute the keypress or keyrelease function (if it exists) of the key at the current possition
void exec_key() {
void (*key_function)(void) =
( (current_is_pressed)
? kb_keyfunc_press(current_layer, current_row, current_col)
: kb_keyfunc_release(current_layer, current_row, current_col) );
if (key_function) { (*key_function)(); }
// FIXME
// If the current layer is in the sticky once up state and a key defined
// for this layer (a non-transparent key) was pressed, pop the layer
if (layer_top_sticky() == StickyOnceUp && sticky_done) {
layer_disable_top();
}
}
bool key_is_modifier(keycode key) {
switch (key) {
case KEY_LeftControl: return true;
@ -381,7 +381,9 @@ bool key_is_modifier(keycode key) {
// normal key
void kbfun_press_release() {
sticky_done = ! key_is_modifier(current_keycode);
if (!key_is_modifier(current_keycode)) {
sticky_done = true;
}
_kbfun_press_release(current_is_pressed, current_keycode);
}

View File

@ -13,6 +13,8 @@ bool _kbfun_is_pressed(keycode key);
void _kbfun_release(keycode key);
void _kbfun_press(keycode key);
void _kbfun_press_release(bool press,keycode key);
keyfunc kb_keyfunc_release(layer l,u8 row,u8 col);
keyfunc kb_keyfunc_press(layer l,u8 row,u8 col);
void layer_enable_upto(layer max_layer);
void kbfun_layer_disable();
bool is_layer_disable(keyfunc f);
@ -20,15 +22,13 @@ void kbfun_layer_sticky();
void kbfun_layer_enable();
bool is_layer_enable(keyfunc f);
layer layer_peek(layer offset);
void layer_disable_top();
void layer_disable(layer l);
void layer_enable(layer l,StickyState sticky);
StickyState layer_sticky(layer l);
layer highest_active_layer(layer offset);
void layer_disable_top();
StickyState layer_top_sticky();
keyfunc kb_keyfunc_release(layer l,u8 row,u8 col);
keyfunc kb_keyfunc_press(layer l,u8 row,u8 col);
void exec_key(void);
layer highest_active_layer(layer offset);
void exec_key();
keycode kb_keycode(layer l,u8 row,u8 col);
void main_key_loop();
void init_layers();