mooz / xkeysnail

Yet another keyboard remapping tool for X environment
891 stars 112 forks source link

Don't expose uinput device as joystick #98

Closed mbachry closed 3 years ago

mbachry commented 4 years ago

I use Fedora 32 with sway wayland wm. After recent libinput update (from 1.15.4 to 1.15.902) my keyboard stopped working, unless I disabled xkeysnail.

libinput is used by sway and all most popular wayland compositors. It always had logic to ignore joysticks, but due to a bug the joystick check didn't work correctly. It was fixed recently. Unfortunately, xkeysnail uinput device is detected as joystick by udev and as a result xkeysnail events are ignored by latest libinput:

$ udevadm info /dev/input/event20
P: /devices/virtual/input/input23/event20
N: input/event20
L: 0
E: DEVPATH=/devices/virtual/input/input23/event20
E: DEVNAME=/dev/input/event20
E: MAJOR=13
E: MINOR=84
E: SUBSYSTEM=input
E: USEC_INITIALIZED=55911717
E: ID_INPUT=1
E: ID_INPUT_JOYSTICK=1
E: ID_INPUT_KEY=1
E: ID_INPUT_KEYBOARD=1
E: ID_SERIAL=noserial
E: LIBINPUT_DEVICE_GROUP=0/0/0:py-evdev-uinput
E: TAGS=:seat:power-switch:uaccess:

(note ID_INPUT_JOYSTICK).

Udev's joystick detection seems to rely on checking which events are requested during uinput device setup. I noticed almost all BTN_ events trigger joystick tag, so as a fix I disabled them all in xkeysnail - but only if wayland compositor is present.

ncaq commented 4 years ago

I built the issue and was not aware of this pull request at the time. Incompatible with libinput-1.16.0 · Issue #99 · mooz/xkeysnail

This pull request is great.

However it have problem.

It is

but only if wayland compositor is present.

Because X11 use libinput in xf86-input-libinput So I think to fix too for X11 env.

ncaq commented 4 years ago

I think solution.

  1. detect to use libinput
  2. disable joystick button for all env
jvasile commented 4 years ago

I am running Debian Testing with libinput 1.16.1-1 but not running Wayland. I removed the Wayland checking, and this patch fixes the problem of udev thinking xkeysnail is a joystick. I reduced the patch to just the documentation change and these two lines:

_keyboard_codes = ecodes.keys.keys() - ecodes.BTN _uinput = UInput(events={ecodes.EV_KEY: _keyboard_codes})

However, there might be related issues. My external keyboard has an integrated mouse and left/right/middle click buttons. With this patch, my keyboard works as expected, but the buttons and mouse pointer movement fail. I can re-enable mouse buttons by adding back in the codes for them. Udev doesn't seem to mind mouse buttons.

I've done that refinement in PR 101.

Lenbok commented 3 years ago

@mbachry I take it this PR should be closed now that #101 is merged?

mbachry commented 3 years ago

Totally! Thanks a lot for #101