MPX
Have you ever wished you could control more than one pointer at the same time in the same X server? No? Well, I'll show you how anyway. X11R7.5 included support for MPX—which allows you to have many keyboards and mice connected to your computer at once. I haven't actually played around with multiple keyboards though: I imagine it'd be a bit hard to get used to.
The magic is all in the xinput command:
9:38:50 ~ % xinput --help
usage :
xinput get-feedbacks <device name>
xinput set-ptr-feedback <device name> <threshold> <num> <denom>
xinput set-integer-feedback <device name> <feedback id> <value>
xinput get-button-map <device name>
xinput set-button-map <device name> <map button 1> [<map button 2> [...]]
xinput set-pointer <device name> [<x index> <y index>]
xinput set-mode <device name> ABSOLUTE|RELATIVE
xinput list [--short || --long] [<device name>...]
xinput query-state <device name>
xinput test [-proximity] <device name>
xinput create-master <id> [<sendCore (dflt:1)>] [<enable (dflt:1)>]
xinput remove-master <id> [Floating|AttachToMaster (dflt:Floating)] [<returnPointer>] [<returnKeyboard>]
xinput reattach <id> <master>
xinput float <id>
xinput set-cp <window> <device>
xinput test-xi2 <device>
xinput list-props <device> [<device> ...]
xinput set-int-prop <device> <property> <format (8, 16, 32)> <val> [<val> ...]
xinput set-float-prop <device> <property> <val> [<val> ...]
xinput set-atom-prop <device> <property> <val> [<val> ...]
xinput watch-props <device>
xinput delete-prop <device> <property>
xinput set-prop <device> [--type=atom|float|int] [--format=8|16|32] <property> <val> [<val> ...]
Don't you just feel enlightened having read that? No? Me neither. There are a few interesting commands though (presumably they're all interesting, but I haven't investigated yet), namely 'list', 'create-master', 'reattach', and 'remove-master'. Go ahead. Try 'xinput list' in a terminal, you should get a list like this if you're on a laptop:
9:38:54 ~ % xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Macintosh mouse button emulation id=6 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=7 [slave pointer (2)]
⎜ ↳ Microsoft Comfort Optical Mouse 1000 id=9 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=8 [slave keyboard (3)]
↳ Chicony USB 2.0 Camera id=10 [slave keyboard (3)]
↳ Power Button id=11 [slave keyboard (3)]
↳ Video Bus id=12 [slave keyboard (3)]
↳ Power Button id=13 [slave keyboard (3)]
Let's say I wanted to create a new mouse/keyboard pair and assign my touchpad mouse to it…
9:43:24 ~ % xinput create-master touchpad
9:44:18 ~ % xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Macintosh mouse button emulation id=6 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=7 [slave pointer (2)]
⎜ ↳ Microsoft Comfort Optical Mouse 1000 id=9 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=8 [slave keyboard (3)]
↳ Chicony USB 2.0 Camera id=10 [slave keyboard (3)]
↳ Power Button id=11 [slave keyboard (3)]
↳ Video Bus id=12 [slave keyboard (3)]
↳ Power Button id=13 [slave keyboard (3)]
⎡ touchpad pointer id=14 [master pointer (15)]
⎜ ↳ touchpad XTEST pointer id=16 [slave pointer (14)]
⎣ touchpad keyboard id=15 [master keyboard (14)]
↳ touchpad XTEST keyboard id=17 [slave keyboard (15)]
Behold, another pointer has appeared on your screen and in your input list! It won't do anything yet though, for that, we need the reattach command. Notice that all devices have an ID. The ID of my touchpad is 7, and the ID of my new pointer is 14.
9:44:22 ~ % xinput reattach 7 14
I can now move my second pointer around with my touchpad! If I attached another keyboard to it, I could do the same thing. If I wanted I could have one master for the built-in keyboard and touchpad, and another for an external keyboard and mouse, though I imagine it could be a little confusing at first.
When you want to return to normal, simply reattach your mouse to where it should be, and remove the master you created:
9:47:35 ~ % xinput reattach 7 2
9:47:42 ~ % xinput remove-master 14
I don't think MPX is really that useful for any input devices other than touchscreens, but I could see it being fun playing with some multitouch-aware 3D thingy with a mouse in either hand. Or you could train yourself to type different things at the same time and be twice as productive.







