Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::Joystick IsConnected() counts single controller twice  (Read 933 times)

0 Members and 1 Guest are viewing this topic.

th

  • Newbie
  • *
  • Posts: 1
    • View Profile
sf::Joystick IsConnected() counts single controller twice
« on: February 02, 2020, 09:39:50 pm »
First time posting, so just let me know if im not doing things right.

I downloaded the most recent version of sfml for windows, and decided to try my hand at up to 4 player local multiplayer, using xBox controllers. So, for example index 0 and 1 are connected at the beginning of the program, so i save the indexes into a std::vector of size 2. The issue is when an indexed joystick (an index less than another connected joystick index) disconnects.The isConnected(0) initially will return false, as anticipated, but then will start returning true and start receiving the same inputs as the index 1 joystick. When the original index 0 joystick is reconnected, index 0 and 1 still recieve inputs from the 1 index controller. is there way to keep the 0 index from thinking a connection is made from the index 1 controller and wait for the original controller to be reconnected. The quick fix i Have now is just disabling the player once a disconnect event happens to them, but a reconnect cannot happen because it is from the wrong controller, so they must remain disconnected until a shutdown the program.

Any help is appreciated, if can post code but it seems quite simple. just one loop to populate a vector of connected indexes, and a game loop to keep checking isConnected. I have an poll event and all that good stuff for the gameloop.