aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/common
diff options
context:
space:
mode:
authorSergey Vlasov <sigprof@gmail.com>2021-08-07 02:16:26 +0300
committerGitHub <noreply@github.com>2021-08-07 09:16:26 +1000
commit610035dce8f4f7010779e61e1cb590eebc8cea46 (patch)
treecd36a37e468c90e64c54fc5371205e186b1be08d /tmk_core/common
parent13b94b468d728f43b7edcd91224ea217851b80bc (diff)
downloadqmk_firmware-610035dce8f4f7010779e61e1cb590eebc8cea46.tar.gz
qmk_firmware-610035dce8f4f7010779e61e1cb590eebc8cea46.zip
Add HOLD_ON_OTHER_KEY_PRESS option for dual-role keys (#9404)
* Add HOLD_ON_OTHER_KEY_PRESS option for dual-role keys Implement an additional option for dual-role keys which converts the dual-role key press into a hold action immediately when another key is pressed (this is different from the existing PERMISSIVE_HOLD option, which selects the hold action when another key is tapped (pressed and then released) while the dual-role key is pressed). The Mod-Tap keys already behave in a similar way, unless the IGNORE_MOD_TAP_INTERRUPT option is enabled (but with some additional delays); the added option makes this behavior available for all other kinds of dual-role keys. * [Docs] Update tap-hold docs for HOLD_ON_OTHER_KEY_PRESS Document the newly added HOLD_ON_OTHER_KEY_PRESS option and update the documentation for closely related options (PERMISSIVE_HOLD and IGNORE_MOD_TAP_INTERRUPT). Use Layer Tap instead of Mod Tap in examples for PERMISSIVE_HOLD and HOLD_ON_OTHER_KEY_PRESS, because the effect of using these options with Mod Tap keys is mostly invisible without IGNORE_MOD_TAP_INTERRUPT. Add comments before return statements in sample implementations of `get_ignore_mod_tap_interrupt()`, `get_hold_on_other_key_press()` and `get_permissive_hold()`. Thanks to @Erovia and @precondition for comments and suggestions to improve the documentation.
Diffstat (limited to 'tmk_core/common')
-rw-r--r--tmk_core/common/action_tapping.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/tmk_core/common/action_tapping.c b/tmk_core/common/action_tapping.c
index 1701ae471..36839f9fa 100644
--- a/tmk_core/common/action_tapping.c
+++ b/tmk_core/common/action_tapping.c
@@ -40,6 +40,10 @@ __attribute__((weak)) bool get_tapping_force_hold(uint16_t keycode, keyrecord_t
40__attribute__((weak)) bool get_permissive_hold(uint16_t keycode, keyrecord_t *record) { return false; } 40__attribute__((weak)) bool get_permissive_hold(uint16_t keycode, keyrecord_t *record) { return false; }
41# endif 41# endif
42 42
43# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
44__attribute__((weak)) bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record) { return false; }
45# endif
46
43static keyrecord_t tapping_key = {}; 47static keyrecord_t tapping_key = {};
44static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {}; 48static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {};
45static uint8_t waiting_buffer_head = 0; 49static uint8_t waiting_buffer_head = 0;
@@ -175,6 +179,19 @@ bool process_tapping(keyrecord_t *keyp) {
175 // set interrupted flag when other key preesed during tapping 179 // set interrupted flag when other key preesed during tapping
176 if (event.pressed) { 180 if (event.pressed) {
177 tapping_key.tap.interrupted = true; 181 tapping_key.tap.interrupted = true;
182# if defined(HOLD_ON_OTHER_KEY_PRESS) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
183# if defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
184 if (get_hold_on_other_key_press(get_record_keycode(&tapping_key, false), keyp))
185# endif
186 {
187 debug("Tapping: End. No tap. Interfered by pressed key\n");
188 process_record(&tapping_key);
189 tapping_key = (keyrecord_t){};
190 debug_tapping_key();
191 // enqueue
192 return false;
193 }
194# endif
178 } 195 }
179 // enqueue 196 // enqueue
180 return false; 197 return false;