Hi,
I'll start by saying, that I've already searched for the solution on the forum and google pretty thoroughly and no luck with finding it and I'm using SFML 2.5.1.
I'm making a game that uses two controllers and whenever I disconnect
controller1 and reconnect it after everything works fine, but if I do the same with
controller0 -
controller1 quickly becomes
controller1 and
controller0 at the same time and reconnecting
controller0 changes nothing and it's not even acknowledged anymore. I'm using
JoystickDisconnected and
JoystickConnected events in
pollEvent loop
I've tried like everything:
- Joystick::update() in several places
- counting Joystick::getIdentification(i) where productId > 0
- additional bool variables
- additional loops
- Joystick::isConnected(i)
- additional pollEvent loop
- sleeping the thread for 100 and 1000 milliseconds
- all of above but in fuctions
and probably more, that I've already forgotten...
Atm my event handling looks like this:
if (event.type == Event::JoystickDisconnected)
{
if (event.joystickConnect.joystickId == 0)
{
cout << "0 is disconnected" << endl;
controller0 = false;
}
else if (event.joystickConnect.joystickId == 1)
{
cout << "1 is disconnected" << endl;
controller1 = false;
}
break;
}
if (event.type == Event::JoystickConnected)
{
if (event.joystickConnect.joystickId == 0)
{
cout << "0 is connected" << endl;
controller0 = true;
}
else if (event.joystickConnect.joystickId == 1)
{
cout << "1 is connected" << endl;
controller1 = true;
}
break;
}
if (!controller0 || !controller1)
{
this_thread::sleep_for(chrono::milliseconds(1000));
window.draw(rect, BlendNone);
window.draw(controllerDisconnectedSprite);
window.display();
continue;
}
I can't really show you my previous attempts, but I can try to rewrite it if it's needed.
I've tried Windows settings too, but as expected it changes nothing. Controllers work fine outside of my game.
I'd really appreciate any help, cause I've been stuck with this for 3 days now.