forked from mirrors/qmk_userspace
Custom Tapping Term per key (#5009)
* Add customizable tapping terms * Add Documentation * Fix function * Fixes * It's not a pointer * Add debugging output * Update documentation to be at least vaguely accurate * Use `get_tapping_term(tapping_key.event)` instead `e` doesn't include column and row information, properly. It registers as 255, regardless of the actual keypress. However `tapping_key.event` actually gives the correct column and row information. It appears be the correct structure to use. In fact, it looks like the issue is that `e` is actually the "TICK" structure, as defined in keyboard.h * Use variable tapping term value rather than define * Silly drashna - tapping_key.event, not event * add get_event_keycode() function * Fix typo Co-Authored-By: drashna <drashna@live.com> * Remove post_process_record_quantum since it's the wrong PR * Update quantum/quantum.c Co-Authored-By: drashna <drashna@live.com> * Better handle ifdef statement for permissive hold Since we can't be sure that tapping term is actually 500 * Update quantum.c comments based on feedback * Clean up get_tapping_term function Clean up function so that users don't need to call the event function, and instead only check the keycode * Add ability to run functionality on and off * Make ifdef's more compact
This commit is contained in:
parent
4c1760883e
commit
5701b75e3c
6 changed files with 74 additions and 13 deletions
|
@ -18,8 +18,17 @@
|
|||
#define IS_TAPPING_PRESSED() (IS_TAPPING() && tapping_key.event.pressed)
|
||||
#define IS_TAPPING_RELEASED() (IS_TAPPING() && !tapping_key.event.pressed)
|
||||
#define IS_TAPPING_KEY(k) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (k)))
|
||||
#define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM)
|
||||
|
||||
__attribute__ ((weak))
|
||||
uint16_t get_tapping_term(uint16_t keycode) {
|
||||
return TAPPING_TERM;
|
||||
}
|
||||
|
||||
#ifdef TAPPING_TERM_PER_KEY
|
||||
#define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < get_tapping_term(get_event_keycode(tapping_key.event)))
|
||||
#else
|
||||
#define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM)
|
||||
#endif
|
||||
|
||||
static keyrecord_t tapping_key = {};
|
||||
static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {};
|
||||
|
@ -100,12 +109,17 @@ bool process_tapping(keyrecord_t *keyp)
|
|||
// enqueue
|
||||
return false;
|
||||
}
|
||||
#if TAPPING_TERM >= 500 || defined PERMISSIVE_HOLD
|
||||
/* Process a key typed within TAPPING_TERM
|
||||
* This can register the key before settlement of tapping,
|
||||
* useful for long TAPPING_TERM but may prevent fast typing.
|
||||
*/
|
||||
else if (IS_RELEASED(event) && waiting_buffer_typed(event)) {
|
||||
#if defined(TAPPING_TERM_PER_KEY) || (!defined(PER_KEY_TAPPING_TERM) && TAPPING_TERM >= 500) || defined(PERMISSIVE_HOLD)
|
||||
#ifdef TAPPING_TERM_PER_KEY
|
||||
else if ( ( get_tapping_term(get_event_keycode(tapping_key.event)) >= 500) && IS_RELEASED(event) && waiting_buffer_typed(event))
|
||||
#else
|
||||
else if ( IS_RELEASED(event) && waiting_buffer_typed(event))
|
||||
#endif
|
||||
{
|
||||
debug("Tapping: End. No tap. Interfered by typing key\n");
|
||||
process_record(&tapping_key);
|
||||
tapping_key = (keyrecord_t){};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue