initialize layers to be safe

master
Stefan Dorn 2016-02-04 14:19:06 +00:00
parent c08df8dc25
commit 37faadc8aa
1 changed files with 19 additions and 10 deletions

View File

@ -43,6 +43,16 @@ bool main_arg_was_pressed;
bool main_arg_any_non_trans_key_pressed;
bool main_arg_trans_key_pressed;
// layer data
struct layer {
bool active;
uint8_t sticky;
};
struct layer layers[KB_LAYERS];
uint8_t layers_top = 0;
// ----------------------------------------------------------------------------
/*
@ -54,6 +64,13 @@ int main(void) {
usb_init();
while (!usb_configured());
// initialize layers
for (uint8_t layer=0; layer < KB_LAYERS; layer++) {
layers[layer].active = false;
layers[layer].sticky = eStickyNone;
}
layers[0].active = true;
for (;;) {
// swap `main_kb_is_pressed` and `main_kb_was_pressed`, then update
bool (*temp)[KB_ROWS][KB_COLUMNS] = main_kb_was_pressed;
@ -106,20 +123,12 @@ int main(void) {
return 0;
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// layer functions
struct layer {
bool active;
uint8_t sticky;
};
struct layer layers[KB_LAYERS];
uint8_t layers_top = 0;
// ----------------------------------------------------------------------------
// find highest active layer
uint8_t _highest_active_layer(uint8_t offset) {
if (offset < layers_top) {