diff options
| author | tmk <nobody@nowhere> | 2013-02-15 12:17:03 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-02-15 12:31:46 +0900 |
| commit | a4aae1c5055d24c400f78fd44618aef5916adc0c (patch) | |
| tree | aed7a0f5dd01527f47d0927ca229d425d78eee21 | |
| parent | a43ab35b7b807db03e3e8150273218d147d1737e (diff) | |
| download | qmk_firmware-a4aae1c5055d24c400f78fd44618aef5916adc0c.tar.gz qmk_firmware-a4aae1c5055d24c400f78fd44618aef5916adc0c.zip | |
Change: 0 means default_layer in current_layer now
- current_layer indicates active layer at the time
- default_layer indicates base layer
- default_layer is used when current_layer is 0
- with this LAYER_BIT action works as overlay even if
default_layer varies other than layer 0.
| -rw-r--r-- | common/action.c | 39 | ||||
| -rw-r--r-- | common/command.c | 7 |
2 files changed, 26 insertions, 20 deletions
diff --git a/common/action.c b/common/action.c index d0c9ddb0a..38c5933ee 100644 --- a/common/action.c +++ b/common/action.c | |||
| @@ -289,6 +289,7 @@ void action_exec(keyevent_t event) | |||
| 289 | static action_t get_action(key_t key) | 289 | static action_t get_action(key_t key) |
| 290 | { | 290 | { |
| 291 | action_t action; | 291 | action_t action; |
| 292 | action.code = ACTION_NO; | ||
| 292 | 293 | ||
| 293 | /* layer stack */ | 294 | /* layer stack */ |
| 294 | for (layer_item_t i = layer_stack[top_layer]; i.used; i = layer_stack[i.next]) { | 295 | for (layer_item_t i = layer_stack[top_layer]; i.used; i = layer_stack[i.next]) { |
| @@ -301,14 +302,18 @@ static action_t get_action(key_t key) | |||
| 301 | debug("layer_stack: through. "); debug_dec(i.layer); debug("\n"); | 302 | debug("layer_stack: through. "); debug_dec(i.layer); debug("\n"); |
| 302 | } | 303 | } |
| 303 | 304 | ||
| 304 | /* current layer */ | 305 | /* current layer: 0 means default layer */ |
| 305 | action = action_for_key(current_layer, key); | 306 | if (current_layer) { |
| 307 | action = action_for_key(current_layer, key); | ||
| 308 | if (action.code != ACTION_TRANSPARENT) { | ||
| 309 | debug("current layer: used. "); debug_dec(current_layer); debug("\n"); | ||
| 310 | return action; | ||
| 311 | } | ||
| 312 | } | ||
| 306 | 313 | ||
| 307 | /* default layer */ | 314 | /* default layer */ |
| 308 | if (action.code == ACTION_TRANSPARENT) { | 315 | debug("default layer: used. \n"); |
| 309 | debug("TRNASPARENT: "); debug_hex16(action.code); debug("\n"); | 316 | action = action_for_key(default_layer, key); |
| 310 | action = action_for_key(default_layer, key); | ||
| 311 | } | ||
| 312 | return action; | 317 | return action; |
| 313 | } | 318 | } |
| 314 | 319 | ||
| @@ -469,7 +474,7 @@ static void process_action(keyrecord_t *record) | |||
| 469 | } | 474 | } |
| 470 | else { | 475 | else { |
| 471 | // NOTE: This is needed by legacy keymap support | 476 | // NOTE: This is needed by legacy keymap support |
| 472 | layer_switch(default_layer); | 477 | layer_switch(0); |
| 473 | } | 478 | } |
| 474 | break; | 479 | break; |
| 475 | case LAYER_ON_PRESS: | 480 | case LAYER_ON_PRESS: |
| @@ -500,18 +505,18 @@ static void process_action(keyrecord_t *record) | |||
| 500 | case LAYER_SET_DEFAULT_ON_PRESS: | 505 | case LAYER_SET_DEFAULT_ON_PRESS: |
| 501 | if (event.pressed) { | 506 | if (event.pressed) { |
| 502 | default_layer = action.layer.val; | 507 | default_layer = action.layer.val; |
| 503 | layer_switch(default_layer); | 508 | layer_switch(0); |
| 504 | } | 509 | } |
| 505 | break; | 510 | break; |
| 506 | case LAYER_SET_DEFAULT_ON_RELEASE: | 511 | case LAYER_SET_DEFAULT_ON_RELEASE: |
| 507 | if (!event.pressed) { | 512 | if (!event.pressed) { |
| 508 | default_layer = action.layer.val; | 513 | default_layer = action.layer.val; |
| 509 | layer_switch(default_layer); | 514 | layer_switch(0); |
| 510 | } | 515 | } |
| 511 | break; | 516 | break; |
| 512 | case LAYER_SET_DEFAULT_ON_BOTH: | 517 | case LAYER_SET_DEFAULT_ON_BOTH: |
| 513 | default_layer = action.layer.val; | 518 | default_layer = action.layer.val; |
| 514 | layer_switch(default_layer); | 519 | layer_switch(0); |
| 515 | break; | 520 | break; |
| 516 | default: | 521 | default: |
| 517 | /* tap key */ | 522 | /* tap key */ |
| @@ -530,7 +535,7 @@ static void process_action(keyrecord_t *record) | |||
| 530 | } else { | 535 | } else { |
| 531 | // NOTE: This is needed by legacy keymap support | 536 | // NOTE: This is needed by legacy keymap support |
| 532 | debug("LAYER_SET: No tap: return to default layer(on release)\n"); | 537 | debug("LAYER_SET: No tap: return to default layer(on release)\n"); |
| 533 | layer_switch(default_layer); | 538 | layer_switch(0); |
| 534 | } | 539 | } |
| 535 | } | 540 | } |
| 536 | break; | 541 | break; |
| @@ -573,19 +578,19 @@ static void process_action(keyrecord_t *record) | |||
| 573 | break; | 578 | break; |
| 574 | case LAYER_SET_DEFAULT_ON_PRESS: | 579 | case LAYER_SET_DEFAULT_ON_PRESS: |
| 575 | if (event.pressed) { | 580 | if (event.pressed) { |
| 576 | default_layer = current_layer ^ action.layer.val; | 581 | default_layer = default_layer ^ action.layer.val; |
| 577 | layer_switch(default_layer); | 582 | layer_switch(0); |
| 578 | } | 583 | } |
| 579 | break; | 584 | break; |
| 580 | case LAYER_SET_DEFAULT_ON_RELEASE: | 585 | case LAYER_SET_DEFAULT_ON_RELEASE: |
| 581 | if (!event.pressed) { | 586 | if (!event.pressed) { |
| 582 | default_layer = current_layer ^ action.layer.val; | 587 | default_layer = default_layer ^ action.layer.val; |
| 583 | layer_switch(default_layer); | 588 | layer_switch(0); |
| 584 | } | 589 | } |
| 585 | break; | 590 | break; |
| 586 | case LAYER_SET_DEFAULT_ON_BOTH: | 591 | case LAYER_SET_DEFAULT_ON_BOTH: |
| 587 | default_layer = current_layer ^ action.layer.val; | 592 | default_layer = default_layer ^ action.layer.val; |
| 588 | layer_switch(default_layer); | 593 | layer_switch(0); |
| 589 | break; | 594 | break; |
| 590 | default: | 595 | default: |
| 591 | // tap key | 596 | // tap key |
diff --git a/common/command.c b/common/command.c index 7bb2a23f1..4c874b109 100644 --- a/common/command.c +++ b/common/command.c | |||
| @@ -261,8 +261,9 @@ static bool command_common(uint8_t code) | |||
| 261 | #endif | 261 | #endif |
| 262 | break; | 262 | break; |
| 263 | #endif | 263 | #endif |
| 264 | case KC_ESC: | ||
| 265 | case KC_GRV: | ||
| 264 | case KC_0: | 266 | case KC_0: |
| 265 | case KC_F10: | ||
| 266 | clear_keyboard(); | 267 | clear_keyboard(); |
| 267 | switch_layer(0); | 268 | switch_layer(0); |
| 268 | break; | 269 | break; |
| @@ -270,7 +271,7 @@ static bool command_common(uint8_t code) | |||
| 270 | clear_keyboard(); | 271 | clear_keyboard(); |
| 271 | switch_layer((code - KC_1) + 1); | 272 | switch_layer((code - KC_1) + 1); |
| 272 | break; | 273 | break; |
| 273 | case KC_F1 ... KC_F9: | 274 | case KC_F1 ... KC_F12: |
| 274 | clear_keyboard(); | 275 | clear_keyboard(); |
| 275 | switch_layer((code - KC_F1) + 1); | 276 | switch_layer((code - KC_F1) + 1); |
| 276 | break; | 277 | break; |
| @@ -545,7 +546,7 @@ static void switch_layer(uint8_t layer) | |||
| 545 | { | 546 | { |
| 546 | print_val_hex8(current_layer); | 547 | print_val_hex8(current_layer); |
| 547 | print_val_hex8(default_layer); | 548 | print_val_hex8(default_layer); |
| 548 | current_layer = layer; | ||
| 549 | default_layer = layer; | 549 | default_layer = layer; |
| 550 | current_layer = 0; | ||
| 550 | print("switch to "); print_val_hex8(layer); | 551 | print("switch to "); print_val_hex8(layer); |
| 551 | } | 552 | } |
