http://www.shamusyoung.com/twentysidedtale/?p=20774
The problem:
"One thing to note is that the hardest part of adding controller support was getting it to handle hot-plugging of joysticks. When you start up SDL, it looks around, takes an inventory of the available joysticks, and sets them up for use. But if you plug one in afterward it doesn’t notice or tell you about it. Not even if you ask.
This is made worse by the fact that some genius at Microsoft decided that when the wireless controller loses connection it should yank the device away from you as if someone physically unplugged the joystick. I have no idea why. The receiver is still plugged in.
This is annoyingly common. If the batteries are starting to go, that will lead to a disconnect. If you set the controller down for more than a couple of minutes it goes to sleep, which is also a disconnect. To your game, this doesn’t just mean you stop getting input. It means the device itself vanishes."
The solution:
"It turns out the secret to fix this is to shut down the SDL joystick subsystem and restart it at regular intervals. Like so:"
//No joystick active. See if one showed up.
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
if (!SDL_NumJoysticks())
return; //Still nothin'
'course, this is in C++, but it can be done in Java too.
Probably has some kind of resource cost but shouldn't be a big deal if you do it once every few seconds.
At worst, you could have users press a button on Esc menu > controls to do it, if performance is an issue.