diff options
Diffstat (limited to 'quantum/process_keycode/process_auto_shift.c')
| -rw-r--r-- | quantum/process_keycode/process_auto_shift.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 51b0efdb4..02af5174f 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c | |||
| @@ -21,6 +21,12 @@ | |||
| 21 | 21 | ||
| 22 | # include "process_auto_shift.h" | 22 | # include "process_auto_shift.h" |
| 23 | 23 | ||
| 24 | #ifndef AUTO_SHIFT_DISABLED_AT_STARTUP | ||
| 25 | # define AUTO_SHIFT_STARTUP_STATE true /* enabled */ | ||
| 26 | #else | ||
| 27 | # define AUTO_SHIFT_STARTUP_STATE false /* disabled */ | ||
| 28 | #endif | ||
| 29 | |||
| 24 | static uint16_t autoshift_time = 0; | 30 | static uint16_t autoshift_time = 0; |
| 25 | static uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT; | 31 | static uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT; |
| 26 | static uint16_t autoshift_lastkey = KC_NO; | 32 | static uint16_t autoshift_lastkey = KC_NO; |
| @@ -34,7 +40,7 @@ static struct { | |||
| 34 | bool in_progress : 1; | 40 | bool in_progress : 1; |
| 35 | // Whether the auto-shifted keypress has been registered. | 41 | // Whether the auto-shifted keypress has been registered. |
| 36 | bool holding_shift : 1; | 42 | bool holding_shift : 1; |
| 37 | } autoshift_flags = {true, false, false, false}; | 43 | } autoshift_flags = {AUTO_SHIFT_STARTUP_STATE, false, false, false}; |
| 38 | 44 | ||
| 39 | /** \brief Record the press of an autoshiftable key | 45 | /** \brief Record the press of an autoshiftable key |
| 40 | * | 46 | * |
| @@ -61,7 +67,7 @@ static bool autoshift_press(uint16_t keycode, uint16_t now, keyrecord_t *record) | |||
| 61 | register_code(autoshift_lastkey); | 67 | register_code(autoshift_lastkey); |
| 62 | } else { | 68 | } else { |
| 63 | // Simulate pressing the shift key. | 69 | // Simulate pressing the shift key. |
| 64 | add_weak_mods(MOD_BIT(KC_LSFT)); | 70 | add_weak_mods(MOD_BIT(KC_LEFT_SHIFT)); |
| 65 | register_code(autoshift_lastkey); | 71 | register_code(autoshift_lastkey); |
| 66 | } | 72 | } |
| 67 | return false; | 73 | return false; |
| @@ -102,7 +108,7 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { | |||
| 102 | autoshift_flags.lastshifted = false; | 108 | autoshift_flags.lastshifted = false; |
| 103 | } else { | 109 | } else { |
| 104 | // Simulate pressing the shift key. | 110 | // Simulate pressing the shift key. |
| 105 | add_weak_mods(MOD_BIT(KC_LSFT)); | 111 | add_weak_mods(MOD_BIT(KC_LEFT_SHIFT)); |
| 106 | register_code(autoshift_lastkey); | 112 | register_code(autoshift_lastkey); |
| 107 | autoshift_flags.lastshifted = true; | 113 | autoshift_flags.lastshifted = true; |
| 108 | # if defined(AUTO_SHIFT_REPEAT) && !defined(AUTO_SHIFT_NO_AUTO_REPEAT) | 114 | # if defined(AUTO_SHIFT_REPEAT) && !defined(AUTO_SHIFT_NO_AUTO_REPEAT) |
| @@ -117,7 +123,7 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { | |||
| 117 | wait_ms(TAP_CODE_DELAY); | 123 | wait_ms(TAP_CODE_DELAY); |
| 118 | # endif | 124 | # endif |
| 119 | unregister_code(autoshift_lastkey); | 125 | unregister_code(autoshift_lastkey); |
| 120 | del_weak_mods(MOD_BIT(KC_LSFT)); | 126 | del_weak_mods(MOD_BIT(KC_LEFT_SHIFT)); |
| 121 | } else { | 127 | } else { |
| 122 | // Release after keyrepeat. | 128 | // Release after keyrepeat. |
| 123 | unregister_code(keycode); | 129 | unregister_code(keycode); |
| @@ -125,7 +131,7 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { | |||
| 125 | // This will only fire when the key was the last auto-shiftable | 131 | // This will only fire when the key was the last auto-shiftable |
| 126 | // pressed. That prevents aaaaBBBB then releasing a from unshifting | 132 | // pressed. That prevents aaaaBBBB then releasing a from unshifting |
| 127 | // later Bs (if B wasn't auto-shiftable). | 133 | // later Bs (if B wasn't auto-shiftable). |
| 128 | del_weak_mods(MOD_BIT(KC_LSFT)); | 134 | del_weak_mods(MOD_BIT(KC_LEFT_SHIFT)); |
| 129 | } | 135 | } |
| 130 | } | 136 | } |
| 131 | send_keyboard_report(); // del_weak_mods doesn't send one. | 137 | send_keyboard_report(); // del_weak_mods doesn't send one. |
| @@ -151,14 +157,14 @@ void autoshift_matrix_scan(void) { | |||
| 151 | 157 | ||
| 152 | void autoshift_toggle(void) { | 158 | void autoshift_toggle(void) { |
| 153 | autoshift_flags.enabled = !autoshift_flags.enabled; | 159 | autoshift_flags.enabled = !autoshift_flags.enabled; |
| 154 | del_weak_mods(MOD_BIT(KC_LSFT)); | 160 | del_weak_mods(MOD_BIT(KC_LEFT_SHIFT)); |
| 155 | } | 161 | } |
| 156 | 162 | ||
| 157 | void autoshift_enable(void) { autoshift_flags.enabled = true; } | 163 | void autoshift_enable(void) { autoshift_flags.enabled = true; } |
| 158 | 164 | ||
| 159 | void autoshift_disable(void) { | 165 | void autoshift_disable(void) { |
| 160 | autoshift_flags.enabled = false; | 166 | autoshift_flags.enabled = false; |
| 161 | del_weak_mods(MOD_BIT(KC_LSFT)); | 167 | del_weak_mods(MOD_BIT(KC_LEFT_SHIFT)); |
| 162 | } | 168 | } |
| 163 | 169 | ||
| 164 | # ifndef AUTO_SHIFT_NO_SETUP | 170 | # ifndef AUTO_SHIFT_NO_SETUP |
| @@ -189,7 +195,7 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { | |||
| 189 | autoshift_end(KC_NO, now, false); | 195 | autoshift_end(KC_NO, now, false); |
| 190 | } | 196 | } |
| 191 | // For pressing another key while keyrepeating shifted autoshift. | 197 | // For pressing another key while keyrepeating shifted autoshift. |
| 192 | del_weak_mods(MOD_BIT(KC_LSFT)); | 198 | del_weak_mods(MOD_BIT(KC_LEFT_SHIFT)); |
| 193 | 199 | ||
| 194 | switch (keycode) { | 200 | switch (keycode) { |
| 195 | case KC_ASTG: | 201 | case KC_ASTG: |
| @@ -238,7 +244,7 @@ __attribute__((weak)) bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *r | |||
| 238 | # ifndef NO_AUTO_SHIFT_SPECIAL | 244 | # ifndef NO_AUTO_SHIFT_SPECIAL |
| 239 | case KC_TAB: | 245 | case KC_TAB: |
| 240 | case KC_MINUS ... KC_SLASH: | 246 | case KC_MINUS ... KC_SLASH: |
| 241 | case KC_NONUS_BSLASH: | 247 | case KC_NONUS_BACKSLASH: |
| 242 | # endif | 248 | # endif |
| 243 | return true; | 249 | return true; |
| 244 | } | 250 | } |
