Using the latest SFML from github (2.1 should also work but I didn't test with it) you can listen for the sf::Event::JoystickConnected
and sf::Event::JoystickDisconnected
events as described in the SFML Events Tutorial. I've tested the events and they are both fired on Mac and Windows.
A sample program to test this would look like:
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML Joystick Events!");
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event:: JoystickConnected)
{
std::cout << "joystick connected: " << event.joystickConnect.joystickId << std::endl;
}
else if (event.type == sf::Event::JoystickDisconnected)
{
std::cout << "joystick disconnected: " << event.joystickConnect.joystickId << std::endl;
}
else if (event.type == sf::Event::Closed)
{
window.close();
}
}
}
return 0;
}