diff --git a/src/main.c b/src/main.c index 044570e..0ae4710 100644 --- a/src/main.c +++ b/src/main.c @@ -1,4 +1,3 @@ -// vim: ts=4 sw=4 sts=4 /* ---------------------------------------------------------------------------- * main() * ---------------------------------------------------------------------------- @@ -20,7 +19,8 @@ // ---------------------------------------------------------------------------- -#define MAX_ACTIVE_LAYERS 20 +// TODO remove this; for now we'll just limit it to the number of layers +#define MAX_ACTIVE_LAYERS KB_LAYERS // ---------------------------------------------------------------------------- @@ -34,9 +34,6 @@ static bool main_kb_was_transparent[KB_ROWS][KB_COLUMNS]; uint8_t main_layers_pressed[KB_ROWS][KB_COLUMNS]; -uint8_t main_loop_row; -uint8_t main_loop_col; - uint8_t main_arg_layer; uint8_t main_arg_layer_offset; uint8_t main_arg_row; @@ -52,78 +49,73 @@ bool main_arg_trans_key_pressed; * main() */ int main(void) { - kb_init(); // does controller initialization too + kb_init(); // does controller initialization too - kb_led_state_power_on(); + kb_led_state_power_on(); - usb_init(); - while (!usb_configured()); - kb_led_delay_usb_init(); // give the OS time to load drivers, etc. + usb_init(); + while (!usb_configured()); + kb_led_delay_usb_init(); // give the OS time to load drivers, etc. - kb_led_state_ready(); + kb_led_state_ready(); - for (;;) { - // swap `main_kb_is_pressed` and `main_kb_was_pressed`, then update - bool (*temp)[KB_ROWS][KB_COLUMNS] = main_kb_was_pressed; - main_kb_was_pressed = main_kb_is_pressed; - main_kb_is_pressed = temp; + for (;;) { + // swap `main_kb_is_pressed` and `main_kb_was_pressed`, then update + bool (*temp)[KB_ROWS][KB_COLUMNS] = main_kb_was_pressed; + main_kb_was_pressed = main_kb_is_pressed; + main_kb_is_pressed = temp; - kb_update_matrix(*main_kb_is_pressed); + kb_update_matrix(*main_kb_is_pressed); - // this loop is responsible to - // - "execute" keys when they change state - // - keep track of which layers the keys were on when they were pressed - // (so they can be released using the function from that layer) - // - // note - // - everything else is the key function's responsibility - // - see the keyboard layout file ("keyboard/ergodox/layout/*.c") for - // which key is assigned which function (per layer) - // - see "lib/key-functions/public/*.c" for the function definitions - for (int row=0; row