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

Author Topic: Joypad/gamepad not detected by SFML 1.6  (Read 5703 times)

0 Members and 3 Guests are viewing this topic.

Knitter

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Joypad/gamepad not detected by SFML 1.6
« 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;
}
 

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Joypad/gamepad not detected by SFML 1.6
« Reply #1 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. ;)
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: 32498
    • View Profile
    • SFML's website
    • Email
Re: Joypad/gamepad not detected by SFML 1.6
« Reply #2 on: June 11, 2012, 08:02:20 am »
Joysticks are not supported at all on OS X in SFML 1.6.
Laurent Gomila - SFML developer

Knitter

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Joypad/gamepad not detected by SFML 1.6
« Reply #3 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Joypad/gamepad not detected by SFML 1.6
« Reply #4 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.
Laurent Gomila - SFML developer

Knitter

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Joypad/gamepad not detected by SFML 1.6
« Reply #5 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.

 

anything