aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2021-04-19 20:34:14 -0700
committerGitHub <noreply@github.com>2021-04-19 20:34:14 -0700
commitc02137a0d245a7be8ca44cf46f05a632cc8fc702 (patch)
tree6576acdd6f248631b0dd9f3f0c313fcd41f6be16
parent49efd6abb0cf4c35a0d8f7ce2d9d112fe83d35e2 (diff)
downloadqmk_firmware-c02137a0d245a7be8ca44cf46f05a632cc8fc702.tar.gz
qmk_firmware-c02137a0d245a7be8ca44cf46f05a632cc8fc702.zip
Add Per Key functionality for AutoShift (#11536)
Co-authored-by: Ryan <fauxpark@gmail.com>
-rw-r--r--docs/feature_auto_shift.md27
-rw-r--r--quantum/process_keycode/process_auto_shift.c20
-rw-r--r--quantum/process_keycode/process_auto_shift.h1
3 files changed, 41 insertions, 7 deletions
diff --git a/docs/feature_auto_shift.md b/docs/feature_auto_shift.md
index 8e04d9dd3..ec7eeaaa0 100644
--- a/docs/feature_auto_shift.md
+++ b/docs/feature_auto_shift.md
@@ -109,6 +109,33 @@ Do not Auto Shift numeric keys, zero through nine.
109 109
110Do not Auto Shift alpha characters, which include A through Z. 110Do not Auto Shift alpha characters, which include A through Z.
111 111
112### Auto Shift Per Key
113
114This is a function that allows you to determine which keys shold be autoshifted, much like the tap-hold keys.
115
116The default function looks like this:
117
118```c
119bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
120 switch (keycode) {
121# ifndef NO_AUTO_SHIFT_ALPHA
122 case KC_A ... KC_Z:
123# endif
124# ifndef NO_AUTO_SHIFT_NUMERIC
125 case KC_1 ... KC_0:
126# endif
127# ifndef NO_AUTO_SHIFT_SPECIAL
128 case KC_TAB:
129 case KC_MINUS ... KC_SLASH:
130 case KC_NONUS_BSLASH:
131# endif
132 return true;
133 }
134 return false;
135}
136```
137This functionality is enabled by default, and does not need a define.
138
112### AUTO_SHIFT_REPEAT (simple define) 139### AUTO_SHIFT_REPEAT (simple define)
113 140
114Enables keyrepeat. 141Enables keyrepeat.
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c
index bf359e994..51b0efdb4 100644
--- a/quantum/process_keycode/process_auto_shift.c
+++ b/quantum/process_keycode/process_auto_shift.c
@@ -216,7 +216,18 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
216# endif 216# endif
217 } 217 }
218 } 218 }
219 if (get_auto_shifted_key(keycode, record)) {
220 if (record->event.pressed) {
221 return autoshift_press(keycode, now, record);
222 } else {
223 autoshift_end(keycode, now, false);
224 return false;
225 }
226 }
227 return true;
228}
219 229
230__attribute__((weak)) bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
220 switch (keycode) { 231 switch (keycode) {
221# ifndef NO_AUTO_SHIFT_ALPHA 232# ifndef NO_AUTO_SHIFT_ALPHA
222 case KC_A ... KC_Z: 233 case KC_A ... KC_Z:
@@ -229,14 +240,9 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
229 case KC_MINUS ... KC_SLASH: 240 case KC_MINUS ... KC_SLASH:
230 case KC_NONUS_BSLASH: 241 case KC_NONUS_BSLASH:
231# endif 242# endif
232 if (record->event.pressed) { 243 return true;
233 return autoshift_press(keycode, now, record);
234 } else {
235 autoshift_end(keycode, now, false);
236 return false;
237 }
238 } 244 }
239 return true; 245 return false;
240} 246}
241 247
242#endif 248#endif
diff --git a/quantum/process_keycode/process_auto_shift.h b/quantum/process_keycode/process_auto_shift.h
index 5b2718f11..00a9ab036 100644
--- a/quantum/process_keycode/process_auto_shift.h
+++ b/quantum/process_keycode/process_auto_shift.h
@@ -31,3 +31,4 @@ bool get_autoshift_state(void);
31uint16_t get_autoshift_timeout(void); 31uint16_t get_autoshift_timeout(void);
32void set_autoshift_timeout(uint16_t timeout); 32void set_autoshift_timeout(uint16_t timeout);
33void autoshift_matrix_scan(void); 33void autoshift_matrix_scan(void);
34bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record);