diff --git a/src/main.c b/src/main.c index 5218cec..d5d3072 100644 --- a/src/main.c +++ b/src/main.c @@ -32,7 +32,7 @@ typedef u8 keycode; typedef u16 media_keycode; typedef u8 layer; -typedef void (*keyfunc)(void); +typedef void (*keyfunc)(keycode, bool); #include "./main.h" @@ -59,15 +59,8 @@ static bool (*kb_was_pressed)[KB_ROWS][KB_COLUMNS] = &_kb_was_pressed; static layer layers_pressed[KB_ROWS][KB_COLUMNS]; -static u8 current_row; -static u8 current_col; -static layer current_layer; -static keycode current_keycode; -static bool current_is_pressed; - static i8 layers_active[KB_LAYERS]; -static layer layers_top = 0; -static bool layer_released = false; +static layer layers_top; static bool layer_sticky_on; static bool layer_sticky[KB_LAYERS]; @@ -75,15 +68,6 @@ static bool layer_sticky_done; static u8 mod_sticky; static bool mod_sticky_done; -static const keyfunc _kb_layer_funcs[] = { // TODO ugh - &kbfun_layer_press_release, - &kbfun_layer_sticky, - &kbfun_shift_layer_press_release, - &kbfun_control_layer_press_release, - &kbfun_alt_layer_press_release, - &kbfun_win_layer_press_release, -}; - // ---------------------------------------------------------------------------- int main() { @@ -113,32 +97,25 @@ void main_key_loop() { // (so they can be released using the function from that layer) for (u8 row=0; row 0; l--) { + for (layer l = KB_LAYERS - 1; l > 0; l--) { if (layers_active[l] > 0) { return l; } } @@ -227,37 +211,22 @@ void layer_disable(layer l) { if (layers_active[l] > 0) { layers_active[l] -= 1; } - layer_released = true; - if (l == layers_top) { - layers_top = highest_active_layer(); - } -} - -bool is_layer_keyfunc(keyfunc f) { - for (int i=0; i