16

January
2013

Mouse grab for vmware

I noticed that many other Linux distributions can detect if they are running in vmware virtual box and automatically configure X to grab / ungrab the mouse cursor. You probably know what I am talking about if you ever tried Slax in vmware, you had to press Ctrl+Alt to release mouse cursor from the guest, and you had to click inside the vmware window to grab the cursor in the virtual machine again. That may be annoying. I thought that vmware tools are needed for automatic grab/ungrab to work, but today I learned it can work out of the box without vmware tools at all.

Xorg has vmmouse driver for long time. It even provides /usr/bin/vmmouse_detect binary, which is a tiny program which detects if the moduse is to be handled by the vmmouse driver. Yet the package xf86-input-vmmouse contains only HAL rules to autodetect vmware mouse, and since HAL is no longer included in Slackware since version 14, X falls back to evdev driver or something like that. The following can be seen in Xorg.log.0:

Hotplugging is on, devices using drivers 'kbd', 'mouse' or 'vmmouse' will be disabled

So how to make Xorg use the vmmouse driver? The following udev rule makes the trick, and will be included in Slax:

ACTION=="add|change", ENV{ID_INPUT_MOUSE}=="?*", ATTRS{description}=="i8042 AUX port", KERNEL=="event[0-9]*", PROGRAM="/usr/bin/vmmouse_detect", ENV{ID_INPUT.tags}="vmmouse"

This is in debian for very long time, but didn't make its way to the official xorg input driver nor to Slackware. I'm going to submit this upstream as well since this tiny change makes a big difference for vmware users.

User comments
Thiago Silvino 2013-01-16 22:28

Awesome finding!

Jason Souza 2013-01-16 22:48

Will the vmmouse driver only compatible with vmware or with virtualbox also?

Tomas M 2013-01-16 22:51

Actually virtualbox doesn't need such driver at all, as far as I can see.

Kadalka 2013-01-16 23:16

Will the vmmouse driver only compatible with vmware or with Qemu ?
Same question for other VM...

Yep, debian rocks...
( my every day distro :-) )

Tomas M 2013-01-17 01:05

vmmouse driver is only for vmware virtual machines. If Qemu and others can emulate vmware mouse then it could probably work as well for them.

joshas 2013-01-17 06:58

Will it provide working mouse scroll wheel too?