views:

86

answers:

4

I was wondering if there is a way to intercept and modify mouse input before it gets to windows?

What I'm wanting to do is intercept mouse motion events, apply some custom scaling and acceleration to the values, and then continue passing them along. I'd need something that can do this before the inputs get to the raw input API or DirectInput.

A: 
YanivH
The question asked specifically for a method that works with DirectInput.
Ben Voigt
A: 

There is a LowLevelMouseProc hook procedure that you can use to get information on any mouse input entering the system, although I doubt if you can actually change this information (and the docs are silent on this).

If this fails, GetMsgProc is an alternative that lets you intercept all messages posted to any window. Though this hook does let you modify the message, it's probably too late to have any effect on APIs such as DirectInput.

casablanca
+2  A: 

In order to affect all mouse input, including DirectInput, during logon and the SAS screen, etc., you'll need to load a filter driver into the mouse driver stack.

Other people have done it, for example http://www.maf-soft.de/mafmouse/

There should be a moufiltr sample in the Windows DDK which you can use as a starting point. You will most likely want to use a virtual machine for development since errors in a driver on your development machine could be difficult to recover from.

Ben Voigt
This seems to be the only way to affect input below the raw input API and DirectInput. Detouring the APIs would also work for my purposes too as I only would need it on a per-process basis. I think I'll hold off on developing a driver though, I really have no work flow set up for that and it seems like more effort than it's worth for what I want to do.
jay.lee
A: 

You could try a windows hook - which are functions you set to receive windows messages before they get passed through to the rest of the system - a CBT hook (for computer based training) is what might get you best results.

I don't know Whether this will work with DirectInput or the other new stuff MS has added to break all the old internal consistency. Its easy to set up though, so try it and see.

gbjbaanb