diff options
Diffstat (limited to 'quantum/process_keycode')
| -rw-r--r-- | quantum/process_keycode/process_auto_shift.c | 43 | ||||
| -rw-r--r-- | quantum/process_keycode/process_auto_shift.h | 5 |
2 files changed, 38 insertions, 10 deletions
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index e2e6b02e0..fcce91849 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c | |||
| @@ -34,8 +34,6 @@ uint16_t autoshift_time = 0; | |||
| 34 | uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT; | 34 | uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT; |
| 35 | uint16_t autoshift_lastkey = KC_NO; | 35 | uint16_t autoshift_lastkey = KC_NO; |
| 36 | 36 | ||
| 37 | bool autoshift_enabled = true; | ||
| 38 | |||
| 39 | void autoshift_timer_report(void) { | 37 | void autoshift_timer_report(void) { |
| 40 | char display[8]; | 38 | char display[8]; |
| 41 | 39 | ||
| @@ -69,6 +67,30 @@ void autoshift_flush(void) { | |||
| 69 | } | 67 | } |
| 70 | } | 68 | } |
| 71 | 69 | ||
| 70 | bool autoshift_enabled = true; | ||
| 71 | |||
| 72 | void autoshift_enable(void) { | ||
| 73 | autoshift_enabled = true; | ||
| 74 | } | ||
| 75 | void autoshift_disable(void) { | ||
| 76 | autoshift_enabled = false; | ||
| 77 | autoshift_flush(); | ||
| 78 | } | ||
| 79 | |||
| 80 | void autoshift_toggle(void) { | ||
| 81 | if (autoshift_enabled) { | ||
| 82 | autoshift_enabled = false; | ||
| 83 | autoshift_flush(); | ||
| 84 | } | ||
| 85 | else { | ||
| 86 | autoshift_enabled = true; | ||
| 87 | } | ||
| 88 | } | ||
| 89 | |||
| 90 | bool autoshift_state(void) { | ||
| 91 | return autoshift_enabled; | ||
| 92 | } | ||
| 93 | |||
| 72 | bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { | 94 | bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { |
| 73 | static uint8_t any_mod_pressed; | 95 | static uint8_t any_mod_pressed; |
| 74 | 96 | ||
| @@ -87,13 +109,14 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { | |||
| 87 | return false; | 109 | return false; |
| 88 | 110 | ||
| 89 | case KC_ASTG: | 111 | case KC_ASTG: |
| 90 | if (autoshift_enabled) { | 112 | autoshift_toggle(); |
| 91 | autoshift_enabled = false; | 113 | return false; |
| 92 | autoshift_flush(); | 114 | case KC_ASON: |
| 93 | } | 115 | autoshift_enable(); |
| 94 | else { | 116 | return false; |
| 95 | autoshift_enabled = true; | 117 | case KC_ASOFF: |
| 96 | } | 118 | autoshift_disable(); |
| 119 | return false; | ||
| 97 | 120 | ||
| 98 | #ifndef NO_AUTO_SHIFT_ALPHA | 121 | #ifndef NO_AUTO_SHIFT_ALPHA |
| 99 | case KC_A: | 122 | case KC_A: |
| @@ -148,9 +171,9 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { | |||
| 148 | case KC_DOT: | 171 | case KC_DOT: |
| 149 | case KC_SLSH: | 172 | case KC_SLSH: |
| 150 | #endif | 173 | #endif |
| 151 | if (!autoshift_enabled) return true; | ||
| 152 | 174 | ||
| 153 | autoshift_flush(); | 175 | autoshift_flush(); |
| 176 | if (!autoshift_enabled) return true; | ||
| 154 | 177 | ||
| 155 | any_mod_pressed = get_mods() & ( | 178 | any_mod_pressed = get_mods() & ( |
| 156 | MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI)| | 179 | MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI)| |
diff --git a/quantum/process_keycode/process_auto_shift.h b/quantum/process_keycode/process_auto_shift.h index a0361346b..a4abf0414 100644 --- a/quantum/process_keycode/process_auto_shift.h +++ b/quantum/process_keycode/process_auto_shift.h | |||
| @@ -25,4 +25,9 @@ | |||
| 25 | 25 | ||
| 26 | bool process_auto_shift(uint16_t keycode, keyrecord_t *record); | 26 | bool process_auto_shift(uint16_t keycode, keyrecord_t *record); |
| 27 | 27 | ||
| 28 | void autoshift_enable(void); | ||
| 29 | void autoshift_disable(void); | ||
| 30 | void autoshift_toggle(void); | ||
| 31 | bool autoshift_state(void); | ||
| 32 | |||
| 28 | #endif | 33 | #endif |
