Skip to content

[WIP] Add C API shared library (dasher.h / CAPI.cpp)#11

Open
willwade wants to merge 71 commits into
mainfrom
feature-CAPI
Open

[WIP] Add C API shared library (dasher.h / CAPI.cpp)#11
willwade wants to merge 71 commits into
mainfrom
feature-CAPI

Conversation

@willwade

Copy link
Copy Markdown

Expose DasherCore as a flat C shared library for cross-platform FFI. Includes command-buffer screen, pointer input, settings, and output text access. Builds as dasher.dll / libdasher.so via BUILD_CAPI cmake option.

Note - GLM 5.5 did a lot of this.. it definitely needs reviewing.. my c++ skills are very poor..

willwade added 30 commits May 19, 2026 17:30
Expose DasherCore as a flat C shared library for cross-platform FFI.
Includes command-buffer screen, pointer input, settings, and output text
access. Builds as dasher.dll / libdasher.so via BUILD_CAPI cmake option.
 Added set_target_properties(DasherCore PROPERTIES POSITION_INDEPENDENT_CODE ON) to make sure  the static library is compiled with -fPIC so it can be linked into a shared library. should pass gh action build now
..that make working with ARGB   colors much easier for frontends
Use %f instead of Windows-specific %I64Ld format specifier for double values in function timing output. compiles nicely on all platforms
- ColorIO: ParseLegacy() handles old <colours>/<palette>/<colour> format
- ColorIO: maps positional colour indices to named groups used by alphabets
- CAPI: colorToARGB detects Color{0,0,0,1} (0-1 range) and scales to 0-255
- DasherInterfaceBase: also scan colour.*.xml (British spelling)
Accepts key codes (0=Start/Stop, 1-4=Buttons, 100=Primary, 101=Secondary,
102=Tertiary) and pressed state. The active DasherCore input filter handles
interpretation — works with DefaultFilter, OneButtonDynamic, TwoButtonDynamic,
ClickFilter etc.
New C API functions:
- dasher_get_parameter_count/info: introspect all engine parameters
- dasher_get_parameter_enum_count/name/value: enum dropdown values
- dasher_get_parameter_string_values: alphabet/palette/filter lists
- dasher_get_palette_count/name/preview_colors: colour theme enumeration
- dasher_set_palette: change colour theme
- dasher_get_alphabet_count/name: alphabet enumeration
- dasher_save_settings: persist settings to XML
Added const char* group to dasher_parameter_info. Groups: "Input", "Language", "Appearance", "Speed", "Output", "Advanced", "Other". The mapping is a switch in CAPI.cpp's parameterGroup() function.
 User directory separation — dasher_create now takes (data_dir, user_dir, out_error):
   - data_dir = read-only bundled data (alphabets, colours, training)
   - user_dir = writable directory for settings (NULL = use data_dir)
   - out_error = if not NULL, receives error message on failure
 Error reporting — Exceptions during creation are caught and the message is returned via out_error (including e.what() from std::exception).
 Current palette accessor — dasher_get_current_palette(ctx) returns the active palette name.
Add settings_manifest.json and a Python generator (Scripts/generate_parameters.py) that emits src/DasherCore/Parameters.cpp. The generator reads the manifest and handles bool/long/string defaults, enum values, ranged parameters, UI types, persistence and platform-specific overrides, and writes an AUTOGENERATED header; Parameters.cpp was updated/regenerated accordingly.
Add CMake logic to generate src/DasherCore/Parameters.cpp from settings_manifest.json using Scripts/generate_parameters.py. The change defines manifest/generator/output paths, locates a Python3 interpreter, and adds an add_custom_command to run the generator (with DEPENDS and WORKING_DIRECTORY). If Python3 is not found a warning guides developers to run the script manually.
Not sure i really like this. But I think better we do as much i10n in this repo than in downstream ones. It means all dasher's become standardised.
…witch; add group field to Parameter_Value; update codegen to emit group
willwade added 30 commits June 8, 2026 11:27
The rewritten GetSymbols had a bug where into.back() was called on an empty
vector. Restored the correct logic from the MIT version that properly handles
empty vectors and space compression.
Guards GetText, GetDisplayText, GetSymbolFixedProbability,
GetSymbolSpeedMultiplier, getColorGroupOffset, getColorGroup
against invalid symbol indices (0 or out of range).
The space symbol in alphabet XML uses label='□' with unicode='32' attribute,
but AlphIO only read the label as Text, so spaces mapped to '□' not ' '.
Now reads unicode attribute to set the correct output character.
When entering game mode mid-session, the existing rendered tree has no
NF_GAME flags. Force SetOffset to rebuild the root with NF_GAME, which
triggers HandleNodePopulated and propagates the game path to children.
… subscribes

The constructor set m_pView=pView in the initializer list, then called
HandleViewChange(pView) which returned early because m_pView==pView.
This meant the game module never subscribed to OnGameNodeDraw, so the
arrow coordinates were never updated.
- New LMRegistry singleton with LMDescriptor struct
- Built-in LMs (PPM, Word, Mixture, CTW) self-register at static init
- AlphabetManager::CreateLanguageModel() now uses registry instead of switch
- CAPI: dasher_get_language_model_count/id_at/name/description
- Full documentation in docs/LM_REGISTRY.md
- Each LMDescriptor now lists its relevant parameter keys
- PPM: alpha, beta, max_order, exclusion, update_exclusion
- Word: word_alpha, max_order
- Mixture: all PPM params + mixture + word_alpha
- CTW: max_order
- CAPI: dasher_get_language_model_param_count/key, dasher_find_parameter_key
- Frontends can now filter Language settings to show only relevant params
…ers.cpp

- generate_parameters.py now reads tier field and maps expert/advanced to true
- Mark SP_ALPHABET_ID as tier: expert (rendered as custom picker in frontend)
- Alphabet history params (SP_ALPHABET_1-4) already tier: expert
- Advanced params are hidden from Language section by frontend
…tered

When a dasher_message_callback is set via dasher_set_message_callback(),
messages are now delivered only to the callback and NOT rendered as
yellow/white text on the canvas. This prevents double-display of
warnings (native alert + canvas text) on frontends that handle messages
in their own UI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant