mirror of
https://github.com/qmk/qmk_userspace.git
synced 2026-03-09 18:00:25 -04:00
Cleanup userspace and add most rules
This commit is contained in:
parent
7996617d44
commit
dc38a134e3
16 changed files with 279 additions and 2095 deletions
|
|
@ -23,3 +23,9 @@
|
|||
// User Added
|
||||
#define COMBO_COUNT 10
|
||||
#define TAPPING_TOGGLE 2
|
||||
#define DOUBLE_TAP_SHIFT_TURNS_ON_CAPS_WORD
|
||||
#define SEQUENCE_TRANSFORM_IDLE_TIMEOUT 3000
|
||||
#define SEQUENCE_TRANSFORM_EXTRA_BUFFER 10
|
||||
// #define SEQUENCE_TRANSFORM_DISABLE_ENHANCED_BACKSPACE
|
||||
#define USER_PRINT
|
||||
// #define SEQUENCE_TRANSFORM_LOG_GENERAL
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@ enum custom_keycodes {
|
|||
US_QUOT_S,
|
||||
};
|
||||
|
||||
#define SEQUENCE_TRANSFORM_SPECIAL_KEY_0 US_MAG1
|
||||
// #define SEQUENCE_TRANSFORM_SPECIAL_KEY_0 US_MAG1
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -109,20 +109,8 @@ combo_t key_combos[COMBO_COUNT] = {
|
|||
COMBO(combo_RB_IR, US_QUOT_S),
|
||||
};
|
||||
|
||||
// extern rgb_config_t rgb_matrix_config;
|
||||
|
||||
// void keyboard_post_init_user(void) {
|
||||
// rgb_matrix_enable();
|
||||
// }
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
// bool return_value;
|
||||
|
||||
// if (sturdy_pr(keycode, record, &return_value))
|
||||
// return return_value;
|
||||
uprintf("Process_record_user for keycode: %d", keycode);
|
||||
|
||||
if (!process_context_magic(keycode, record))
|
||||
if (!process_sequence_transform(keycode, record, US_MAG1))
|
||||
return false;
|
||||
|
||||
if (record->event.pressed) {
|
||||
|
|
@ -137,3 +125,16 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// extern rgb_config_t rgb_matrix_config;
|
||||
|
||||
void keyboard_post_init_user(void)
|
||||
{
|
||||
rgb_matrix_enable();
|
||||
debug_enable=true;
|
||||
}
|
||||
|
||||
void matrix_scan_user(void)
|
||||
{
|
||||
sequence_transform_task();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,52 +0,0 @@
|
|||
// 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 (6 entries):
|
||||
// j☆ -> just
|
||||
// j☆☆ -> j☆ment
|
||||
// ☆☆ -> ☆n
|
||||
// j✵ -> join
|
||||
// jud☆ -> judge
|
||||
// jud☆☆ -> jud☆ment
|
||||
|
||||
#define AUTOCORRECT_MIN_LENGTH 2 // "j☆"
|
||||
#define AUTOCORRECT_MAX_LENGTH 5 // "jud☆☆"
|
||||
#define DICTIONARY_SIZE 37
|
||||
#define COMPLETIONS_SIZE 18
|
||||
#define MAGICKEY_COUNT 4
|
||||
|
||||
static const uint16_t magickey_data[DICTIONARY_SIZE] PROGMEM = {
|
||||
0x4100, 0x0005, 0x0101, 0x0021, 0x0000, 0x4007, 0x000C, 0x000D, 0x0011, 0x0100, 0x0013, 0x0000, 0x0018, 0x000D, 0x0000, 0x8000,
|
||||
0x0000, 0x8000, 0x0003, 0xC000, 0x0007, 0x4007, 0x001A, 0x000D, 0x001F, 0x0000, 0x0018, 0x000D, 0x0000, 0x8000, 0x0009, 0x8000,
|
||||
0x0009, 0x000D, 0x0000, 0x8000, 0x000E
|
||||
};
|
||||
|
||||
static const uint8_t magickey_completions_data[COMPLETIONS_SIZE] PROGMEM = {
|
||||
0x67, 0x65, 0x00, 0x75, 0x73, 0x74, 0x00, 0x6E, 0x00, 0x6D, 0x65, 0x6E, 0x74, 0x00, 0x6F, 0x69,
|
||||
0x6E, 0x00
|
||||
};
|
||||
|
|
@ -6,6 +6,14 @@ SPACE_CADET_ENABLE = no
|
|||
COMBO_ENABLE = yes
|
||||
REPEAT_KEY_ENABLE = yes
|
||||
DEFERRED_EXEC_ENABLE = yes
|
||||
CAPS_WORD_ENABLE = yes
|
||||
|
||||
SRC += sequence_transform/sequence_transform.c
|
||||
SRC += sequence_transform/utils.c
|
||||
SRC += sequence_transform/keybuffer.c
|
||||
SRC += sequence_transform/trie.c
|
||||
|
||||
# Automatically rebuild my sequence_transform rules from the latest config
|
||||
$(shell python3 /home/qmk/qmk_userspace/keyboards/moonlander/keymaps/ikcelaks/sequence_transform/generator/sequence_transform_data.py -q)
|
||||
|
||||
TOP_SYMBOLS=10
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 48b1a6d0b4f85e3e228042bed0b5ba25b5a18c94
|
||||
Subproject commit 3a3dee168ceb2ac6359d1eba3edef17501f85ab8
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"rules_file_name": "./sequence_transform_dict.txt",
|
||||
"rules_file_name": "sequence_transform_dict.txt",
|
||||
"magic_chars": "👆👍★✪",
|
||||
"wordbreak_char": "⎵",
|
||||
"output_func_chars": "↻⇑",
|
||||
|
|
|
|||
|
|
@ -1,212 +0,0 @@
|
|||
// 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 (114 entries):
|
||||
// 👍 -> ↻
|
||||
// d★ -> develop
|
||||
// d★t -> development
|
||||
// d★r -> developer
|
||||
// d★d -> developed
|
||||
// ⎵i👍 -> I
|
||||
// ⎵i👍m -> I'm
|
||||
// ⎵i👍d -> I'd
|
||||
// ⎵i👍l -> I'll
|
||||
// ⎵c👍 -> come
|
||||
// ⎵s👍 -> some
|
||||
// ⎵c👍u -> could
|
||||
// ⎵w👍u -> would
|
||||
// ⎵s👍u -> should
|
||||
// ⎵c👍ut -> couldn't
|
||||
// ⎵w👍ut -> wouldn't
|
||||
// ⎵s👍ut -> shouldn't
|
||||
// ⎵c👍uv -> could've
|
||||
// ⎵w👍uv -> would've
|
||||
// ⎵s👍uv -> should've
|
||||
// ⎵👆 -> the
|
||||
// ⎵👆r⎵ -> there⎵
|
||||
// ⎵👆rs -> there's
|
||||
// ⎵👆i -> their
|
||||
// ⎵👆yr -> they're
|
||||
// ⎵👆yl -> they'll
|
||||
// ⎵👆d -> they'd
|
||||
// ⎵👆s -> these
|
||||
// ⎵👆t -> that
|
||||
// ⎵👆a -> than
|
||||
// ⎵👆o⎵ -> those
|
||||
// ⎵t👍 -> time
|
||||
// ⎵t👍g -> though
|
||||
// ⎵t👍t -> thought
|
||||
// ⎵t👍r -> through
|
||||
// ⎵t👍c -> technology
|
||||
// ⎵t👍a -> take
|
||||
// ⎵w👍 -> why
|
||||
// ⎵w👍n -> when
|
||||
// ⎵w👍e -> where
|
||||
// ⎵w👍t -> what
|
||||
// ⎵w👍r -> we're
|
||||
// ⎵w👍d -> we'd
|
||||
// ⎵w👍l -> we'll
|
||||
// ⎵w👍v -> we've
|
||||
// ⎵a👆 -> abo
|
||||
// ⎵a👆t -> about
|
||||
// ⎵a👆v -> above
|
||||
// ⎵a👆d -> aboard
|
||||
// ⎵a👆s -> absolute
|
||||
// ⎵a👍r -> after
|
||||
// ⎵a👍n -> again
|
||||
// ⎵a👍t -> against
|
||||
// ⎵a👍s -> answer
|
||||
// ⎵a👍p -> appear
|
||||
// ⎵a👍w -> always
|
||||
// ⎵a👍y -> already
|
||||
// ⎵a👍l -> alright
|
||||
// ⎵u👍 -> use
|
||||
// ⎵u👍f -> useful
|
||||
// ⎵u👍t -> update
|
||||
// ⎵u👍g -> upgrade
|
||||
// ⎵u👍s -> upside
|
||||
// ⎵u👍sd -> upsidedown
|
||||
// v👆 -> ver
|
||||
// s👆 -> sk
|
||||
// x👆 -> es
|
||||
// m👆 -> ment
|
||||
// t👆 -> tment
|
||||
// k👆 -> ks
|
||||
// l👆 -> lk
|
||||
// r👆 -> rl
|
||||
// j👆 -> just
|
||||
// j👆👆 -> justment
|
||||
// ⎵j👍 -> join
|
||||
// ⎵j👍d -> judge
|
||||
// ⎵j👍dt -> judgment
|
||||
// ⎵j👍dta -> judgmental
|
||||
// c👆 -> cy
|
||||
// p👆 -> py
|
||||
// d👆 -> dy
|
||||
// y👆 -> yp
|
||||
// g👆 -> gy
|
||||
// w👆 -> which
|
||||
// q👆 -> question
|
||||
// b👆 -> before
|
||||
// f👆 -> first
|
||||
// z👆 -> zone
|
||||
// 👆👆 -> 👆n
|
||||
// n👆 -> nion
|
||||
// h👆 -> however
|
||||
// u👆 -> ue
|
||||
// e👆 -> eu
|
||||
// o👆 -> oa
|
||||
// ,👆 -> ,⎵but
|
||||
// i👆 -> ion
|
||||
// .👆 -> .\ [escape]
|
||||
// ⎵👍 -> for
|
||||
// a👍 -> and
|
||||
// x👍 -> xer
|
||||
// k👍 -> know
|
||||
// i👍 -> ing
|
||||
// y👍 -> you
|
||||
// q👍 -> quick
|
||||
// j👍 -> join
|
||||
// c👍 -> ck
|
||||
// n👍 -> nf
|
||||
// h👍 -> hn
|
||||
// ,👍 -> ,⎵and
|
||||
// .👍 -> .⎵⇑
|
||||
// ?👍 -> ?⎵⇑
|
||||
// :👍 -> :⎵⇑
|
||||
// ;👍 -> ;⎵⇑
|
||||
// !👍 -> !⎵⇑
|
||||
|
||||
#define SEQUENCE_MIN_LENGTH 1 // "👍"
|
||||
#define SEQUENCE_MAX_LENGTH 6 // "⎵j👍dta"
|
||||
#define DICTIONARY_SIZE 684
|
||||
#define COMPLETIONS_SIZE 213
|
||||
#define SEQUENCE_TRANSFORM_COUNT 4
|
||||
|
||||
static const uint16_t sequence_transform_data[DICTIONARY_SIZE] PROGMEM = {
|
||||
0x4004, 0x002D, 0x0006, 0x0044, 0x0007, 0x004A, 0x0008, 0x007B, 0x0009, 0x0081, 0x000A, 0x0087, 0x000C, 0x0096, 0x000F, 0x009B,
|
||||
0x0010, 0x00B8, 0x0011, 0x00BE, 0x0013, 0x00CD, 0x0015, 0x00D3, 0x0016, 0x00F6, 0x0017, 0x011A, 0x0018, 0x0168, 0x0019, 0x017D,
|
||||
0x001A, 0x01A3, 0x001C, 0x01A9, 0x002C, 0x01AF, 0x0102, 0x01BE, 0x0100, 0x01C2, 0x0101, 0x0241, 0x0000, 0x4017, 0x0034, 0x0100,
|
||||
0x003B, 0x0101, 0x003F, 0x0000, 0x0007, 0x0101, 0x000D, 0x002C, 0x0000, 0x8002, 0x00CD, 0x002C, 0x0000, 0x8082, 0x0071, 0x0017,
|
||||
0x002C, 0x0000, 0x8183, 0x00A1, 0x0101, 0x0017, 0x002C, 0x0000, 0x8189, 0x0000, 0x4016, 0x0053, 0x0102, 0x0059, 0x0100, 0x005D,
|
||||
0x0101, 0x0068, 0x0000, 0x0101, 0x0018, 0x002C, 0x0000, 0x8004, 0x007C, 0x0007, 0x0000, 0x8002, 0x00C9, 0x4004, 0x0062, 0x002C,
|
||||
0x0066, 0x0000, 0x002C, 0x0000, 0x8003, 0x00AD, 0x8003, 0x0098, 0x400C, 0x006F, 0x000D, 0x0073, 0x001A, 0x0077, 0x0000, 0x002C,
|
||||
0x0000, 0x8002, 0x0099, 0x002C, 0x0000, 0x8184, 0x0080, 0x002C, 0x0000, 0x8103, 0x00B6, 0x0101, 0x001A, 0x002C, 0x0000, 0x8083,
|
||||
0x0092, 0x0101, 0x0018, 0x002C, 0x0000, 0x8003, 0x00BF, 0x0101, 0x0000, 0x4017, 0x008E, 0x0018, 0x0092, 0x0000, 0x002C, 0x0000,
|
||||
0x8185, 0x0010, 0x002C, 0x0000, 0x8106, 0x0022, 0x0100, 0x002C, 0x0000, 0x8002, 0x0064, 0x401C, 0x00A0, 0x0101, 0x00A5, 0x0000,
|
||||
0x0100, 0x002C, 0x0000, 0x8003, 0x0095, 0x4004, 0x00AC, 0x000C, 0x00B0, 0x001A, 0x00B4, 0x0000, 0x002C, 0x0000, 0x8106, 0x0028,
|
||||
0x002C, 0x0000, 0x8003, 0x0095, 0x002C, 0x0000, 0x8104, 0x0094, 0x0101, 0x000C, 0x002C, 0x0000, 0x8002, 0x00C7, 0x0101, 0x0000,
|
||||
0x4004, 0x00C5, 0x001A, 0x00C9, 0x0000, 0x002C, 0x0000, 0x8104, 0x003A, 0x002C, 0x0000, 0x8082, 0x006D, 0x0101, 0x0004, 0x002C,
|
||||
0x0000, 0x8105, 0x0055, 0x401C, 0x00DA, 0x0102, 0x00DF, 0x0101, 0x00E3, 0x0000, 0x0100, 0x002C, 0x0000, 0x8003, 0x0085, 0x0007,
|
||||
0x0000, 0x8002, 0x0044, 0x4004, 0x00EA, 0x0017, 0x00EE, 0x001A, 0x00F2, 0x0000, 0x002C, 0x0000, 0x8104, 0x0090, 0x002C, 0x0000,
|
||||
0x8186, 0x0034, 0x002C, 0x0000, 0x8104, 0x0084, 0x4015, 0x00FD, 0x0100, 0x0102, 0x0101, 0x010D, 0x0000, 0x0100, 0x002C, 0x0000,
|
||||
0x8003, 0x00AA, 0x4004, 0x0107, 0x002C, 0x010B, 0x0000, 0x002C, 0x0000, 0x8086, 0x001C, 0x8002, 0x009C, 0x4004, 0x0112, 0x0018,
|
||||
0x0116, 0x0000, 0x002C, 0x0000, 0x8084, 0x0068, 0x002C, 0x0000, 0x8105, 0x004B, 0x4007, 0x0125, 0x0018, 0x012B, 0x0102, 0x0140,
|
||||
0x0100, 0x0144, 0x0101, 0x014F, 0x0000, 0x0101, 0x000D, 0x002C, 0x0000, 0x8084, 0x006C, 0x0101, 0x0000, 0x4006, 0x0134, 0x0016,
|
||||
0x0138, 0x001A, 0x013C, 0x0000, 0x002C, 0x0000, 0x8003, 0x009E, 0x002C, 0x0000, 0x8003, 0x009E, 0x002C, 0x0000, 0x8003, 0x009E,
|
||||
0x0007, 0x0000, 0x8004, 0x006C, 0x4004, 0x0149, 0x002C, 0x014D, 0x0000, 0x002C, 0x0000, 0x8002, 0x001F, 0x8082, 0x0048, 0x4004,
|
||||
0x0158, 0x0017, 0x015C, 0x0018, 0x0160, 0x001A, 0x0164, 0x0000, 0x002C, 0x0000, 0x8106, 0x003A, 0x002C, 0x0000, 0x8186, 0x0010,
|
||||
0x002C, 0x0000, 0x8105, 0x0046, 0x002C, 0x0000, 0x8082, 0x0048, 0x0101, 0x0000, 0x4006, 0x0171, 0x0016, 0x0175, 0x001A, 0x0179,
|
||||
0x0000, 0x002C, 0x0000, 0x8103, 0x0061, 0x002C, 0x0000, 0x8185, 0x005F, 0x002C, 0x0000, 0x8104, 0x0060, 0x4018, 0x0184, 0x0100,
|
||||
0x0199, 0x0101, 0x019E, 0x0000, 0x0101, 0x0000, 0x4006, 0x018D, 0x0016, 0x0191, 0x001A, 0x0195, 0x0000, 0x002C, 0x0000, 0x8003,
|
||||
0x0089, 0x002C, 0x0000, 0x8003, 0x0089, 0x002C, 0x0000, 0x8003, 0x0089, 0x0004, 0x002C, 0x0000, 0x8002, 0x0017, 0x001A, 0x002C,
|
||||
0x0000, 0x8104, 0x0088, 0x0101, 0x0004, 0x002C, 0x0000, 0x8105, 0x0050, 0x0101, 0x0004, 0x002C, 0x0000, 0x8106, 0x002E, 0x4012,
|
||||
0x01B4, 0x0015, 0x01B9, 0x0000, 0x0100, 0x002C, 0x0000, 0x8203, 0x009B, 0x0100, 0x002C, 0x0000, 0x8002, 0x00C5, 0x0007, 0x0000,
|
||||
0x8006, 0x0016, 0x4036, 0x01FF, 0x0037, 0x0201, 0x0004, 0x0203, 0x0005, 0x0207, 0x0006, 0x0209, 0x0007, 0x020B, 0x0008, 0x020D,
|
||||
0x0009, 0x020F, 0x000A, 0x0211, 0x000B, 0x0213, 0x000C, 0x0215, 0x000D, 0x0217, 0x000E, 0x0219, 0x000F, 0x021B, 0x0010, 0x021D,
|
||||
0x0011, 0x021F, 0x0012, 0x0221, 0x0013, 0x0223, 0x0014, 0x0225, 0x0015, 0x0227, 0x0016, 0x0229, 0x0017, 0x022B, 0x0018, 0x022D,
|
||||
0x0019, 0x022F, 0x001A, 0x0231, 0x001B, 0x0233, 0x001C, 0x0235, 0x001D, 0x0237, 0x002C, 0x0239, 0x0100, 0x023B, 0x0000, 0x8004,
|
||||
0x0078, 0x8001, 0x00D4, 0x002C, 0x0000, 0x8002, 0x00CB, 0x8005, 0x005A, 0x8001, 0x0008, 0x8001, 0x0008, 0x8001, 0x0009, 0x8004,
|
||||
0x0064, 0x8001, 0x0008, 0x8006, 0x0040, 0x8002, 0x000E, 0x8003, 0x00B9, 0x8001, 0x000B, 0x8001, 0x0077, 0x8003, 0x006D, 0x8003,
|
||||
0x000D, 0x8001, 0x0025, 0x8001, 0x0008, 0x8007, 0x0009, 0x8001, 0x0005, 0x8001, 0x0077, 0x8004, 0x006C, 0x8001, 0x0000, 0x8002,
|
||||
0x0044, 0x8004, 0x008C, 0x8082, 0x000A, 0x8001, 0x001B, 0x8003, 0x00BC, 0x8003, 0x00B0, 0xC001, 0x0003, 0x000D, 0x0000, 0x8004,
|
||||
0x006C, 0xC800, 0x0000, 0x421E, 0x026E, 0x0036, 0x0270, 0x0037, 0x0272, 0x0233, 0x0274, 0x0033, 0x0276, 0x0238, 0x0278, 0x0004,
|
||||
0x027A, 0x0006, 0x027C, 0x000B, 0x0282, 0x000C, 0x0284, 0x000D, 0x028A, 0x000E, 0x0290, 0x0011, 0x0292, 0x0014, 0x0294, 0x0016,
|
||||
0x0296, 0x0017, 0x029A, 0x0018, 0x029E, 0x001A, 0x02A2, 0x001B, 0x02A6, 0x001C, 0x02A8, 0x002C, 0x02AA, 0x0000, 0x9001, 0x0070,
|
||||
0x8004, 0x0070, 0x9001, 0x0070, 0x9001, 0x0070, 0x9001, 0x0070, 0x9001, 0x0070, 0x8002, 0x0072, 0xC001, 0x0077, 0x002C, 0x0000,
|
||||
0x8003, 0x00B3, 0x8001, 0x0003, 0xC002, 0x00CF, 0x002C, 0x0000, 0x8081, 0x00D3, 0xC003, 0x00A7, 0x002C, 0x0000, 0x8003, 0x00A7,
|
||||
0x8003, 0x00C2, 0x8001, 0x005B, 0x8004, 0x0074, 0x002C, 0x0000, 0x8003, 0x00B3, 0x002C, 0x0000, 0x8003, 0x00A4, 0x002C, 0x0000,
|
||||
0x8002, 0x009C, 0x002C, 0x0000, 0x8002, 0x00D1, 0x8002, 0x0044, 0x8002, 0x0011, 0x8003, 0x005B
|
||||
};
|
||||
|
||||
static const uint8_t sequence_transform_completions_data[COMPLETIONS_SIZE] PROGMEM = {
|
||||
0x65, 0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x79, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6F, 0x6E,
|
||||
0x68, 0x6F, 0x75, 0x67, 0x68, 0x74, 0x65, 0x76, 0x65, 0x6C, 0x6F, 0x70, 0x73, 0x6F, 0x6C, 0x75,
|
||||
0x74, 0x65, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x6C, 0x72, 0x69, 0x67, 0x68, 0x74, 0x6C, 0x72,
|
||||
0x65, 0x61, 0x64, 0x79, 0x68, 0x72, 0x6F, 0x75, 0x67, 0x68, 0x67, 0x61, 0x69, 0x6E, 0x73, 0x74,
|
||||
0x6F, 0x77, 0x65, 0x76, 0x65, 0x72, 0x70, 0x64, 0x61, 0x74, 0x65, 0x70, 0x73, 0x69, 0x64, 0x65,
|
||||
0x6C, 0x77, 0x61, 0x79, 0x73, 0x70, 0x70, 0x65, 0x61, 0x72, 0x65, 0x66, 0x6F, 0x72, 0x65, 0x68,
|
||||
0x6F, 0x75, 0x6C, 0x64, 0x69, 0x72, 0x73, 0x74, 0x73, 0x77, 0x65, 0x72, 0x6D, 0x65, 0x6E, 0x74,
|
||||
0x20, 0x61, 0x6E, 0x64, 0x75, 0x69, 0x63, 0x6B, 0x20, 0x62, 0x75, 0x74, 0x64, 0x6F, 0x77, 0x6E,
|
||||
0x75, 0x64, 0x67, 0x65, 0x65, 0x27, 0x72, 0x65, 0x65, 0x27, 0x76, 0x65, 0x68, 0x69, 0x63, 0x68,
|
||||
0x66, 0x74, 0x65, 0x72, 0x65, 0x27, 0x6C, 0x6C, 0x79, 0x27, 0x64, 0x6F, 0x73, 0x65, 0x6E, 0x27,
|
||||
0x74, 0x61, 0x6B, 0x65, 0x69, 0x6D, 0x65, 0x6F, 0x69, 0x6E, 0x65, 0x27, 0x73, 0x61, 0x72, 0x64,
|
||||
0x74, 0x68, 0x65, 0x6F, 0x6D, 0x65, 0x65, 0x27, 0x64, 0x75, 0x73, 0x74, 0x6F, 0x6E, 0x65, 0x66,
|
||||
0x75, 0x6C, 0x6E, 0x6F, 0x77, 0x65, 0x20, 0x27, 0x6D, 0x65, 0x64, 0x62, 0x6F, 0x61, 0x6C, 0x6E,
|
||||
0x67, 0x68, 0x79, 0x49, 0x5C
|
||||
};
|
||||
|
|
@ -12,10 +12,26 @@ d★d ⇒ developed
|
|||
⎵i👍m ⇒ I'm
|
||||
⎵i👍d ⇒ I'd
|
||||
⎵i👍l ⇒ I'll
|
||||
⎵i👍r ⇒ increase
|
||||
⎵i👍rg ⇒ increasing
|
||||
⎵i👍e ⇒ include
|
||||
⎵i👍eg ⇒ including
|
||||
⎵i👍t ⇒ interest
|
||||
⎵i👍tg ⇒ interesting
|
||||
⎵i👍td ⇒ interested
|
||||
|
||||
|
||||
⎵c👍 ⇒ come
|
||||
⎵s👍 ⇒ some
|
||||
⎵c👍o ⇒ course
|
||||
⎵c👍a ⇒ change
|
||||
⎵c👍ai ⇒ changing
|
||||
⎵c👍s ⇒ cause
|
||||
⎵c👍n ⇒ consider
|
||||
⎵c👍m ⇒ complete
|
||||
⎵c👍l ⇒ call
|
||||
⎵c👍h ⇒ child
|
||||
⎵c👍hr ⇒ children
|
||||
|
||||
|
||||
⎵c👍u ⇒ could
|
||||
⎵w👍u ⇒ would
|
||||
|
|
@ -28,41 +44,173 @@ d★d ⇒ developed
|
|||
⎵s👍uv ⇒ should've
|
||||
|
||||
|
||||
⎵r👍 ⇒ right
|
||||
⎵r👍d ⇒ round
|
||||
⎵r👍y ⇒ ready
|
||||
⎵r👍i ⇒ river
|
||||
⎵r👍e ⇒ real
|
||||
⎵r👍ey ⇒ really
|
||||
⎵r👍m ⇒ remember
|
||||
⎵r👍c ⇒ record
|
||||
⎵r👍h ⇒ reach
|
||||
⎵r👍s ⇒ restaurant
|
||||
|
||||
⎵l👍 ⇒ like
|
||||
⎵l👍i ⇒ light
|
||||
⎵l👍a ⇒ large
|
||||
⎵l👍o ⇒ look
|
||||
⎵l👍f ⇒ life
|
||||
⎵l👍t ⇒ last
|
||||
⎵l👍n ⇒ line
|
||||
|
||||
⎵m👍 ⇒ make
|
||||
⎵m👍g ⇒ making
|
||||
⎵m👍i ⇒ might
|
||||
⎵m👍o ⇒ most
|
||||
⎵m👍e ⇒ more
|
||||
⎵m👍u ⇒ must
|
||||
⎵m👍c ⇒ much
|
||||
⎵m👍v ⇒ move
|
||||
⎵m👍n ⇒ mean
|
||||
⎵m👍r ⇒ mother
|
||||
|
||||
⎵👆 ⇒ the
|
||||
⎵👆r⎵ ⇒ there⎵
|
||||
⎵👆rs ⇒ there's
|
||||
⎵👆i ⇒ their
|
||||
⎵👆g ⇒ thing
|
||||
⎵👆k ⇒ think
|
||||
⎵👆yr ⇒ they're
|
||||
⎵👆yl ⇒ they'll
|
||||
⎵👆d ⇒ they'd
|
||||
⎵👆s ⇒ these
|
||||
⎵👆s⎵ ⇒ this⎵
|
||||
⎵👆t ⇒ that
|
||||
⎵👆a ⇒ than
|
||||
⎵👆o⎵ ⇒ those
|
||||
⎵👆a⎵ ⇒ than⎵
|
||||
⎵👆ak ⇒ thank
|
||||
⎵👆o⎵ ⇒ those⎵
|
||||
|
||||
⎵t👍 ⇒ time
|
||||
⎵t👍g ⇒ though
|
||||
⎵t👍t ⇒ thought
|
||||
⎵t👍r ⇒ through
|
||||
⎵t👍c ⇒ technology
|
||||
⎵t👍n ⇒ techn
|
||||
⎵t👍ny ⇒ technology
|
||||
⎵t👍nl ⇒ technical
|
||||
⎵t👍nly ⇒ technically
|
||||
⎵t👍nu ⇒ technique
|
||||
⎵t👍w ⇒ throw
|
||||
⎵t👍a ⇒ take
|
||||
⎵t👍ag ⇒ taking
|
||||
|
||||
⎵t👆 ⇒ tell
|
||||
|
||||
k👍d ⇒ knowledge
|
||||
k👍di ⇒ knowledging
|
||||
|
||||
⎵k👆 ⇒ keep
|
||||
|
||||
⎵o👍 ⇒ one
|
||||
⎵o👍x ⇒ oxygen
|
||||
⎵o👍r ⇒ other
|
||||
⎵o👍t ⇒ often
|
||||
⎵o👍b ⇒ object
|
||||
⎵o👍s ⇒ observe
|
||||
⎵o👍p ⇒ opposite
|
||||
⎵o👍g ⇒ original
|
||||
⎵o👍c ⇒ occur
|
||||
⎵o👍f ⇒ offer
|
||||
⎵o👍d ⇒ order
|
||||
⎵o👍di ⇒ ordering
|
||||
|
||||
⎵x👍 ⇒ xab
|
||||
⎵x👍x ⇒ xabcd
|
||||
⎵x👍xx ⇒ y
|
||||
⎵x👍kx ⇒ k
|
||||
|
||||
ou👍 ⇒ ough
|
||||
au👍 ⇒ augh
|
||||
|
||||
st👍 ⇒ sts
|
||||
rs👍 ⇒ rst
|
||||
|
||||
⎵b👍 ⇒ be
|
||||
⎵b👍s ⇒ because
|
||||
⎵b👍c ⇒ become
|
||||
⎵b👍t ⇒ between
|
||||
⎵b👍g ⇒ begin
|
||||
⎵b👍l ⇒ believe
|
||||
⎵b👍e ⇒ been
|
||||
⎵b👍r ⇒ brother
|
||||
⎵b👍o ⇒ both
|
||||
|
||||
⎵f👍 ⇒ from
|
||||
⎵f👍l ⇒ follow
|
||||
⎵f👍l👆 ⇒ follower
|
||||
⎵f👍ld ⇒ followed
|
||||
⎵f👍r ⇒ friend
|
||||
⎵f👍d ⇒ find
|
||||
⎵f👍e ⇒ feel
|
||||
⎵f👍c ⇒ face
|
||||
⎵f👍t ⇒ fact
|
||||
|
||||
⎵n👍 ⇒ not
|
||||
⎵n👍v ⇒ never
|
||||
⎵n👍t ⇒ nation
|
||||
⎵n👍d ⇒ need
|
||||
⎵n👍w ⇒ nowhere
|
||||
⎵n👍g ⇒ nothing
|
||||
⎵n👍m ⇒ number
|
||||
|
||||
⎵e👍 ⇒ each
|
||||
⎵e👍g ⇒ enough
|
||||
⎵e👍n ⇒ even
|
||||
⎵e👍y ⇒ every
|
||||
⎵e👍ym ⇒ everytime
|
||||
⎵e👍yt ⇒ everything
|
||||
⎵e👍r ⇒ early
|
||||
⎵e👍x ⇒ example
|
||||
⎵e👍c ⇒ exercise
|
||||
⎵e👍p ⇒ expert
|
||||
⎵e👍q ⇒ equal
|
||||
⎵e👍qe ⇒ equate
|
||||
|
||||
⎵w👍 ⇒ why
|
||||
⎵w👍i ⇒ which
|
||||
⎵w👍n ⇒ when
|
||||
⎵w👍h ⇒ while
|
||||
⎵w👍e ⇒ where
|
||||
⎵w👍t ⇒ what
|
||||
⎵w👍o ⇒ world
|
||||
⎵w👍k ⇒ work
|
||||
⎵w👍ts ⇒ what's
|
||||
⎵w👍r ⇒ we're
|
||||
⎵w👍d ⇒ we'd
|
||||
⎵w👍l ⇒ we'll
|
||||
⎵w👍v ⇒ we've
|
||||
|
||||
⎵w👆i ⇒ will
|
||||
⎵w👆l ⇒ well
|
||||
⎵w👆r ⇒ write
|
||||
⎵w👆o ⇒ word
|
||||
⎵w👆t ⇒ with
|
||||
⎵w👆to ⇒ without
|
||||
|
||||
⎵v👍 ⇒ view
|
||||
⎵v👍r ⇒ viewer
|
||||
⎵v👍d ⇒ viewed
|
||||
⎵v👍i ⇒ vision
|
||||
⎵v👍n ⇒ version
|
||||
|
||||
⎵a👆 ⇒ abo
|
||||
⎵a👆t ⇒ about
|
||||
⎵a👆v ⇒ above
|
||||
⎵a👆d ⇒ aboard
|
||||
⎵a👆s ⇒ absolute
|
||||
⎵a👆l ⇒ also
|
||||
|
||||
⎵a👍r ⇒ after
|
||||
⎵a👍👆 ⇒ another
|
||||
⎵a👍d ⇒ around
|
||||
⎵a👍n ⇒ again
|
||||
⎵a👍t ⇒ against
|
||||
⎵a👍s ⇒ answer
|
||||
|
|
@ -71,22 +219,101 @@ d★d ⇒ developed
|
|||
⎵a👍y ⇒ already
|
||||
⎵a👍l ⇒ alright
|
||||
|
||||
⎵s👍 ⇒ some
|
||||
⎵s👍t ⇒ sometimes
|
||||
⎵s👍g ⇒ something
|
||||
⎵s👍h ⇒ somehow
|
||||
⎵s👍y ⇒ system
|
||||
⎵s👍d ⇒ sound
|
||||
⎵s👍c ⇒ success
|
||||
⎵s👍l ⇒ school
|
||||
⎵s👍m ⇒ small
|
||||
⎵s👍p ⇒ special
|
||||
⎵s👍w ⇒ show
|
||||
⎵s👍wr ⇒ shower
|
||||
⎵s👍wd ⇒ showed
|
||||
⎵s👍wi ⇒ showing
|
||||
⎵s👍a ⇒ state
|
||||
⎵s👍e ⇒ seem
|
||||
⎵s👍i ⇒ still
|
||||
⎵s👍n ⇒ since
|
||||
|
||||
⎵s👆c ⇒ such
|
||||
|
||||
s👆l ⇒ school
|
||||
|
||||
⎵p👍 ⇒ pro
|
||||
⎵p👍b ⇒ problem
|
||||
⎵p👍m ⇒ program
|
||||
⎵p👍r ⇒ present
|
||||
⎵p👍e ⇒ people
|
||||
⎵p👍a ⇒ play
|
||||
⎵p👍s ⇒ possible
|
||||
⎵p👍n ⇒ person
|
||||
⎵p👍o ⇒ power
|
||||
⎵p👍u ⇒ public
|
||||
⎵p👍h ⇒ psych
|
||||
⎵p👍l ⇒ place
|
||||
⎵p👍t ⇒ point
|
||||
|
||||
⎵d👍 ⇒ do
|
||||
⎵d👍t ⇒ don't
|
||||
⎵d👍i ⇒ did
|
||||
⎵d👍it ⇒ didn't
|
||||
⎵d👍f ⇒ differ
|
||||
⎵d👍ft ⇒ different
|
||||
⎵d👍u ⇒ difficult
|
||||
⎵d👍r ⇒ during
|
||||
⎵d👍n ⇒ down
|
||||
⎵d👍d ⇒ decide
|
||||
⎵d👍l ⇒ develop
|
||||
⎵d👍lm ⇒ development
|
||||
⎵d👍ld ⇒ developed
|
||||
⎵d👍l👆 ⇒ developer
|
||||
|
||||
⎵u👍 ⇒ use
|
||||
⎵u👍g ⇒ using
|
||||
⎵u👍f ⇒ useful
|
||||
⎵u👍t ⇒ update
|
||||
⎵u👍g ⇒ upgrade
|
||||
⎵u👍s ⇒ upside
|
||||
⎵u👍sd ⇒ upsidedown
|
||||
⎵u👍r ⇒ upgrade
|
||||
⎵u👍n ⇒ under
|
||||
|
||||
⎵h👍 ⇒ have
|
||||
⎵h👍r ⇒ here
|
||||
⎵h👍s ⇒ house
|
||||
⎵h👍t ⇒ height
|
||||
⎵h👍l ⇒ help
|
||||
⎵h👍d ⇒ hold
|
||||
|
||||
⎵g👍 ⇒ give
|
||||
⎵g👍v ⇒ govern
|
||||
⎵g👍e ⇒ general
|
||||
⎵g👍d ⇒ governed
|
||||
⎵g👍m ⇒ government
|
||||
⎵g👍r ⇒ group
|
||||
⎵g👍t ⇒ great
|
||||
⎵g👍o ⇒ good
|
||||
⎵g👍u ⇒ guage
|
||||
⎵g👍a ⇒ guarantee
|
||||
|
||||
⎵l👆 ⇒ little
|
||||
|
||||
v👆 ⇒ ver
|
||||
s👆 ⇒ sk
|
||||
x👆 ⇒ es
|
||||
x👆 ⇒ xes
|
||||
|
||||
m👆 ⇒ ment
|
||||
ma👆 ⇒ make
|
||||
mr👆 ⇒ mark
|
||||
t👆 ⇒ tment
|
||||
ta👆 ⇒ take
|
||||
k👆 ⇒ ks
|
||||
|
||||
l👆 ⇒ lk
|
||||
li👆 ⇒ list
|
||||
blivi👆 ⇒ blivion
|
||||
vili👆 ⇒ vilion
|
||||
lli👆 ⇒ llion
|
||||
r👆 ⇒ rl
|
||||
|
||||
j👆 ⇒ just
|
||||
|
|
@ -98,11 +325,17 @@ j👆👆 ⇒ justment
|
|||
|
||||
c👆 ⇒ cy
|
||||
p👆 ⇒ py
|
||||
pl👆 ⇒ ply
|
||||
pa👆 ⇒ page
|
||||
d👆 ⇒ dy
|
||||
da👆 ⇒ day
|
||||
dr👆 ⇒ dry
|
||||
y👆 ⇒ yp
|
||||
g👆 ⇒ gy
|
||||
w👆 ⇒ which
|
||||
q👆 ⇒ question
|
||||
w👆 ⇒ way
|
||||
q👆 ⇒ quest
|
||||
q👆👆 ⇒ question
|
||||
q👆d ⇒ quested
|
||||
|
||||
b👆 ⇒ before
|
||||
f👆 ⇒ first
|
||||
|
|
@ -119,6 +352,8 @@ o👆 ⇒ oa
|
|||
,👆 ⇒ ,⎵but
|
||||
i👆 ⇒ ion
|
||||
.👆 ⇒ .\
|
||||
-👆 ⇒ ->
|
||||
=👆 ⇒ =>
|
||||
|
||||
⎵👍 ⇒ for
|
||||
a👍 ⇒ and
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
#include "stack.h"
|
||||
#include <stdio.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
void stack_push(stack_t *s, char c)
|
||||
{
|
||||
if (s->size < STACK_SIZE)
|
||||
s->buffer[s->size++] = c;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
void stack_pop(stack_t *s)
|
||||
{
|
||||
if (s->size > 0)
|
||||
s->size--;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
void stack_print(stack_t *s)
|
||||
{
|
||||
for (int i = s->size - 1; i >= 0; --i)
|
||||
printf("%c", s->buffer[i]);
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
#define STACK_SIZE 256
|
||||
typedef struct {
|
||||
char buffer[STACK_SIZE];
|
||||
int size;
|
||||
} stack_t;
|
||||
|
||||
void stack_push(stack_t *s, char c);
|
||||
void stack_pop(stack_t *s);
|
||||
void stack_print(stack_t *s);
|
||||
|
|
@ -1,240 +0,0 @@
|
|||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "trie2.h"
|
||||
#include "stack.h"
|
||||
#include "util2.h"
|
||||
|
||||
#define KEY_BUFFER_MAX_LENGTH MAGICKEY_MAX_LENGTH
|
||||
#define TDATA(i) trie->dict[i]
|
||||
#define CDATA(i) trie->completions[i]
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
typedef struct {
|
||||
char data[KEY_BUFFER_MAX_LENGTH];
|
||||
int size;
|
||||
// result data
|
||||
const char *completion;
|
||||
int complete_len;
|
||||
int func_num;
|
||||
int num_backspaces;
|
||||
} search_buffer_t;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
typedef struct trie2_visitor trie2_visitor_t;
|
||||
typedef void (*trie2_visitor_cb_t)(trie2_visitor_t *, int, int, const char *);
|
||||
struct trie2_visitor {
|
||||
stack_t stack;
|
||||
trie2_visitor_cb_t cb_func;
|
||||
void *cb_data;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// traverse trie and call v->cb_func at each MATCH node
|
||||
void traverse_trie2(const trie2_t *trie, int offset, trie2_visitor_t *v)
|
||||
{
|
||||
assert(offset < trie->dict_size);
|
||||
uint16_t code = TDATA(offset);
|
||||
assert(code);
|
||||
// MATCH node
|
||||
if (code & 0x8000) {
|
||||
// Traverse down child node if this isn't the only match
|
||||
if (code & 0x4000)
|
||||
traverse_trie2(trie, offset+2, v);
|
||||
printf("offset %d: ", offset);
|
||||
const int bspaces = (code & 0x3F);
|
||||
const int func = (code >> 11 & 0x07);
|
||||
const int complete_offset = TDATA(offset+1);
|
||||
const char *completion = (const char *)&CDATA(complete_offset);
|
||||
v->cb_func(v, bspaces, func, completion);
|
||||
}
|
||||
// BRANCH node
|
||||
else if (code & 0x4000) {
|
||||
//printf("BRANCH node at offset %d\n", offset);
|
||||
code &= 0x3FFF;
|
||||
for (; code; offset += 2, code = TDATA(offset)) {
|
||||
// Get 16bit offset to child node
|
||||
const int child_offset = TDATA(offset+1);
|
||||
// Traverse down child node
|
||||
stack_push(&v->stack, keycode_to_char(code));
|
||||
traverse_trie2(trie, child_offset, v);
|
||||
stack_pop(&v->stack);
|
||||
}
|
||||
}
|
||||
// Chain node
|
||||
else {
|
||||
//printf("CHAIN node at offset %d\n", offset);
|
||||
// Travel down chain until we reach a zero byte
|
||||
const int prev_stack_size = v->stack.size;
|
||||
for (; code; code = TDATA(++offset))
|
||||
stack_push(&v->stack, keycode_to_char(code));
|
||||
// After a chain, there should be a leaf or branch
|
||||
traverse_trie2(trie, offset+1, v);
|
||||
v->stack.size = prev_stack_size;
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
bool search_trie2(const trie2_t *trie, int offset, trie2_visitor_t *v)
|
||||
{
|
||||
assert(offset < trie->dict_size);
|
||||
search_buffer_t *search = (search_buffer_t*)v->cb_data;
|
||||
uint16_t code = TDATA(offset);
|
||||
assert(code);
|
||||
// MATCH node if bit 15 is set
|
||||
if (code & 0x8000) {
|
||||
// If bit 14 is also set, there's a child node after the completion string
|
||||
if ((code & 0x4000) && search_trie2(trie, offset+2, v))
|
||||
return true;
|
||||
// If no better match found deeper, this is the result!
|
||||
const int bspaces = (code & 0x3F);
|
||||
const int func = (code >> 11 & 0x7);
|
||||
const int complete_offset = TDATA(offset+1);
|
||||
const char *completion = (const char *)&CDATA(complete_offset);
|
||||
v->cb_func(v, bspaces, func, completion);
|
||||
// Found a match so return true!
|
||||
return true;
|
||||
}
|
||||
// BRANCH node if bit 14 is set
|
||||
if (code & 0x4000) {
|
||||
if ((v->stack.size+1) > search->size)
|
||||
return false;
|
||||
code &= 0x3FFF;
|
||||
const char cur_char = search->data[search->size - (v->stack.size+1)];
|
||||
// find child that matches our current buffer location
|
||||
for (; code; offset += 2, code = TDATA(offset)) {
|
||||
const char c = keycode_to_char(code);
|
||||
if (cur_char == c) {
|
||||
// Get 15bit offset to child node
|
||||
const int child_offset = TDATA(offset+1);
|
||||
// Traverse down child node
|
||||
stack_push(&v->stack, c);
|
||||
const bool res = search_trie2(trie, child_offset, v);
|
||||
stack_pop(&v->stack);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
// Couldn't go deeper, so return false.
|
||||
return false;
|
||||
}
|
||||
// No high bits set, so this is a chain node
|
||||
// Travel down chain until we reach a zero code, or we no longer match our buffer
|
||||
const int prev_stack_size = v->stack.size;
|
||||
for (; code; code = TDATA(++offset)) {
|
||||
const char c = keycode_to_char(code);
|
||||
stack_push(&v->stack, c);
|
||||
if (v->stack.size > search->size ||
|
||||
c != search->data[search->size - v->stack.size]) {
|
||||
v->stack.size = prev_stack_size;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// After a chain, there should be a leaf or branch
|
||||
const bool res = search_trie2(trie, offset+1, v);
|
||||
v->stack.size = prev_stack_size;
|
||||
return res;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
void print_traverse_cb2(trie2_visitor_t *v, int bspaces, int func, const char *completion)
|
||||
{
|
||||
printf(" depth %d: ", v->stack.size);
|
||||
printf(" -> %s (bspc: %d, func: %d)\n", completion, bspaces, func);
|
||||
|
||||
if (v->cb_data) {
|
||||
int entries = *(int*)v->cb_data;
|
||||
*(int*)v->cb_data = entries + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
void print_search_cb2(trie2_visitor_t *v, int bspaces, int func, const char *completion)
|
||||
{
|
||||
printf(" depth %d: ", v->stack.size);
|
||||
stack_print(&v->stack);
|
||||
search_buffer_t *search = (search_buffer_t*)v->cb_data;
|
||||
char last_char;
|
||||
int i;
|
||||
switch (func) {
|
||||
case 1: // repeat
|
||||
i = search->size - 1;
|
||||
last_char = search->data[i];
|
||||
while ((last_char == '*' || last_char == '@') && i >= 0) {
|
||||
last_char = search->data[--i];
|
||||
}
|
||||
search->data[search->size-1] = last_char;
|
||||
printf(" -> %s%c (bspc: %d, func: %d)\n", completion, last_char, bspaces, func);
|
||||
printf(" new buffer: %s", search->data);
|
||||
printf("\n");
|
||||
break;
|
||||
case 2: // one-shot-shift
|
||||
printf(" -> %s (bspc: %d, func: %d)\n", completion, bspaces, func);
|
||||
printf(" Activating One-Shot-Shift\n");
|
||||
break;
|
||||
default:
|
||||
printf(" -> %s (bspc: %d, func: %d)\n", completion, bspaces, func);
|
||||
}
|
||||
|
||||
if (v->cb_data) {
|
||||
int entries = *(int*)v->cb_data;
|
||||
*(int*)v->cb_data = entries + 1;
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
void test_traverse2(trie2_t *trie)
|
||||
{
|
||||
printf("Traversing Trie2:\n");
|
||||
int entries = 0;
|
||||
trie2_visitor_t visitor;
|
||||
visitor.stack.size = 0;
|
||||
visitor.cb_data = (void*)&entries;
|
||||
visitor.cb_func = print_traverse_cb2;
|
||||
traverse_trie2(trie, 0, &visitor);
|
||||
printf("Found %d entries.\n\n", entries);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
void test_search2(const trie2_t *trie, const char *buffer)
|
||||
{
|
||||
printf("Searching Trie2 for '%s':\n", buffer);
|
||||
search_buffer_t search;
|
||||
strcpy(search.data, buffer);
|
||||
search.size = (int)strlen(buffer);
|
||||
trie2_visitor_t visitor;
|
||||
visitor.stack.size = 0;
|
||||
visitor.cb_data = (void*)&search;
|
||||
visitor.cb_func = print_search_cb2;
|
||||
search_trie2(trie, 0, &visitor);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
void test_trie2()
|
||||
{
|
||||
trie2_t trie2 = {
|
||||
magickey_data,
|
||||
magickey_completions_data,
|
||||
DICTIONARY_SIZE,
|
||||
COMPLETIONS_SIZE
|
||||
};
|
||||
test_traverse2(&trie2);
|
||||
// Test search
|
||||
test_search2(&trie2, "i*");
|
||||
test_search2(&trie2, ":sti@");
|
||||
test_search2(&trie2, "stati*");
|
||||
test_search2(&trie2, "bo*");
|
||||
test_search2(&trie2, "judge@");
|
||||
test_search2(&trie2, "cop*");
|
||||
test_search2(&trie2, "beh@");
|
||||
test_search2(&trie2, ":beh@");
|
||||
test_search2(&trie2, "cat*");
|
||||
test_search2(&trie2, ":ex@");
|
||||
test_search2(&trie2, "j*");
|
||||
test_search2(&trie2, ":i@");
|
||||
test_search2(&trie2, ":i@m");
|
||||
test_search2(&trie2, ":i@d");
|
||||
test_search2(&trie2, ":i@l");
|
||||
test_search2(&trie2, "o@");
|
||||
test_search2(&trie2, ".@");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_trie2();
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
#define PROGMEM
|
||||
#include "magickey_data.h"
|
||||
|
||||
typedef struct {
|
||||
const uint16_t *dict;
|
||||
const uint8_t *completions;
|
||||
int dict_size;
|
||||
int completions_size;
|
||||
} trie2_t;
|
||||
|
||||
void test_trie2();
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
#include "keycodes-copy.h"
|
||||
#include "util2.h"
|
||||
|
||||
#define QK_LSFT 0x0200
|
||||
#define pgm_read_byte(address_short) *((uint8_t*)(address_short))
|
||||
#define PROGMEM
|
||||
|
||||
static const char magic_chars[] = { '*', '@' };
|
||||
|
||||
const char unshifted_keycode_to_ascii_lut[53] PROGMEM = {
|
||||
// KC_A KC_B KC_C KC_D
|
||||
'a', 'b', 'c', 'd',
|
||||
// KC_E KC_F KC_G KC_H KC_I KC_J KC_K KC_L
|
||||
'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
|
||||
// KC_M KC_N KC_O KC_P KC_Q KC_R KC_S KC_T
|
||||
'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
|
||||
// KC_U KC_V KC_W KC_X KC_Y KC_Z KC_1 KC_2
|
||||
'u', 'v', 'w', 'x', 'y', 'z', '1', '2',
|
||||
// KC_3 KC_4 KC_5 KC_6 KC_7 KC_8 KC_9 KC_0
|
||||
'3', '4', '5', '6', '7', '8', '9', '0',
|
||||
// KC_ENTR KC_ESC KC_BSPC KC_TAB KC_SPC KC_MINS KC_EQL KC_LBRC
|
||||
' ', ' ', ' ', ' ', ' ', '-', '=', '[',
|
||||
// KC_RBRC KC_BSLS KC_NUHS KC_SCLN KC_QUOT KC_GRV KC_COMM KC_DOT
|
||||
']', '\\', ' ', ';', '\'', '`', ',', '.',
|
||||
// KC_SLSH
|
||||
'/'
|
||||
};
|
||||
const char shifted_keycode_to_ascii_lut[53] PROGMEM = {
|
||||
// KC_A KC_B KC_C KC_D
|
||||
'A', 'B', 'C', 'D',
|
||||
// KC_E KC_F KC_G KC_H KC_I KC_J KC_K KC_L
|
||||
'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
|
||||
// KC_M KC_N KC_O KC_P KC_Q KC_R KC_S KC_T
|
||||
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
|
||||
// KC_U KC_V KC_W KC_X KC_Y KC_Z KC_EXLM KC_AT
|
||||
'U', 'V', 'W', 'X', 'Y', 'Z', '!', '@',
|
||||
// KC_HASH KC_DLR KC_PERC KC_CIRC KC_AMPR KC_ASTR KC_LPRN KC_RPRN
|
||||
'#', '$', '%', '^', '&', '*', '(', ')',
|
||||
// KC_ENTR KC_ESC KC_BSPC KC_TAB KC_SPC KC_UNDS KC_PLUS KC_LCBR
|
||||
' ', ' ', ' ', ' ', ' ', '_', '+', '{',
|
||||
// KC_RCBR KC_PIPE KC_NUHS KC_COLN KC_DQUO KC_GRV KC_LABK KC_RABK
|
||||
'}', '|', ' ', ':', '"', '~', '<', '>',
|
||||
// KC_QUES
|
||||
'?'
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
char keycode_to_char(uint16_t keycode)
|
||||
{
|
||||
if (keycode >= KC_MAGIC_0)
|
||||
return magic_chars[keycode - KC_MAGIC_0];
|
||||
if (keycode == KC_SPC)
|
||||
return ':';
|
||||
const bool shifted = keycode & QK_LSFT;
|
||||
keycode &= 0xFF;
|
||||
if (keycode >= KC_A && keycode <= KC_SLASH) {
|
||||
keycode -= KC_A;
|
||||
return shifted ? pgm_read_byte(&shifted_keycode_to_ascii_lut[keycode]) :
|
||||
pgm_read_byte(&unshifted_keycode_to_ascii_lut[keycode]);
|
||||
}
|
||||
return ' ';
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
#define KC_MAGIC_0 0x0100
|
||||
|
||||
char keycode_to_char(uint16_t code);
|
||||
Loading…
Add table
Add a link
Reference in a new issue