Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xkeysnail captures all my input, but it doesn't work anywhere else #164

Open
UlyC opened this issue Aug 29, 2022 · 9 comments
Open

xkeysnail captures all my input, but it doesn't work anywhere else #164

UlyC opened this issue Aug 29, 2022 · 9 comments

Comments

@UlyC
Copy link

UlyC commented Aug 29, 2022

xkeysnail captures all my input, but it doesn't work anywhere else, and it seems to be acting like my keyboard is not working
image

@JunYang-tes
Copy link

I got the same issue.

@UlyC
Copy link
Author

UlyC commented Sep 24, 2022

I got the same issue.

I upgrade version from 0.3.0 to 0.4.0, the problem was solved.

You can also try to upgrade the version:
sudo pip3 install --upgrade xkeysnail

@ddshore
Copy link

ddshore commented Feb 16, 2023

I'm having this same problem and it's driving me crazy. I'm using version 0.4.0 and I've had it installed for years with no problems. I've tried:

  1. Uninstalling and reinstalling.
  2. Using the default config.py file
  3. Using different windows managers (kde, awesomewm)
  4. Using different terminals (xterm, konsole)
  5. Not using sudo (this won't work at all)

They all act the same: I'll run xkeysnail with its config file, and once it's running, it'll capture my input, but my keyboard will not work anymore. I can't even ctrl + C to kill it. How can I debug it?

@bobgroks
Copy link

I have the exact same problem, here's the fix that worked for me.
in '/usr/lib/python3.10/site-packages/xkeysnail/output.py',
line 30 should be
_uinput = UInput(events={ecodes.EV_KEY: _keyboard_codes, ecodes.EV_REL: set([0,1,6,8,9]), })
I deleted the events parameter because evdev was working without it.
Now it looks like this
_uinput = UInput()
And it magically works?
I'm not sure if this fix will create more problems with different configs... But for my usecase, everything seems to be working fine.

@ddshore
Copy link

ddshore commented Feb 27, 2023

Wow, that worked. Can you explained why it works? I'm not really clear on it.

Just in case it works for anyone else, I've been using keyd temporarily while I fixed this and it's working okay. Not as well as xkeysnail but it could probably get there without too much work.

@vladimir-g
Copy link

It seems that UInput init params with latest udev makes virtual device identified not as keyboard but as tablet, and events are ignored. More info: joshgoebel/keyszer#137 (comment)

There are few ways to fix it. Removing events parameter makes device seen as keyboard by udev, because default events value is all keys (according to python-evdev doc). But then you may lose ability to bind axes and wheels events (EV_REL). But I guess people rarely use them in bindings.

Other solution is to modify _keyboard_codes variable, like changing it to set(ecodes.keys.keys()). At least on my machines it makes virtual input device detected as keyboard.

I can't propose proper patch though, because all these solutions may break some user configs or not work with different udev versions.

@joshgoebel
Copy link

Other solution is to modify _keyboard_codes variable, like changing it to set(ecodes.keys.keys()). At least on my machines it makes virtual input device detected as keyboard.

From reading the systemd source I have no idea how this would change anything. You'd still have all the buttons registered and if you didn't remove the REL reference you'd have the relative events also - putting you squarely in the "touchpad" game again... or worse joystick - which is what we were trying to avoid with the "not all the buttons" hacks.

If you're only using it to remap a keyboard ONLY then simply removing the EV_REL stuff from the constructor should cause no harm at all.

@vladimir-g
Copy link

From reading the systemd source I have no idea how this would change anything. You'd still have all the buttons registered and if you didn't remove the REL reference you'd have the relative events also - putting you squarely in the "touchpad" game again... or worse joystick - which is what we were trying to avoid with the "not all the buttons" hacks.

I guess it is here: https://github.com/systemd/systemd/blob/877e68e7022c3f551d9f485f6791f2070c500aca/src/udev/udev-builtin-input_id.c#L261

    if (has_pad_buttons && has_wheel) {
            is_tablet = true;
            is_tablet_pad = true;
    }

has_pad_buttons becomes true when we have BTN_0, BTN_1 and not BTN_TOOL_PEN.

    has_pen = test_bit(BTN_TOOL_PEN, bitmask_key);
    // ...
    has_pad_buttons = test_bit(BTN_0, bitmask_key) && test_bit(BTN_1, bitmask_key) && !has_pen;

Initially all these buttons are inside ecodes.keys. When we doing ecodes.keys.keys() - ecodes.BTN, the BTN_TOOL_PEN value is removed and never added, so has_pen is false. Meanwhile, _MOUSE_BUTTONS in xkeysnail/keyszer adds BTN_0 and BTN_1 later. Then has_pad_buttons becomes true (and has_wheel is also true) and udev assignes ID_TABLET and ID_TABLET_PAD.

When all BTNs aren't removed from events, that BTN_TOOL_PEN forces has_pen to be true and that tabled ids not assigned to device. There are other places in udev code that assign tablet ids, but they rely on has_abs_coordinates and has_mt_coordinates, both must be false because app code doesn't do anything with ABS_*.

@joshgoebel
Copy link

Ah, right. I missed the the TOOL_PEN connection...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants