From 8a16968d71d1ee26a51592713157cce1407cf749 Mon Sep 17 00:00:00 2001 From: Matt Skalecki Date: Tue, 13 Feb 2024 15:27:48 -0500 Subject: [PATCH] Basic autocorrect work --- .../keymaps/ikcelaks/autocorrect_data.h | 41 +++++++++++ .../magic_sturdy/autocorrection_dict.txt | 17 +++++ .../keymaps/ikcelaks/magic_sturdy/general.c | 2 +- .../ikcelaks/magic_sturdy/magic_keys.c | 73 ++++++++++++++----- .../ikcelaks/magic_sturdy/practice.txt | 2 +- 5 files changed, 114 insertions(+), 21 deletions(-) create mode 100644 keyboards/moonlander/keymaps/ikcelaks/autocorrect_data.h create mode 100644 keyboards/moonlander/keymaps/ikcelaks/magic_sturdy/autocorrection_dict.txt diff --git a/keyboards/moonlander/keymaps/ikcelaks/autocorrect_data.h b/keyboards/moonlander/keymaps/ikcelaks/autocorrect_data.h new file mode 100644 index 00000000..f87a1756 --- /dev/null +++ b/keyboards/moonlander/keymaps/ikcelaks/autocorrect_data.h @@ -0,0 +1,41 @@ +// Copyright 2024 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +/******************************************************************************* + 88888888888 888 d8b .d888 d8b 888 d8b + 888 888 Y8P d88P" Y8P 888 Y8P + 888 888 888 888 + 888 88888b. 888 .d8888b 888888 888 888 .d88b. 888 .d8888b + 888 888 "88b 888 88K 888 888 888 d8P Y8b 888 88K + 888 888 888 888 "Y8888b. 888 888 888 88888888 888 "Y8888b. + 888 888 888 888 X88 888 888 888 Y8b. 888 X88 + 888 888 888 888 88888P' 888 888 888 "Y8888 888 88888P' + 888 888 + 888 888 + 888 888 + .d88b. .d88b. 88888b. .d88b. 888d888 8888b. 888888 .d88b. .d88888 + d88P"88b d8P Y8b 888 "88b d8P Y8b 888P" "88b 888 d8P Y8b d88" 888 + 888 888 88888888 888 888 88888888 888 .d888888 888 88888888 888 888 + Y88b 888 Y8b. 888 888 Y8b. 888 888 888 Y88b. Y8b. Y88b 888 + "Y88888 "Y8888 888 888 "Y8888 888 "Y888888 "Y888 "Y8888 "Y88888 + 888 + Y8b d88P + "Y88P" +*******************************************************************************/ + +#pragma once + +// Autocorrection dictionary with longest match semantics: +// Autocorrection dictionary (3 entries): +// aa -> ab +// baa -> bac +// caa -> cad + +#define AUTOCORRECT_MIN_LENGTH 2 // "aa" +#define AUTOCORRECT_MAX_LENGTH 3 // "baa" +#define DICTIONARY_SIZE 19 + +static const uint8_t autocorrect_data[DICTIONARY_SIZE] PROGMEM = { + 0x04, 0x04, 0x00, 0xC0, 0x62, 0x00, 0x45, 0x0D, 0x00, 0x06, 0x10, 0x00, 0x00, 0x80, 0x63, 0x00, + 0x80, 0x64, 0x00 +}; diff --git a/keyboards/moonlander/keymaps/ikcelaks/magic_sturdy/autocorrection_dict.txt b/keyboards/moonlander/keymaps/ikcelaks/magic_sturdy/autocorrection_dict.txt new file mode 100644 index 00000000..a48326a5 --- /dev/null +++ b/keyboards/moonlander/keymaps/ikcelaks/magic_sturdy/autocorrection_dict.txt @@ -0,0 +1,17 @@ +# Copyright 2021-2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +aa -> ab +baa -> bac +caa -> cad diff --git a/keyboards/moonlander/keymaps/ikcelaks/magic_sturdy/general.c b/keyboards/moonlander/keymaps/ikcelaks/magic_sturdy/general.c index ef68c69d..1f13d8ca 100644 --- a/keyboards/moonlander/keymaps/ikcelaks/magic_sturdy/general.c +++ b/keyboards/moonlander/keymaps/ikcelaks/magic_sturdy/general.c @@ -26,7 +26,7 @@ void refresh_token(void) { void record_send_string(const char *str) { for (int i = 0; str[i] != '\0'; i++) { - if (str[i] == 11) dequeue(); + if (str[i] == 8) dequeue(); // dequeue when sending backspace else if (65 <= str[i] && str[i] <= 90) enqueue(str[i] - 61); else if (97 <= str[i] && str[i] <= 122) enqueue(str[i] - 93); } diff --git a/keyboards/moonlander/keymaps/ikcelaks/magic_sturdy/magic_keys.c b/keyboards/moonlander/keymaps/ikcelaks/magic_sturdy/magic_keys.c index b8820ebf..eecf0453 100644 --- a/keyboards/moonlander/keymaps/ikcelaks/magic_sturdy/magic_keys.c +++ b/keyboards/moonlander/keymaps/ikcelaks/magic_sturdy/magic_keys.c @@ -3,6 +3,7 @@ #include "keycodes.h" #include "keymap_us.h" #include "magic_sturdy/__init__.h" +#include "magic_sturdy/general.h" void process_magic_key_1(void) { if (mag1_key_count >= 2) { @@ -49,8 +50,14 @@ void process_magic_key_1(void) { magic_case(KC_X, "ample"); ); + double_magic_switch(KC_T, + magic_case(KC_A, "ke"); + magic_case(KC_I, "me"); + ); + + double_magic_case(KC_M, KC_A, "ke"); + double_magic_case(KC_U, KC_S, "e"); - double_magic_case(KC_T, KC_I, "me"); double_magic_case(KC_I, KC_N, "form"); ); @@ -125,6 +132,8 @@ void process_magic_key_1(void) { double_magic_case(KC_B, KC_E, "en"); double_magic_case(KC_L, KC_I, "st"); double_magic_case(KC_V, KC_I, "sion"); + double_magic_case(KC_A, KC_B, "ility"); + double_magic_case(KC_I, KC_B, "ility"); } switch (queue(-1)) { @@ -173,6 +182,13 @@ void process_magic_key_1(void) { } void process_magic_key_2(void) { + switch (queue(-5)) { + quintuple_magic_switch(KC_SPC, + quadruple_magic_case(KC_M, KC_A, KC_K, KC_E, "\bing"); + quadruple_magic_case(KC_T, KC_A, KC_K, KC_E, "\bing"); + ); + } + switch (queue(-4)) { quadruple_magic_switch(KC_SPC, triple_magic_case(KC_A, KC_L, KC_R, "ight"); @@ -198,6 +214,7 @@ void process_magic_key_2(void) { ); triple_magic_case(KC_R, KC_S, KC_C, "hool"); + triple_magic_case(KC_I, KC_T, KC_Y, "\bies"); } switch (queue(-2)) { @@ -206,7 +223,7 @@ void process_magic_key_2(void) { magic_case(KC_S, "hould"); // KC_X, "er" - magic_case(KC_M, "ake"); + magic_case(KC_M, "ight"); magic_case(KC_T, "hrough"); // KC_K, "now" @@ -255,7 +272,7 @@ void process_magic_key_2(void) { magic_case(KC_K, "now"); magic_case(KC_I, "ng"); magic_case(KC_Y, "ou"); - magic_case(KC_Q, "ui"); + magic_case(KC_Q, "uick"); magic_case(KC_J, "oin"); magic_case(KC_W, "ould"); magic_case(KC_C, "k"); @@ -278,28 +295,46 @@ void process_magic_key_2(void) { void process_magic_key_3(void) { switch (queue(-1)) { - magic_case(KC_B, "ecome"); - magic_case(KC_F, "ollow"); - magic_case(KC_N, "eighbor"); - magic_case(KC_H, "owever"); - magic_case(KC_U, "pgrade"); - magic_case(KC_O, "ther"); - magic_case(KC_A, "fter"); - magic_case(KC_P, "ower"); - magic_case(KC_I, "'ll"); - magic_case(KC_K, "now"); + magic_case(KC_V, "isit"); + magic_case(KC_S, "mall"); + // KC_X + + magic_case(KC_M, "anage"); magic_case(KC_T, "hough"); - magic_case(KC_L, "ight"); - magic_case(KC_M, "ight"); - magic_case(KC_R, "ight"); + magic_case(KC_K, "new"); + + magic_case(KC_L, "ocation"); + magic_case(KC_R, "ecommend"); magic_case(KC_J, "udge"); + magic_case(KC_C, "onsider"); magic_case(KC_D, "evelop"); magic_case(KC_G, "overn"); + + magic_case(KC_P, "ower"); + // KC_Y magic_case(KC_W, "here"); - magic_case(KC_S, "hould"); - magic_case(KC_DOT, "org"); + magic_case(KC_Q, "mlativ"); + + magic_case(KC_B, "ecome"); + magic_case(KC_F, "ound"); + // KC_Z + + // KC_MAG1 + magic_case(KC_N, "eighbor"); + magic_case(KC_H, "appen"); + + magic_case(KC_U, "pgrade"); + magic_case(KC_E, "'ll"); + // KC_QUOT + + magic_case(KC_O, "ther"); + magic_case(KC_A, "fter"); + // KC_QUES + magic_case(KC_COMM, " however"); + magic_case(KC_I, "'ll"); + magic_case(KC_DOT, "org"); default: return; } } @@ -314,11 +349,11 @@ void process_magic_key_4(void) { magic_case(KC_P, "rogram"); magic_case(KC_I, "'m"); magic_case(KC_T, "echnology"); - magic_case(KC_M, "anage"); magic_case(KC_C, "rowd"); magic_case(KC_W, "orld"); magic_case(KC_S, "ervice"); magic_case(KC_E, "'re"); + magic_case(KC_Q, "uiet"); magic_case(KC_DOT, "com"); magic_case(KC_COMM, " since"); default: return; diff --git a/keyboards/moonlander/keymaps/ikcelaks/magic_sturdy/practice.txt b/keyboards/moonlander/keymaps/ikcelaks/magic_sturdy/practice.txt index 3b6c2ee6..dcfc5a84 100644 --- a/keyboards/moonlander/keymaps/ikcelaks/magic_sturdy/practice.txt +++ b/keyboards/moonlander/keymaps/ikcelaks/magic_sturdy/practice.txt @@ -1 +1 @@ -the be of and a to in he have it that for they I with as not on she at by this we you do but from or which one would all will there say who make when can more if no man out other so what time up go about than into could state only new year some take come these know see use get like then first any work now may such give over think most even find day also after way many must look before great back through long where much should well people down own just because good each those feel seem how high too place little world very still nation hand old life tell write become here show house both between need mean call develop under last right move thing general school never same another begin while number part turn real leave might want point form off child few small since against ask late home interest large person end open public follow during present without again hold govern around possible head consider word program problem however lead system set order eye plan run keep face fact group play stand increase early course change help line power powerschool oxygen already alright judge judgment above edge ledge bridge inform information various video different difference definite definitely anyway anywhere obvious hilarious page previous dry list vision division question view review light don't zero update upgrade enough often ought bought fought fraught caught success successful access crack quite quiet neighbor mother brother though thought crowd govern government manage nation network service university universe +the be of and a to in he have it that for they I with as not on she at by this we you do but from or which one would all will there say who make when can more if no man out other so what time up go about than into could state only new year some take come these know see use get like then first any work now may such give over think most even find day also after way many must look before great back through long where much should well people down own just because good each those feel seem how high too place little world very still nation hand old life tell write become here show house both between need mean call develop under last right move thing general school never same another begin while number part turn real leave might want point form off child few small since against ask late home interest large person end open public follow during present without again hold govern around possible head consider word program problem however lead system set order eye plan run keep face fact group play stand increase early course change help line power powerschool oxygen already alright judge judgment above edge ledge bridge inform information various video different difference definite definitely anyway anywhere obvious hilarious page previous dry list vision division question view review light don't zero update upgrade enough often ought bought fought fraught caught success successful access crack quite quiet neighbor mother brother though thought crowd govern government manage management nation network service university universe location ability abilities responsibility responsibilities make making take taking qmlativ