Sorry to bump an old topic, but I also had this problem and discovered a different solution.
I modified JoystickImpl::IsConnected to use XInput instead of JoyGetPosEx, and there's no longer any lag. I was getting huge spikes when triggering mouse move events on my SFML window, particularly when a gamepad was recently unplugged (even after restarting the program).
This probably only works for Xbox controllers as I haven't got anything else to test it with, but here's what I changed:
src\SFML\Window\Win32\JoystickImpl.cpp
#include <Xinput.h>
...
bool JoystickImpl::IsConnected(unsigned int index)
{
//removed joyGetPosEx stuff
XINPUT_STATE dummy;
ZeroMemory(&dummy, sizeof(XINPUT_STATE));
DWORD result = XInputGetState(index, &dummy);
return result == ERROR_SUCCESS;
}
But it allows you to poll the connection state as often as you like with no slowdown.