diff options
Diffstat (limited to 'users/replicaJunction/features')
| -rw-r--r-- | users/replicaJunction/features/.gitignore | 2 | ||||
| -rw-r--r-- | users/replicaJunction/features/caps_word.c | 105 | ||||
| -rw-r--r-- | users/replicaJunction/features/caps_word.h | 26 | ||||
| -rw-r--r-- | users/replicaJunction/features/mouse_jiggle.c | 46 | ||||
| -rw-r--r-- | users/replicaJunction/features/mouse_jiggle.h | 23 | ||||
| -rw-r--r-- | users/replicaJunction/features/num_word.c | 129 | ||||
| -rw-r--r-- | users/replicaJunction/features/num_word.h | 27 | ||||
| -rw-r--r-- | users/replicaJunction/features/secrets.c | 51 | ||||
| -rw-r--r-- | users/replicaJunction/features/secrets.h | 30 | ||||
| -rw-r--r-- | users/replicaJunction/features/super_alt_tab.c | 52 | ||||
| -rw-r--r-- | users/replicaJunction/features/super_alt_tab.h | 27 |
11 files changed, 518 insertions, 0 deletions
diff --git a/users/replicaJunction/features/.gitignore b/users/replicaJunction/features/.gitignore new file mode 100644 index 000000000..9b590ee80 --- /dev/null +++ b/users/replicaJunction/features/.gitignore | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | # Do not include the secrets definitions | ||
| 2 | secret_definitions.h | ||
diff --git a/users/replicaJunction/features/caps_word.c b/users/replicaJunction/features/caps_word.c new file mode 100644 index 000000000..536da81ec --- /dev/null +++ b/users/replicaJunction/features/caps_word.c | |||
| @@ -0,0 +1,105 @@ | |||
| 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 "caps_word.h" | ||
| 18 | |||
| 19 | static bool is_caps_word_on = false; | ||
| 20 | |||
| 21 | bool is_caps_word_enabled(void) { | ||
| 22 | return is_caps_word_on; | ||
| 23 | } | ||
| 24 | |||
| 25 | void enable_caps_word(void) { | ||
| 26 | if (is_caps_word_on) return; | ||
| 27 | is_caps_word_on = true; | ||
| 28 | tap_code(KC_CAPS); | ||
| 29 | } | ||
| 30 | |||
| 31 | void disable_caps_word(void) { | ||
| 32 | if (!is_caps_word_on) return; | ||
| 33 | is_caps_word_on = false; | ||
| 34 | tap_code(KC_CAPS); | ||
| 35 | } | ||
| 36 | |||
| 37 | void toggle_caps_word(void) { | ||
| 38 | if (is_caps_word_on) { | ||
| 39 | disable_caps_word(); | ||
| 40 | } | ||
| 41 | else { | ||
| 42 | enable_caps_word(); | ||
| 43 | } | ||
| 44 | } | ||
| 45 | |||
| 46 | bool should_terminate_caps_word(uint16_t keycode, const keyrecord_t *record) { | ||
| 47 | switch (keycode) { | ||
| 48 | // Keycodes which should not disable caps word mode | ||
| 49 | case KC_A ... KC_Z: | ||
| 50 | case KC_1 ... KC_0: | ||
| 51 | case KC_MINS: | ||
| 52 | case KC_UNDS: | ||
| 53 | case KC_BSPC: | ||
| 54 | return false; | ||
| 55 | |||
| 56 | default: | ||
| 57 | if (record->event.pressed) { | ||
| 58 | return true; | ||
| 59 | } | ||
| 60 | return false; | ||
| 61 | } | ||
| 62 | |||
| 63 | // Should be unreachable | ||
| 64 | return false; | ||
| 65 | } | ||
| 66 | |||
| 67 | |||
| 68 | bool process_record_caps_word(uint16_t keycode, const keyrecord_t *record) { | ||
| 69 | // Nothing in this function acts on key release | ||
| 70 | if (!record->event.pressed) { | ||
| 71 | return true; | ||
| 72 | } | ||
| 73 | |||
| 74 | // Handle the custom keycodes that go with this feature | ||
| 75 | if (keycode == CAPWORD) { | ||
| 76 | enable_caps_word(); | ||
| 77 | return false; | ||
| 78 | } | ||
| 79 | |||
| 80 | // If the behavior isn't enabled and the keypress isn't a keycode to | ||
| 81 | // toggle the behavior, allow QMK to handle the keypress as usual | ||
| 82 | if (!is_caps_word_on) { | ||
| 83 | return true; | ||
| 84 | } | ||
| 85 | |||
| 86 | // Get the base keycode of a mod or layer tap key | ||
| 87 | switch (keycode) { | ||
| 88 | case QK_MOD_TAP ... QK_MOD_TAP_MAX: | ||
| 89 | case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: | ||
| 90 | case QK_TAP_DANCE ... QK_TAP_DANCE_MAX: | ||
| 91 | // Earlier return if this has not been considered tapped yet | ||
| 92 | if (record->tap.count == 0) | ||
| 93 | return true; | ||
| 94 | keycode = keycode & 0xFF; | ||
| 95 | break; | ||
| 96 | default: | ||
| 97 | break; | ||
| 98 | } | ||
| 99 | |||
| 100 | if (should_terminate_caps_word(keycode, record)) { | ||
| 101 | disable_caps_word(); | ||
| 102 | } | ||
| 103 | |||
| 104 | return true; | ||
| 105 | } | ||
diff --git a/users/replicaJunction/features/caps_word.h b/users/replicaJunction/features/caps_word.h new file mode 100644 index 000000000..4182ce582 --- /dev/null +++ b/users/replicaJunction/features/caps_word.h | |||
| @@ -0,0 +1,26 @@ | |||
| 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 | #pragma once | ||
| 18 | #include QMK_KEYBOARD_H | ||
| 19 | #include "rj_keycodes.h" | ||
| 20 | |||
| 21 | bool is_caps_word_enabled(void); | ||
| 22 | void enable_caps_word(void); | ||
| 23 | void disable_caps_word(void); | ||
| 24 | void toggle_caps_word(void); | ||
| 25 | |||
| 26 | bool process_record_caps_word(uint16_t keycode, const keyrecord_t *record); | ||
diff --git a/users/replicaJunction/features/mouse_jiggle.c b/users/replicaJunction/features/mouse_jiggle.c new file mode 100644 index 000000000..b2c451d33 --- /dev/null +++ b/users/replicaJunction/features/mouse_jiggle.c | |||
| @@ -0,0 +1,46 @@ | |||
| 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 "mouse_jiggle.h" | ||
| 18 | |||
| 19 | bool is_mouse_jiggle_active = false; | ||
| 20 | |||
| 21 | void matrix_scan_mouse_jiggle(void) { | ||
| 22 | if (is_mouse_jiggle_active) { | ||
| 23 | tap_code(KC_MS_UP); | ||
| 24 | tap_code(KC_MS_DOWN); | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | bool process_record_mouse_jiggle(uint16_t keycode, const keyrecord_t *record) { | ||
| 29 | if (!record->event.pressed) { | ||
| 30 | return true; | ||
| 31 | } | ||
| 32 | |||
| 33 | if (is_mouse_jiggle_active) { | ||
| 34 | // If active, quit whenever another key is pressed | ||
| 35 | is_mouse_jiggle_active = false; | ||
| 36 | return true; | ||
| 37 | } | ||
| 38 | |||
| 39 | if (keycode != MS_JIGL) { | ||
| 40 | return true; | ||
| 41 | } | ||
| 42 | |||
| 43 | is_mouse_jiggle_active = true; | ||
| 44 | SEND_STRING("Mouse jiggler enabled"); | ||
| 45 | return false; | ||
| 46 | } | ||
diff --git a/users/replicaJunction/features/mouse_jiggle.h b/users/replicaJunction/features/mouse_jiggle.h new file mode 100644 index 000000000..ba2c6e757 --- /dev/null +++ b/users/replicaJunction/features/mouse_jiggle.h | |||
| @@ -0,0 +1,23 @@ | |||
| 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 | #pragma once | ||
| 18 | #include QMK_KEYBOARD_H | ||
| 19 | #include "rj_keycodes.h" | ||
| 20 | |||
| 21 | void matrix_scan_mouse_jiggle(void); | ||
| 22 | |||
| 23 | bool process_record_mouse_jiggle(uint16_t keycode, const keyrecord_t *record); | ||
diff --git a/users/replicaJunction/features/num_word.c b/users/replicaJunction/features/num_word.c new file mode 100644 index 000000000..4cca5c19a --- /dev/null +++ b/users/replicaJunction/features/num_word.c | |||
| @@ -0,0 +1,129 @@ | |||
| 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 "num_word.h" | ||
| 18 | |||
| 19 | static uint16_t num_word_timer = 0; | ||
| 20 | static bool is_num_word_on = false; | ||
| 21 | |||
| 22 | bool is_num_word_enabled(void) { | ||
| 23 | return is_num_word_on; | ||
| 24 | } | ||
| 25 | |||
| 26 | void enable_num_word(void) { | ||
| 27 | if (is_num_word_on) return; | ||
| 28 | is_num_word_on = true; | ||
| 29 | layer_on(L_NUMBERS); | ||
| 30 | } | ||
| 31 | |||
| 32 | void disable_num_word(void) { | ||
| 33 | if (!is_num_word_on) return; | ||
| 34 | is_num_word_on = false; | ||
| 35 | layer_off(L_NUMBERS); | ||
| 36 | } | ||
| 37 | |||
| 38 | void toggle_num_word(void) { | ||
| 39 | if (is_num_word_on) { | ||
| 40 | disable_num_word(); | ||
| 41 | } | ||
| 42 | else { | ||
| 43 | enable_num_word(); | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | bool should_terminate_num_word(uint16_t keycode, const keyrecord_t *record) { | ||
| 48 | switch (keycode) { | ||
| 49 | // Keycodes which should not disable num word mode. | ||
| 50 | // We could probably be more brief with these definitions by using | ||
| 51 | // a couple more ranges, but I believe "explicit is better than | ||
| 52 | // implicit" | ||
| 53 | case KC_1 ... KC_0: | ||
| 54 | case KC_EQL: | ||
| 55 | case KC_SCLN: | ||
| 56 | case KC_MINS: | ||
| 57 | case KC_DOT: | ||
| 58 | |||
| 59 | // Numpad keycodes | ||
| 60 | case KC_P1 ... KC_P0: | ||
| 61 | case KC_PSLS ... KC_PPLS: | ||
| 62 | case KC_PDOT: | ||
| 63 | |||
| 64 | // Misc | ||
| 65 | case KC_UNDS: | ||
| 66 | case KC_BSPC: | ||
| 67 | return false; | ||
| 68 | |||
| 69 | default: | ||
| 70 | if (record->event.pressed) { | ||
| 71 | return true; | ||
| 72 | } | ||
| 73 | return false; | ||
| 74 | } | ||
| 75 | |||
| 76 | // Should be unreachable | ||
| 77 | return false; | ||
| 78 | } | ||
| 79 | |||
| 80 | |||
| 81 | bool process_record_num_word(uint16_t keycode, const keyrecord_t *record) { | ||
| 82 | // Handle the custom keycodes that go with this feature | ||
| 83 | if (keycode == NUMWORD) { | ||
| 84 | if (record->event.pressed) { | ||
| 85 | enable_num_word(); | ||
| 86 | num_word_timer = timer_read(); | ||
| 87 | return false; | ||
| 88 | } | ||
| 89 | else { | ||
| 90 | if (timer_elapsed(num_word_timer) > TAPPING_TERM) { | ||
| 91 | // If the user held the key longer than TAPPING_TERM, | ||
| 92 | // consider it a hold, and disable the behavior on | ||
| 93 | // key release. | ||
| 94 | disable_num_word(); | ||
| 95 | return false; | ||
| 96 | } | ||
| 97 | } | ||
| 98 | } | ||
| 99 | |||
| 100 | // Other than the custom keycodes, nothing else in this feature will | ||
| 101 | // activate if the behavior is not on, so allow QMK to handle the | ||
| 102 | // event as usual | ||
| 103 | if (!is_num_word_on) return true; | ||
| 104 | |||
| 105 | // Nothing else acts on key release, either | ||
| 106 | if (!record->event.pressed) { | ||
| 107 | return true; | ||
| 108 | } | ||
| 109 | |||
| 110 | // Get the base keycode of a mod or layer tap key | ||
| 111 | switch (keycode) { | ||
| 112 | case QK_MOD_TAP ... QK_MOD_TAP_MAX: | ||
| 113 | case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: | ||
| 114 | case QK_TAP_DANCE ... QK_TAP_DANCE_MAX: | ||
| 115 | // Earlier return if this has not been considered tapped yet | ||
| 116 | if (record->tap.count == 0) | ||
| 117 | return true; | ||
| 118 | keycode = keycode & 0xFF; | ||
| 119 | break; | ||
| 120 | default: | ||
| 121 | break; | ||
| 122 | } | ||
| 123 | |||
| 124 | if (should_terminate_num_word(keycode, record)) { | ||
| 125 | disable_num_word(); | ||
| 126 | } | ||
| 127 | |||
| 128 | return true; | ||
| 129 | } | ||
diff --git a/users/replicaJunction/features/num_word.h b/users/replicaJunction/features/num_word.h new file mode 100644 index 000000000..194c4e2e0 --- /dev/null +++ b/users/replicaJunction/features/num_word.h | |||
| @@ -0,0 +1,27 @@ | |||
| 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 | #pragma once | ||
| 18 | #include QMK_KEYBOARD_H | ||
| 19 | #include "rj_keycodes.h" | ||
| 20 | #include "rj_layers.h" | ||
| 21 | |||
| 22 | bool is_num_word_enabled(void); | ||
| 23 | void enable_num_word(void); | ||
| 24 | void disable_num_word(void); | ||
| 25 | void toggle_num_word(void); | ||
| 26 | |||
| 27 | bool process_record_num_word(uint16_t keycode, const keyrecord_t *record); | ||
diff --git a/users/replicaJunction/features/secrets.c b/users/replicaJunction/features/secrets.c new file mode 100644 index 000000000..3e1ea283d --- /dev/null +++ b/users/replicaJunction/features/secrets.c | |||
| @@ -0,0 +1,51 @@ | |||
| 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 | // Before you can compile with this feature, you'll need to manually | ||
| 18 | // create a file in this directory called "secret_definitions.h" | ||
| 19 | // containing the data to be added. | ||
| 20 | // | ||
| 21 | // Example implementation: | ||
| 22 | // | ||
| 23 | // #pragma once | ||
| 24 | // static const char * const secrets[] = { | ||
| 25 | // "secret1", | ||
| 26 | // "secret2", | ||
| 27 | // "secret3", | ||
| 28 | // "secret4" | ||
| 29 | // } | ||
| 30 | |||
| 31 | #include QMK_KEYBOARD_H | ||
| 32 | #include "replicaJunction.h" | ||
| 33 | #include "secrets.h" | ||
| 34 | #include "secret_definitions.h" | ||
| 35 | |||
| 36 | #ifndef MACRO_TIMER | ||
| 37 | # define MACRO_TIMER 5 | ||
| 38 | #endif | ||
| 39 | |||
| 40 | bool process_record_secrets(uint16_t keycode, const keyrecord_t *record) { | ||
| 41 | switch (keycode) { | ||
| 42 | case K_SECR1 ... K_SECR4: // Secrets! Externally defined strings, not stored in repo | ||
| 43 | if (!record->event.pressed) { | ||
| 44 | clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); | ||
| 45 | send_string_with_delay(secrets[keycode - K_SECR1], MACRO_TIMER); | ||
| 46 | } | ||
| 47 | return false; | ||
| 48 | } | ||
| 49 | |||
| 50 | return true; | ||
| 51 | } | ||
diff --git a/users/replicaJunction/features/secrets.h b/users/replicaJunction/features/secrets.h new file mode 100644 index 000000000..ef4396227 --- /dev/null +++ b/users/replicaJunction/features/secrets.h | |||
| @@ -0,0 +1,30 @@ | |||
| 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 | #pragma once | ||
| 18 | #include QMK_KEYBOARD_H | ||
| 19 | |||
| 20 | // NOTE: In some implementations of the "secrets" functionality, the | ||
| 21 | // secrets.h file is the file that actually contains secret text. | ||
| 22 | // | ||
| 23 | // This is not the case in my implementation. That file is called | ||
| 24 | // "secret_definitions.h", and it's in a local .gitignore file so it | ||
| 25 | // does not get committed. | ||
| 26 | // | ||
| 27 | // The inclusion of this file is not an error, and there is no sensitive | ||
| 28 | // text here. | ||
| 29 | |||
| 30 | bool process_record_secrets(uint16_t keycode, const keyrecord_t *record); | ||
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 | } | ||
diff --git a/users/replicaJunction/features/super_alt_tab.h b/users/replicaJunction/features/super_alt_tab.h new file mode 100644 index 000000000..8bdf2bc22 --- /dev/null +++ b/users/replicaJunction/features/super_alt_tab.h | |||
| @@ -0,0 +1,27 @@ | |||
| 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 | #pragma once | ||
| 18 | #include QMK_KEYBOARD_H | ||
| 19 | #include "rj_keycodes.h" | ||
| 20 | |||
| 21 | #ifndef USER_SUPER_ALT_TAB_TIMEOUT | ||
| 22 | # define USER_SUPER_ALT_TAB_TIMEOUT 500 | ||
| 23 | #endif | ||
| 24 | |||
| 25 | void matrix_scan_super_alt_tab(void); | ||
| 26 | |||
| 27 | bool process_record_super_alt_tab(uint16_t keycode, const keyrecord_t *record); | ||
