diff --git a/README.md b/README.md index 273b0637..8f8c4487 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ It is possible to write timed macros into the center column: - `k(1).k(2)` 1, 2 - `r(3, k(a).w(500))` a, a, a with 500ms pause - `m(Control_L, k(a).k(x))` CTRL + a, CTRL + x +- `h(k(1))` writes ones while the key is pressed down Documentation: - `r` repeats the execution of the second parameter @@ -31,7 +32,8 @@ Documentation: - `h` executes the parameter as long as the key is pressed down - `.` executes two actions behind each other -Syntax errors are logged to the console. +Syntax errors are logged to the console. each `k` function adds a short delay +of 10ms that can be configured in `~/.config/key-mapper/config`. ##### Names diff --git a/keymapper/dev/keycode_mapper.py b/keymapper/dev/keycode_mapper.py index c3f51e09..2a67a0b6 100644 --- a/keymapper/dev/keycode_mapper.py +++ b/keymapper/dev/keycode_mapper.py @@ -90,6 +90,15 @@ def handle_keycode(code_to_code, macros, event, uinput): # only key-down events trigger macros return + existing_macro = active_macros.get(input_keycode) + if existing_macro is not None: + # make sure that a duplicate key-down event won't make a + # macro with a hold function run forever. there should always + # be only one active. + # TODO test, throw in a ton of key-down events and one key up + # event and check that no macro is writing stuff + existing_macro.release_key() + macro = macros[input_keycode] active_macros[input_keycode] = macro # TODO test that holding is true