SFML community forums

Help => Window => Topic started by: Knitter on June 10, 2012, 11:34:16 pm

Title: Joypad/gamepad not detected by SFML 1.6
Post by: Knitter on June 10, 2012, 11:34:16 pm
Hi,

I'm just starting to work with SFML and I'm using version 1.6 for the time being. I'm trying to understand how to read user input and am having trouble getting the gamepad to work. Mouse and keyboard work ok.

I just wanted to test the way SFML offers me information about the input devices but I seem to find no way to make my code detected the gamepad I'm using (Logitech RumblePad2, on OS X Lion, no driver needed). Other games detect the gamepad correctly (all features including vibration) but the code I wrote seems not to detect anything.

I've searched the forum but found only one topic about some XBox 360 joypad...

The code I'm using is nothing special:
sf::Window win(sf::VideoMode(800, 600, 16), "", sf::Style::Close);
sf::Event event;

bool finished = false;
while (!finished) {
    while (win.GetEvent(event)) {
        switch (event.Type) {
            case sf::Event::KeyPressed:
                if (event.Key.Code == sf::Key::Escape) {
                    finished = true;
                }
                break;

            case sf::Event::JoyButtonPressed:
                std::cout << "Pressed joy " << event.JoyButton.JoystickId << " at " << event.JoyButton.Button << "\n";
                break;
            case sf::Event::JoyMoved:
                std::cout << "Moved " << event.JoyMove.JoystickId << " on axis ";

                switch (event.JoyMove.Axis) {
                     case sf::Joy::AxisR:
                        std::cout << "R ";
                        break;
                    case sf::Joy::AxisU:
                        std::cout << "U ";
                        break;
                    case sf::Joy::AxisV:
                        std::cout << "V ";
                        break;
                    case sf::Joy::AxisX:
                        std::cout << "X ";
                        break;
                    case sf::Joy::AxisY:
                        std::cout << "Y ";
                        break;
                    case sf::Joy::AxisZ:
                        std::cout << "Z ";
                        break;
                    case sf::Joy::AxisPOV:
                        std::cout << "POV ";
                        break;
                }
                 std::cout << "amount " << event.JoyMove.Position << "\n";
                break;
            }
        }
        win.Display();
    }
    win.Close();

    return 0;
}
 
Title: Re: Joypad/gamepad not detected by SFML 1.6
Post by: eXpl0it3r on June 10, 2012, 11:58:15 pm
I assume with "seems not to detect anything" you mean that you don't get any output in terminal window?

Next I'd really advice you to use SFML 2, maybe it's already fixed there...

For the code I can't really tell if it's allright or not, since I've never done anything with gamepads. ;)
Title: Re: Joypad/gamepad not detected by SFML 1.6
Post by: Laurent on June 11, 2012, 08:02:20 am
Joysticks are not supported at all on OS X in SFML 1.6.
Title: Re: Joypad/gamepad not detected by SFML 1.6
Post by: Knitter on June 11, 2012, 10:41:51 am
I assume with "seems not to detect anything" you mean that you don't get any output in terminal window?
Yes, sorry if I wasn't clear.

Joysticks are not supported at all on OS X in SFML 1.6.
That's unfortunate... is there support for them in version 2? I was going to wait until SFML 2 was officially released and take the time to learn how to use 1.6 but I guess I'm going to have to try SFML 2 now, that is if there is support for Joysticks on OS X in SFML 2.

Is there any place I can see what is and what isn't supported in the various versions of SFML in OS X?
Title: Re: Joypad/gamepad not detected by SFML 1.6
Post by: Laurent on June 11, 2012, 10:45:45 am
Quote
is there support for them in version 2?
Yes.

Quote
I was going to wait until SFML 2 was officially released and take the time to learn how to use 1.6
SFML 1.6 is already deprecated, and although there's no official release of SFML 2.0 yet there is a RC which is already 99.999% of what the final release will be.

Quote
Is there any place I can see what is and what isn't supported in the various versions of SFML in OS X?
I think everything is supported now in the OS X version.
Title: Re: Joypad/gamepad not detected by SFML 1.6
Post by: Knitter on June 11, 2012, 11:04:48 am
Nice, so I guess it's time to see how to install SFML 2 in OS X and start porting my code to it. Thanks for the answers.