Fix: Plover + Lapwing are additive, not exclusive
Both CONFIG_ZMK_JAVELIN_STENO_DICT_PLOVER and DICT_LAPWING can be y. All enabled dicts downloaded + compiled into one binary. Javelin stacks them in StenoDictionaryList — user toggles at runtime. Dict priority at runtime (highest first): 1. User dict (add_translation, on-keyboard) 2. All built-in dicts (Plover, Lapwing, etc. from embedded binary) Upload dict (USB) not yet implemented — future enhancement.
This commit is contained in:
parent
0f0861ffd4
commit
32f1812709
2 changed files with 31 additions and 36 deletions
|
|
@ -250,9 +250,14 @@ print(f'Stripped test blocks from {count} files')
|
||||||
)
|
)
|
||||||
|
|
||||||
# --- Dictionary binary embedding ---
|
# --- Dictionary binary embedding ---
|
||||||
# Priority: 1) JAVELIN_DICT_BIN cmake var
|
# Plover and Lapwing are additive — both can be enabled.
|
||||||
|
# All enabled dicts get compiled into one binary. Javelin's
|
||||||
|
# StenoDictionaryList stacks them (first in list = highest priority).
|
||||||
|
# User dict (add_translation) is always on top at runtime.
|
||||||
|
#
|
||||||
|
# Priority: 1) JAVELIN_DICT_BIN cmake var (skip auto-download)
|
||||||
# 2) pre-compiled dicts/steno_dict.bin
|
# 2) pre-compiled dicts/steno_dict.bin
|
||||||
# 3) auto-download based on Kconfig choice (Plover/Lapwing)
|
# 3) auto-download enabled dicts + compile
|
||||||
# 4) null placeholder (engine won't start)
|
# 4) null placeholder (engine won't start)
|
||||||
|
|
||||||
set(DICT_DIR "${CMAKE_CURRENT_LIST_DIR}/dicts")
|
set(DICT_DIR "${CMAKE_CURRENT_LIST_DIR}/dicts")
|
||||||
|
|
@ -260,36 +265,33 @@ print(f'Stripped test blocks from {count} files')
|
||||||
set(COMPILER "${CMAKE_CURRENT_LIST_DIR}/tools/dict_compiler/compile_dict.py")
|
set(COMPILER "${CMAKE_CURRENT_LIST_DIR}/tools/dict_compiler/compile_dict.py")
|
||||||
set(DICT_BIN "${DICT_DIR}/steno_dict.bin")
|
set(DICT_BIN "${DICT_DIR}/steno_dict.bin")
|
||||||
|
|
||||||
# Determine which dict to download based on Kconfig
|
# Collect all enabled dicts (additive)
|
||||||
|
set(DICT_URLS "")
|
||||||
|
set(DICT_NAMES "")
|
||||||
|
|
||||||
if(CONFIG_ZMK_JAVELIN_STENO_DICT_PLOVER)
|
if(CONFIG_ZMK_JAVELIN_STENO_DICT_PLOVER)
|
||||||
set(DICT_NAME "plover-main")
|
list(APPEND DICT_URLS
|
||||||
set(DICT_JSON "${DICT_SRC_DIR}/plover-main.json")
|
"https://raw.githubusercontent.com/openstenoproject/plover/main/plover/assets/main.json")
|
||||||
set(DICT_URLS
|
list(APPEND DICT_NAMES "plover-main")
|
||||||
"https://raw.githubusercontent.com/openstenoproject/plover/main/plover/assets/main.json"
|
endif()
|
||||||
)
|
|
||||||
set(DICT_NAMES "plover-main")
|
if(CONFIG_ZMK_JAVELIN_STENO_DICT_LAPWING)
|
||||||
elseif(CONFIG_ZMK_JAVELIN_STENO_DICT_LAPWING)
|
list(APPEND DICT_URLS
|
||||||
set(DICT_NAME "lapwing")
|
|
||||||
set(DICT_JSON "${DICT_SRC_DIR}/lapwing-base.json")
|
|
||||||
set(DICT_URLS
|
|
||||||
"https://raw.githubusercontent.com/aerickt/plover-lapwing-aio/main/plover_lapwing/dictionaries/lapwing-base.json"
|
"https://raw.githubusercontent.com/aerickt/plover-lapwing-aio/main/plover_lapwing/dictionaries/lapwing-base.json"
|
||||||
"https://raw.githubusercontent.com/aerickt/plover-lapwing-aio/main/plover_lapwing/dictionaries/lapwing-commands.json"
|
"https://raw.githubusercontent.com/aerickt/plover-lapwing-aio/main/plover_lapwing/dictionaries/lapwing-commands.json"
|
||||||
"https://raw.githubusercontent.com/aerickt/plover-lapwing-aio/main/plover_lapwing/dictionaries/lapwing-numbers.json"
|
"https://raw.githubusercontent.com/aerickt/plover-lapwing-aio/main/plover_lapwing/dictionaries/lapwing-numbers.json")
|
||||||
)
|
list(APPEND DICT_NAMES "lapwing-base" "lapwing-commands" "lapwing-numbers")
|
||||||
set(DICT_NAMES "lapwing-base" "lapwing-commands" "lapwing-numbers")
|
|
||||||
else()
|
|
||||||
set(DICT_NAME "none")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(DEFINED JAVELIN_DICT_BIN)
|
if(DEFINED JAVELIN_DICT_BIN)
|
||||||
set(DICT_BIN_PATH "${JAVELIN_DICT_BIN}")
|
set(DICT_BIN_PATH "${JAVELIN_DICT_BIN}")
|
||||||
elseif(EXISTS "${DICT_BIN}")
|
elseif(EXISTS "${DICT_BIN}")
|
||||||
set(DICT_BIN_PATH "${DICT_BIN}")
|
set(DICT_BIN_PATH "${DICT_BIN}")
|
||||||
elseif(NOT "${DICT_NAME}" STREQUAL "none")
|
elseif(DICT_URLS)
|
||||||
# Auto-download + compile
|
# Auto-download + compile all enabled dicts
|
||||||
file(MAKE_DIRECTORY "${DICT_SRC_DIR}")
|
file(MAKE_DIRECTORY "${DICT_SRC_DIR}")
|
||||||
set(DICT_JSONS "")
|
set(DICT_JSONS "")
|
||||||
set(DICT_COMPILE_NAMES "")
|
set(DICT_COMPILE_ARGS "")
|
||||||
list(LENGTH DICT_URLS DICT_COUNT)
|
list(LENGTH DICT_URLS DICT_COUNT)
|
||||||
math(EXPR DICT_LAST "${DICT_COUNT} - 1")
|
math(EXPR DICT_LAST "${DICT_COUNT} - 1")
|
||||||
|
|
||||||
|
|
@ -312,21 +314,21 @@ print(f'Stripped test blocks from {count} files')
|
||||||
|
|
||||||
if(EXISTS "${JSON_PATH}")
|
if(EXISTS "${JSON_PATH}")
|
||||||
list(APPEND DICT_JSONS "${JSON_PATH}")
|
list(APPEND DICT_JSONS "${JSON_PATH}")
|
||||||
list(APPEND DICT_COMPILE_NAMES "-n" "${NAME}")
|
list(APPEND DICT_COMPILE_ARGS "-n" "${NAME}")
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if(DICT_JSONS AND EXISTS "${COMPILER}")
|
if(DICT_JSONS AND EXISTS "${COMPILER}")
|
||||||
message(STATUS "Javelin steno: compiling ${DICT_NAME} dictionary...")
|
message(STATUS "Javelin steno: compiling ${DICT_COUNT} dict(s)...")
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND python3 "${COMPILER}" ${DICT_JSONS}
|
COMMAND python3 "${COMPILER}" ${DICT_JSONS}
|
||||||
${DICT_COMPILE_NAMES} -o "${DICT_BIN}"
|
${DICT_COMPILE_ARGS} -o "${DICT_BIN}"
|
||||||
RESULT_VARIABLE COMPILE_RC
|
RESULT_VARIABLE COMPILE_RC
|
||||||
ERROR_VARIABLE COMPILE_ERR
|
ERROR_VARIABLE COMPILE_ERR
|
||||||
)
|
)
|
||||||
if(COMPILE_RC EQUAL 0)
|
if(COMPILE_RC EQUAL 0)
|
||||||
set(DICT_BIN_PATH "${DICT_BIN}")
|
set(DICT_BIN_PATH "${DICT_BIN}")
|
||||||
message(STATUS "Javelin steno: ${DICT_NAME} dictionary compiled")
|
message(STATUS "Javelin steno: dictionary compiled")
|
||||||
else()
|
else()
|
||||||
message(WARNING "Javelin steno: compile failed: ${COMPILE_ERR}")
|
message(WARNING "Javelin steno: compile failed: ${COMPILE_ERR}")
|
||||||
set(DICT_BIN_PATH "")
|
set(DICT_BIN_PATH "")
|
||||||
|
|
|
||||||
15
Kconfig
15
Kconfig
|
|
@ -8,20 +8,13 @@ config ZMK_JAVELIN_STENO
|
||||||
|
|
||||||
if ZMK_JAVELIN_STENO
|
if ZMK_JAVELIN_STENO
|
||||||
|
|
||||||
choice ZMK_JAVELIN_STENO_DICT
|
|
||||||
prompt "Steno dictionary"
|
|
||||||
default ZMK_JAVELIN_STENO_DICT_PLOVER
|
|
||||||
|
|
||||||
config ZMK_JAVELIN_STENO_DICT_PLOVER
|
config ZMK_JAVELIN_STENO_DICT_PLOVER
|
||||||
bool "Plover (standard English)"
|
bool "Include Plover dictionary (standard English)"
|
||||||
|
default y
|
||||||
|
|
||||||
config ZMK_JAVELIN_STENO_DICT_LAPWING
|
config ZMK_JAVELIN_STENO_DICT_LAPWING
|
||||||
bool "Lapwing (modern, recommended for new learners)"
|
bool "Include Lapwing dictionary (modern, recommended for new learners)"
|
||||||
|
default n
|
||||||
config ZMK_JAVELIN_STENO_DICT_NONE
|
|
||||||
bool "None (upload via USB or provide custom binary)"
|
|
||||||
|
|
||||||
endchoice
|
|
||||||
|
|
||||||
endif # ZMK_JAVELIN_STENO
|
endif # ZMK_JAVELIN_STENO
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue