2026-11-08 14:46:04 +01:00
|
|
|
#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,
|
2026-11-08 16:18:48 +01:00
|
|
|
ACTION_SELECT_BEACON,
|
|
|
|
|
ACTION_SELECT_BOAT,
|
|
|
|
|
ACTION_SELECT_TUB,
|
|
|
|
|
ACTION_SELECT_BEEHIVE,
|
|
|
|
|
ACTION_SELECT_RPENTOMINO,
|
|
|
|
|
ACTION_SELECT_ACORN,
|
2026-11-08 14:46:04 +01:00
|
|
|
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
|