I am trying to modify an existing application by adding an input gathering thread outside of its main thread.
The original application already processes mouse input pretty decently inside its main loop, but it does so at a rate that's very slow for my project to properly work.
So I want to process mouse input outside the main thread on a very high rate, without interfering with the original application's input handling process at all? How can I do that? Can I register a mouse device and get corresponding WM_INPUT without preventing the original app from doing its own processing untouched?
You can register for Raw Input in a separate thread. But first you need to create invisible window in that thread. Also to receive input in that thread you need to provide
RIDEV_INPUTSINKto yourRegisterRawInputDevices()call.Here is my code that doing that:
You even can make WM_CHAR to work in your thread by posting
WM_KEYDOWNfromWM_INPUTkeyboard messages:Another more common approach is to push
WM_INPUTevents in queue (possibly lockless) and process them in some input worker thread that could emit input events etc to other parts of your program.