diff options
Diffstat (limited to 'quantum/process_keycode')
| -rw-r--r-- | quantum/process_keycode/process_dynamic_macro.c | 257 | ||||
| -rw-r--r-- | quantum/process_keycode/process_dynamic_macro.h | 41 | ||||
| -rw-r--r-- | quantum/process_keycode/process_magic.c | 178 | ||||
| -rw-r--r-- | quantum/process_keycode/process_magic.h | 20 | ||||
| -rw-r--r-- | quantum/process_keycode/process_tap_dance.h | 6 | ||||
| -rw-r--r-- | quantum/process_keycode/process_terminal.c | 2 |
6 files changed, 499 insertions, 5 deletions
diff --git a/quantum/process_keycode/process_dynamic_macro.c b/quantum/process_keycode/process_dynamic_macro.c new file mode 100644 index 000000000..2065f242d --- /dev/null +++ b/quantum/process_keycode/process_dynamic_macro.c | |||
| @@ -0,0 +1,257 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * Copyright 2019 Drashna Jael're (@drashna, aka Christopher Courtney) | ||
| 3 | * | ||
| 4 | * This program is free software: you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation, either version 2 of the License, or | ||
| 7 | * (at your option) any later version. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | /* Author: Wojciech Siewierski < wojciech dot siewierski at onet dot pl > */ | ||
| 19 | #include "process_dynamic_macro.h" | ||
| 20 | |||
| 21 | // default feedback method | ||
| 22 | void dynamic_macro_led_blink(void) { | ||
| 23 | #ifdef BACKLIGHT_ENABLE | ||
| 24 | backlight_toggle(); | ||
| 25 | wait_ms(100); | ||
| 26 | backlight_toggle(); | ||
| 27 | #endif | ||
| 28 | } | ||
| 29 | |||
| 30 | /* User hooks for Dynamic Macros */ | ||
| 31 | |||
| 32 | __attribute__((weak)) void dynamic_macro_record_start_user(void) { dynamic_macro_led_blink(); } | ||
| 33 | |||
| 34 | __attribute__((weak)) void dynamic_macro_play_user(int8_t direction) { dynamic_macro_led_blink(); } | ||
| 35 | |||
| 36 | __attribute__((weak)) void dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record) { dynamic_macro_led_blink(); } | ||
| 37 | |||
| 38 | __attribute__((weak)) void dynamic_macro_record_end_user(int8_t direction) { dynamic_macro_led_blink(); } | ||
| 39 | |||
| 40 | /* Convenience macros used for retrieving the debug info. All of them | ||
| 41 | * need a `direction` variable accessible at the call site. | ||
| 42 | */ | ||
| 43 | #define DYNAMIC_MACRO_CURRENT_SLOT() (direction > 0 ? 1 : 2) | ||
| 44 | #define DYNAMIC_MACRO_CURRENT_LENGTH(BEGIN, POINTER) ((int)(direction * ((POINTER) - (BEGIN)))) | ||
| 45 | #define DYNAMIC_MACRO_CURRENT_CAPACITY(BEGIN, END2) ((int)(direction * ((END2) - (BEGIN)) + 1)) | ||
| 46 | |||
| 47 | /** | ||
| 48 | * Start recording of the dynamic macro. | ||
| 49 | * | ||
| 50 | * @param[out] macro_pointer The new macro buffer iterator. | ||
| 51 | * @param[in] macro_buffer The macro buffer used to initialize macro_pointer. | ||
| 52 | */ | ||
| 53 | void dynamic_macro_record_start(keyrecord_t **macro_pointer, keyrecord_t *macro_buffer) { | ||
| 54 | dprintln("dynamic macro recording: started"); | ||
| 55 | |||
| 56 | dynamic_macro_record_start_user(); | ||
| 57 | |||
| 58 | clear_keyboard(); | ||
| 59 | layer_clear(); | ||
| 60 | *macro_pointer = macro_buffer; | ||
| 61 | } | ||
| 62 | |||
| 63 | /** | ||
| 64 | * Play the dynamic macro. | ||
| 65 | * | ||
| 66 | * @param macro_buffer[in] The beginning of the macro buffer being played. | ||
| 67 | * @param macro_end[in] The element after the last macro buffer element. | ||
| 68 | * @param direction[in] Either +1 or -1, which way to iterate the buffer. | ||
| 69 | */ | ||
| 70 | void dynamic_macro_play(keyrecord_t *macro_buffer, keyrecord_t *macro_end, int8_t direction) { | ||
| 71 | dprintf("dynamic macro: slot %d playback\n", DYNAMIC_MACRO_CURRENT_SLOT()); | ||
| 72 | |||
| 73 | layer_state_t saved_layer_state = layer_state; | ||
| 74 | |||
| 75 | clear_keyboard(); | ||
| 76 | layer_clear(); | ||
| 77 | |||
| 78 | while (macro_buffer != macro_end) { | ||
| 79 | process_record(macro_buffer); | ||
| 80 | macro_buffer += direction; | ||
| 81 | } | ||
| 82 | |||
| 83 | clear_keyboard(); | ||
| 84 | |||
| 85 | layer_state = saved_layer_state; | ||
| 86 | |||
| 87 | dynamic_macro_play_user(direction); | ||
| 88 | } | ||
| 89 | |||
| 90 | /** | ||
| 91 | * Record a single key in a dynamic macro. | ||
| 92 | * | ||
| 93 | * @param macro_buffer[in] The start of the used macro buffer. | ||
| 94 | * @param macro_pointer[in,out] The current buffer position. | ||
| 95 | * @param macro2_end[in] The end of the other macro. | ||
| 96 | * @param direction[in] Either +1 or -1, which way to iterate the buffer. | ||
| 97 | * @param record[in] The current keypress. | ||
| 98 | */ | ||
| 99 | void dynamic_macro_record_key(keyrecord_t *macro_buffer, keyrecord_t **macro_pointer, keyrecord_t *macro2_end, int8_t direction, keyrecord_t *record) { | ||
| 100 | /* If we've just started recording, ignore all the key releases. */ | ||
| 101 | if (!record->event.pressed && *macro_pointer == macro_buffer) { | ||
| 102 | dprintln("dynamic macro: ignoring a leading key-up event"); | ||
| 103 | return; | ||
| 104 | } | ||
| 105 | |||
| 106 | /* The other end of the other macro is the last buffer element it | ||
| 107 | * is safe to use before overwriting the other macro. | ||
| 108 | */ | ||
| 109 | if (*macro_pointer - direction != macro2_end) { | ||
| 110 | **macro_pointer = *record; | ||
| 111 | *macro_pointer += direction; | ||
| 112 | } else { | ||
| 113 | dynamic_macro_record_key_user(direction, record); | ||
| 114 | } | ||
| 115 | |||
| 116 | dprintf("dynamic macro: slot %d length: %d/%d\n", DYNAMIC_MACRO_CURRENT_SLOT(), DYNAMIC_MACRO_CURRENT_LENGTH(macro_buffer, *macro_pointer), DYNAMIC_MACRO_CURRENT_CAPACITY(macro_buffer, macro2_end)); | ||
| 117 | } | ||
| 118 | |||
| 119 | /** | ||
| 120 | * End recording of the dynamic macro. Essentially just update the | ||
| 121 | * pointer to the end of the macro. | ||
| 122 | */ | ||
| 123 | void dynamic_macro_record_end(keyrecord_t *macro_buffer, keyrecord_t *macro_pointer, int8_t direction, keyrecord_t **macro_end) { | ||
| 124 | dynamic_macro_record_end_user(direction); | ||
| 125 | |||
| 126 | /* Do not save the keys being held when stopping the recording, | ||
| 127 | * i.e. the keys used to access the layer DYN_REC_STOP is on. | ||
| 128 | */ | ||
| 129 | while (macro_pointer != macro_buffer && (macro_pointer - direction)->event.pressed) { | ||
| 130 | dprintln("dynamic macro: trimming a trailing key-down event"); | ||
| 131 | macro_pointer -= direction; | ||
| 132 | } | ||
| 133 | |||
| 134 | dprintf("dynamic macro: slot %d saved, length: %d\n", DYNAMIC_MACRO_CURRENT_SLOT(), DYNAMIC_MACRO_CURRENT_LENGTH(macro_buffer, macro_pointer)); | ||
| 135 | |||
| 136 | *macro_end = macro_pointer; | ||
| 137 | } | ||
| 138 | |||
| 139 | /* Handle the key events related to the dynamic macros. Should be | ||
| 140 | * called from process_record_user() like this: | ||
| 141 | * | ||
| 142 | * bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 143 | * if (!process_record_dynamic_macro(keycode, record)) { | ||
| 144 | * return false; | ||
| 145 | * } | ||
| 146 | * <...THE REST OF THE FUNCTION...> | ||
| 147 | * } | ||
| 148 | */ | ||
| 149 | bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record) { | ||
| 150 | /* Both macros use the same buffer but read/write on different | ||
| 151 | * ends of it. | ||
| 152 | * | ||
| 153 | * Macro1 is written left-to-right starting from the beginning of | ||
| 154 | * the buffer. | ||
| 155 | * | ||
| 156 | * Macro2 is written right-to-left starting from the end of the | ||
| 157 | * buffer. | ||
| 158 | * | ||
| 159 | * ¯o_buffer macro_end | ||
| 160 | * v v | ||
| 161 | * +------------------------------------------------------------+ | ||
| 162 | * |>>>>>> MACRO1 >>>>>> <<<<<<<<<<<<< MACRO2 <<<<<<<<<<<<<| | ||
| 163 | * +------------------------------------------------------------+ | ||
| 164 | * ^ ^ | ||
| 165 | * r_macro_end r_macro_buffer | ||
| 166 | * | ||
| 167 | * During the recording when one macro encounters the end of the | ||
| 168 | * other macro, the recording is stopped. Apart from this, there | ||
| 169 | * are no arbitrary limits for the macros' length in relation to | ||
| 170 | * each other: for example one can either have two medium sized | ||
| 171 | * macros or one long macro and one short macro. Or even one empty | ||
| 172 | * and one using the whole buffer. | ||
| 173 | */ | ||
| 174 | static keyrecord_t macro_buffer[DYNAMIC_MACRO_SIZE]; | ||
| 175 | |||
| 176 | /* Pointer to the first buffer element after the first macro. | ||
| 177 | * Initially points to the very beginning of the buffer since the | ||
| 178 | * macro is empty. */ | ||
| 179 | static keyrecord_t *macro_end = macro_buffer; | ||
| 180 | |||
| 181 | /* The other end of the macro buffer. Serves as the beginning of | ||
| 182 | * the second macro. */ | ||
| 183 | static keyrecord_t *const r_macro_buffer = macro_buffer + DYNAMIC_MACRO_SIZE - 1; | ||
| 184 | |||
| 185 | /* Like macro_end but for the second macro. */ | ||
| 186 | static keyrecord_t *r_macro_end = r_macro_buffer; | ||
| 187 | |||
| 188 | /* A persistent pointer to the current macro position (iterator) | ||
| 189 | * used during the recording. */ | ||
| 190 | static keyrecord_t *macro_pointer = NULL; | ||
| 191 | |||
| 192 | /* 0 - no macro is being recorded right now | ||
| 193 | * 1,2 - either macro 1 or 2 is being recorded */ | ||
| 194 | static uint8_t macro_id = 0; | ||
| 195 | |||
| 196 | if (macro_id == 0) { | ||
| 197 | /* No macro recording in progress. */ | ||
| 198 | if (!record->event.pressed) { | ||
| 199 | switch (keycode) { | ||
| 200 | case DYN_REC_START1: | ||
| 201 | dynamic_macro_record_start(¯o_pointer, macro_buffer); | ||
| 202 | macro_id = 1; | ||
| 203 | return false; | ||
| 204 | case DYN_REC_START2: | ||
| 205 | dynamic_macro_record_start(¯o_pointer, r_macro_buffer); | ||
| 206 | macro_id = 2; | ||
| 207 | return false; | ||
| 208 | case DYN_MACRO_PLAY1: | ||
| 209 | dynamic_macro_play(macro_buffer, macro_end, +1); | ||
| 210 | return false; | ||
| 211 | case DYN_MACRO_PLAY2: | ||
| 212 | dynamic_macro_play(r_macro_buffer, r_macro_end, -1); | ||
| 213 | return false; | ||
| 214 | } | ||
| 215 | } | ||
| 216 | } else { | ||
| 217 | /* A macro is being recorded right now. */ | ||
| 218 | switch (keycode) { | ||
| 219 | case DYN_REC_STOP: | ||
| 220 | /* Stop the macro recording. */ | ||
| 221 | if (record->event.pressed) { /* Ignore the initial release | ||
| 222 | * just after the recoding | ||
| 223 | * starts. */ | ||
| 224 | switch (macro_id) { | ||
| 225 | case 1: | ||
| 226 | dynamic_macro_record_end(macro_buffer, macro_pointer, +1, ¯o_end); | ||
| 227 | break; | ||
| 228 | case 2: | ||
| 229 | dynamic_macro_record_end(r_macro_buffer, macro_pointer, -1, &r_macro_end); | ||
| 230 | break; | ||
| 231 | } | ||
| 232 | macro_id = 0; | ||
| 233 | } | ||
| 234 | return false; | ||
| 235 | #ifdef DYNAMIC_MACRO_NO_NESTING | ||
| 236 | case DYN_MACRO_PLAY1: | ||
| 237 | case DYN_MACRO_PLAY2: | ||
| 238 | dprintln("dynamic macro: ignoring macro play key while recording"); | ||
| 239 | return false; | ||
| 240 | #endif | ||
| 241 | default: | ||
| 242 | /* Store the key in the macro buffer and process it normally. */ | ||
| 243 | switch (macro_id) { | ||
| 244 | case 1: | ||
| 245 | dynamic_macro_record_key(macro_buffer, ¯o_pointer, r_macro_end, +1, record); | ||
| 246 | break; | ||
| 247 | case 2: | ||
| 248 | dynamic_macro_record_key(r_macro_buffer, ¯o_pointer, macro_end, -1, record); | ||
| 249 | break; | ||
| 250 | } | ||
| 251 | return true; | ||
| 252 | break; | ||
| 253 | } | ||
| 254 | } | ||
| 255 | |||
| 256 | return true; | ||
| 257 | } | ||
diff --git a/quantum/process_keycode/process_dynamic_macro.h b/quantum/process_keycode/process_dynamic_macro.h new file mode 100644 index 000000000..39036541b --- /dev/null +++ b/quantum/process_keycode/process_dynamic_macro.h | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | /* Copyright 2016 Jack Humbert | ||
| 2 | * Copyright 2019 Drashna Jael're (@drashna, aka Christopher Courtney) | ||
| 3 | * | ||
| 4 | * This program is free software: you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation, either version 2 of the License, or | ||
| 7 | * (at your option) any later version. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | /* Author: Wojciech Siewierski < wojciech dot siewierski at onet dot pl > */ | ||
| 19 | #pragma once | ||
| 20 | |||
| 21 | #include "quantum.h" | ||
| 22 | |||
| 23 | /* May be overridden with a custom value. Be aware that the effective | ||
| 24 | * macro length is half of this value: each keypress is recorded twice | ||
| 25 | * because of the down-event and up-event. This is not a bug, it's the | ||
| 26 | * intended behavior. | ||
| 27 | * | ||
| 28 | * Usually it should be fine to set the macro size to at least 256 but | ||
| 29 | * there have been reports of it being too much in some users' cases, | ||
| 30 | * so 128 is considered a safe default. | ||
| 31 | */ | ||
| 32 | #ifndef DYNAMIC_MACRO_SIZE | ||
| 33 | # define DYNAMIC_MACRO_SIZE 128 | ||
| 34 | #endif | ||
| 35 | |||
| 36 | void dynamic_macro_led_blink(void); | ||
| 37 | bool process_dynamic_macro(uint16_t keycode, keyrecord_t *record); | ||
| 38 | void dynamic_macro_record_start_user(void); | ||
| 39 | void dynamic_macro_play_user(int8_t direction); | ||
| 40 | void dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record); | ||
| 41 | void dynamic_macro_record_end_user(int8_t direction); | ||
diff --git a/quantum/process_keycode/process_magic.c b/quantum/process_keycode/process_magic.c new file mode 100644 index 000000000..44dd5f057 --- /dev/null +++ b/quantum/process_keycode/process_magic.c | |||
| @@ -0,0 +1,178 @@ | |||
| 1 | /* Copyright 2019 Jack Humbert | ||
| 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 | #include "process_magic.h" | ||
| 17 | |||
| 18 | #ifdef AUDIO_ENABLE | ||
| 19 | # ifndef AG_NORM_SONG | ||
| 20 | # define AG_NORM_SONG SONG(AG_NORM_SOUND) | ||
| 21 | # endif | ||
| 22 | # ifndef AG_SWAP_SONG | ||
| 23 | # define AG_SWAP_SONG SONG(AG_SWAP_SOUND) | ||
| 24 | # endif | ||
| 25 | # ifndef CG_NORM_SONG | ||
| 26 | # define CG_NORM_SONG SONG(AG_NORM_SOUND) | ||
| 27 | # endif | ||
| 28 | # ifndef CG_SWAP_SONG | ||
| 29 | # define CG_SWAP_SONG SONG(AG_SWAP_SOUND) | ||
| 30 | # endif | ||
| 31 | float ag_norm_song[][2] = AG_NORM_SONG; | ||
| 32 | float ag_swap_song[][2] = AG_SWAP_SONG; | ||
| 33 | float cg_norm_song[][2] = CG_NORM_SONG; | ||
| 34 | float cg_swap_song[][2] = CG_SWAP_SONG; | ||
| 35 | #endif | ||
| 36 | |||
| 37 | /** | ||
| 38 | * MAGIC actions (BOOTMAGIC without the boot) | ||
| 39 | */ | ||
| 40 | bool process_magic(uint16_t keycode, keyrecord_t *record) { | ||
| 41 | // skip anything that isn't a keyup | ||
| 42 | if (record->event.pressed) { | ||
| 43 | switch (keycode) { | ||
| 44 | case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_ALT_GUI: | ||
| 45 | case MAGIC_SWAP_LCTL_LGUI ... MAGIC_EE_HANDS_RIGHT: | ||
| 46 | /* keymap config */ | ||
| 47 | keymap_config.raw = eeconfig_read_keymap(); | ||
| 48 | switch (keycode) { | ||
| 49 | case MAGIC_SWAP_CONTROL_CAPSLOCK: | ||
| 50 | keymap_config.swap_control_capslock = true; | ||
| 51 | break; | ||
| 52 | case MAGIC_CAPSLOCK_TO_CONTROL: | ||
| 53 | keymap_config.capslock_to_control = true; | ||
| 54 | break; | ||
| 55 | case MAGIC_SWAP_LALT_LGUI: | ||
| 56 | keymap_config.swap_lalt_lgui = true; | ||
| 57 | break; | ||
| 58 | case MAGIC_SWAP_RALT_RGUI: | ||
| 59 | keymap_config.swap_ralt_rgui = true; | ||
| 60 | break; | ||
| 61 | case MAGIC_SWAP_LCTL_LGUI: | ||
| 62 | keymap_config.swap_lctl_lgui = true; | ||
| 63 | break; | ||
| 64 | case MAGIC_SWAP_RCTL_RGUI: | ||
| 65 | keymap_config.swap_rctl_rgui = true; | ||
| 66 | break; | ||
| 67 | case MAGIC_NO_GUI: | ||
| 68 | keymap_config.no_gui = true; | ||
| 69 | break; | ||
| 70 | case MAGIC_SWAP_GRAVE_ESC: | ||
| 71 | keymap_config.swap_grave_esc = true; | ||
| 72 | break; | ||
| 73 | case MAGIC_SWAP_BACKSLASH_BACKSPACE: | ||
| 74 | keymap_config.swap_backslash_backspace = true; | ||
| 75 | break; | ||
| 76 | case MAGIC_HOST_NKRO: | ||
| 77 | clear_keyboard(); // clear first buffer to prevent stuck keys | ||
| 78 | keymap_config.nkro = true; | ||
| 79 | break; | ||
| 80 | case MAGIC_SWAP_ALT_GUI: | ||
| 81 | keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = true; | ||
| 82 | #ifdef AUDIO_ENABLE | ||
| 83 | PLAY_SONG(ag_swap_song); | ||
| 84 | #endif | ||
| 85 | break; | ||
| 86 | case MAGIC_SWAP_CTL_GUI: | ||
| 87 | keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = true; | ||
| 88 | #ifdef AUDIO_ENABLE | ||
| 89 | PLAY_SONG(cg_swap_song); | ||
| 90 | #endif | ||
| 91 | break; | ||
| 92 | case MAGIC_UNSWAP_CONTROL_CAPSLOCK: | ||
| 93 | keymap_config.swap_control_capslock = false; | ||
| 94 | break; | ||
| 95 | case MAGIC_UNCAPSLOCK_TO_CONTROL: | ||
| 96 | keymap_config.capslock_to_control = false; | ||
| 97 | break; | ||
| 98 | case MAGIC_UNSWAP_LALT_LGUI: | ||
| 99 | keymap_config.swap_lalt_lgui = false; | ||
| 100 | break; | ||
| 101 | case MAGIC_UNSWAP_RALT_RGUI: | ||
| 102 | keymap_config.swap_ralt_rgui = false; | ||
| 103 | break; | ||
| 104 | case MAGIC_UNSWAP_LCTL_LGUI: | ||
| 105 | keymap_config.swap_lctl_lgui = false; | ||
| 106 | break; | ||
| 107 | case MAGIC_UNSWAP_RCTL_RGUI: | ||
| 108 | keymap_config.swap_rctl_rgui = false; | ||
| 109 | break; | ||
| 110 | case MAGIC_UNNO_GUI: | ||
| 111 | keymap_config.no_gui = false; | ||
| 112 | break; | ||
| 113 | case MAGIC_UNSWAP_GRAVE_ESC: | ||
| 114 | keymap_config.swap_grave_esc = false; | ||
| 115 | break; | ||
| 116 | case MAGIC_UNSWAP_BACKSLASH_BACKSPACE: | ||
| 117 | keymap_config.swap_backslash_backspace = false; | ||
| 118 | break; | ||
| 119 | case MAGIC_UNHOST_NKRO: | ||
| 120 | clear_keyboard(); // clear first buffer to prevent stuck keys | ||
| 121 | keymap_config.nkro = false; | ||
| 122 | break; | ||
| 123 | case MAGIC_UNSWAP_ALT_GUI: | ||
| 124 | keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = false; | ||
| 125 | #ifdef AUDIO_ENABLE | ||
| 126 | PLAY_SONG(ag_norm_song); | ||
| 127 | #endif | ||
| 128 | break; | ||
| 129 | case MAGIC_UNSWAP_CTL_GUI: | ||
| 130 | keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = false; | ||
| 131 | #ifdef AUDIO_ENABLE | ||
| 132 | PLAY_SONG(cg_norm_song); | ||
| 133 | #endif | ||
| 134 | break; | ||
| 135 | case MAGIC_TOGGLE_ALT_GUI: | ||
| 136 | keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui; | ||
| 137 | keymap_config.swap_ralt_rgui = keymap_config.swap_lalt_lgui; | ||
| 138 | #ifdef AUDIO_ENABLE | ||
| 139 | if (keymap_config.swap_ralt_rgui) { | ||
| 140 | PLAY_SONG(ag_swap_song); | ||
| 141 | } else { | ||
| 142 | PLAY_SONG(ag_norm_song); | ||
| 143 | } | ||
| 144 | #endif | ||
| 145 | break; | ||
| 146 | case MAGIC_TOGGLE_CTL_GUI: | ||
| 147 | keymap_config.swap_lctl_lgui = !keymap_config.swap_lctl_lgui; | ||
| 148 | keymap_config.swap_rctl_rgui = keymap_config.swap_lctl_lgui; | ||
| 149 | #ifdef AUDIO_ENABLE | ||
| 150 | if (keymap_config.swap_rctl_rgui) { | ||
| 151 | PLAY_SONG(cg_swap_song); | ||
| 152 | } else { | ||
| 153 | PLAY_SONG(cg_norm_song); | ||
| 154 | } | ||
| 155 | #endif | ||
| 156 | break; | ||
| 157 | case MAGIC_TOGGLE_NKRO: | ||
| 158 | clear_keyboard(); // clear first buffer to prevent stuck keys | ||
| 159 | keymap_config.nkro = !keymap_config.nkro; | ||
| 160 | break; | ||
| 161 | case MAGIC_EE_HANDS_LEFT: | ||
| 162 | eeconfig_update_handedness(true); | ||
| 163 | break; | ||
| 164 | case MAGIC_EE_HANDS_RIGHT: | ||
| 165 | eeconfig_update_handedness(false); | ||
| 166 | break; | ||
| 167 | } | ||
| 168 | |||
| 169 | eeconfig_update_keymap(keymap_config.raw); | ||
| 170 | clear_keyboard(); // clear to prevent stuck keys | ||
| 171 | |||
| 172 | return false; | ||
| 173 | } | ||
| 174 | } | ||
| 175 | |||
| 176 | // Not a magic keycode so continue processing | ||
| 177 | return true; | ||
| 178 | } | ||
diff --git a/quantum/process_keycode/process_magic.h b/quantum/process_keycode/process_magic.h new file mode 100644 index 000000000..1eb39f145 --- /dev/null +++ b/quantum/process_keycode/process_magic.h | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | /* Copyright 2019 | ||
| 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 | #pragma once | ||
| 17 | |||
| 18 | #include "quantum.h" | ||
| 19 | |||
| 20 | bool process_magic(uint16_t keycode, keyrecord_t *record); | ||
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h index 8f3f3ff3c..09ceef74d 100644 --- a/quantum/process_keycode/process_tap_dance.h +++ b/quantum/process_keycode/process_tap_dance.h | |||
| @@ -63,10 +63,10 @@ typedef struct { | |||
| 63 | { .fn = {qk_tap_dance_pair_on_each_tap, qk_tap_dance_pair_finished, qk_tap_dance_pair_reset}, .user_data = (void *)&((qk_tap_dance_pair_t){kc1, kc2}), } | 63 | { .fn = {qk_tap_dance_pair_on_each_tap, qk_tap_dance_pair_finished, qk_tap_dance_pair_reset}, .user_data = (void *)&((qk_tap_dance_pair_t){kc1, kc2}), } |
| 64 | 64 | ||
| 65 | # define ACTION_TAP_DANCE_DUAL_ROLE(kc, layer) \ | 65 | # define ACTION_TAP_DANCE_DUAL_ROLE(kc, layer) \ |
| 66 | { .fn = { qk_tap_dance_dual_role_on_each_tap, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset }, .user_data = (void *)&((qk_tap_dance_dual_role_t) { kc, layer, layer_move }), } | 66 | { .fn = {qk_tap_dance_dual_role_on_each_tap, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset}, .user_data = (void *)&((qk_tap_dance_dual_role_t){kc, layer, layer_move}), } |
| 67 | 67 | ||
| 68 | # define ACTION_TAP_DANCE_LAYER_TOGGLE(kc, layer) \ | 68 | # define ACTION_TAP_DANCE_LAYER_TOGGLE(kc, layer) \ |
| 69 | { .fn = { NULL, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset }, .user_data = (void *)&((qk_tap_dance_dual_role_t) { kc, layer, layer_invert }), } | 69 | { .fn = {NULL, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset}, .user_data = (void *)&((qk_tap_dance_dual_role_t){kc, layer, layer_invert}), } |
| 70 | 70 | ||
| 71 | # define ACTION_TAP_DANCE_LAYER_MOVE(kc, layer) ACTION_TAP_DANCE_DUAL_ROLE(kc, layer) | 71 | # define ACTION_TAP_DANCE_LAYER_MOVE(kc, layer) ACTION_TAP_DANCE_DUAL_ROLE(kc, layer) |
| 72 | 72 | ||
| @@ -79,8 +79,6 @@ typedef struct { | |||
| 79 | # define ACTION_TAP_DANCE_FN_ADVANCED_TIME(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset, tap_specific_tapping_term) \ | 79 | # define ACTION_TAP_DANCE_FN_ADVANCED_TIME(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset, tap_specific_tapping_term) \ |
| 80 | { .fn = {user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset}, .user_data = NULL, .custom_tapping_term = tap_specific_tapping_term, } | 80 | { .fn = {user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset}, .user_data = NULL, .custom_tapping_term = tap_specific_tapping_term, } |
| 81 | 81 | ||
| 82 | |||
| 83 | |||
| 84 | extern qk_tap_dance_action_t tap_dance_actions[]; | 82 | extern qk_tap_dance_action_t tap_dance_actions[]; |
| 85 | 83 | ||
| 86 | /* To be used internally */ | 84 | /* To be used internally */ |
diff --git a/quantum/process_keycode/process_terminal.c b/quantum/process_keycode/process_terminal.c index f48f3d702..7d1eefa9e 100644 --- a/quantum/process_keycode/process_terminal.c +++ b/quantum/process_keycode/process_terminal.c | |||
| @@ -61,7 +61,7 @@ void enable_terminal(void) { | |||
| 61 | memset(cmd_buffer, 0, CMD_BUFF_SIZE * 80); | 61 | memset(cmd_buffer, 0, CMD_BUFF_SIZE * 80); |
| 62 | for (int i = 0; i < 6; i++) strcpy(arguments[i], ""); | 62 | for (int i = 0; i < 6; i++) strcpy(arguments[i], ""); |
| 63 | // select all text to start over | 63 | // select all text to start over |
| 64 | // SEND_STRING(SS_LCTRL("a")); | 64 | // SEND_STRING(SS_LCTL("a")); |
| 65 | send_string(terminal_prompt); | 65 | send_string(terminal_prompt); |
| 66 | } | 66 | } |
| 67 | 67 | ||
