zsugabubus / interception-k2k

Configurable plugin for Interception Tools (caps2esc, space2meta, tab2altgr...)
GNU General Public License v3.0
53 stars 11 forks source link

broken configuration for multitple keyboards #3

Closed brabalan closed 4 years ago

brabalan commented 4 years ago

I have the following configuration:

- JOB: "intercept -g $DEVNODE | /opt/interception/interception-ergo | uinput -d $DEVNODE"
  DEVICE:
    NAME: "TrulyErgonomic.com Truly Ergonomic Computer Keyboard"
    EVENTS:
      EV_KEY: [KEY_CAPSLOCK, KEY_ESC]
- JOB: "intercept -g $DEVNODE | /opt/interception/interception-dell | uinput -d $DEVNODE"
  DEVICE:
    NAME: "AT Translated Set 2 keyboard"
    EVENTS:
      EV_KEY: [KEY_CAPSLOCK, KEY_ESC]

with the following tap-rules.h.in for dell

{ .base_key = KEY_CAPSLOCK, .tap_key = KEY_ESC, .repeat_key = KEY_LEFTCTRL, .hold_key = KEY_LEFTCTRL },
{ .base_key = KEY_APOSTROPHE, .tap_key = KEY_APOSTROPHE, .repeat_key = KEY_RIGHTCTRL, .hold_key = KEY_APOSTROPHE },

and for the ergo external keyboard

{ .base_key = KEY_CAPSLOCK, .tap_key = KEY_ESC, .repeat_key = KEY_LEFTCTRL, .hold_key = KEY_LEFTCTRL },
{ .base_key = KEY_RIGHTCTRL, .tap_key = KEY_APOSTROPHE, .repeat_key = KEY_APOSTROPHE, .hold_key = KEY_RIGHTCTRL },

Everything works with the internal dell keyboard, but it does not with the ergo one: I get an unconditional ESC on the caps lock key, and ' on the right control key (even when holding the key). Did something change when you introduced the tapping rules?

zsugabubus commented 4 years ago

That's strange because CapsLock has the same config.

Can you confirm the behavior with evtest? Also debug messages would be helpful, so could compile using make test and send the output?

brabalan commented 4 years ago

I cannot run evtest, it tells me This device is grabbed by another process.

If I run make test, I get this:

➜ sudo make test
CFLAGS=-DVERBOSE make
make[1]: Entering directory '/home/schmitta/src/interception-k2k'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/schmitta/src/interception-k2k'
make install
make[1]: Entering directory '/home/schmitta/src/interception-k2k'
# If you have run `make test` then do not forget to run `make clean` after. Otherwise you may install with debug logs on.
install -D --strip -t /opt/interception out/interception-pipe0 out/interception-ergo out/interception-pipe1 out/interception-dell
make[1]: Leaving directory '/home/schmitta/src/interception-k2k'
timeout 10 udevmon -c /etc/udevmon.yaml
make: *** [Makefile:35: test] Error 124

Hitting any key while it's waiting just display it. I guess I'm doing it wrong…

zsugabubus commented 4 years ago

I cannot run evtest, it tells me This device is grabbed by another process.

Yes, this is how interception-tools supposed to work. It grabs the input, so it has exclusive access to it. Then it reads the device and transforms the input with the help of plugins (like interception-k2k). In order to make it working, it also creates a new keyboard device that will emit the final result.

So you have to start evtest after udevmon and select the new device (Will be the last entry probably).

Hitting any key while it's waiting just display it. I guess I'm doing it wrong…

You have to run something like sudo env CONFIG_DIR=yourconfig make test. You need sudo, because it runs make install internally and starts udevmon with a timeout. (It helps me test if everything works and kills udevmon if I have messed things up. You can change timeout with sudo env TIMEOUT=30 ...)

Please check out master.

brabalan commented 4 years ago

I managed to test using evtest, and with the exception of one try (the first one), I have the same behavior (holding caps gives me repeated esc).

I had to reboot and I discovered that the interception works for a short while, and then it no longer works.

I am able to run the make test. My observations are that the problem happens as soon as I hold RIGHT_CONTROL. Until then, caps works as intended (esc or ctrl), and as soon as I hold RIGHT_CONTROL, caps only generates escape:

timeout 30 udevmon -c /etc/udevmon.yaml
Tap rule #1: Armed.
Tap rule #1: Tapped.
Tap rule #1: Up.
Typing: Yes.
'Typing: No; elapsed: 1964 ms.
Tap rule #0: Armed.
Tap rule #0: Repeated.
^CTyping: Yes.
Tap rule #0: Up.
Typing: No; elapsed: 931 ms.
Tap rule #0: Armed.
Tap rule #0: Repeated.
^CTyping: Yes.
Tap rule #0: Up.
Typing: No; elapsed: 1208 ms.
Tap rule #1: Armed.
Tap rule #1: Repeated.
''''''''''Tap rule #1: Up.
Typing: Yes.
Typing: No; elapsed: 712 ms.
Tap rule #0: Tapped immediately.
^[^[^[^[^[^[^[^[^[^[Tap rule #0: Up.
zsugabubus commented 4 years ago

My observations are that the problem happens as soon as I hold RIGHT_CONTROL. Until then, caps works as intended (esc or ctrl), and as soon as I hold RIGHT_CONTROL, caps only generates escape

What do you think what CapsLock should do in this case? Would it be beneficial to generate a L-Ctrl?

Because a Ctrl is already down (R-Ctrl) the tap rule thinks that it makes no sense to press that key again (L-Ctrl), so it instead generates the tap key (Escape) ("Tapped immediately.").

This way you can do things like this:

https://github.com/zsugabubus/interception-k2k/blob/83b0f3b338e172e1ad6d499727eaf8a72b802064/default/interception-pipe0/tap-rules.h.in#L8-L9

(F -> F; J -> J; FJ -> Shift+J; JF -> Shift+F)

brabalan commented 4 years ago

What I mean is that as soon as I hold (a little bit, until it repeats) right ctrl and then release it, from that point on caps lock stops working (and I no longer touch right ctrl).

Can I have a tap rule that is right ctrl → apostrophe when tapped, and to right ctrl otherwise?

zsugabubus commented 4 years ago

Thanks for the report! Now it should work.

brabalan commented 4 years ago

Thanks, it's fixed indeed!