diff options
-rw-r--r-- | docs/feature_auto_shift.md | 3 | ||||
-rw-r--r-- | keyboards/ergodox_ez/keymaps/drashna/keymap.c | 2 | ||||
-rw-r--r-- | quantum/process_keycode/process_auto_shift.c | 43 | ||||
-rw-r--r-- | quantum/process_keycode/process_auto_shift.h | 5 | ||||
-rw-r--r-- | quantum/quantum_keycodes.h | 4 |
5 files changed, 44 insertions, 13 deletions
diff --git a/docs/feature_auto_shift.md b/docs/feature_auto_shift.md index 273045976..f6c248744 100644 --- a/docs/feature_auto_shift.md +++ b/docs/feature_auto_shift.md | |||
@@ -110,6 +110,9 @@ Map three keys temporarily in your keymap: | |||
110 | | KC_ASDN | Lower the Auto Shift timeout variable (down) | | 110 | | KC_ASDN | Lower the Auto Shift timeout variable (down) | |
111 | | KC_ASUP | Raise the Auto Shift timeout variable (up) | | 111 | | KC_ASUP | Raise the Auto Shift timeout variable (up) | |
112 | | KC_ASRP | Report your current Auto Shift timeout value | | 112 | | KC_ASRP | Report your current Auto Shift timeout value | |
113 | | KC_ASON | Turns on the Auto Shift Function | | ||
114 | | KC_ASOFF | Turns off the Auto Shift Function | | ||
115 | | KC_ASTG | Toggles the statn of the Auto Shift feature | | ||
113 | 116 | ||
114 | Compile and upload your new firmware. | 117 | Compile and upload your new firmware. |
115 | 118 | ||
diff --git a/keyboards/ergodox_ez/keymaps/drashna/keymap.c b/keyboards/ergodox_ez/keymaps/drashna/keymap.c index 81231242d..8743ae282 100644 --- a/keyboards/ergodox_ez/keymaps/drashna/keymap.c +++ b/keyboards/ergodox_ez/keymaps/drashna/keymap.c | |||
@@ -294,7 +294,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
294 | KC_I, KC_O, KC_NO, KC_NO, KC_NO, KC_NO, | 294 | KC_I, KC_O, KC_NO, KC_NO, KC_NO, KC_NO, |
295 | TG(_GAMEPAD), KC_N, KC_M, KC_NO, KC_NO, KC_NO, KC_NO, | 295 | TG(_GAMEPAD), KC_N, KC_M, KC_NO, KC_NO, KC_NO, KC_NO, |
296 | KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_NO, | 296 | KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_NO, |
297 | KC_ASTG, KC_NO, | 297 | KC_NO, KC_NO, |
298 | KC_NO, | 298 | KC_NO, |
299 | KC_PGDOWN, KC_DELETE, KC_ENTER | 299 | KC_PGDOWN, KC_DELETE, KC_ENTER |
300 | ), | 300 | ), |
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 |
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index b0e555f2e..65bf9e141 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
@@ -121,13 +121,13 @@ enum quantum_keycodes { | |||
121 | KC_LEAD, | 121 | KC_LEAD, |
122 | #endif | 122 | #endif |
123 | 123 | ||
124 | #ifdef AUTO_SHIFT_ENABLE | ||
125 | // Auto Shift setup | 124 | // Auto Shift setup |
126 | KC_ASUP, | 125 | KC_ASUP, |
127 | KC_ASDN, | 126 | KC_ASDN, |
128 | KC_ASRP, | 127 | KC_ASRP, |
129 | KC_ASTG, | 128 | KC_ASTG, |
130 | #endif // AUTO_SHIFT_ENABLE | 129 | KC_ASON, |
130 | KC_ASOFF, | ||
131 | 131 | ||
132 | // Audio on/off/toggle | 132 | // Audio on/off/toggle |
133 | AU_ON, | 133 | AU_ON, |