diff options
author | precondition <57645186+precondition@users.noreply.github.com> | 2021-11-25 20:06:50 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-26 07:06:50 +1100 |
commit | 4bac5f53d864a77a6f0fa8a2a046ed7748824ecc (patch) | |
tree | 75153ff862bdb0644e9d7622c1b80517e10a30f8 /quantum/process_keycode | |
parent | 5e9c29da0df045b03ada9278c34f37b22349a6f7 (diff) | |
download | qmk_firmware-4bac5f53d864a77a6f0fa8a2a046ed7748824ecc.tar.gz qmk_firmware-4bac5f53d864a77a6f0fa8a2a046ed7748824ecc.zip |
New feature: `DYNAMIC_TAPPING_TERM_ENABLE` (#11036)
* New feature: `DYNAMIC_TAPPING_TERM_ENABLE`
3 new quantum keys to configure the tapping term on the fly.
* Replace sprintf call in tapping_term_report by get_u16_str
* Replace tab with 4 spaces
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r-- | quantum/process_keycode/process_dynamic_tapping_term.c | 50 | ||||
-rw-r--r-- | quantum/process_keycode/process_dynamic_tapping_term.h | 26 |
2 files changed, 76 insertions, 0 deletions
diff --git a/quantum/process_keycode/process_dynamic_tapping_term.c b/quantum/process_keycode/process_dynamic_tapping_term.c new file mode 100644 index 000000000..bdc5529e3 --- /dev/null +++ b/quantum/process_keycode/process_dynamic_tapping_term.c | |||
@@ -0,0 +1,50 @@ | |||
1 | /* Copyright 2020 Vladislav Kucheriavykh | ||
2 | * | ||
3 | * This program is free software: you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License as published by | ||
5 | * the Free Software Foundation, either version 2 of the License, or | ||
6 | * (at your option) any later version. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #include "quantum.h" | ||
18 | #include "process_dynamic_tapping_term.h" | ||
19 | |||
20 | #ifndef DYNAMIC_TAPPING_TERM_INCREMENT | ||
21 | # define DYNAMIC_TAPPING_TERM_INCREMENT 5 | ||
22 | #endif | ||
23 | |||
24 | static void tapping_term_report(void) { | ||
25 | const char *tapping_term_str = get_u16_str(g_tapping_term, ' '); | ||
26 | // Skip padding spaces | ||
27 | while (*tapping_term_str == ' ') { | ||
28 | tapping_term_str++; | ||
29 | } | ||
30 | send_string(tapping_term_str); | ||
31 | } | ||
32 | |||
33 | bool process_dynamic_tapping_term(uint16_t keycode, keyrecord_t *record) { | ||
34 | if (record->event.pressed) { | ||
35 | switch (keycode) { | ||
36 | case DT_PRNT: | ||
37 | tapping_term_report(); | ||
38 | return false; | ||
39 | |||
40 | case DT_UP: | ||
41 | g_tapping_term += DYNAMIC_TAPPING_TERM_INCREMENT; | ||
42 | return false; | ||
43 | |||
44 | case DT_DOWN: | ||
45 | g_tapping_term -= DYNAMIC_TAPPING_TERM_INCREMENT; | ||
46 | return false; | ||
47 | } | ||
48 | } | ||
49 | return true; | ||
50 | } | ||
diff --git a/quantum/process_keycode/process_dynamic_tapping_term.h b/quantum/process_keycode/process_dynamic_tapping_term.h new file mode 100644 index 000000000..85e83ee73 --- /dev/null +++ b/quantum/process_keycode/process_dynamic_tapping_term.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* Copyright 2020 Vladislav Kucheriavykh | ||
2 | * | ||
3 | * This program is free software: you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License as published by | ||
5 | * the Free Software Foundation, either version 2 of the License, or | ||
6 | * (at your option) any later version. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #pragma once | ||
18 | |||
19 | #include <stdbool.h> | ||
20 | #include "action.h" | ||
21 | |||
22 | #ifndef DYNAMIC_TAPPING_TERM_INCREMENT | ||
23 | # define DYNAMIC_TAPPING_TERM_INCREMENT 5 | ||
24 | #endif | ||
25 | |||
26 | bool process_dynamic_tapping_term(uint16_t keycode, keyrecord_t *record); | ||