diff options
author | tmk <nobody@nowhere> | 2012-10-12 04:00:52 +0200 |
---|---|---|
committer | tmk <nobody@nowhere> | 2012-10-17 08:55:37 +0200 |
commit | f7a445e537243f886d9cb022bede18859c9bfd12 (patch) | |
tree | 59d9ddf0a131e1a25fb4e7397408f3052001457e /common | |
parent | 1677b021d7bff6af7763532b038612363b61dada (diff) | |
download | qmk_firmware-f7a445e537243f886d9cb022bede18859c9bfd12.tar.gz qmk_firmware-f7a445e537243f886d9cb022bede18859c9bfd12.tar.xz |
Fix use of default_layer
Diffstat (limited to 'common')
-rw-r--r-- | common/keyboard.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/common/keyboard.c b/common/keyboard.c index 7a17a9e38..be01e5540 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -46,8 +46,13 @@ typedef enum keykind { typedef enum { IDLE, DELAYING, WAITING, PRESSING } kbdstate_t; -uint8_t current_layer = 0; +#ifdef KEYMAP_DEFAULT_LAYER +uint8_t default_layer = KEYMAP_DEFAULT_LAYER; +uint8_t current_layer = KEYMAP_DEFAULT_LAYER; +#else uint8_t default_layer = 0; +uint8_t current_layer = 0; +#endif /* keyboard internal states */ static kbdstate_t kbdstate = IDLE; @@ -120,12 +125,13 @@ static void layer_switch_on(uint8_t code) { if (!IS_FN(code)) return; fn_state_bits |= FN_BIT(code); - if (current_layer != keymap_fn_layer(FN_INDEX(code))) { - clear_keyboard_but_mods(); - + uint8_t new_layer = (fn_state_bits ? keymap_fn_layer(biton(fn_state_bits)) : default_layer); + if (current_layer != new_layer) { debug("Layer Switch(on): "); debug_hex(current_layer); - current_layer = keymap_fn_layer(FN_INDEX(code)); - debug(" -> "); debug_hex(current_layer); debug("\n"); + debug(" -> "); debug_hex(new_layer); debug("\n"); + + clear_keyboard_but_mods(); + current_layer = new_layer; } } @@ -133,12 +139,13 @@ static bool layer_switch_off(uint8_t code) { if (!IS_FN(code)) return false; fn_state_bits &= ~FN_BIT(code); - if (current_layer != keymap_fn_layer(biton(fn_state_bits))) { - clear_keyboard_but_mods(); - + uint8_t new_layer = (fn_state_bits ? keymap_fn_layer(biton(fn_state_bits)) : default_layer); + if (current_layer != new_layer) { debug("Layer Switch(off): "); debug_hex(current_layer); - current_layer = keymap_fn_layer(biton(fn_state_bits)); - debug(" -> "); debug_hex(current_layer); debug("\n"); + debug(" -> "); debug_hex(new_layer); debug("\n"); + + clear_keyboard_but_mods(); + current_layer = new_layer; return true; } return false; @@ -606,8 +613,9 @@ void keyboard_task(void) is_matrix_on |= matrix_get_row(r); } if (!is_matrix_on) { - debug("FAIL SAFE: clear all keys.\n"); + debug("FAIL SAFE: clear all keys(default layer).\n"); clear_keyboard(); + current_layer = default_layer; } } |