Search code examples
c++macosjoystick

How can detect number of joystick connected with my mac using c++?


I am stuck on a problem: in my software I have to code for finding the number of joysticks connected to my Mac using C++... I have no idea about that...

Any sample code or suggestion will very much helpful for me.


Solution

  • You can use SDL library, it should work on Mac and PC as well. Documentation

    Number of joysticks can be determined with just one function call:

    int n = SDL_NumJoysticks();