• Advertisement
Sign in to follow this  

Why RawInput does not work from dll C#

This topic is 1096 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am using sharpdx rawinput lib from my C# lib and I see that its not working at all, BUT if I start it from my main WPF app it works pretty well.

Could someone say why it is so? Why I dont receive any event from mouse if I use it from lib and not from the main app?

Share this post


Link to post
Share on other sites
Advertisement

Does your DLL have it's own thread/window/message loop?

Are you calling RegisterRawInputDevices, and does it return TRUE (no error)?

Are you setting RAWINPUTDEVICE.hwndTarget to the handle of the window you wish to receive WM_INPUT messages? (If not, the messages are sent to the window which has focus).

You do need a window - just a message loop handling WM_INPUT without a window won't work.

 

Maybe RegisterRawInputDevices only works once per process for the same device, so make sure nothing else is using it in the process which loads your DLL (and processing the WM_INPUT messages before your DLL gets them)?

Edited by tonemgub

Share this post


Link to post
Share on other sites

You might want to check that your interface to the DLL from C# is correct, e.g. all your Interop and DllImport lines match the correct signatures.

 

Sometimes Interop can be a little fussy about pointer types, and what it tries to have as managed types, e.g. managed pointers vs raw pointers.

Share this post


Link to post
Share on other sites

I am using C# + Sharpdx, so I have managed raw input lib without any Win 32. 

But seems I understood the problem - on main thread I need to register device and then I can subscribe to events on any part of the code.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement