Skip to content

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

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

[WIP] Add C API shared library (dasher.h / CAPI.cpp)#11
willwade wants to merge 36 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
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