Skip to content

Commit af43076

Browse files
ridingqwertynoroadsleft
authored andcommitted
New feature: Retro Tapping per key (#10622)
1 parent 37ba464 commit af43076

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

docs/config_options.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ If you define these options you will enable the associated feature, which may in
135135
* `#define RETRO_TAPPING`
136136
* tap anyway, even after TAPPING_TERM, if there was no other key interruption between press and release
137137
* See [Retro Tapping](tap_hold.md#retro-tapping) for details
138+
* `#define RETRO_TAPPING_PER_KEY`
139+
* enables handling for per key `RETRO_TAPPING` settings
138140
* `#define TAPPING_TOGGLE 2`
139141
* how many taps before triggering the toggle
140142
* `#define PERMISSIVE_HOLD`

docs/tap_hold.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,25 @@ Holding and releasing a dual function key without pressing another key will resu
179179

180180
For instance, holding and releasing `LT(2, KC_SPACE)` without hitting another key will result in nothing happening. With this enabled, it will send `KC_SPACE` instead.
181181

182+
For more granular control of this feature, you can add the following to your `config.h`:
183+
184+
```c
185+
#define RETRO_TAPPING_PER_KEY
186+
```
187+
188+
You can then add the following function to your keymap:
189+
190+
```c
191+
bool get_retro_tapping(uint16_t keycode, keyrecord_t *record) {
192+
switch (keycode) {
193+
case LT(2, KC_SPACE):
194+
return true;
195+
default:
196+
return false;
197+
}
198+
}
199+
```
200+
182201
## Why do we include the key record for the per key functions?
183202
184203
One thing that you may notice is that we include the key record for all of the "per key" functions, and may be wondering why we do that.

tmk_core/common/action.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
4343

4444
int tp_buttons;
4545

46-
#ifdef RETRO_TAPPING
46+
#if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY)
4747
int retro_tapping_counter = 0;
4848
#endif
4949

@@ -55,6 +55,10 @@ int retro_tapping_counter = 0;
5555
__attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record) { return false; }
5656
#endif
5757

58+
#ifdef RETRO_TAPPING_PER_KEY
59+
__attribute__((weak)) bool get_retro_tapping(uint16_t keycode, keyrecord_t *record) { return false; }
60+
#endif
61+
5862
#ifndef TAP_CODE_DELAY
5963
# define TAP_CODE_DELAY 0
6064
#endif
@@ -71,7 +75,7 @@ void action_exec(keyevent_t event) {
7175
dprint("EVENT: ");
7276
debug_event(event);
7377
dprintln();
74-
#ifdef RETRO_TAPPING
78+
#if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY)
7579
retro_tapping_counter++;
7680
#endif
7781
}
@@ -725,20 +729,23 @@ void process_action(keyrecord_t *record, action_t action) {
725729
#endif
726730

727731
#ifndef NO_ACTION_TAPPING
728-
# ifdef RETRO_TAPPING
732+
# if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY)
729733
if (!is_tap_action(action)) {
730734
retro_tapping_counter = 0;
731735
} else {
732736
if (event.pressed) {
733737
if (tap_count > 0) {
734738
retro_tapping_counter = 0;
735-
} else {
736739
}
737740
} else {
738741
if (tap_count > 0) {
739742
retro_tapping_counter = 0;
740743
} else {
741-
if (retro_tapping_counter == 2) {
744+
if (
745+
# ifdef RETRO_TAPPING_PER_KEY
746+
get_retro_tapping(get_event_keycode(record->event, false), record) &&
747+
# endif
748+
retro_tapping_counter == 2) {
742749
tap_code(action.layer_tap.code);
743750
}
744751
retro_tapping_counter = 0;

0 commit comments

Comments
 (0)