python-uinput
python-uinput copied to clipboard
python-uinput mouse clicks don't work with libinput
I'm not exactly sure what's going wrong, but python-uinput seems to be not outputting mouse commands on my machine (Ubuntu 18.10). Keyboard commands all work,.
I've downloaded master and run python setup.py build/install, so I'll be debugging it on my end, but any suggestions as to causes, solutions, or things to investigate would be greatly appreciated.
MVP:
>>> import uinput
>>> events = (uinput.BTN_LEFT,)
>>> device = uinput.Device(events)
>>> device.emit_click(uinput.BTN_LEFT)
(expect left click, get nothing)
via /proc/bus/input/devices:
II: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="python-uinput"
P: Phys=
S: Sysfs=/devices/virtual/input/input54
U: Uniq=
H: Handlers=event259
B: PROP=0
B: EV=3
B: KEY=10000 0 0 0 0
Looks like some of the basic settings are bad
From my Xorg log file:
[ 303.549] (II) config/udev: Adding input device python-uinput (/dev/input/mouse4) [ 303.549] (II) No input driver specified, ignoring this device. [ 303.549] (II) This device may have been added with another device file. [ 303.550] (II) config/udev: Adding input device python-uinput (/dev/input/js1) [ 303.550] (II) No input driver specified, ignoring this device. [ 303.550] (II) This device may have been added with another device file. [ 303.665] (II) config/udev: Adding input device python-uinput (/dev/input/event259) [ 303.665] (**) python-uinput: Applying InputClass "libinput pointer catchall" [ 303.665] (**) python-uinput: Applying InputClass "libinput keyboard catchall" [ 303.665] (II) Using input driver 'libinput' for 'python-uinput' [ 303.665] (**) python-uinput: always reports core events [ 303.665] (**) Option "Device" "/dev/input/event259" [ 303.665] (**) Option "_source" "server/udev" [ 303.666] (II) event259 - python-uinput: is tagged by udev as: Keyboard Mouse [ 303.666] (EE) event259 - python-uinput: kernel bug: device has min == max on ABS_X [ 303.666] (II) event259 - python-uinput: was rejected [ 303.712] (II) event259 - not using input device '/dev/input/event259'. [ 303.712] (EE) libinput: python-uinput: Failed to create a device for /dev/input/event259 [ 303.712] (EE) PreInit returned 2 for "python-uinput" [ 303.712] (II) UnloadModule: "libinput"
Used https://github.com/derekhe/waveshare-7inch-touchscreen-driver/issues/22 to solve min == max error, now it looks like the input driver "uinput" needs to be specified for mouse4 and js1.
For reference what a "good" log looks like (Ubuntu 16.04)
[ 72.640] (II) config/udev: Adding input device python-uinput (/dev/input/mouse4) [ 72.640] (**) python-uinput: Applying InputClass "python-uinput" [ 72.640] (II) No input driver specified, ignoring this device. [ 72.640] (II) This device may have been added with another device file. [ 72.641] (II) config/udev: Adding input device python-uinput (/dev/input/js1) [ 72.641] (**) python-uinput: Applying InputClass "python-uinput" [ 72.641] (II) No input driver specified, ignoring this device. [ 72.641] (II) This device may have been added with another device file. [ 72.676] (II) config/udev: Adding input device python-uinput (/dev/input/event28) [ 72.676] (**) python-uinput: Applying InputClass "evdev pointer catchall" [ 72.676] (**) python-uinput: Applying InputClass "evdev keyboard catchall" [ 72.676] (**) python-uinput: Applying InputClass "python-uinput" [ 72.676] (II) Using input driver 'evdev' for 'python-uinput' [ 72.676] (**) python-uinput: always reports core events [ 72.676] (**) evdev: python-uinput: Device: "/dev/input/event28" [ 72.692] (--) evdev: python-uinput: Vendor 0 Product 0 [ 72.692] (--) evdev: python-uinput: Found 3 mouse buttons [ 72.692] (--) evdev: python-uinput: Found relative axes [ 72.692] (--) evdev: python-uinput: Found x and y relative axes [ 72.692] (--) evdev: python-uinput: Found absolute axes [ 72.692] (--) evdev: python-uinput: Found x and y absolute axes [ 72.692] (--) evdev: python-uinput: Found keys [ 72.692] (II) evdev: python-uinput: Configuring as mouse [ 72.692] (II) evdev: python-uinput: Configuring as keyboard [ 72.692] (**) evdev: python-uinput: YAxisMapping: buttons 4 and 5 [ 72.692] (**) evdev: python-uinput: EmulateWheelButton: 4, EmulateWheelInertia: 10, EmulateWheelTimeout: 200 [ 72.692] (**) Option "config_info" "udev:/sys/devices/virtual/input/input32/event28" [ 72.692] (II) XINPUT: Adding extended input device "python-uinput" (type: KEYBOARD, id 21) [ 72.692] (**) Option "xkb_rules" "evdev" [ 72.692] (**) Option "xkb_model" "pc105" [ 72.692] (**) Option "xkb_layout" "us" [ 72.692] (**) Option "xkb_variant" "dvorak" [ 72.692] (WW) Option "xkb_options" requires a string value [ 72.692] (II) evdev: python-uinput: initialized for relative axes. [ 72.692] (WW) evdev: python-uinput: ignoring absolute axes. [ 72.692] (**) Option "AccelerationScheme" "none" [ 72.692] (**) python-uinput: (accel) selected scheme none/0 [ 72.692] (**) python-uinput: (accel) acceleration factor: 2.000 [ 72.692] (**) python-uinput: (accel) acceleration threshold: 4
My conclusion here is there's a bug related to the transition from evdev to libinput. I'll file a report over there and keep this issue open in the meantime as documentation of non-functionality.
I got some help from Peter Hutterer at https://gitlab.freedesktop.org/libinput/libinput/issues/203. It turns out that emitting [(BTN_LEFT, 1), (BTN_LEFT, 0), (SYN)] will not register with libinput as a left mouse click (but the evdev driver will). Updating libsuinput to emit [(BTN_LEFT, 1), (SYN), (BTN_LEFT, 0), (SYN)] will register as a left mouse click. Once the scope of what needs to be updated is determined, I'll start working on a pull request. In the meantime, adding the line suinput_syn(uinput_fd);
right before
this line with resolve the issue.
@Chazzz Thank you so much! Was debugging this for hours, finally stumbled upon this ticket. For reference, I'm running into the same issue with Ubuntu 22.04.