Comments (7)
Thank you for the report.
For ease of use, mouse buttons are defined in an enum, so arbitrary values are not supported. I think an acceptable solution would be to:
- Add
UNKNOWN
to the base button class---this server as documentation only---and all platform implementations. - Wrap creation of button values for listeners in a method that returns
UNKNOWN
when lookup fails. - Add missing buttons to the Xorg backend.
You are more than welcome to submit a pull request to fix this issue. If you do, please run python setup.py lint
with master checked out before, and then once afterwards to ensure that you do not introduce linter errors. I will merge well documented code quickly!
If you prefer to wait, I will fix this issue next week, as I am going on vacation tomorrow.
from pynput.
Looking at the code, wrapping creation of button values may be a bit pointless, since only the Xorg backend blindly transforms values this way.
from pynput.
I pushed a proposed solution to fixup-unknown-mouse-buttons.
It simply adds new button constants---rather hacky, but I much prefer to use an enum for mouse buttons for consistency---and falls back on Button.unknown
for unknown buttons.
Since I don't have access to a fancy mouse, I need your help to test it. Could you please pull down the fixup branch and:
- Check out 5602a65fe3ced12c9357a4e1301b818c2d9de57b and verify that you get
Button.button8
when you press the offending button. - Check out 50378d51a40fc4147f838b9e9ba7c8a69f4e8b6b and verify that you get
Button.unknown
when you press the offending button.
Thank you in advance.
from pynput.
Oh I completely missed your earlier messages, so I didn't work on a fix. Thanks for pushing that, I'll test it when I get back to my computer later today!
from pynput.
I just tested with a few extra mouse buttons and everything works as expected on the latest on the fixup branch. Did you want me to test the individual commits?
Here's the output of testing 8, 9, 10 and 11.
In [1]: from pynput import mouse
In [2]: with mouse.Listener(on_click=lambda e,f,g,h: print(e,f,g,h)) as l: l.join()
682 883 Button.button8 True
682 883 Button.button8 False
680 881 Button.button9 True
692 872 Button.button9 False
654 881 Button.unknown True
654 881 Button.unknown False
649 879 Button.unknown True
649 879 Button.unknown False
from pynput.
Thank you!
The reason I wanted you to test two commits was that I wanted to check that the fallback to Button.unknown
works---I certainly didn't expect your mouse to have more than eight buttons!
But it seems to work, so I'll merge the branch and make a new release.
from pynput.
Awesome, thanks for responding and fixing this! I've really liked using this library so far, it's quite easy to work with.
from pynput.
Related Issues (20)
- Which python version is the latest release of pynput compatible with?
- Keyboardtracking CTRL + "second_key" doesn't output "second_key"
- pynput not detecting media keys on kde plasma wayland HOT 1
- Type method crashes on cyrillic characters HOT 1
- Suppress mouse move not working when using parsec HOT 1
- mouse listener example for win32_event_filter HOT 1
- Script Continues Rapid Clicking Despite Mouse Button Release (is_pressed Functionality Issue) HOT 6
- Press cmd_r and release with cmd pressed will produce two presses instead of press + release HOT 3
- Can this be used in Micropython? HOT 5
- Get the original pressed key HOT 1
- The Numpad numbers does not work in HotKeys.
- pynput types ">" instead of "|" HOT 1
- Need to sync keyboard lock keys
- AttributeError: record_create_context HOT 5
- capslock crshed on macOS HOT 2
- lazy imports cause a KeyError HOT 4
- Cannot install on linux Ubuntu (depends on pywin32) HOT 2
- name 'keyboard' is not defined HOT 1
- Additional keys can still trigger events HOT 2
- Missing 1.7.7 tarball on PyPI
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pynput.