Reputation: 527
Here's my code
#include <SDL.h>
#include <iostream>
int main(int argc,char **argv)
{
std::cout<<SDL_NumHaptics()<<std::endl<<SDL_NumJoysticks()<<std::endl;
return 0;
}
When I run it it says 0 joysticks and 0 haptic devices, this happens on both linux and windows. On linux I have xboxdrv installed and it detects the controller and on windows I also have the necessary drivers installed. SFML does detect the controller as a joystick on linux, however, I would much rather use SDL, due to its support for haptic devices and openGL profiles.
Upvotes: 0
Views: 1981
Reputation: 51842
You forgot to initialize SDL. For example:
SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC);
Or, if you're using SDL for everything (graphics, audio, etc.) then:
SDL_Init(SDL_INIT_EVERYTHING);
Upvotes: 3