I already have a WH_MOUSE_LL hook in my application, but need a different behavior for Mouse and Touchpad.
I know about Raw Input API, but have no idea how to use it
Pretty simple example of read data from any different usb devices: http://sourceforge.net/projects/libusbdotnet/
This open source C# project. Module Test_Bulk
is exactly what you want to distinguish between USB-devices and read(write) data from it.
Disassemble some Touchpad driver and see how it works. This is the only way to go, cause drivers might use different methods of mouse emulation. And don't forget to vote for my answer ;).
You could use Raw Input to register for devices that you are interested to receive input from if you want to receive input for only the Touchpad, the Mouse, or both. You just need to register to receive input from the devices of your interest using the RegisterRawInputDevices function. this Microsoft docs example explains how to do this for a mouse and keyboard. Listening for Touchpad input would require a similar approach. you would use page 0x0D and usage 0x05. As for using this API with hooks, the AbsoluteTouchEx repository could provide some guidance on how to do this.
I was tried cnPackRawInput and its working fine. it have a KeyboardFromHandle function and i can compare is it my special keyboard(eg. msr device,barcode scanner). But i don't have any idea about is it handle pointing device. anyway you can try. if it support than you can use.
sorry for bad english.
http://www.google.com/codesearch/p?hl=en#6CoJUlkQju4/trunk/cnvcl/Source/NonVisual/CnRawInput.pas&q=rawinput%20package:http://cnpack%5C.googlecode%5C.com&sa=N&cd=3&ct=rc
It should be the same as distinguishing between multiple keyboard devices.
In your case, most probably, Raw Input will do. I've no experience with it beyond knowing its limitations regarding being able to capture input but not being able to prevent it from making after you have captured it, which means keystrokes and mouse events are going to happen for other applications even if you capture them with Raw Input. At last, this is what I have learned in forums abroad.
I have built an alternative approach that is able to distinguish between devices, intercept input and also prevent this input from making. It's a C library that internally communicates with device filter drivers.
I have two basic samples for device disambiguation at github:
The key difference between the two samples is that the hardwareid sample shows how to obtain an identifier provided by your device hardware, including vendor id, product id, and maybe some serial information. The problem is that commonly this provided information is not enough to disambiguate between two identical devices. They happen to be from the same vendor, have the same model, in sum, are equal but not the same. So what lasts to disambiguate is some kind of connection id, that may change at reconnection, but helps to disambiguate at runtime, and this is what the identify sample shows how to do.
I have a macbook and was able to distinguish my magic mouse from my touch pad (at bootcamp) with my library.
More docs at http://oblita.com/Interception.
NOTE: currently the library has a limit of 10 keyboards and 10 mice.