diff options
| author | Lena <lena@omega> | 2026-01-01 00:00:00 +0000 |
|---|---|---|
| committer | Lena <lena@omega> | 2026-01-01 00:00:00 +0000 |
| commit | 2fa72ee0dc67d973330aec4ba98260e9f57f7821 (patch) | |
| tree | e6a25c07c8da61d29e4e1f8a72436565e63c5777 /config.h | |
| download | mouseboard-0.1.tar.gz | |
Keyboard-only pointing: a labelled grid over every monitor, type a
label to jump to a cell, bisect it by quadrant until the crosshair is
exact, then one key clicks. The coarse grid keeps labels short and
bisection keeps precision unlimited, so a hotkey and a few keystrokes
replace the mouse.
The core talks only to the backend interface in platform.h; wlroots
Wayland and Win32 backends supply the overlay, keyboard grab and
pointer.
Diffstat (limited to 'config.h')
| -rw-r--r-- | config.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/config.h b/config.h new file mode 100644 index 0000000..efbd74f --- /dev/null +++ b/config.h @@ -0,0 +1,60 @@ +/* + * config.h - configuration: defaults, file parsing, and CLI overrides all flow + * through config_set(), so the file and the command line share one vocabulary. + * + * Colours are stored 0xAARRGGBB and written in the config as #RRGGBB or + * #RRGGBBAA. Key bindings are single ASCII characters; cancel (Esc) and undo + * (Backspace) are fixed. + */ +#ifndef MOUSEBOARD_CONFIG_H +#define MOUSEBOARD_CONFIG_H + +#include <stdint.h> + +#define MB_MAX_GRID_DIM 200 +#define MB_MAX_FONT_SCALE 64 + +struct config { + char alphabet[64]; /* label characters, most-preferred first */ + int cell_size; /* target coarse-cell size in px (if cols/rows 0) */ + int cols, rows; /* explicit grid; 0 means derive from cell_size */ + int font_scale; /* label scale; 0 means auto-fit per cell */ + + int opacity_bg; /* backdrop opacity 0..100 (100 = solid) */ + int opacity_fg; /* labels/grid/crosshair opacity 0..100 */ + uint32_t color_bg; /* full-screen backdrop */ + uint32_t color_grid; /* grid lines */ + uint32_t color_label; /* label glyphs */ + uint32_t color_typed; /* already-typed portion of a label */ + uint32_t color_active; /* refine box and crosshair */ + + char k_tl, k_tr, k_bl, k_br; /* refine: keep TL/TR/BL/BR quadrant */ + char k_left, k_middle, k_right; /* click buttons */ + char k_double, k_drag; /* double-click; start/finish drag */ +}; + +void config_defaults(struct config *c); + +/* Apply one "key value" pair. Returns 0 on success, -1 unknown key, + * -2 bad value. */ +int config_set(struct config *c, const char *key, const char *val); + +/* Return NULL if the complete configuration is usable, otherwise a short + * diagnostic. Call after file and command-line overrides have been applied. */ +const char *config_validate(const struct config *c); + +/* Scale color_bg's alpha by opacity_bg/100 and the other colours' by + * opacity_fg/100. Call exactly once, after all file and command-line + * overrides. The default colours carry full alpha, so 100 means solid. */ +void config_apply_opacity(struct config *c); + +/* Parse a config file. Returns 0 on success, -1 if it does not exist (not an + * error), -2 on a parse error (message printed to stderr). */ +int config_load_file(struct config *c, const char *path); + +/* Default config path: $XDG_CONFIG_HOME/mouseboard/config, falling back to + * %APPDATA%/mouseboard/config (Windows), then ~/.config/mouseboard/config. + * Static buffer. */ +const char *config_default_path(void); + +#endif /* MOUSEBOARD_CONFIG_H */ |