From ec423d0c01ca47fd80f07c26c414b7e7e1ae5f88 Mon Sep 17 00:00:00 2001 From: Raheman Vaiya Date: Tue, 30 Nov 2021 13:39:55 -0500 Subject: [PATCH] Fix overload bug. (Fixes #34) If an interposed key up event is detected after an overloaded key is pressed the overloaded key up event is not interpreted as a tap. This is especially noticeable in cases where the overloaded key is struck quickly in succession. This patch modifies the behaviour so only an interposed key down resolves the overloaded key in favour of its associated layer. --- Makefile | 2 +- src/main.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 31a2c70..6747de5 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ LOCK_FILE="/var/lock/keyd.lock" LOG_FILE="/var/log/keyd.log" CONFIG_DIR="/etc/keyd" -VERSION=1.3.0 +VERSION=1.3.1 GIT_HASH=$(shell git describe --no-match --always --abbrev=40 --dirty) CFLAGS=-DVERSION=\"$(VERSION)\" \ diff --git a/src/main.c b/src/main.c index 738275e..bebf366 100644 --- a/src/main.c +++ b/src/main.c @@ -465,6 +465,10 @@ static void process_key_event(struct keyboard *kbd, uint16_t code, int pressed) static uint8_t oneshot_layers[MAX_LAYERS] = {0}; static uint64_t last_keyseq_timestamp = 0; static uint16_t swapped_keycode = 0; + static uint16_t last_keydown = 0; + + if(pressed) + last_keydown = code; uint16_t mods = 0; @@ -488,7 +492,7 @@ static void process_key_event(struct keyboard *kbd, uint16_t code, int pressed) } else { layer->active = 0; - if(lastd == d) { //If tapped + if(last_keydown == code) { //If tapped uint16_t key = keyseq & 0xFFFF; mods |= keyseq >> 16;