diff options
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/common/action_tapping.c | 20 | ||||
| -rw-r--r-- | tmk_core/common/action_tapping.h | 2 |
2 files changed, 19 insertions, 3 deletions
diff --git a/tmk_core/common/action_tapping.c b/tmk_core/common/action_tapping.c index 8adf013e1..3b67ed152 100644 --- a/tmk_core/common/action_tapping.c +++ b/tmk_core/common/action_tapping.c | |||
| @@ -18,8 +18,17 @@ | |||
| 18 | #define IS_TAPPING_PRESSED() (IS_TAPPING() && tapping_key.event.pressed) | 18 | #define IS_TAPPING_PRESSED() (IS_TAPPING() && tapping_key.event.pressed) |
| 19 | #define IS_TAPPING_RELEASED() (IS_TAPPING() && !tapping_key.event.pressed) | 19 | #define IS_TAPPING_RELEASED() (IS_TAPPING() && !tapping_key.event.pressed) |
| 20 | #define IS_TAPPING_KEY(k) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (k))) | 20 | #define IS_TAPPING_KEY(k) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (k))) |
| 21 | #define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM) | ||
| 22 | 21 | ||
| 22 | __attribute__ ((weak)) | ||
| 23 | uint16_t get_tapping_term(uint16_t keycode) { | ||
| 24 | return TAPPING_TERM; | ||
| 25 | } | ||
| 26 | |||
| 27 | #ifdef TAPPING_TERM_PER_KEY | ||
| 28 | #define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < get_tapping_term(get_event_keycode(tapping_key.event))) | ||
| 29 | #else | ||
| 30 | #define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM) | ||
| 31 | #endif | ||
| 23 | 32 | ||
| 24 | static keyrecord_t tapping_key = {}; | 33 | static keyrecord_t tapping_key = {}; |
| 25 | static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {}; | 34 | static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {}; |
| @@ -100,12 +109,17 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 100 | // enqueue | 109 | // enqueue |
| 101 | return false; | 110 | return false; |
| 102 | } | 111 | } |
| 103 | #if TAPPING_TERM >= 500 || defined PERMISSIVE_HOLD | ||
| 104 | /* Process a key typed within TAPPING_TERM | 112 | /* Process a key typed within TAPPING_TERM |
| 105 | * This can register the key before settlement of tapping, | 113 | * This can register the key before settlement of tapping, |
| 106 | * useful for long TAPPING_TERM but may prevent fast typing. | 114 | * useful for long TAPPING_TERM but may prevent fast typing. |
| 107 | */ | 115 | */ |
| 108 | else if (IS_RELEASED(event) && waiting_buffer_typed(event)) { | 116 | #if defined(TAPPING_TERM_PER_KEY) || (!defined(PER_KEY_TAPPING_TERM) && TAPPING_TERM >= 500) || defined(PERMISSIVE_HOLD) |
| 117 | #ifdef TAPPING_TERM_PER_KEY | ||
| 118 | else if ( ( get_tapping_term(get_event_keycode(tapping_key.event)) >= 500) && IS_RELEASED(event) && waiting_buffer_typed(event)) | ||
| 119 | #else | ||
| 120 | else if ( IS_RELEASED(event) && waiting_buffer_typed(event)) | ||
| 121 | #endif | ||
| 122 | { | ||
| 109 | debug("Tapping: End. No tap. Interfered by typing key\n"); | 123 | debug("Tapping: End. No tap. Interfered by typing key\n"); |
| 110 | process_record(&tapping_key); | 124 | process_record(&tapping_key); |
| 111 | tapping_key = (keyrecord_t){}; | 125 | tapping_key = (keyrecord_t){}; |
diff --git a/tmk_core/common/action_tapping.h b/tmk_core/common/action_tapping.h index 2f143ae8b..1db43a442 100644 --- a/tmk_core/common/action_tapping.h +++ b/tmk_core/common/action_tapping.h | |||
| @@ -35,6 +35,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 35 | 35 | ||
| 36 | 36 | ||
| 37 | #ifndef NO_ACTION_TAPPING | 37 | #ifndef NO_ACTION_TAPPING |
| 38 | uint16_t get_event_keycode(keyevent_t event); | ||
| 39 | uint16_t get_tapping_term(uint16_t keycode); | ||
| 38 | void action_tapping_process(keyrecord_t record); | 40 | void action_tapping_process(keyrecord_t record); |
| 39 | #endif | 41 | #endif |
| 40 | 42 | ||
