1
General / Re: One controller counted as two BUG
« on: July 08, 2020, 09:08:01 pm »
I've made an entirely new project that looks like this:
Tested by:
1. Connecting c0
2. Connecting c1
3. Disconnecting c0
As you can see from console output, disconnecting c0 is recognized as disconnecting them both and reconnecting c0 after...
I've done some more tests and there is much more wrong going on including controller clonning as before :/
#include <iostream>
#include <SFML/Graphics.hpp>
using namespace sf;
using namespace std;
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "window");
sf::Event event;
bool controller0;
bool controller1;
if (Joystick::isConnected(0))
{
controller0 = true;
}
if (Joystick::isConnected(1))
{
controller1 = true;
}
while (window.isOpen()) {
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
window.close();
}
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;
}
}
}
return 0;
}
#include <SFML/Graphics.hpp>
using namespace sf;
using namespace std;
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "window");
sf::Event event;
bool controller0;
bool controller1;
if (Joystick::isConnected(0))
{
controller0 = true;
}
if (Joystick::isConnected(1))
{
controller1 = true;
}
while (window.isOpen()) {
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
window.close();
}
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;
}
}
}
return 0;
}
Tested by:
1. Connecting c0
2. Connecting c1
3. Disconnecting c0
0 is connected
1 is connected
1 is disconnected
Failed to create DirectInput device: -2147467259
0 is disconnected
Failed to create DirectInput device: -2147467259
0 is connected
1 is connected
1 is disconnected
Failed to create DirectInput device: -2147467259
0 is disconnected
Failed to create DirectInput device: -2147467259
0 is connected
As you can see from console output, disconnecting c0 is recognized as disconnecting them both and reconnecting c0 after...
I've done some more tests and there is much more wrong going on including controller clonning as before :/