When I press any button or stick on the gamepad, I get several sf::Event::JoystickMoved events.
I think it's axis calibration issue...
Check out what you get with this program (don't press any axes. Just press any button).
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode(640, 480), "");
window.setVerticalSyncEnabled(true);
sf::Joystick::update();
std::vector<std::string> names = {
"X", ///< The X axis
"Y", ///< The Y axis
"Z", ///< The Z axis
"R", ///< The R axis
"U", ///< The U axis
"V", ///< The V axis
"PovX", ///< The X axis of the point-of-view hat
"PovY" ///< The Y axis of the point-of-view hat
};
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
switch (event.type) {
case sf::Event::Closed:
window.close();
break;
case sf::Event::JoystickMoved:
std::cout << names[event.joystickMove.axis] << " " << event.joystickMove.position << std::endl;
break;
default:
break;
}
}
window.clear(); // fill background with color
window.display();
}
}
I consistently get this:
X 0.389105
Y -1.17952
R -395209
U 4.31067
What can I do about it?