This is the strangest thing I ever seen. I have a joystick "EXEQ Spitfire" and tested it on 4 different systems:
- Linux 32bit laptop ASUS X200CA
- Linux 64bit (Ubuntu 14.10) at home
- WinXP 32bit at home
- Linux 64bit (Ubuntu 14.10) at work
All the linux systems throw me two messages to console:
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.
This code:
printf("[%u : %u] %s\n", sf::Joystick::getIdentification(0).vendorId,
sf::Joystick::getIdentification(0).productId,
sf::Joystick::getIdentification(0).name.toAnsiString().c_str());
Gives me:
[0 : 0] Microntek USB Joystick
Well, about the problem:
Linux 64bit (Ubuntu 14.10) at work works properly.
WinXP 32bit at home gives me (-0.78, -0.78) on X and Y axes when nothing is pressed.
Linux 32bit on laptop and
Linux 64bit (Ubuntu 14.10) at home got same results on following sequence:
1. I connect joystick
2. Run application
3. Get axes positions (-100, -100) on X and Y
4. Pressing D-pad on X and Y
5. Releasing D-pad and got (0, 0)
6. Run application again
7. Get axes positions (0, 0) on X and Y
So the initial state is wrong.
Can anyone help me, what could be the reason of this strange behavior?
Tested on this:
#include <SFML/Window.hpp>
#include <stdio.h>
#include <unistd.h>
int main() {
sf::Window window(sf::VideoMode(800, 600), "My window");
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
}
printf("(%3.2f, %3.2f)\n", sf::Joystick::getAxisPosition(0, sf::Joystick::X),
sf::Joystick::getAxisPosition(0, sf::Joystick::Y));
}
return 0;
}
gcc main.cpp -o test -lsfml-window -lsfml-system -lstdc++