From a830187f55abdc03bc56b3029dae8befb0d3b7b7 Mon Sep 17 00:00:00 2001 From: Raheman Vaiya Date: Wed, 19 Jul 2023 20:08:11 -0400 Subject: [PATCH] overload: Fix hold behaviour for keys bound to the overloaded key (#534) --- src/keyboard.c | 11 ++++++----- t/overload-same-key.t | 9 +++++++++ t/test.conf | 2 ++ 3 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 t/overload-same-key.t diff --git a/src/keyboard.c b/src/keyboard.c index 2f39d8d..4af48f5 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -496,9 +496,10 @@ static long process_descriptor(struct keyboard *kbd, uint8_t code, struct macro *macro; struct descriptor *action; uint8_t mods; + uint8_t new_code; case OP_KEYSEQUENCE: - code = d->args[0].code; + new_code = d->args[0].code; mods = d->args[1].mods; if (pressed) { @@ -507,15 +508,15 @@ static long process_descriptor(struct keyboard *kbd, uint8_t code, * to be actuated next to each other * E.G [/{ */ - if (kbd->keystate[code]) - send_key(kbd, code, 0); + if (kbd->keystate[new_code]) + send_key(kbd, new_code, 0); update_mods(kbd, dl, mods); - send_key(kbd, code, 1); + send_key(kbd, new_code, 1); clear_oneshot(kbd); } else { - send_key(kbd, code, 0); + send_key(kbd, new_code, 0); update_mods(kbd, -1, 0); } diff --git a/t/overload-same-key.t b/t/overload-same-key.t new file mode 100644 index 0000000..6aa6c5a --- /dev/null +++ b/t/overload-same-key.t @@ -0,0 +1,9 @@ +z down +/ down +/ up +z up + +control down +z down +z up +control up diff --git a/t/test.conf b/t/test.conf index a8ed1e8..03bd453 100644 --- a/t/test.conf +++ b/t/test.conf @@ -43,6 +43,8 @@ o = overloadt(control, a, 10) = = timeout(a, 300, b) \ = 😄 [ = togglem(control, macro(one)) +z = overload(control, enter) +/ = z [altgr]