Clear oneshot after macro execution

master
Raheman Vaiya 4 years ago
parent dc46ddecc2
commit 0dd39a3606
  1. 22
      src/keyboard.c
  2. 22
      t/oneshot10.t
  3. 4
      t/run.sh
  4. 1
      t/test.conf

@ -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) int kbd_execute_expression(struct keyboard *kbd, const char *exp)
@ -313,7 +312,7 @@ static long get_time_ms()
/* /*
* Here be tiny dragons. * 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 * 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 * 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); kbd_process_keyseq(kbd, verbatim, &d.args[0].sequence, pressed);
if (pressed) { if (!pressed)
oneshot_latch = 0;
kbd_clear_oneshots(kbd);
} else
kbd_reify_mods(kbd); kbd_reify_mods(kbd);
break; break;
@ -494,8 +490,10 @@ long kbd_process_key_event(struct keyboard *kbd,
kbd_execute_macro(kbd, macro); kbd_execute_macro(kbd, macro);
timeout = MACRO_REPEAT_TIMEOUT; timeout = MACRO_REPEAT_TIMEOUT;
} else } else {
kbd_reify_mods(kbd);
active_macro = NULL; active_macro = NULL;
}
break; break;
default: default:
@ -506,5 +504,15 @@ long kbd_process_key_event(struct keyboard *kbd,
if (pressed) if (pressed)
last_pressed_keycode = code; 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; return timeout;
} }

@ -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 down
o up o up
l up n down
a down n up
a up x down
x up
control down
control up
b down
b up

@ -17,9 +17,9 @@ cd "$(dirname $0)"
sudo cp test.conf /etc/keyd sudo cp test.conf /etc/keyd
sudo pkill keyd sudo pkill keyd
sleep .5s sleep 1s
sudo ../bin/keyd -d || exit sudo ../bin/keyd -d || exit
sleep 2s sleep 4s
if [ $# -ne 0 ]; then if [ $# -ne 0 ]; then
test_files="$(echo "$@"|sed -e 's/ /.t /g').t" test_files="$(echo "$@"|sed -e 's/ /.t /g').t"

@ -96,6 +96,7 @@ a = b
t = toggle(customshift) t = toggle(customshift)
b = a b = a
x = macro(o n)
[capslock:C] [capslock:C]
alt = layer(target) alt = layer(target)

Loading…
Cancel
Save