diff options
author | Drashna Jael're <drashna@live.com> | 2017-12-19 10:37:25 -0800 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2017-12-20 14:38:56 -0500 |
commit | 4f484bc1c990793f019deb54448ad534389cc938 (patch) | |
tree | 0509a2a43953c73803dfc4e9666df7703d119954 /quantum/process_keycode/process_auto_shift.c | |
parent | a1fa70f94ddddcd6b51914a89cee7218ae1281ce (diff) | |
download | qmk_firmware-4f484bc1c990793f019deb54448ad534389cc938.tar.gz qmk_firmware-4f484bc1c990793f019deb54448ad534389cc938.zip |
Add on/off/toggle keycodes for Auto Shift
Diffstat (limited to 'quantum/process_keycode/process_auto_shift.c')
-rw-r--r-- | quantum/process_keycode/process_auto_shift.c | 43 |
1 files changed, 33 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)| |