diff --git a/src/keyboard.c b/src/keyboard.c index 184ee18..5455dc5 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -288,7 +288,6 @@ static void kbd_execute_macro(struct keyboard *kbd, } } - kbd_reify_mods(kbd); } int kbd_execute_expression(struct keyboard *kbd, const char *exp) @@ -313,7 +312,7 @@ static long get_time_ms() /* * Here be tiny dragons. * - * Code may be 0 in the event of a timeout. + * `code` may be 0 in the event of a timeout. * * The return value corresponds to a timeout before which the next invocation * of kbd_process_key_event must take place. A return value of 0 permits the @@ -382,10 +381,7 @@ long kbd_process_key_event(struct keyboard *kbd, kbd_process_keyseq(kbd, verbatim, &d.args[0].sequence, pressed); - if (pressed) { - oneshot_latch = 0; - kbd_clear_oneshots(kbd); - } else + if (!pressed) kbd_reify_mods(kbd); break; @@ -494,8 +490,10 @@ long kbd_process_key_event(struct keyboard *kbd, kbd_execute_macro(kbd, macro); timeout = MACRO_REPEAT_TIMEOUT; - } else + } else { + kbd_reify_mods(kbd); active_macro = NULL; + } break; default: @@ -506,5 +504,15 @@ long kbd_process_key_event(struct keyboard *kbd, if (pressed) last_pressed_keycode = code; + if (!d.op || + (pressed && + (d.op == OP_KEYSEQ || + d.op == OP_MACRO || + d.op == OP_OVERLOAD))) { + oneshot_latch = 0; + kbd_clear_oneshots(kbd); + } + + return timeout; } diff --git a/t/oneshot10.t b/t/oneshot10.t index 812504c..c42f3d3 100644 --- a/t/oneshot10.t +++ b/t/oneshot10.t @@ -1,11 +1,15 @@ -l down +2 down +2 up +x down +x up +x down +x up + +shift down +shift up o down o up -l up -a down -a up - -control down -control up -b down -b up +n down +n up +x down +x up diff --git a/t/run.sh b/t/run.sh index cb1f958..8c4e3b4 100755 --- a/t/run.sh +++ b/t/run.sh @@ -17,9 +17,9 @@ cd "$(dirname $0)" sudo cp test.conf /etc/keyd sudo pkill keyd -sleep .5s +sleep 1s sudo ../bin/keyd -d || exit -sleep 2s +sleep 4s if [ $# -ne 0 ]; then test_files="$(echo "$@"|sed -e 's/ /.t /g').t" diff --git a/t/test.conf b/t/test.conf index b01133d..93ed81a 100644 --- a/t/test.conf +++ b/t/test.conf @@ -96,6 +96,7 @@ a = b t = toggle(customshift) b = a +x = macro(o n) [capslock:C] alt = layer(target)