SFML community forums
Help => Window => Topic started by: Lo-X on August 15, 2011, 08:13:15 pm
-
Hello
I tried the last build of SFML 2 with the new sf::Joystick and I saw a strange thing while using it with a gamepad, I don't know if it's normal or not.
If I Use this code :
int main(void)
{
// App = sf::RenderWindow
sf::Joystick::Update();
int MyJoystickNumber = 0;
for(int i = 0; i < 8; i++)
if(sf::Joystick::IsConnected(i)) {
MyJoystickNumber = i; break;
}
// Some code
// Problematic code
if(sf::Joystick::GetAxisPosition(MyJoystickNumber, sf::Joystick::X) < -40)
cout << "Turn Left !" << endl;
}
In fact, "Turn Left !" just never appear, the Joystick number is not my gamepad number and I've nothing else than a mouse and a keyboard on the computer.
If I have a table of joystick's numbers and I check all these joysticks, the message appear.
So my game works well and the new interface is nice, but I'm obliged to check 2 Joysticks instead of one in a single game loop.
-
the Joystick number is not my gamepad number
How do you know what your gamepad number is?
If I have a table of joystick's numbers and I check all these joysticks, the message appear.
So my game works well and the new interface is nice, but I'm obliged to check 2 Joysticks instead of one in a single game loop.
Sorry I don't get this part. Can you elaborate?
-
How do you know what your gamepad number is?
Je vais illustrer mon propos :
Je dois utiliser une boucle pour avoir tous les numéros de Joystick :
int JoystickNumberTable[8], j = 0;
for(int i = 0; i < 8; i++)
if(sf::Joystick::IsConnected(i)) {
JoystickNumberTable[j] = i;
j++;
}
(Chez moi, je récupère toujours deux nombres : 0 et 1)
Puis, lorsque je veux vérifier si le joystick est tourné ou non :
for(int i = 0; i < j; i++)
{
if(sf::Joystick::GetAxisPosition(JoystickNumberTable[i], sf::Joystick::X) < -40)
cout << "Turn Left !" << endl;
}
Si je récupère le premier numéro de Joystick trouvé avec IsConnected(NUMERO), sf::Joystick::GetAxisPosition( NUMERO , ...) retourne des valeurs comprises entre -3 et 3 (à quelques décimales près).
Mais je viens de me dire que le premier numéro trouvé correspond au stick POV de la manette, même si en le tournant également, rien ne se passe.
Je ne sais pas si c'est clair ^^
Sorry for english speaking people :/
-
But how many joysticks do you have? I don't think that POV should be seen as a separate joystick.
Sorry for english speaking people :/
Hmm... there's a french forum you know ;)
-
But how many joysticks do you have? I don't think that POV should be seen as a separate joystick.
I've only one gamepad, so one joystick.
I've Linux (ubuntu 11.04)
Here is the pad :
(http://www.pcsolidario.com/pcsolidario/components/com_virtuemart/shop_image/product/Mando_NGS_Tanker_4d65041c544e1.jpg)
(NGS Tanker, a Playstation 2/3 and PC compatible pad)
Hmm... there's a french forum you know ;)
I need to learn english, and there are more people to answer on english side :D
-
Ok. Is there a standard utility that you can run to see how your gamepad is detected and mapped? If it's the same as SFML, it's probably a problem with the gamepad's driver. Otherwise it's a bug in SFML :)
I need to learn english, and there are more people to answer on english side
So don't answer in french :lol:
-
Ok. Is there a standard utility that you can run to see how your gamepad is detected and mapped? If it's the same as SFML, it's probably a problem with the gamepad's driver. Otherwise it's a bug in SFML
I'll see that