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:
+19
-1
@@ -8,6 +8,7 @@
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
|
||||
#include <tkeyboard.h>
|
||||
#include <config.h>
|
||||
|
||||
static void keyboard_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int32_t fd, uint32_t size)
|
||||
{
|
||||
@@ -61,9 +62,26 @@ static void keyboard_key(void *data, struct wl_keyboard *keyboard, uint32_t seri
|
||||
|
||||
printf("keyboard_key: scancode=%d state=%d keysym=%u\n", key, state, sym);
|
||||
|
||||
uint32_t mods = 0;
|
||||
if (kbd->xkb_state != NULL && kbd->xkb_keymap != NULL)
|
||||
{
|
||||
xkb_mod_index_t ci = xkb_keymap_mod_get_index(kbd->xkb_keymap, "Control");
|
||||
if (ci != XKB_MOD_INVALID && xkb_state_mod_index_is_active(kbd->xkb_state, ci, XKB_STATE_MODS_EFFECTIVE))
|
||||
mods |= MOD_CTRL;
|
||||
xkb_mod_index_t si = xkb_keymap_mod_get_index(kbd->xkb_keymap, "Shift");
|
||||
if (si != XKB_MOD_INVALID && xkb_state_mod_index_is_active(kbd->xkb_state, si, XKB_STATE_MODS_EFFECTIVE))
|
||||
mods |= MOD_SHIFT;
|
||||
xkb_mod_index_t ai = xkb_keymap_mod_get_index(kbd->xkb_keymap, "Mod1");
|
||||
if (ai != XKB_MOD_INVALID && xkb_state_mod_index_is_active(kbd->xkb_state, ai, XKB_STATE_MODS_EFFECTIVE))
|
||||
mods |= MOD_ALT;
|
||||
xkb_mod_index_t sui = xkb_keymap_mod_get_index(kbd->xkb_keymap, "Mod4");
|
||||
if (sui != XKB_MOD_INVALID && xkb_state_mod_index_is_active(kbd->xkb_state, sui, XKB_STATE_MODS_EFFECTIVE))
|
||||
mods |= MOD_SUPER;
|
||||
}
|
||||
|
||||
if (kbd->handler != NULL)
|
||||
{
|
||||
kbd->handler(key, state, sym, kbd->user_data);
|
||||
kbd->handler(key, state, sym, mods, kbd->user_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user