From 789169a86fd2af6019c81ca0e0a46918cf472351 Mon Sep 17 00:00:00 2001 From: Stefan Dorn Date: Sun, 12 Jun 2016 05:26:27 +0100 Subject: [PATCH] refactor --- src/main.c | 122 ++++++++++++++++++++++++----------------------------- src/main.h | 3 +- 2 files changed, 57 insertions(+), 68 deletions(-) diff --git a/src/main.c b/src/main.c index de993ef..0395169 100644 --- a/src/main.c +++ b/src/main.c @@ -77,6 +77,61 @@ int main(void) { return 0; } +// -------------------------------------------------------------------------------------- + +void main_key_loop() { + for (;;) { + // swap `kb_is_pressed` and `kb_was_pressed`, then update + bool (*temp)[KB_ROWS][KB_COLUMNS] = kb_was_pressed; + kb_was_pressed = kb_is_pressed; + kb_is_pressed = temp; + + kb_update_matrix(*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/layout/*.c") for + // which key is assigned which function (per layer) + // - see "lib/key-functions/public/*.c" for the function definitions + for (uint8_t row=0; row