aboutsummaryrefslogtreecommitdiff
path: root/common/action.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/action.c')
-rw-r--r--common/action.c50
1 files changed, 21 insertions, 29 deletions
diff --git a/common/action.c b/common/action.c
index 9a8d75596..4f0a5f906 100644
--- a/common/action.c
+++ b/common/action.c
@@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
24#include "util.h" 24#include "util.h"
25#include "debug.h" 25#include "debug.h"
26#include "action.h" 26#include "action.h"
27#include "layer_stack.h" 27#include "layer_switch.h"
28 28
29 29
30/* default layer indicates base layer */ 30/* default layer indicates base layer */
@@ -213,8 +213,8 @@ static action_t get_action(key_t key)
213 action_t action; 213 action_t action;
214 action.code = ACTION_NO; 214 action.code = ACTION_NO;
215 215
216 /* layer stack */ 216 /* layer_switch */
217 action = layer_stack_get_action(key); 217 action = layer_switch_get_action(key);
218 if (action.code != ACTION_TRANSPARENT) { 218 if (action.code != ACTION_TRANSPARENT) {
219 return action; 219 return action;
220 } 220 }
@@ -531,45 +531,38 @@ static void process_action(keyrecord_t *record)
531 break; 531 break;
532 } 532 }
533 break; 533 break;
534 case ACT_LAYER_STACK: 534 case ACT_LAYER_SWITCH:
535 switch (action.layer.code) { 535 switch (action.layer.code) {
536 case LAYER_MOMENTARY: /* momentary */ 536 case LAYER_MOMENTARY: /* momentary */
537 if (event.pressed) { 537 if (event.pressed) {
538 layer_stack_remove_then_push(action.layer.val); 538 layer_switch_on(action.layer.val);
539 layer_stack_debug();
540 } else { 539 } else {
541 layer_stack_remove(action.layer.val); 540 layer_switch_off(action.layer.val);
542 layer_stack_debug();
543 } 541 }
544 break; 542 break;
545 case LAYER_ON_PRESS: 543 case LAYER_ON_PRESS:
546 if (event.pressed) { 544 if (event.pressed) {
547 layer_stack_remove_or_push(action.layer.val); 545 layer_switch_inv(action.layer.val);
548 layer_stack_debug();
549 } 546 }
550 break; 547 break;
551 case LAYER_ON_RELEASE: 548 case LAYER_ON_RELEASE:
552 if (!event.pressed) { 549 if (!event.pressed) {
553 layer_stack_remove_or_push(action.layer.val); 550 layer_switch_inv(action.layer.val);
554 layer_stack_debug();
555 } 551 }
556 break; 552 break;
557 case LAYER_ON_BOTH: 553 case LAYER_ON_BOTH:
558 layer_stack_remove_or_push(action.layer.val); 554 layer_switch_inv(action.layer.val);
559 layer_stack_debug();
560 break; 555 break;
561 case LAYER_TAP_TOGGLE: /* switch on hold and toggle on several taps */ 556 case LAYER_TAP_TOGGLE: /* switch on hold and toggle on several taps */
562 if (event.pressed) { 557 if (event.pressed) {
563 if (tap_count < TAPPING_TOGGLE) { 558 if (tap_count < TAPPING_TOGGLE) {
564 debug("LAYER_STACK: tap toggle(press).\n"); 559 debug("LAYER_SWITCH: tap toggle(press).\n");
565 layer_stack_remove_or_push(action.layer.val); 560 layer_switch_inv(action.layer.val);
566 layer_stack_debug();
567 } 561 }
568 } else { 562 } else {
569 if (tap_count <= TAPPING_TOGGLE) { 563 if (tap_count <= TAPPING_TOGGLE) {
570 debug("LAYER_STACK: tap toggle(release).\n"); 564 debug("LAYER_SWITCH: tap toggle(release).\n");
571 layer_stack_remove_or_push(action.layer.val); 565 layer_switch_inv(action.layer.val);
572 layer_stack_debug();
573 } 566 }
574 } 567 }
575 break; 568 break;
@@ -577,21 +570,19 @@ static void process_action(keyrecord_t *record)
577 // tap key 570 // tap key
578 if (event.pressed) { 571 if (event.pressed) {
579 if (IS_TAPPING_KEY(event.key) && tap_count > 0) { 572 if (IS_TAPPING_KEY(event.key) && tap_count > 0) {
580 debug("LAYER_STACK: Tap: register_code\n"); 573 debug("LAYER_SWITCH: Tap: register_code\n");
581 register_code(action.layer.code); 574 register_code(action.layer.code);
582 } else { 575 } else {
583 debug("LAYER_STACK: No tap: layer_stack(on press)\n"); 576 debug("LAYER_SWITCH: No tap: layer_switch(on press)\n");
584 layer_stack_remove_or_push(action.layer.val); 577 layer_switch_inv(action.layer.val);
585 layer_stack_debug();
586 } 578 }
587 } else { 579 } else {
588 if (IS_TAPPING_KEY(event.key) && tap_count > 0) { 580 if (IS_TAPPING_KEY(event.key) && tap_count > 0) {
589 debug("LAYER_STACK: Tap: unregister_code\n"); 581 debug("LAYER_SWITCH: Tap: unregister_code\n");
590 unregister_code(action.layer.code); 582 unregister_code(action.layer.code);
591 } else { 583 } else {
592 debug("LAYER_STACK: No tap: layer_stack(on release)\n"); 584 debug("LAYER_SWITCH: No tap: layer_switch(on release)\n");
593 layer_stack_remove_or_push(action.layer.val); 585 layer_switch_inv(action.layer.val);
594 layer_stack_debug();
595 } 586 }
596 } 587 }
597 break; 588 break;
@@ -898,6 +889,7 @@ bool sending_anykey(void)
898 host_last_sysytem_report() || host_last_consumer_report()); 889 host_last_sysytem_report() || host_last_consumer_report());
899} 890}
900 891
892// TODO: rename or reinpl with new layer_switch.c
901void layer_switch(uint8_t new_layer) 893void layer_switch(uint8_t new_layer)
902{ 894{
903 if (current_layer != new_layer) { 895 if (current_layer != new_layer) {
@@ -966,7 +958,7 @@ static void debug_action(action_t action)
966 case ACT_MOUSEKEY: debug("ACT_MOUSEKEY"); break; 958 case ACT_MOUSEKEY: debug("ACT_MOUSEKEY"); break;
967 case ACT_LAYER: debug("ACT_LAYER"); break; 959 case ACT_LAYER: debug("ACT_LAYER"); break;
968 case ACT_LAYER_BIT: debug("ACT_LAYER_BIT"); break; 960 case ACT_LAYER_BIT: debug("ACT_LAYER_BIT"); break;
969 case ACT_LAYER_STACK: debug("ACT_LAYER_STACK"); break; 961 case ACT_LAYER_SWITCH: debug("ACT_LAYER_SWITCH"); break;
970 case ACT_MACRO: debug("ACT_MACRO"); break; 962 case ACT_MACRO: debug("ACT_MACRO"); break;
971 case ACT_COMMAND: debug("ACT_COMMAND"); break; 963 case ACT_COMMAND: debug("ACT_COMMAND"); break;
972 case ACT_FUNCTION: debug("ACT_FUNCTION"); break; 964 case ACT_FUNCTION: debug("ACT_FUNCTION"); break;