Giter VIP home page Giter VIP logo

Comments (7)

moses-palmer avatar moses-palmer commented on July 2, 2024

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.

moses-palmer avatar moses-palmer commented on July 2, 2024

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.

moses-palmer avatar moses-palmer commented on July 2, 2024

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:

Thank you in advance.

from pynput.

lezed1 avatar lezed1 commented on July 2, 2024

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.

lezed1 avatar lezed1 commented on July 2, 2024

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.

moses-palmer avatar moses-palmer commented on July 2, 2024

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.

lezed1 avatar lezed1 commented on July 2, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.