diff options
author | tmk <nobody@nowhere> | 2013-02-15 15:27:19 +0900 |
---|---|---|
committer | tmk <nobody@nowhere> | 2013-02-15 15:27:19 +0900 |
commit | 2b811352a1497e28b946a49f9f31dc15dbda420b (patch) | |
tree | 98b2502fd231d4916270b76632242a15bb27781d /common/layer_stack.c | |
parent | 0c1d98bd3c0b0ea4f109d2515521f1fcbccf3d3f (diff) | |
download | firmware-2b811352a1497e28b946a49f9f31dc15dbda420b.tar.gz firmware-2b811352a1497e28b946a49f9f31dc15dbda420b.tar.bz2 firmware-2b811352a1497e28b946a49f9f31dc15dbda420b.zip |
Fix switch_default_layer command
Diffstat (limited to 'common/layer_stack.c')
-rw-r--r-- | common/layer_stack.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/common/layer_stack.c b/common/layer_stack.c index 07c84870c..0076bf779 100644 --- a/common/layer_stack.c +++ b/common/layer_stack.c @@ -9,13 +9,23 @@ static uint8_t top_layer = 0; /* [0] always works as sentinel and not used for store.*/ static layer_item_t layer_stack[LAYER_STACK_SIZE] = {}; + +void layer_stack_clear(void) +{ + for (uint8_t i = 0; i < LAYER_STACK_SIZE; i++) { + layer_stack[i] = (layer_item_t){ .layer = 0, + .next = 0, + .used = false }; + } +} + bool layer_stack_push(uint8_t layer) { for (uint8_t i = 1; i < LAYER_STACK_SIZE; i++) { if (!layer_stack[i].used) { layer_stack[i] = (layer_item_t){ .layer = layer, - .next = top_layer, - .used = true }; + .next = top_layer, + .used = true }; top_layer = i; return true; } @@ -73,14 +83,12 @@ void layer_stack_debug(void) layer_item_t item = layer_stack[top_layer]; while (item.used) { debug_dec(item.layer); - debug("["); debug_dec(item.next); debug("]"); + debug("["); debug_dec(item.next); debug("] "); item = layer_stack[item.next]; } debug("\n"); } - - action_t layer_stack_get_action(key_t key) { action_t action; |