2 Mice, capturing exclusively one mouse on windows

2019-08-07 19:19发布

问题:

I have connected 2 mice to PC and I wish one mouse to work as regular mouse and capture second mouse exclusively.

First I was trying DirectInput. It showed 2 devices with word mouse in InstanceName. But only one device had DeviceType.Mouse and it was only really working device. When I was acquiring it was blocking both mice.

Second I decided to create driver. I downloaded WinDDK. There is Mouse Filter driver sample. I was able to compile it. But I am not driver programmer. It is complex for me to understand but it has some code related to PS/2 mouse. All my mice are USB.

It should be installed with .INF file. I prefer it be dynamically loaded.

I am not quite sure that it is right direction. I do it for my hobbyist robotic project. I wish PC take some information from mouse as sensor. I think there must be existing similar projects or solutions.

I have linux pc on my table as well. May be better to attach mouse to linux and parse

/dev/input/mouse0
/dev/input/mouse1
/dev/input/mouse2

looks like sudo cat /dev/input/mouse1 - gives some data but does not block device from clicks and movements.

I hope simple solution already exists

Cheers Max

回答1:

For Linux, you need to either declare the first mouse as the CorePointer or configure the second mouse to have SendCoreEvents false. See the xorg.conf(5) man page for more details.