diff options
Diffstat (limited to 'docs/feature_auto_shift.md')
-rw-r--r-- | docs/feature_auto_shift.md | 176 |
1 files changed, 162 insertions, 14 deletions
diff --git a/docs/feature_auto_shift.md b/docs/feature_auto_shift.md index a54cd79e4..99b0ca3c8 100644 --- a/docs/feature_auto_shift.md +++ b/docs/feature_auto_shift.md | |||
@@ -26,20 +26,26 @@ down will repeat the shifted key, though this can be disabled with | |||
26 | once then immediately (within `TAPPING_TERM`) hold it down again (this works | 26 | once then immediately (within `TAPPING_TERM`) hold it down again (this works |
27 | with the shifted value as well if auto-repeat is disabled). | 27 | with the shifted value as well if auto-repeat is disabled). |
28 | 28 | ||
29 | There are also the `get_auto_shift_repeat` and `get_auto_shift_no_auto_repeat` | ||
30 | functions for more granular control. Neither will have an effect unless | ||
31 | `AUTO_SHIFT_REPEAT_PER_KEY` or `AUTO_SHIFT_NO_AUTO_REPEAT_PER_KEY` respectively | ||
32 | are defined. | ||
33 | |||
29 | ## Are There Limitations to Auto Shift? | 34 | ## Are There Limitations to Auto Shift? |
30 | 35 | ||
31 | Yes, unfortunately. | 36 | Yes, unfortunately. |
32 | 37 | ||
33 | You will have characters that are shifted when you did not intend on shifting, and | 38 | 1. You will have characters that are shifted when you did not intend on shifting, and |
34 | other characters you wanted shifted, but were not. This simply comes down to | 39 | other characters you wanted shifted, but were not. This simply comes down to |
35 | practice. As we get in a hurry, we think we have hit the key long enough for a | 40 | practice. As we get in a hurry, we think we have hit the key long enough for a |
36 | shifted version, but we did not. On the other hand, we may think we are tapping | 41 | shifted version, but we did not. On the other hand, we may think we are tapping |
37 | the keys, but really we have held it for a little longer than anticipated. | 42 | the keys, but really we have held it for a little longer than anticipated. |
38 | 43 | 2. Additionally, with keyrepeat the desired shift state can get mixed up. It will | |
39 | Additionally, with keyrepeat the desired shift state can get mixed up. It will | 44 | always 'belong' to the last key pressed. For example, keyrepeating a capital |
40 | always 'belong' to the last key pressed. For example, keyrepeating a capital | 45 | and then tapping something lowercase (whether or not it's an Auto Shift key) |
41 | and then tapping something lowercase (whether or not it's an Auto Shift key) | 46 | will result in the capital's *key* still being held, but shift not. |
42 | will result in the capital's *key* still being held, but shift not. | 47 | 3. Auto Shift does not apply to Tap Hold keys. For automatic shifting of Tap Hold |
48 | keys see [Retro Shift](#retro-shift). | ||
43 | 49 | ||
44 | ## How Do I Enable Auto Shift? | 50 | ## How Do I Enable Auto Shift? |
45 | 51 | ||
@@ -96,6 +102,34 @@ quicker than normal and you will be set. | |||
96 | 102 | ||
97 | ?> Auto Shift has three special keys that can help you get this value right very quick. See "Auto Shift Setup" for more details! | 103 | ?> Auto Shift has three special keys that can help you get this value right very quick. See "Auto Shift Setup" for more details! |
98 | 104 | ||
105 | For more granular control of this feature, you can add the following to your `config.h`: | ||
106 | |||
107 | ```c | ||
108 | #define AUTO_SHIFT_TIMEOUT_PER_KEY | ||
109 | ``` | ||
110 | |||
111 | You can then add the following function to your keymap: | ||
112 | |||
113 | ```c | ||
114 | uint16_t get_autoshift_timeout(uint16_t keycode, keyrecord_t *record) { | ||
115 | switch(keycode) { | ||
116 | case AUTO_SHIFT_NUMERIC: | ||
117 | return 2 * get_generic_autoshift_timeout(); | ||
118 | case AUTO_SHIFT_SPECIAL: | ||
119 | return get_generic_autoshift_timeout() + 50; | ||
120 | case AUTO_SHIFT_ALPHA: | ||
121 | default: | ||
122 | return get_generic_autoshift_timeout(); | ||
123 | } | ||
124 | } | ||
125 | ``` | ||
126 | |||
127 | Note that you cannot override individual keys that are in one of those groups | ||
128 | if you are using them; trying to add a case for `KC_A` in the above example will | ||
129 | not compile as `AUTO_SHIFT_ALPHA` is there. A possible solution is a second switch | ||
130 | above to handle individual keys with no default case and only referencing the | ||
131 | groups in the below fallback switch. | ||
132 | |||
99 | ### NO_AUTO_SHIFT_SPECIAL (simple define) | 133 | ### NO_AUTO_SHIFT_SPECIAL (simple define) |
100 | 134 | ||
101 | Do not Auto Shift special keys, which include -\_, =+, [{, ]}, ;:, '", ,<, .>, | 135 | Do not Auto Shift special keys, which include -\_, =+, [{, ]}, ;:, '", ,<, .>, |
@@ -109,11 +143,24 @@ Do not Auto Shift numeric keys, zero through nine. | |||
109 | 143 | ||
110 | Do not Auto Shift alpha characters, which include A through Z. | 144 | Do not Auto Shift alpha characters, which include A through Z. |
111 | 145 | ||
112 | ### Auto Shift Per Key | 146 | ### Auto Shift Per Key |
113 | 147 | ||
114 | This is a function that allows you to determine which keys shold be autoshifted, much like the tap-hold keys. | 148 | There are functions that allows you to determine which keys shold be autoshifted, much like the tap-hold keys. |
115 | 149 | ||
116 | The default function looks like this: | 150 | The first of these, used to simply add a key to Auto Shift, is `get_custom_auto_shifted_key`: |
151 | |||
152 | ```c | ||
153 | bool get_custom_auto_shifted_key(uint16_t keycode, keyrecord_t *record) { | ||
154 | switch(keycode) { | ||
155 | case KC_DOT: | ||
156 | return true; | ||
157 | default: | ||
158 | return false; | ||
159 | } | ||
160 | } | ||
161 | ``` | ||
162 | |||
163 | For more granular control, there is `get_auto_shifted_key`. The default function looks like this: | ||
117 | 164 | ||
118 | ```c | 165 | ```c |
119 | bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) { | 166 | bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) { |
@@ -131,9 +178,10 @@ bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) { | |||
131 | # endif | 178 | # endif |
132 | return true; | 179 | return true; |
133 | } | 180 | } |
134 | return false; | 181 | return get_custom_auto_shifted_key(keycode, record); |
135 | } | 182 | } |
136 | ``` | 183 | ``` |
184 | |||
137 | This functionality is enabled by default, and does not need a define. | 185 | This functionality is enabled by default, and does not need a define. |
138 | 186 | ||
139 | ### AUTO_SHIFT_REPEAT (simple define) | 187 | ### AUTO_SHIFT_REPEAT (simple define) |
@@ -144,6 +192,106 @@ Enables keyrepeat. | |||
144 | 192 | ||
145 | Disables automatically keyrepeating when `AUTO_SHIFT_TIMEOUT` is exceeded. | 193 | Disables automatically keyrepeating when `AUTO_SHIFT_TIMEOUT` is exceeded. |
146 | 194 | ||
195 | ## Custom Shifted Values | ||
196 | |||
197 | Especially on small keyboards, the default shifted value for many keys is not | ||
198 | optimal. To provide more customizability, there are two user-definable | ||
199 | functions, `autoshift_press/release_user`. These register or unregister the | ||
200 | correct value for the passed key. Below is an example adding period to Auto | ||
201 | Shift and making its shifted value exclamation point. Make sure to use weak | ||
202 | mods - setting real would make any keys following it use their shifted values | ||
203 | as if you were holding the key. Clearing of modifiers is handled by Auto Shift, | ||
204 | and the OS-sent shift value if keyrepeating multiple keys is always that of | ||
205 | the last key pressed (whether or not it's an Auto Shift key). | ||
206 | |||
207 | You can also have non-shifted keys for the shifted values (or even no shifted | ||
208 | value), just don't set a shift modifier! | ||
209 | |||
210 | ```c | ||
211 | bool get_custom_auto_shifted_key(uint16_t keycode, keyrecord_t *record) { | ||
212 | switch(keycode) { | ||
213 | case KC_DOT: | ||
214 | return true; | ||
215 | default: | ||
216 | return false; | ||
217 | } | ||
218 | } | ||
219 | |||
220 | void autoshift_press_user(uint16_t keycode, bool shifted, keyrecord_t *record) { | ||
221 | switch(keycode) { | ||
222 | case KC_DOT: | ||
223 | register_code16((!shifted) ? KC_DOT : KC_EXLM); | ||
224 | break; | ||
225 | default: | ||
226 | if (shifted) { | ||
227 | add_weak_mods(MOD_BIT(KC_LSFT)); | ||
228 | } | ||
229 | // & 0xFF gets the Tap key for Tap Holds, required when using Retro Shift | ||
230 | register_code16((IS_RETRO(keycode)) ? keycode & 0xFF : keycode); | ||
231 | } | ||
232 | } | ||
233 | |||
234 | void autoshift_release_user(uint16_t keycode, bool shifted, keyrecord_t *record) { | ||
235 | switch(keycode) { | ||
236 | case KC_DOT: | ||
237 | unregister_code16((!shifted) ? KC_DOT : KC_EXLM); | ||
238 | break; | ||
239 | default: | ||
240 | // & 0xFF gets the Tap key for Tap Holds, required when using Retro Shift | ||
241 | // The IS_RETRO check isn't really necessary here, always using | ||
242 | // keycode & 0xFF would be fine. | ||
243 | unregister_code16((IS_RETRO(keycode)) ? keycode & 0xFF : keycode); | ||
244 | } | ||
245 | } | ||
246 | ``` | ||
247 | |||
248 | ## Retro Shift | ||
249 | |||
250 | Holding and releasing a Tap Hold key without pressing another key will ordinarily | ||
251 | result in only the hold. With `retro shift` enabled this action will instead | ||
252 | produce a shifted version of the tap keycode on release. | ||
253 | |||
254 | It does not require [Retro Tapping](tap_hold.md#retro-tapping) to be enabled, and | ||
255 | if both are enabled the state of `retro tapping` will only apply if the tap keycode | ||
256 | is not matched by Auto Shift. `RETRO_TAPPING_PER_KEY` and its corresponding | ||
257 | function, however, are checked before `retro shift` is applied. | ||
258 | |||
259 | To enable `retro shift`, add the following to your `config.h`: | ||
260 | |||
261 | ```c | ||
262 | #define RETRO_SHIFT | ||
263 | ``` | ||
264 | |||
265 | If `RETRO_SHIFT` is defined to a value, hold times greater than that value will | ||
266 | not produce a tap on release for Mod Taps, and instead triggers the hold action. | ||
267 | This enables modifiers to be held for combining with mouse clicks without | ||
268 | generating taps on release. For example: | ||
269 | |||
270 | ```c | ||
271 | #define RETRO_SHIFT 500 | ||
272 | ``` | ||
273 | |||
274 | This value (if set) must be greater than one's `TAPPING_TERM`, as the key press | ||
275 | must be designated as a 'hold' by `process_tapping` before we send the modifier. | ||
276 | There is no such limitation in regards to `AUTO_SHIFT_TIMEOUT` for normal keys. | ||
277 | |||
278 | ### Retro Shift and Tap Hold Configurations | ||
279 | |||
280 | Tap Hold Configurations work a little differently when using Retro Shift. | ||
281 | Referencing `TAPPING_TERM` makes little sense, as holding longer would result in | ||
282 | shifting one of the keys. | ||
283 | |||
284 | `IGNORE_MOD_TAP_INTERRUPT` changes *only* rolling from a mod tap (releasing it | ||
285 | first), sending both keys instead of the modifier on the second. Its effects on | ||
286 | nested presses are ignored. | ||
287 | |||
288 | As nested taps were changed to act as though `PERMISSIVE_HOLD` is set unless only | ||
289 | `IGNORE_MOD_TAP_INTERRUPT` is (outside of Retro Shift), and Retro Shift ignores | ||
290 | `IGNORE_MOD_TAP_INTERRUPT`, `PERMISSIVE_HOLD` has no effect on Mod Taps. | ||
291 | |||
292 | Nested taps will *always* act as though the `TAPPING_TERM` was exceeded for both | ||
293 | Mod and Layer Tap keys. | ||
294 | |||
147 | ## Using Auto Shift Setup | 295 | ## Using Auto Shift Setup |
148 | 296 | ||
149 | This will enable you to define three keys temporarily to increase, decrease and report your `AUTO_SHIFT_TIMEOUT`. | 297 | This will enable you to define three keys temporarily to increase, decrease and report your `AUTO_SHIFT_TIMEOUT`. |