diff options
| author | Pablo MartÃnez <58857054+elpekenin@users.noreply.github.com> | 2023-06-04 03:11:54 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-04 02:11:54 +0100 |
| commit | edaf6654143fdd2dffaaa9c3ba8db1c9b282b5d0 (patch) | |
| tree | 7175ab0777415094c51c11c8fc0c0b4d403eea3b /quantum | |
| parent | 220dad26d053ef6ecf69653e0a5eb123115a778f (diff) | |
[Enhancement] Decouple autocorrect logic (#21116)
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/process_keycode/process_autocorrect.c | 19 | ||||
| -rw-r--r-- | quantum/process_keycode/process_autocorrect.h | 1 |
2 files changed, 19 insertions, 1 deletions
diff --git a/quantum/process_keycode/process_autocorrect.c b/quantum/process_keycode/process_autocorrect.c index 1376788266..7c9cb814e5 100644 --- a/quantum/process_keycode/process_autocorrect.c +++ b/quantum/process_keycode/process_autocorrect.c | |||
| @@ -57,7 +57,7 @@ void autocorrect_toggle(void) { | |||
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | /** | 59 | /** |
| 60 | * @brief handler for determining if autocorrect should process keypress | 60 | * @brief handler for user to override whether autocorrect should process this keypress |
| 61 | * | 61 | * |
| 62 | * @param keycode Keycode registered by matrix press, per keymap | 62 | * @param keycode Keycode registered by matrix press, per keymap |
| 63 | * @param record keyrecord_t structure | 63 | * @param record keyrecord_t structure |
| @@ -67,6 +67,23 @@ void autocorrect_toggle(void) { | |||
| 67 | * @return false Stop processing and escape from autocorrect. | 67 | * @return false Stop processing and escape from autocorrect. |
| 68 | */ | 68 | */ |
| 69 | __attribute__((weak)) bool process_autocorrect_user(uint16_t *keycode, keyrecord_t *record, uint8_t *typo_buffer_size, uint8_t *mods) { | 69 | __attribute__((weak)) bool process_autocorrect_user(uint16_t *keycode, keyrecord_t *record, uint8_t *typo_buffer_size, uint8_t *mods) { |
| 70 | return process_autocorrect_default_handler(keycode, record, typo_buffer_size, mods); | ||
| 71 | } | ||
| 72 | |||
| 73 | /** | ||
| 74 | * @brief fallback handler for determining if autocorrect should process this keypress | ||
| 75 | * can be used by user callback to get the basic keycode being "wrapped" | ||
| 76 | * | ||
| 77 | * NOTE: These values may have been edited by user callback before getting here | ||
| 78 | * | ||
| 79 | * @param keycode Keycode registered by matrix press, per keymap | ||
| 80 | * @param record keyrecord_t structure | ||
| 81 | * @param typo_buffer_size passed along to allow resetting of autocorrect buffer | ||
| 82 | * @param mods allow processing of mod status | ||
| 83 | * @return true Allow autocorection | ||
| 84 | * @return false Stop processing and escape from autocorrect. | ||
| 85 | */ | ||
| 86 | bool process_autocorrect_default_handler(uint16_t *keycode, keyrecord_t *record, uint8_t *typo_buffer_size, uint8_t *mods) { | ||
| 70 | // See quantum_keycodes.h for reference on these matched ranges. | 87 | // See quantum_keycodes.h for reference on these matched ranges. |
| 71 | switch (*keycode) { | 88 | switch (*keycode) { |
| 72 | // Exclude these keycodes from processing. | 89 | // Exclude these keycodes from processing. |
diff --git a/quantum/process_keycode/process_autocorrect.h b/quantum/process_keycode/process_autocorrect.h index c7596107e5..00dacbf958 100644 --- a/quantum/process_keycode/process_autocorrect.h +++ b/quantum/process_keycode/process_autocorrect.h | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | 9 | ||
| 10 | bool process_autocorrect(uint16_t keycode, keyrecord_t *record); | 10 | bool process_autocorrect(uint16_t keycode, keyrecord_t *record); |
| 11 | bool process_autocorrect_user(uint16_t *keycode, keyrecord_t *record, uint8_t *typo_buffer_size, uint8_t *mods); | 11 | bool process_autocorrect_user(uint16_t *keycode, keyrecord_t *record, uint8_t *typo_buffer_size, uint8_t *mods); |
| 12 | bool process_autocorrect_default_handler(uint16_t *keycode, keyrecord_t *record, uint8_t *typo_buffer_size, uint8_t *mods); | ||
| 12 | bool apply_autocorrect(uint8_t backspaces, const char *str); | 13 | bool apply_autocorrect(uint8_t backspaces, const char *str); |
| 13 | 14 | ||
| 14 | bool autocorrect_is_enabled(void); | 15 | bool autocorrect_is_enabled(void); |
