7 Commits

Author SHA1 Message Date
Maarten van Gompel
1a60d1abed version bump 2026-02-06 15:36:41 +01:00
Maarten van Gompel
49d8a629a5 fix: copy keys were broken with shift
A regression was introduced in b0eff37239
, leading to accented keys (accessed via Cmp) to only be available in
lower case, as shift had no effect there anymore. This should fix it.

Ref: https://github.com/jjsullivan5196/wvkbd/issues/115
2026-02-06 15:33:12 +01:00
Maarten van Gompel
9fb1964f5d version bump 2026-01-22 17:33:05 +01:00
Willow Barraco
5b29d8c1a7 Makefile: do not rebuild on install
Because the directory timestamp depends on the file insise, this rule
cause a second rebuild. Let's just silently create the directory
when we require it.

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2026-01-22 17:32:10 +01:00
Maarten van Gompel
987ea03f84 Makefile: fix in make clean 2026-01-22 10:31:18 +01:00
Maarten van Gompel
0c743d9518 version bump 2026-01-22 10:27:20 +01:00
Willow Barraco
1963de0165 Improve the makefile to simplify building multiple layouts
At the moment, packaging multiple layout is a bit of a mess, because
there is no easy way to build multiple layouts binary in a row. The
clean task also drop the binary outpus. And the dependency checking is
somehow incorrect. It reuses the same config.h while building the
following layout.

To solve this, we now build config.h and %.o outputs in a builddir,
one per layout.

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2026-01-22 10:26:42 +01:00
5 changed files with 37 additions and 21 deletions

6
.gitignore vendored
View File

@@ -5,8 +5,6 @@
include/config.h
.gdb_history
*.log
wvkbd
*.1
config.h
wvkbd-mobintl
wvkbd-deskintl
build-*/*
wvkbd-*

View File

@@ -1,5 +1,7 @@
include config.mk
BUILDDIR=build-${LAYOUT}
NAME=wvkbd
BIN=${NAME}-${LAYOUT}
SRC=.
@@ -9,6 +11,7 @@ PKGS = wayland-client xkbcommon pangocairo
WVKBD_SOURCES += $(wildcard $(SRC)/*.c)
WVKBD_HEADERS += $(wildcard $(SRC)/*.h)
WVKBD_DIR_SOURCES = $(foreach src, $(WVKBD_SOURCES), $(addprefix $(BUILDDIR)/, $(src)))
PKG_CONFIG ?= pkg-config
CFLAGS += -std=gnu99 -Wall -g -DWITH_WAYLAND_SHM -DLAYOUT=\"layout.${LAYOUT}.h\" -DKEYMAP=\"keymap.${LAYOUT}.h\"
@@ -20,16 +23,21 @@ WAYLAND_HEADERS = $(wildcard proto/*.xml)
HDRS = $(WAYLAND_HEADERS:.xml=-client-protocol.h)
WAYLAND_SRC = $(HDRS:.h=.c)
SOURCES = $(WVKBD_SOURCES) $(WAYLAND_SRC)
OBJECTS = $(WVKBD_DIR_SOURCES:.c=.o) $(WAYLAND_SRC:.c=.o)
SCDOC=scdoc
DOCS = wvkbd.1
OBJECTS = $(SOURCES:.c=.o)
all: ${BIN} ${DOCS}
config.h:
cp config.${LAYOUT}.h config.h
$(BUILDDIR)/config.h:
mkdir -p $(BUILDDIR)
cp config.$(LAYOUT).h $@
$(BUILDDIR)/%.o: %.c
mkdir -p $(BUILDDIR)
$(CC) -I $(CURDIR) -I $(CURDIR)/$(BUILDDIR) -c $(CFLAGS) -o $@ $<
proto/%-client-protocol.c: proto/%.xml
wayland-scanner code < $? > $@
@@ -39,11 +47,11 @@ proto/%-client-protocol.h: proto/%.xml
$(OBJECTS): $(HDRS) $(WVKBD_HEADERS)
wvkbd-${LAYOUT}: config.h $(OBJECTS) layout.${LAYOUT}.h
wvkbd-${LAYOUT}: $(BUILDDIR)/config.h $(OBJECTS) layout.${LAYOUT}.h
$(CC) -o wvkbd-${LAYOUT} $(OBJECTS) $(LDFLAGS)
clean:
rm -f $(OBJECTS) config.h $(HDRS) $(WAYLAND_SRC) ${BIN} ${DOCS}
rm -rf "$(BUILDDIR)" wvkbd-$(LAYOUT)
format:
clang-format -i $(WVKBD_SOURCES) $(WVKBD_HEADERS)

View File

@@ -1,4 +1,4 @@
VERSION = 0.19
VERSION = 0.19.3
CFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=700
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man

View File

@@ -38,7 +38,7 @@ kbd_switch_layout(struct kbd *kb, struct layout *l, size_t layer_index)
if ((!kb->prevlayout) ||
(strcmp(kb->prevlayout->keymap_name, kb->layout->keymap_name) != 0)) {
fprintf(stderr, "Switching to keymap %s\n", kb->layout->keymap_name);
create_and_upload_keymap(kb, kb->layout->keymap_name, 0, 0);
create_and_upload_keymap(kb, kb->layout->keymap_name, 0);
}
kbd_draw_layout(kb);
}
@@ -198,7 +198,7 @@ kbd_init(struct kbd *kb, struct layout *layouts, char *layer_names_list,
kb->last_abc_layout = &kb->layouts[layer];
/* upload keymap */
create_and_upload_keymap(kb, kb->layout->keymap_name, 0, 0);
create_and_upload_keymap(kb, kb->layout->keymap_name, 0);
}
void
@@ -304,9 +304,11 @@ kbd_unpress_key(struct kbd *kb, uint32_t time)
unlatch_altgr = (kb->mods & AltGr) == AltGr;
if (kb->last_press->type == Copy) {
if (kb->debug) fprintf(stderr, "release copy key (unlatch_shift=%d, mods=%d)\n", unlatch_shift, kb->mods);
zwp_virtual_keyboard_v1_key(kb->vkbd, time, 127, // COMP key
WL_KEYBOARD_KEY_STATE_RELEASED);
} else {
if (kb->debug) fprintf(stderr, "release key %d", kb->last_press->code);
if ((kb->shift_space_is_tab) && (kb->last_press->code == KEY_SPACE) && (unlatch_shift)) {
// shift + space is tab
unlatch_shift = false;
@@ -322,6 +324,7 @@ kbd_unpress_key(struct kbd *kb, uint32_t time)
}
if (unlatch_shift) {
if (kb->debug) fprintf(stderr, "unlatch shift");
kb->mods ^= Shift;
zwp_virtual_keyboard_v1_key_mods(kb->vkbd, time, Shift, WL_KEYBOARD_KEY_STATE_RELEASED);
}
@@ -460,8 +463,12 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time)
case Mod:
kb->mods ^= k->code;
if (kb->mods & k->code) {
if (kb->debug)
fprintf(stderr, "mod pressed\n");
zwp_virtual_keyboard_v1_key_mods(kb->vkbd, time, k->code, WL_KEYBOARD_KEY_STATE_PRESSED);
} else {
if (kb->debug)
fprintf(stderr, "mod released\n");
zwp_virtual_keyboard_v1_key_mods(kb->vkbd, time, k->code, WL_KEYBOARD_KEY_STATE_RELEASED);
}
if ((k->code == Shift) || (k->code == CapsLock)) {
@@ -523,10 +530,15 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time)
// copy code as unicode chr by setting a temporary keymap
kb->last_swipe = kb->last_press = k;
kbd_draw_key(kb, k, Press);
if (kb->debug)
fprintf(stderr, "pressing copy key\n");
create_and_upload_keymap(kb, kb->layout->keymap_name, k->code,
k->code_mod);
if (kb->mods & Shift) {
if (kb->debug)
fprintf(stderr, "Pressing copy key (with shift)\n");
create_and_upload_keymap(kb, kb->layout->keymap_name, k->code_mod
} else {
if (kb->debug)
fprintf(stderr, "Pressing copy key\n");
create_and_upload_keymap(kb, kb->layout->keymap_name, k->code);
}
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
zwp_virtual_keyboard_v1_key(kb->vkbd, time, 127, // COMP key
WL_KEYBOARD_KEY_STATE_PRESSED);
@@ -699,8 +711,7 @@ draw_over_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
}
void
create_and_upload_keymap(struct kbd *kb, const char *name, uint32_t comp_unichr,
uint32_t comp_shift_unichr)
create_and_upload_keymap(struct kbd *kb, const char *name, uint32_t comp_unichr)
{
int keymap_index = -1;
for (int i = 0; i < NUMKEYMAPS; i++) {
@@ -715,7 +726,7 @@ create_and_upload_keymap(struct kbd *kb, const char *name, uint32_t comp_unichr,
const char *keymap_template = keymaps[keymap_index];
size_t keymap_size = strlen(keymap_template) + 64;
char *keymap_str = malloc(keymap_size);
sprintf(keymap_str, keymap_template, comp_unichr, comp_shift_unichr);
sprintf(keymap_str, keymap_template, comp_unichr, comp_unichr);
keymap_size = strlen(keymap_str);
int keymap_fd = os_create_anonymous_file(keymap_size);
if (keymap_fd < 0) {

View File

@@ -148,8 +148,7 @@ double kbd_get_row_length(struct key *k);
void kbd_next_layer(struct kbd *kb, struct key *k, bool invert);
void kbd_switch_layout(struct kbd *kb, struct layout *l, size_t layer_index);
void create_and_upload_keymap(struct kbd *kb, const char *name,
uint32_t comp_unichr, uint32_t comp_shift_unichr);
void create_and_upload_keymap(struct kbd *kb, const char *name, uint32_t comp_unichr);
#ifndef LAYOUT
#error "make sure to define LAYOUT"