SFML community forums

Help => General => Topic started by: Martin379 on May 25, 2017, 01:25:56 am

Title: Register sf::RenderWindow to listen for WM_DEVICECHANGE Windows event
Post by: Martin379 on May 25, 2017, 01:25:56 am
Is there a way to do that?

I know how to do it in a win32 application.

Any help will be appreciated.

thanks!
Title: Re: Register sf::RenderWindow to listen for WM_DEVICECHANGE Windows event
Post by: eXpl0it3r on May 25, 2017, 02:51:44 am
Not directly (if at all). SFML abstracts the event handling and doesn't (yet) allow for custom interaction with it.
In the latest version the event you mentioned is used to track whrn a joystick is plugged in or unplugged.
There maybe a way to hook yourself into the event queue, by like using some WinAPI calls and using the native window handle, but you're basically on your own in that territory. ;)
Title: Re: Register sf::RenderWindow to listen for WM_DEVICECHANGE Windows event
Post by: I_HATE_FIDGET_SPINNERS on May 26, 2017, 08:16:12 am
It might be possible to intercept the message before it gets to the window proc function by using the SetWindowsHookEx function. Be prepared to spend a bit of time digging through MSDN to figure out how to get it working though.