summaryrefslogtreecommitdiffstats
path: root/users/drashna/keyrecords/autocorrection/autocorrection.c
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2021-12-29 20:17:34 -0800
committerGitHub <noreply@github.com>2021-12-29 20:17:34 -0800
commitc4551d7ef1ed2c1069f23cc8499b7c7fc30f3ecf (patch)
tree67dc381a45d59626132c4c59b71c4b36fa971f8b /users/drashna/keyrecords/autocorrection/autocorrection.c
parent1a8a842cfb3e87a82afb57ba29ca59c5fa6fe97b (diff)
[Keymap] Reorganization, cleanup and readmes for drashna code (#15617)
Diffstat (limited to 'users/drashna/keyrecords/autocorrection/autocorrection.c')
-rw-r--r--users/drashna/keyrecords/autocorrection/autocorrection.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/users/drashna/keyrecords/autocorrection/autocorrection.c b/users/drashna/keyrecords/autocorrection/autocorrection.c
index 7c8c28c674..e561224374 100644
--- a/users/drashna/keyrecords/autocorrection/autocorrection.c
+++ b/users/drashna/keyrecords/autocorrection/autocorrection.c
@@ -1,5 +1,5 @@
// Copyright 2021 Google LLC
-// Copyright 2022 @filterpaper
+// Copyright 2021 @filterpaper
// SPDX-License-Identifier: Apache-2.0
// Original source: https://getreuer.info/posts/keyboards/autocorrection
@@ -7,10 +7,15 @@
#include <string.h>
#if __has_include("autocorrection_data.h")
+# pragma GCC push_options
+# pragma GCC optimize("O0")
# include "autocorrection_data.h"
# if AUTOCORRECTION_MIN_LENGTH < 4
# error Minimum Length is too short and may cause overflows
# endif
+# if DICTIONARY_SIZE > SIZE_MAX
+# error Dictionary size excees maximum size permitted
+# endif
bool process_autocorrection(uint16_t keycode, keyrecord_t* record) {
static uint8_t typo_buffer[AUTOCORRECTION_MAX_LENGTH] = {KC_SPC};
@@ -55,11 +60,17 @@ bool process_autocorrection(uint16_t keycode, keyrecord_t* record) {
}
# endif
default:
+ // Disable autocorrection while a mod other than shift is active.
+ if (((get_mods() | get_oneshot_mods()) & ~MOD_MASK_SHIFT) != 0) {
+ typo_buffer_size = 0;
+ return true;
+ }
if (!record->event.pressed) {
return true;
}
}
+
// Subtract buffer for Backspace key, reset for other non-alpha.
if (!(KC_A <= keycode && keycode <= KC_Z)) {
if (keycode == KC_BSPC) {
@@ -137,6 +148,7 @@ bool process_autocorrection(uint16_t keycode, keyrecord_t* record) {
}
return true;
}
+# pragma GCC pop_options
#else
# pragma message "Warning!!! Autocorrect is not corretly setup!"
bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { return true; }