aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2019-07-22 20:23:57 -0700
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-07-22 20:23:57 -0700
commit3261c408e454dbc3cc2a1591ba62575036af19ad (patch)
treebf877266d79a30b5e0ab8cb115338e7382702259
parentd41961c9eddb78591d3b55ea65e6e0baff4bdd69 (diff)
downloadqmk_firmware-3261c408e454dbc3cc2a1591ba62575036af19ad.tar.gz
qmk_firmware-3261c408e454dbc3cc2a1591ba62575036af19ad.zip
Add support for TAP_CODE_DELAY to Hold-Tap keys (#5400)
* Add support for TAP_CODE_DELAY to Hold-Tap keys * Better handling for tap code delay and caps version
-rw-r--r--tmk_core/common/action.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index 285786cb7..5172e8650 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -44,6 +44,9 @@ int retro_tapping_counter = 0;
44#include <fauxclicky.h> 44#include <fauxclicky.h>
45#endif 45#endif
46 46
47#ifndef TAP_CODE_DELAY
48# define TAP_CODE_DELAY 0
49#endif
47#ifndef TAP_HOLD_CAPS_DELAY 50#ifndef TAP_HOLD_CAPS_DELAY
48# define TAP_HOLD_CAPS_DELAY 80 51# define TAP_HOLD_CAPS_DELAY 80
49#endif 52#endif
@@ -330,6 +333,9 @@ void process_action(keyrecord_t *record, action_t action)
330 } else { 333 } else {
331 if (tap_count > 0) { 334 if (tap_count > 0) {
332 dprint("MODS_TAP: Tap: unregister_code\n"); 335 dprint("MODS_TAP: Tap: unregister_code\n");
336 if (action.layer_tap.code == KC_CAPS) {
337 wait_ms(TAP_HOLD_CAPS_DELAY);
338 }
333 unregister_code(action.key.code); 339 unregister_code(action.key.code);
334 } else { 340 } else {
335 dprint("MODS_TAP: No tap: add_mods\n"); 341 dprint("MODS_TAP: No tap: add_mods\n");
@@ -522,7 +528,9 @@ void process_action(keyrecord_t *record, action_t action)
522 dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n"); 528 dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n");
523 if (action.layer_tap.code == KC_CAPS) { 529 if (action.layer_tap.code == KC_CAPS) {
524 wait_ms(TAP_HOLD_CAPS_DELAY); 530 wait_ms(TAP_HOLD_CAPS_DELAY);
525 } 531 } else {
532 wait_ms(TAP_CODE_DELAY);
533 }
526 unregister_code(action.layer_tap.code); 534 unregister_code(action.layer_tap.code);
527 } else { 535 } else {
528 dprint("KEYMAP_TAP_KEY: No tap: Off on release\n"); 536 dprint("KEYMAP_TAP_KEY: No tap: Off on release\n");
@@ -618,6 +626,7 @@ void process_action(keyrecord_t *record, action_t action)
618 if (event.pressed) { 626 if (event.pressed) {
619 register_code(action.swap.code); 627 register_code(action.swap.code);
620 } else { 628 } else {
629 wait_ms(TAP_CODE_DELAY);
621 unregister_code(action.swap.code); 630 unregister_code(action.swap.code);
622 *record = (keyrecord_t){}; // hack: reset tap mode 631 *record = (keyrecord_t){}; // hack: reset tap mode
623 } 632 }
@@ -670,8 +679,7 @@ void process_action(keyrecord_t *record, action_t action)
670 retro_tapping_counter = 0; 679 retro_tapping_counter = 0;
671 } else { 680 } else {
672 if (retro_tapping_counter == 2) { 681 if (retro_tapping_counter == 2) {
673 register_code(action.layer_tap.code); 682 tap_code(action.layer_tap.code);
674 unregister_code(action.layer_tap.code);
675 } 683 }
676 retro_tapping_counter = 0; 684 retro_tapping_counter = 0;
677 } 685 }
@@ -858,12 +866,9 @@ void tap_code(uint8_t code) {
858 register_code(code); 866 register_code(code);
859 if (code == KC_CAPS) { 867 if (code == KC_CAPS) {
860 wait_ms(TAP_HOLD_CAPS_DELAY); 868 wait_ms(TAP_HOLD_CAPS_DELAY);
861 } 869 } else {
862 #if TAP_CODE_DELAY > 0
863 else {
864 wait_ms(TAP_CODE_DELAY); 870 wait_ms(TAP_CODE_DELAY);
865 } 871 }
866 #endif
867 unregister_code(code); 872 unregister_code(code);
868} 873}
869 874