📜 ⬆️ ⬇️

Linux :: two, three, five ... mouse pointers

I do not know why it will be useful to me, but I suddenly wanted to have two mouse pointers in Linux, because I have two “mice” - the wireless mouse itself and the touchpad. The idea came at that moment when I connected the second mouse, i.e. third pointer control device.


How many mice, so many cursors, but how?


Let's see what xinput tells us:
')
max 23:20:19 ~ $ xinput list ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ Logitech USB Receiver id=10 [slave pointer (2)] ⎜ ↳ Logitech USB Receiver id=11 [slave pointer (2)] ⎜ ↳ Genius 2.4G Wireless Mouse id=12 [slave pointer (2)] ⎜ ↳ SynPS/2 Synaptics TouchPad id=14 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ Power Button id=6 [slave keyboard (3)] ↳ Video Bus id=7 [slave keyboard (3)] ↳ Sleep Button id=8 [slave keyboard (3)] ↳ Villem id=9 [slave keyboard (3)] ↳ AT Translated Set 2 keyboard id=13 [slave keyboard (3)] ↳ HP WMI hotkeys id=15 [slave keyboard (3)] 


I honestly do not know why the Logitech USB whistle is displayed twice. I would be grateful if someone tells you why.

But I digress! From the exhaust it is clear that we have only 4 mice:



To see the second cursor, create a group:
 xinput create-master logitech 


Now on the screen there are TWO pointers of the mouse, but the second is still immobile, and all three devices control the same pointer. Let's say to the X server that Logitech will control the still fixed cursor. To do this, look again at

 max 23:23:40 ~ $ xinput list ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ Logitech USB Receiver id=10 [slave pointer (2)] ⎜ ↳ Logitech USB Receiver id=11 [slave pointer (2)] ⎜ ↳ Genius 2.4G Wireless Mouse id=12 [slave pointer (2)] ⎜ ↳ SynPS/2 Synaptics TouchPad id=14 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ Power Button id=6 [slave keyboard (3)] ↳ Video Bus id=7 [slave keyboard (3)] ↳ Sleep Button id=8 [slave keyboard (3)] ↳ Villem id=9 [slave keyboard (3)] ↳ AT Translated Set 2 keyboard id=13 [slave keyboard (3)] ↳ HP WMI hotkeys id=15 [slave keyboard (3)] ⎡ logitech pointer id=16 [master pointer (17)] ⎜ ↳ logitech XTEST pointer id=18 [slave pointer (16)] ⎣ logitech keyboard id=17 [master keyboard (16)] ↳ logitech XTEST keyboard id=19 [slave keyboard (17)] 


You can now distinguish between two groups of input devices. “Virtual core” and “logitech”, however, we see that the logitech device is still included in the Virtual core group. Correct the situation - let's connect devices with ID = 10 (Logitech) to a group with ID = 16 (logitech)
 xinput reattach 10 16 


Now the mouse from Logitech controls the previously fixed cursor.

Create another group and attach our touchpad to it:

 max 23:30:30 ~ $ xinput create-master touchpad max 23:32:35 ~ $ xinput list ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ Logitech USB Receiver id=11 [slave pointer (2)] ⎜ ↳ Genius 2.4G Wireless Mouse id=12 [slave pointer (2)] ⎜ ↳ SynPS/2 Synaptics TouchPad id=14 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ Power Button id=6 [slave keyboard (3)] ↳ Video Bus id=7 [slave keyboard (3)] ↳ Sleep Button id=8 [slave keyboard (3)] ↳ Villem id=9 [slave keyboard (3)] ↳ AT Translated Set 2 keyboard id=13 [slave keyboard (3)] ↳ HP WMI hotkeys id=15 [slave keyboard (3)] ⎡ logitech pointer id=16 [master pointer (17)] ⎜ ↳ Logitech USB Receiver id=10 [slave pointer (16)] ⎜ ↳ logitech XTEST pointer id=18 [slave pointer (16)] ⎣ logitech keyboard id=17 [master keyboard (16)] ↳ logitech XTEST keyboard id=19 [slave keyboard (17)] ⎡ touchpad pointer id=20 [master pointer (21)] ⎜ ↳ touchpad XTEST pointer id=22 [slave pointer (20)] ⎣ touchpad keyboard id=21 [master keyboard (20)] ↳ touchpad XTEST keyboard id=23 [slave keyboard (21)] max 23:32:39 ~ $ xinput reattach 14 20 max 23:32:53 ~ $ 


After that we see three mouse pointers and control each one from a separate device!

How it can be useful - not yet invented. Just for fun - look into the Windows-amazed eyes of the user and proudly say:
 ,   ! 

Source: https://habr.com/ru/post/165385/


All Articles