HI, I have a strange problem as said in the title.
First jstest-gtk show my controller and i can calibrate it.
The problem was first the detection. I have to print all the event and replace the Global value from an imediate value
case SDL_CONTROLLERDEVICEADDED:
case 1541:
fprintf(stdout,"Controller #%d plugged\n",event.cdevice.which);
addController(event.cdevice.which);
now It print “Controller #0 plugged” when i plug my controller. This is Odd as in Fedora I didn’t have the “case 1541”
now the main problem is the controller is not supported by interface when it is in fedora with the same code.
Here is the code to test controllers:
SDL_Event event;
while(SDL_PollEvent(&event))
{
//fprintf(stderr,"%d\n",event.type);
switch(event.type)
{
default:
break;
case SDL_CONTROLLERDEVICEADDED:
case 1541:
fprintf(stdout,"Controller #%d plugged\n",event.cdevice.which);
addController(event.cdevice.which);
break;
case SDL_CONTROLLERDEVICEREMOVED:
case 1542:
fprintf(stdout,"Controller #%d unplugged\n",event.cdevice.which);
removeController(event.cdevice.which);
break;
}
}
Now the function addController()
static void addController(int id)
{
if(joystick == NULL)
{
fprintf(stderr,"%d = %d\n",id,SDL_IsGameController( id ));
if( SDL_IsGameController( id ) )
{
SDL_GameController *pad = SDL_GameControllerOpen( id );
if( pad )
{
joystick = SDL_GameControllerGetJoystick( pad );
//int instanceID = SDL_JoystickInstanceID( joystick );
}
else
{
fprintf(stderr,"gamecontroller not set pad = %p\n",pad);
}
}
else
{
fprintf(stderr,"Controller #%d not recognized\n",id);
}
}
else
{
fprintf(stdout,"Only one joystick for this game\n");
}
return;
}
So when I run my program and plug my controller here is the output:
Controller #0 plugged
0 = 0
Controller #0 not recognized
Controller #1 plugged
1 = 0
Controller #1 not recognized
As you can see two controllers are detected, I unplugged every USB devices to be sure my BT keyboard and mouse or usbstick or whatever are not seen as controller and only plugged my controller,
and finally the detection is OK but not supported device.
It doesn’t make any sense for me to work on one system and not on an another one with the same code. I probably installed something wrong or forgot to install something.
Thanks for reading me