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;
}