New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSX Trackpad Right Click Not Triggered #716

Closed
pnappa opened this Issue Oct 12, 2014 · 2 comments

Comments

Projects
None yet
4 participants
@pnappa

pnappa commented Oct 12, 2014

On the recent build of SFML from Github, only left clicks are being recognised on the touchpad. However, when connecting a mouse, all the mouse buttons are correctly triggered.

I have two finger right click enabled in trackpad preferences, yet no right clicks are logged.

Using the latest Macbook Retina running OSX Mavericks this code is a good example of effects:

#include <iostream>

int main(int, char const**)
{
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");

    // Start the game loop
    while (window.isOpen())
    {
        // Process events
        sf::Event event;
        while (window.pollEvent(event))
        {
            // Close window : exit
            if (event.type == sf::Event::Closed) {
                window.close();
            }

            // Escape pressed : exit
            if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) {
                window.close();
            }
        }

        // Clear screen
        window.clear();


        if (sf::Mouse::isButtonPressed(sf::Mouse::XButton1)){
            std::cout << "xbutton1\n";
        }
        if (sf::Mouse::isButtonPressed(sf::Mouse::XButton2)){
            std::cout << "xbutton2\n";
        }
        if (sf::Mouse::isButtonPressed(sf::Mouse::Right)){
            std::cout << "Right\n";
        }
        if (sf::Mouse::isButtonPressed(sf::Mouse::Left)){
            std::cout << "left\n";
        }
        if (sf::Mouse::isButtonPressed(sf::Mouse::Middle)){
            std::cout << "middle\n";
        }


        // Update the window
        window.display();
    }

    return EXIT_SUCCESS;
}

And watching the console log whilst pressing mouse buttons, the effects can be clearly observed.

@mantognini

This comment has been minimized.

Show comment
Hide comment
@mantognini

mantognini Oct 12, 2014

Member

That's a limitation of the HID interface used by SFML to scan hardware state. The thing is, at the USB level, the trackpad has x and y axes, a wheel and only one button.

Now, I initially used this very low level interface because in 10.5 there was no other solution. But since we will drop this old OS with SFML 2.2, I can use a much simpler API: +[NSEvent pressedMouseButtons] which, I hope, would work better for that corner case.

However, using events already work. So if you don't want to wait for this fix, use them.

Member

mantognini commented Oct 12, 2014

That's a limitation of the HID interface used by SFML to scan hardware state. The thing is, at the USB level, the trackpad has x and y axes, a wheel and only one button.

Now, I initially used this very low level interface because in 10.5 there was no other solution. But since we will drop this old OS with SFML 2.2, I can use a much simpler API: +[NSEvent pressedMouseButtons] which, I hope, would work better for that corner case.

However, using events already work. So if you don't want to wait for this fix, use them.

@mantognini mantognini self-assigned this Oct 12, 2014

@mantognini mantognini added this to the 2.2 milestone Oct 12, 2014

mantognini added a commit that referenced this issue Oct 25, 2014

Fix right click not detected on OS X with trackpads, close #716
Now that `+[NSEvent pressedMouseButtons]` can be used, part of HIDInputManager becomes obsolete and is therefore removed.

mantognini added a commit that referenced this issue Oct 25, 2014

Fixed right click not detected on OS X with trackpads, close #716
Now that `+[NSEvent pressedMouseButtons]` can be used, part of HIDInputManager becomes obsolete and is therefore removed.
@mantognini

This comment has been minimized.

Show comment
Hide comment
@mantognini

mantognini Oct 25, 2014

Member

Superseded by PR #730.

Member

mantognini commented Oct 25, 2014

Superseded by PR #730.

@mantognini mantognini closed this Oct 25, 2014

mantognini added a commit that referenced this issue Nov 3, 2014

Fixed right click not detected on OS X with trackpads, close #716
Now that `+[NSEvent pressedMouseButtons]` can be used, part of HIDInputManager becomes obsolete and is therefore removed.

@Bromeon Bromeon removed the s:accepted label Mar 31, 2015

@mantognini mantognini self-assigned this Feb 7, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment