diff options
Diffstat (limited to 'users/replicaJunction/features/super_alt_tab.c')
-rw-r--r-- | users/replicaJunction/features/super_alt_tab.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/users/replicaJunction/features/super_alt_tab.c b/users/replicaJunction/features/super_alt_tab.c new file mode 100644 index 000000000..9759898c8 --- /dev/null +++ b/users/replicaJunction/features/super_alt_tab.c | |||
@@ -0,0 +1,52 @@ | |||
1 | /* Copyright 2021 Joshua T. | ||
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 "super_alt_tab.h" | ||
18 | |||
19 | // https://docs.qmk.fm/#/feature_macros?id=super-alt%E2%86%AFtab | ||
20 | |||
21 | bool is_alt_tab_active = false; | ||
22 | uint16_t alt_tab_timer = 0; | ||
23 | |||
24 | void matrix_scan_super_alt_tab(void) { | ||
25 | if (is_alt_tab_active) { | ||
26 | if (timer_elapsed(alt_tab_timer) > USER_SUPER_ALT_TAB_TIMEOUT) { | ||
27 | unregister_code(KC_LALT); | ||
28 | is_alt_tab_active = false; | ||
29 | } | ||
30 | } | ||
31 | } | ||
32 | |||
33 | |||
34 | bool process_record_super_alt_tab(uint16_t keycode, const keyrecord_t *record) { | ||
35 | if (keycode != SALTTAB) { | ||
36 | return true; | ||
37 | } | ||
38 | |||
39 | if (record->event.pressed) { | ||
40 | if (!is_alt_tab_active) { | ||
41 | is_alt_tab_active = true; | ||
42 | register_code(KC_LALT); | ||
43 | } | ||
44 | alt_tab_timer = timer_read(); | ||
45 | register_code(KC_TAB); | ||
46 | } | ||
47 | else { | ||
48 | unregister_code(KC_TAB); | ||
49 | } | ||
50 | |||
51 | return false; | ||
52 | } | ||