houmain / keymapper

A cross-platform context-aware key remapper.
GNU General Public License v3.0
257 stars 21 forks source link

Restart of keymapper on a terminal repeats enter key several times (Linux) #101

Closed ristomatti closed 5 months ago

ristomatti commented 5 months ago

I've been monitoring the syslog in hopes to help solve #41 or #99. I wonder if this is to be expected:

$ journalctl --boot --system | grep -i Keymapper | grep kernel | head -n 3
Jan 12 02:13:30 x1e kernel: input: Keymapper as /devices/virtual/input/input30
Jan 12 20:15:19 x1e kernel: input: Keymapper as /devices/virtual/input/input62
Jan 12 20:16:04 x1e kernel: input: Keymapper as /devices/virtual/input/input63

$ journalctl --boot --system | grep -i Keymapper | grep kernel | tail -n 3
Jan 17 23:48:02 x1e kernel: input: Keymapper as /devices/virtual/input/input502
Jan 17 23:51:05 x1e kernel: input: Keymapper as /devices/virtual/input/input503
Jan 17 23:53:26 x1e kernel: input: Keymapper as /devices/virtual/input/input504

$ journalctl --boot --system | grep -i Keymapper | grep kernel | wc -l
109

I believe as a side effect of this, every time I restart keymapperd on a terminal this occurs:

$ sudo systemctl restart keymapperd

$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $

If I now check:

$ journalctl --boot --system | grep -i Keymapper | grep kernel | wc -l
111

Pasted to an editor and with each $ replaced with a new line, it results in 99 new lines. As this to be expected? Surely the scenario is somewhat unusual. I've restarted it quite a few times just to make sure a change to my config has been properly applied.

Correction: It's actually every restart of keymapper when keymapperd is running.

ristomatti commented 5 months ago

In case someone knows a way to unregister these without rebooting, I'd be happy to hear it. Reboot would be something I'd like to avoid just now.

houmain commented 5 months ago

Hi, thanks for your investigations and thorough reports! I checked this and I think that this is not an issue. I could not find it in the documentation or the source but Linux does not seem to reuse the uinput device IDs but simply increment them. They are not piling up in '/sys/devices/virtual/input/' so I think they are properly released. Even though I do not think that it caused problems, I improved keymapperds signal handling and shutdown sequence.

houmain commented 5 months ago

I believe as a side effect of this, every time I restart keymapperd on a terminal this occurs:

This should be fixed now. Now it releases all still pressed keys before it shuts down (the Return key you hit after sudo systemctl restart keymapperd).

ristomatti commented 5 months ago

I could not find it in the documentation or the source but Linux does not seem to reuse the uinput device IDs but simply increment them. They are not piling up in '/sys/devices/virtual/input/' so I think they are properly released.

Yep that seems to be the case. I just observed similar behavior when testing evemu-record and evemu-play I found out about by accident from apropos output. Playing back a recording creates a new input device every time.

This should be fixed now. Now it releases all still pressed keys before it shuts down (the Return key you hit after sudo systemctl restart keymapperd).

Thanks! I'll try to find time to test it tomorrow. I've also updated the issue title to describe the actual bug found. I have to say this was a classic example of how seemingly related observations in fact weren't. A bit of a disappointment it was not related to #99. The issue is a constant source of frustration. I've tried redoing/rearranging the config around the affected parts several times the last few days in hopes it's just an error on my side.

ristomatti commented 5 months ago

No more repeated key presses on restart. Great work!

houmain commented 5 months ago

A bit of a disappointment it was not related to https://github.com/houmain/keymapper/issues/99. The issue is a constant source of frustration.

Sorry, I did not get to trying it out yet. Hopefully this weekend!