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

Author Topic: 2.5.1 Joystick Class not reading my controller in my program  (Read 1444 times)

0 Members and 2 Guests are viewing this topic.

Monoking007

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
I'm trying to configure my controller to my program using the Joystick class for SFML 2.5.1 but no matter what number i use it still says it's not connected. the code i used to test the connection is

#include <SFML/Window/Joystick.hpp>
using namespace std;

int main()

{
   bool connected = sf::Joystick::isConnected(0);
   cout << connected << endl;
   }

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: 2.5.1 Joystick Class not reading my controller in my program
« Reply #1 on: May 25, 2019, 09:52:52 pm »
Unlike the keyboard or mouse, the state of joysticks is sometimes not directly available (depending on the OS), therefore an update() function must be called in order to update the current state of joysticks. When you have a window with event handling, this is done automatically, you don't need to call anything. But if you have no window, or if you want to check joysticks state before creating one, you must call sf::Joystick::update explicitly.

Monoking007

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: 2.5.1 Joystick Class not reading my controller in my program
« Reply #2 on: May 25, 2019, 11:52:28 pm »
Thank you! I will test it out and see if it works.