开发者

Input from 4 different mice

I need to build a simple app that takes (click only) input from 4 USB mice c开发者_开发技巧onnected in addition to the built-in touchpad on a notebook. My preferred operating system for this setup would be Linux.

Any idea how I might be able to discern in an application which mouse a click came from? I'm open to C programming or whatever it takes. It's a simple, one-off project, so nothing too elaborate though.


For what it's worth, I think I found an answer to my question.

bobince's mention of xorg led me to look in /etc/X11/xorg.conf. That turns out to be full of comments like

# commented out by update-manager, HAL is now used

I had heard of HAL before, and not just in 2001. I tried man -k hal and found lshal, which lists 133 (!) HAL devices in my PC. In the entry for one of my mice, I found

linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:0b.0/usb2/2-7/2-7:1.0/input/input6/event6'

which turns out to be a directory in the file system. Exploring from there, I discovered a reference back to /dev/input/mouse3. In fact, all my mice were sitting there in /dev/input!

Wearing my superuser cape, I was able to read /dev/input/mouse3:

root@carl-ubuntu:/dev/input# od -t x1 -w6 mouse3
0000000 09 00 00 08 00 00
*

so it turns out a left mouse click is 09 00 00 08 00 00, consistently and repeatably.

Conclusion: I can read mouse clicks from /dev/input/mouseX. Having done chmod a+r on those files, I can even read them from a normal user account. I need to figure out a way to stop 4 mice running wild in the hands of probably drunk people from actually interacting directly with the GUI, but that's a problem for another day.


MPX is where it's at for multiple-mouse and multitouch under Linux, but you'll need to be using xorg xserver 1.7 to get the ‘proper’ version of it; this is generally taken as part of X11R7.5, which has only just come out as ‘stable’ and has not been integrated by the distros yet. (Even xorg-edgers doesn't have it, though that's where you'd keep an eye on if you're an Ubuntu-er.)

GTK+ seems to have had some work put into allowing you to detect which mouse clicked (GdkEvent.gdk_event_get_device), but I don't know what the timetable is for getting this into a full stable release. Nor do I know how far along Qt4 is with it. So in summary the situation is: it works if you're willing to put the time into grabbing, compiling and fixing stuff, but it's not smooth with mainstream Linux, yet.


I'm not too sure where to start for this, but it sounds a lot to me like it'd be similar to getting multi-touch to work. Maybe start looking for multi-touch drivers for linux?

Also, luvieere's first link might be helpful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜