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

Author Topic: Mouse buttons ignore OS settings, bug?  (Read 2414 times)

0 Members and 1 Guest are viewing this topic.

thePyro_13

  • Full Member
  • ***
  • Posts: 156
    • View Profile
Mouse buttons ignore OS settings, bug?
« on: August 27, 2012, 09:54:10 am »
Wasn't sure of a good way to word the title.

On windows 7 x64(and possibly other OS's) the sf::Mouse::isButtonPressed() function doesn't take into account OS settings to flip the left and right mouse buttons.

I have my mouse buttons reversed, so the physical right button, should be registered as a left click. However SFML2 still reports it as a right click.

I did a search and couldn't find any mention of this on the forums or bug tracker.

Minimal example:
Set the OS to reverse mouse settings and press the left mouse button while running the following code. sf::Mouse::isButtonPressed() still returns true, though it should not.
#include <SFML/Window.hpp>

int main()
{
    sf::Window window(sf::VideoMode(800, 600), "My window");

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            //here, isButtonPressed should return false when hitting the physical left button. and the reverse
            //should be true when testing against sf::Mouse::Button::Right
            if (sf::Mouse::isButtonPressed(sf::Mouse::Button::Left))
                window.close();


        }
    }
   
« Last Edit: August 27, 2012, 09:55:54 am by thePyro_13 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
Re: Mouse buttons ignore OS settings, bug?
« Reply #1 on: August 27, 2012, 10:21:18 am »
Hmmm I'm not quite sure what you're trying to achive with reversing the settings, if it's just because you're left handed and want to use the mouse on the left side, then it's probably adviced to set the mouse settings to left handed, with that option I had no problem and my right mouse button responded as left mouse button. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Mouse buttons ignore OS settings, bug?
« Reply #2 on: August 27, 2012, 10:26:27 am »
Using the physical buttons is clearly a bug, it's not consistent with the rest of the API. Both Keyboard::isKeyPressed and Event::MouseButtonPressed deal with logical keys/buttons.

It will be fixed in 5 minutes, thanks for your feedback :)
Laurent Gomila - SFML developer