Skip to main content
GameDev.net gamedev.net
🔒 Locked

Low level mouse filtering

Started by atreyu Aug 8, 2005 at 11:11 PM 2 replies 2.3k views
Original Post
atreyu
atreyu
Does anykone now a way to recieve (and modify) mouse information near the driver level so it can be modified before being used by any applications? I want to insert a low-pass filter to remove high frequency motion components (ie. shaking from diseases like parkinson's). IBM Research has done something similiar to this with a custom mouse driver and a really awful averaging filter. I want to try improving on what they did but I'd rather find a more elegant way than writing a mouse driver if possible. Thanks, --Ben /Wow, It has been a long time since I posted here...
mfawcett
mfawcett
If you are dealing with Win32, you can use SetWindowsHookEx with WH_MOUSE_LL along with your own LowLevelMouseProc.
--Michael Fawcett
atreyu
atreyu
Can I modify the data with a hook and then pass it on? I played around with one last week but couldn't seem to actually modify the mouse coordinates (just read them).

If I'm just missing something, that would be perfect.

Thanks,
--Ben
mfawcett
mfawcett
I believe you can modify the message, but I'm not sure. Give it a try and post back. It will probably go something like this:
LRESULT CALLBACK LowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam){	if (nCode < 0)		return CallNextHookEx(mouseLLHook, nCode, wParam, lParam);	// Are we expected to handle this callback?	if (instance && nCode == HC_ACTION)	{		MSLLHOOKSTRUCT *hook = reinterpret_cast<MSLLHOOKSTRUCT *>(lParam);		if (wParam == WM_LBUTTONDOWN || wParam == WM_LBUTTONUP)		{			POINT pt = { hook->pt.x, hook->pt.y };			HWND hwnd = WindowFromPoint(pt);		}	}	// Otherwise, pass on the message	return CallNextHookEx(mouseLLHook, nCode, wParam, lParam);}

--Michael Fawcett

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.