Hi.
I have a tiny concern that I want to put forward, just to clear up if I am screwing something up or I found a quirk.
I have a Playstation 2 -> USB converter and your standard dual shock plugged into it.
In a game I am programming, I have an InputManager written which loads binds and the like and handles all input. The InputManager is initialized before anything happens in the engine. So, since there is no window created yet, I need to call sf::Joystick::update() to update the joystick first. Here is where I found a problem.
In my gamepad, it detect all axises (using hasAxis()) as available, although my pad uses only 4 of them. The axises that are "unavailable" have a constant position value of either -100 or 100. No big deal, I just check to see if those values are constant when setting up binds and disallow use of those axises. With that workaround, everything works fine. Now, here is where I have run into a quirk.
Axis::U is one axis that is unavailable to me. So, if I call sf::Joystick::update(), that axis should give back a value of either 100 or -100 on getAxisPosition(). Except, this axis returns the value of Axis::R UNTIL I create a window and update the joystick again.
Here is the test code that demonstrates. It may or may not work for you, depending on which axis does this for you.
int main() {
// no window, so update joystick.
sf::Joystick::update();
// U is "(un)available" on my pad, so check value. value will be the same as Axis::R, which is a problem.
std::cout << "Axis U Value:" << sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::U) << std::endl;
// now, we'll open a window --
sf::RenderWindow window;
window.create(sf::VideoMode(640, 480), "A Window", sf::Style::Close);
// -- and reupdate the joystick. If I don't reupdate, the value will be the same as above.
sf::Joystick::update();
// value is now -100, since it's technically not available to me.
std::cout << "Axis U Value:" << sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::U) << std::endl;
bool done = false;
while (!done) {
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Escape))
done = true;
}
}
It is my understanding that once I call the first sf::Joystick::update(), the joystick should be ready to go, but it isn't.
EDIT: This is the build I am using:
https://github.com/SFML/SFML/tree/265c411c39f498f95a03517818167b47b754c440