Getting SDL_SYSWMEVENT when application is runn ing

Hello,

I’m trying to catch the plugging/unplugging of a USB device under Windows
from SDL.

I did something like this:

SDL_EventState (SDL_SYSWMEVENT, SDL_ENABLE);
while(running)
{
while (SDL_PollEvent (&event))
{
switch (event.type)
{
case SDL_QUIT:
running = 0;
break;
case SDL_SYSWMEVENT:
if (event.syswm.msg->msg == WM_DEVICECHANGE)
{
printf (“Got the WM_DEVICECHANGE message\n”);
}
break;
}
}
// Doing the rest of my stuff here
}

In VC8, if I put a breakpoint on the printf I get 2 WM_DEVICECHANGE event when
the application closes, not when I actually unplug and plug the device.
And ONLY if I do unplug and then plug it back on. If I only unplug it I don’t
even get notified. Are SDL_SYSWMEVENT only triggered when something actually
happens to the window? In my case closing it? Is there a way to get those
events to trigger while my application is running?

Thanks for your help.

-WildCoder