question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mouse movements/hooks work, but mouse clicks do not. (kubuntu cosmic 18.10, KDE/Plasma)

See original GitHub issue

Title.

The test case is as simple as:

~/mouse (master|✔) $ sudo python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mouse
>>> mouse.move(50, 50) ## works
>>> mouse.click() ## nothing happens?
>>> ## no error

(alongside this, mouse.wait() and mouse.record() work, but mouse.replay() will replay movements but not clicks)

(the mouse directory is a fresh clone of this repository)

I’m not intimately familiar with how mouse interacts with linux on an i/o level, so i’m going to attempt to provide as much useful information as possible. Let me know what specific information you’d need about my environment.

This is a relatively vanilla installation of kubuntu:

~ $ apt list --installed | grep input

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

inputattach/cosmic,now 1:1.6.0-2 amd64 [installed,automatic]
libinput-bin/cosmic,now 1.12.1-1 amd64 [installed,automatic]
libinput10/cosmic,now 1.12.1-1 amd64 [installed,automatic]
libwinpr-input0.1/cosmic,now 1.1.0~git20140921.1.440916e+dfsg1-15ubuntu1 amd64 [installed,automatic]
xinput/cosmic,now 1.6.2-1build1 amd64 [installed,automatic]
xserver-xorg-input-all/cosmic,now 1:7.7+19ubuntu8 amd64 [installed,automatic]
xserver-xorg-input-libinput/cosmic,now 0.28.1-1 amd64 [installed,automatic]
~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.10
Release:        18.10
Codename:       cosmic
~ $

With the standard KDE window manager.

Nothing appears in dmesg except for the input: Virtual Keyboard as /devices/virtual/input/input## messages.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
EliRibblecommented, Aug 25, 2021

I reproduced this as well. I tracked it down by reading the code and seeing that on POSIX systems the library is using the uinput module. After creating a sample program based on this blog post I was able to figure out that the issue comes down to this call:

# From _nixcommon.py lines 34 - 39
UI_SET_KEYBIT = 0x40045565
for i in range(256):
    fcntl.ioctl(uinput, UI_SET_KEYBIT, i)

I’m not sure why this is necessary. In my sample C program the analagous call is:

ioctl(fd, UI_SET_KEYBIT, BTN_LEFT);

Where BTN_LEFT on my system is defined as 0x00000110. This means I can replace the Python code with:

fcntl.ioctl(uinput, UI_SET_KEYBIT, 0x00000110)

…and button clicks work again.

I’d submit a PR if I knew this was stable on other systems, but I don’t know that for sure.

0reactions
MasterChenSenseicommented, Apr 19, 2022

I reproduced this as well. I tracked it down by reading the code and seeing that on POSIX systems the library is using the uinput module. After creating a sample program based on this blog post I was able to figure out that the issue comes down to this call:

# From _nixcommon.py lines 34 - 39
UI_SET_KEYBIT = 0x40045565
for i in range(256):
    fcntl.ioctl(uinput, UI_SET_KEYBIT, i)

I’m not sure why this is necessary. In my sample C program the analagous call is:

ioctl(fd, UI_SET_KEYBIT, BTN_LEFT);

Where BTN_LEFT on my system is defined as 0x00000110. This means I can replace the Python code with:

fcntl.ioctl(uinput, UI_SET_KEYBIT, 0x00000110)

…and button clicks work again.

I’d submit a PR if I knew this was stable on other systems, but I don’t know that for sure.

Can confirm this fixes the issue (Linux Manjaro user here), thanks for your investigation and help! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mouse clicks not registered above panel
I just installed a fresh copy of Kubuntu 12.04 (KDE 4.8.2) on my desktop. I was previously using 11.10, which worked perfectly fine....
Read more >
Mouse clicks not registering in KDM/KDE : r/Kubuntu
The only remedy is to switch to a Terminal via e.g. CTRL+ALT+F2, then (without doing anything there) switching back to KDE via CTRL+ALT+F1. ......
Read more >
mouse
Hook and simulate global mouse events in pure Python. Become a Bounty Hunter ... Mouse movements/hooks work, but mouse clicks do not. (kubuntu...
Read more >
KDE plasma right mouse click dead end problem [closed]
Since I made the change entering the now lost menu and I can not find it elsewhere in the system settings, I find...
Read more >
Bug #1795292 “ELAN469D touch pad not working”
I installed Bionic Beaver and now upgraded to Cosmic Cuttlefish on this Lenovo Ideapad 330S-15ARR laptop. The touch pad doesn't work in either....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found