Hello,
I started digging into coding gamepad support for my game, but ran into some issues, particularly with getting seemingly bad values from the axis inputs on my (brand new) Xbox 360 wired controller.
When I compile and start my program, I see the following printed to stdout:
Unable to get joystick attribute. Could not find USB device for joystick at index 0.
Unable to get joystick attribute. Could not find USB device for joystick at index 0.
When I query the values of sf::Joystick::getIdentification(0), I get the following:
name: Microsoft X-Box 360 pad
vendorId: 0
productId: 0
I am able to see input occurring from all of the buttons and axis, however the state of the axis appear to be incorrect. In the resting/center position, either of the axis will return values anywhere across the spectrum, from -1 to 1.
For example:
sf::Joystick::update()
float x = sf::Joystick::getAxisPosition(0, sf::Joystick::X);
float y = sf::Joystick::getAxisPosition(0, sf::Joystick::Y);
sf::Vector2f normalized = normalize(x, y);
Output at resting/center position (not touching the controller):
x: -0.977409
y: 0.211355
If I move the controller around and then release it back to the resting state, it will give a totally different set of nonzero values. At least one of the x/y axis is typically pegged at around 0.9 (or -0.9).
Interestingly, I plugged in another generic controller with a similar layout (an old Belkin Nostromo N45) and it works fine with the same code, giving zero values in the center position and normal/expected values throughout it's movement range (although SFML outputs the same warning message about not finding the USB device).
However, the Xbox gamepad works great and behaves as expected in all other games on my system, so I don't think it's faulty controller hardware.
I'm running the latest SFML (built from github source) on Archlinux x86_64. The xpad driver module is automatically loaded.