feat: implement keyboard and mouse input, pattern placement, and HiDPI scaling

Add configurable key bindings (TOML), modifier-aware dispatch, mouse-driven
pattern placement with preview and rotation, cell grid storage/rendering,
and fractional/integer HiDPI scaling. Archive the input-and-placement change
and sync its specs to main specs.

Tests: Hashtable, Config, Grid, Pattern (4/4 pass).
This commit is contained in:
2026-11-08 14:46:04 +01:00
parent 5e7abfb56b
commit 7874a5f7c6
31 changed files with 4081 additions and 96 deletions
+59
View File
@@ -0,0 +1,59 @@
#ifndef CONFIG_H
#define CONFIG_H
#include <stdint.h>
#include <xkbcommon/xkbcommon.h>
#define MOD_CTRL (1u << 0)
#define MOD_SHIFT (1u << 1)
#define MOD_ALT (1u << 2)
#define MOD_SUPER (1u << 3)
typedef enum {
ACTION_NONE = 0,
ACTION_QUIT,
ACTION_CANCEL,
ACTION_ROTATE,
ACTION_SELECT_GLIDER,
ACTION_SELECT_BLINKER,
ACTION_SELECT_BLOCK,
ACTION_SELECT_TOAD,
ACTION_CLEAR,
ACTION_PAUSE,
ACTION_STEP,
ACTION_SPEED_UP,
ACTION_SPEED_DOWN,
ACTION_TOGGLE_GRID,
} action_t;
typedef struct {
uint32_t mods;
xkb_keysym_t keysym;
action_t action;
} binding_t;
typedef struct {
binding_t *items;
int count;
int capacity;
} config_t;
/* Built-in defaults. */
config_t config_defaults(void);
/* Ensure config file exists; create with defaults if missing. Returns 0 on success. */
int config_ensure_default_file(const char *path);
/* Load config from path, merging over defaults. */
config_t config_load(const char *path);
void config_free(config_t *cfg);
/* Lookup action for a key press. Returns ACTION_NONE if no binding. */
action_t config_lookup(const config_t *cfg, uint32_t mods, xkb_keysym_t keysym);
/* Helpers exposed for tests. */
int config_parse_mods(const char *s, uint32_t *out_mods, char **out_key);
action_t config_parse_action(const char *s);
#endif