How to detect the input device if mouse and touchpad are both enabled

此生再无相见时 提交于 2019-12-06 14:28:30
Rob Kennedy

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 ;).

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

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!