Sign in to follow this  
BlackJoker

Why RawInput does not work from dll C#

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this