Hi
Started joystick programming today.... I have some doubts.. :-\
1) I have discovered that some buttons of my wired X360 controller are not detected as pressed (the buttons are LT and RT)... sf::Joystick::getButtonCount is returning 10..... Using my generic usb gamepad getButtonCount returns 12 buttons (and they all count as pressed when I press them) ... is this a bug?
2) I´m getting some errors trying to get the joystick moved with the events system. This is my code:
sf::Event event;
while (window.pollEvent (event)) {
// Close window : exit
if (event.type == sf::Event::Closed)
window.close();
// HERE I want to know the joystick number, the axis, and the new position
if (event.type == sf::Event::JoystickMoved) {
// error: expected primary expression before ´.´ token
unsigned int njoy = sf::Event::JoystickMoveEvent.joystickId;
// trying this way.. error: invalid use of ´struct sf::Event::JoystickMoveEvent´
unsigned int njoy = event.JoystickMoveEvent.joystickId;
what is the correct way of getting the joy number, the axis moved, and the new position (using the event system) ?
win7 x64, codeblocks, sfml 2 updated
thanks
i figured it out:
1) LT and RT are not detected as buttons... They are detected as axis ??? ... Why?
2) correct code:
if (event.type == sf::Event::JoystickMoved) {
unsigned int njoy = event.joystickMove.joystickId; // Joy Number
sf::Joystick::Axis eje = event.joystickMove.axis; // Axis moved
float pos = event.joystickMove.position; // New position
But now I have a 3rd question.... Is SFML axis handling code very bug? or Joystick programming is just a pain in the ... ;D ?
Generic USB gamepad uses diferent axes with analog mode on and off
X360 controller uses the same axes for left stick, right stick, LT and RT button, and digital pad :o (the controller works fine with most commercial games)