Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Polling real time state of mouse extra buttons doesn't work in Linux  (Read 3562 times)

0 Members and 1 Guest are viewing this topic.

Man0Sand

  • Newbie
  • *
  • Posts: 2
    • View Profile
Hello!
Since this is my first post here, let me briefly introduce myself. For living I develop software for electric drives, which in software point of view are predominantly real-time embedded devices. Programming is also a hobby of mine, and my journey with SFML began a couple of years ago when my co-worker persuaded me to participate in an open university C++ course. Besides the usual programming exercises there was a project, and we ended up making a game using SFML, which was suggested for making games and similar programs. And since then I've been writing small programs and games with SFML.

I'm using SFML 2.5.1 on Ubuntu 18.04. I've got a Logitech G Pro Wireless gaming mouse which has side buttons. I noticed that the side button presses and releases can be polled using sf::Event just fine, but polling their states in real time doesn't work: Mouse::isButtonPressed(Mouse::XButton1); and Mouse::isButtonPressed(Mouse::XButton2); always return false. For other buttons real time polling works without problems.

The Linux version of InputImpl::isMouseButtonPressed implementation (https://github.com/SFML/SFML/blob/master/src/SFML/Window/Unix/InputImpl.cpp) suggests that XButton1 and XButton2 aren't supported by XLib. I spent a while with Google and it seems the XLib function (XQueryPointer) used to poll the real time data in Linux supports buttons 1 to 5, and some sources state that in Linux buttons 1-3 are the normal buttons and buttons 4-5 are actually the wheel scrolls to up and down direction.

So even though the problem seems to be in Linux instead of SFML, I think it'd be helpful to mention this in SFML documentation somewhere, since at least I was a bit surprised by this. It could save somebody's time if this information is available for example in public headers instead of the source code files. I didn't quite know where to put this kind of suggestion so I chose general discussion.

Man0Sand

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Polling real time state of mouse extra buttons doesn't work in Linux
« Reply #1 on: January 23, 2022, 07:21:04 pm »
I guess the additional information could be useful for some future dev, as such I wouldn't necessarily mind if the comment there was expanded, but I'd guess it also isn't very hard to track down the reason as to why it's not supported.

If you come up with good, short alternative text, feel free to open a PR (and link this discussion thread).
« Last Edit: January 23, 2022, 07:23:16 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Man0Sand

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Polling real time state of mouse extra buttons doesn't work in Linux
« Reply #2 on: January 28, 2022, 10:31:44 pm »
Hm, judging from you mentioning the future developer, did you perhaps interpret that I'm suggesting to elaborate on the comments in the implementation file, https://github.com/SFML/SFML/blob/master/src/SFML/Window/Unix/InputImpl.cpp ? Because that actually wasn't my idea, but rather to hint the user of SFML that sf::Mouse::isButtonPressed won't work for the extra buttons in Linux. So I think that comment would go right into the mouse header, https://github.com/SFML/SFML/blob/master/include/SFML/Window/Mouse.hpp.

kimci86

  • Full Member
  • ***
  • Posts: 128
    • View Profile
Re: Polling real time state of mouse extra buttons doesn't work in Linux
« Reply #3 on: November 22, 2022, 10:33:31 pm »
For reference, a little bit of documentation was added to the 2.6.x branch about this in pull request #2271.

 

anything