vmmouse fixes
Subsystems (2)
cover vmmouse fixes
Patch 1 fixes up joydev to not recognize the vmmouse as a joystick. The mouse detection heuristics should be improved, but IMHO it's too late in the release cycle to do that. The second patch just fixes a user-space driver version in the Kconfig help text.
PATCH 1/2 input/joydev: Don't classify the vmmouse as a joystick
Joydev is currently thinking some absolute mice are joystick, and that messes up games in VMware guests, as the cursor typically gets stuck in the top left corner.
Try to detect the event signature of a VMmouse input device and back off for such devices. We're still incorrectly detecting, for example, the VMware absolute USB mouse as a joystick, but adding an event signature matching also that device would be considerably more risky, so defer that to a later merge window.
--- drivers/input/joydev.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/input/joydev.c +40 -0
@@ -747,6 +747,42 @@ static void joydev_cleanup(struct joydev *joydev)input_close_device (handle); } +static bool joydev_dev_is_mouse (struct input_dev *dev) +{ +DECLARE_BITMAP (jd_scratch,KEY_CNT ); + +BUILD_BUG_ON (ABS_CNT >KEY_CNT ||EV_CNT >KEY_CNT ); + +/* +* A device is, for joystick detection purposes, considered to be +* a mouse if the following is true. (This is currently tailored to +* the VMware PS/2 VMMouse device but might be extended). +* +* 1) Absolute events are exactly ABS_X and ABS_Y. +* 2) Keys are exactly BTN_LEFT, BTN_RIGHT and BTN_MIDDLE. +* 3) Event types include EV_ABS, EV_KEY and possibly EV_SYN. +*/ + +bitmap_zero (jd_scratch,EV_CNT ); + jd_scratch[BIT_WORD (EV_ABS )] =BIT_MASK (EV_ABS ) |BIT_MASK (EV_KEY ); +if (!bitmap_subset (jd_scratch, dev->evbit,EV_CNT )) +return false; + +__set_bit (EV_SYN , jd_scratch); +if (!bitmap_subset (dev->evbit, jd_scratch,EV_CNT )) +return false; + +bitmap_zero (jd_scratch,ABS_CNT ); + jd_scratch[BIT_WORD (ABS_X )] =BIT_MASK (ABS_X ) |BIT_MASK (ABS_Y ); +if (!bitmap_equal (dev->absbit, jd_scratch,ABS_CNT )) +return false; + +bitmap_zero (jd_scratch,KEY_CNT ); + jd_scratch[BIT_WORD (BTN_LEFT )] =BIT_MASK (BTN_LEFT ) | +BIT_MASK (BTN_RIGHT ) |BIT_MASK (BTN_MIDDLE ); + +return bitmap_equal (dev->keybit, jd_scratch,KEY_CNT ); +}static bool joydev_match (struct input_handler *handler,struct input_dev *dev) {
@@ -758,6 +794,10 @@ static bool joydev_match(struct input_handler *handler, struct input_dev *dev)if (test_bit (EV_KEY , dev->evbit) &&test_bit (BTN_DIGI , dev->keybit))return false; +/* Avoid absolute mice */ +if (joydev_dev_is_mouse (dev)) +return false; +return true; }
Signature · 1 line
2.1.0
Dmitry Torokhov
maintainerRe: [PATCH 1/2] input/joydev: Don't classify the vmmouse as a joystick
Hi Thomas,
Quoted 9 lines · Thomas Hellstrom
Joydev is currently thinking some absolute mice are joystick, and that messes up games in VMware guests, as the cursor typically gets stuck in the top left corner.
Try to detect the event signature of a VMmouse input device and back off for such devices. We're still incorrectly detecting, for example, the VMware absolute USB mouse as a joystick, but adding an event signature matching also that device would be considerably more risky, so defer that to a later merge window.
Right. What events does it report?
Quoted 18 lines
Signed-off-by Thomas Hellstrom <[email protected]>--- drivers/input/joydev.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)drivers/input/joydev.c +4
-0@@ -747,6 +747,42 @@ static void joydev_cleanup(struct joydev *joydev)input_close_device (handle); } +static bool joydev_dev_is_mouse (struct input_dev *dev) +{ +DECLARE_BITMAP (jd_scratch,KEY_CNT ); +
drivers/input/joydev.c static void joydev_cleanup(struct joydev *joydev) · line 763
Quoted 10 lines
drivers/input/joydev.c +10
-0+BUILD_BUG_ON (ABS_CNT >KEY_CNT ||EV_CNT >KEY_CNT ); + +/* +* A device is, for joystick detection purposes, considered to be +* a mouse if the following is true. (This is currently tailored to +* the VMware PS/2 VMMouse device but might be extended). +* +* 1) Absolute events are exactly ABS_X and ABS_Y. +* 2) Keys are exactly BTN_LEFT, BTN_RIGHT and BTN_MIDDLE. +* 3) Event types include EV_ABS, EV_KEY and possibly EV_SYN.
EV_SYN is set automatically on _every_ input device. There is also amijoy driver that historically uses BTN_LEFT/RIGHT/MIDDLE.
Does the version of the patch below still work for you?
Signature · 22 lines
Dmitry Input: joydev - don't classify the vmmouse as a joystick From: Thomas Hellstrom <[email protected]> Joydev is currently thinking some absolute mice are joystick, and that messes up games in VMware guests, as the cursor typically gets stuck in the top left corner. Try to detect the event signature of a VMmouse input device and back off for such devices. We're still incorrectly detecting, for example, the VMware absolute USB mouse as a joystick, but adding an event signature matching also that device would be considerably more risky, so defer that to a later merge window. Signed-off-by: Thomas Hellstrom <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]> --- drivers/input/joydev.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+)
drivers/input/joydev.c +61 -0
@@ -747,6 +747,63 @@ static void joydev_cleanup(struct joydev *joydev)input_close_device (handle); } +static bool joydev_dev_is_absolute_mouse (struct input_dev *dev) +{ +DECLARE_BITMAP (jd_scratch,KEY_CNT ); + +BUILD_BUG_ON (ABS_CNT >KEY_CNT ||EV_CNT >KEY_CNT ); + +/* +* Virtualization (VMware, etc) and remote management (HP +* ILO2) solutions use absolute coordinates for their virtual +* pointing devices so that there is one-to-one relationship +* between pointer position on the host screen and virtual +* guest screen, and so their mice use ABS_X, ABS_Y and 3 +* primary button events. This clashes with what joydev +* considers to be joysticks (a device with at minimum ABS_X +* axis). +* +* Here we are trying to separate absolute mice from +* joysticks. A device is, for joystick detection purposes, +* considered to be an absolute mouse if the following is +* true: +* +* 1) Event types are exactly EV_ABS, EV_KEY and EV_SYN. +* 2) Absolute events are exactly ABS_X and ABS_Y. +* 3) Keys are exactly BTN_LEFT, BTN_RIGHT and BTN_MIDDLE. +* 4) Device is not on "Amiga" bus. +*/ + +bitmap_zero (jd_scratch,EV_CNT ); +__set_bit (EV_ABS , jd_scratch); +__set_bit (EV_KEY , jd_scratch); +__set_bit (EV_SYN , jd_scratch); +if (!bitmap_equal (jd_scratch, dev->evbit,EV_CNT )) +return false; + +bitmap_zero (jd_scratch,ABS_CNT ); +__set_bit (ABS_X , jd_scratch); +__set_bit (ABS_Y , jd_scratch); +if (!bitmap_equal (dev->absbit, jd_scratch,ABS_CNT )) +return false; + +bitmap_zero (jd_scratch,KEY_CNT ); +__set_bit (BTN_LEFT , jd_scratch); +__set_bit (BTN_RIGHT , jd_scratch); +__set_bit (BTN_MIDDLE , jd_scratch); + +if (!bitmap_equal (dev->keybit, jd_scratch,KEY_CNT )) +return false; + +/* +* Amiga joystick (amijoy) historically uses left/middle/right +* button events. +*/ +if (dev->id.bustype ==BUS_AMIGA ) +return false; + +return true; +}static bool joydev_match (struct input_handler *handler,struct input_dev *dev) {
@@ -758,6 +815,10 @@ static bool joydev_match(struct input_handler *handler, struct input_dev *dev)if (test_bit (EV_KEY , dev->evbit) &&test_bit (BTN_DIGI , dev->keybit))return false; +/* Avoid absolute mice */ +if (joydev_dev_is_absolute_mouse (dev)) +return false; +return true; }
Re: [PATCH 1/2] input/joydev: Don't classify the vmmouse as a joystick
Quoted 7 lines · Dmitry Torokhov
Hi Thomas,
Quoted 4 lines · Thomas Hellstrom
Joydev is currently thinking some absolute mice are joystick, and that messes up games in VMware guests, as the cursor typically gets stuck in the top left corner.
Quoted 6 lines
Quoted 5 lines
Try to detect the event signature of a VMmouse input device and back off for such devices. We're still incorrectly detecting, for example, the VMware absolute USB mouse as a joystick, but adding an event signature matching also that device would be considerably more risky, so defer that to a later merge window.
Right. What events does it report?
I'm attaching an evemu-describe event report. One possibility would be to relax the mouse button requirement from being strictly left-right-middle to just include left-right-middle, and also accept relative mouse wheels.
However note that VMware's absolute usb mouse is disabled (by default) on Linux because of joydev, and even if joydev is
fixed I doubt that it will be enabled by default again, as long as there are "buggy" joydevs out there. Still, I see a point in adding signature matching for it anyway, as users can override the default off setting and it would also pave the way for upcoming similar devices, as adding signature matching like this in the last minute tends to be risky...
Quoted 7 lines
EV_SYNis set automatically on _every_ input device. There is also amijoy driver that historically uses BTN_LEFT/RIGHT/MIDDLE.Does the version of the patch below still work for you?
Yes, it works just fine. If there's a chance we can have that patch in 4.1GA that would be great.
Thanks,
Thomas
# EVEMU 1.2
# Input device name: "VMware VMware Virtual USB Mouse"
# Input device ID: bus 0x03 vendor 0xe0f product 0x03 version 0x110 # Supported events:
# Event type 0 (EV_SYN)
# Event code 0 (SYN_REPORT) # Event code 1 (SYN_CONFIG) # Event code 2 (SYN_MT_REPORT) # Event code 3 (SYN_DROPPED) # Event code 4 ((null)) # Event code 5 ((null)) # Event code 6 ((null)) # Event code 7 ((null)) # Event code 8 ((null)) # Event code 9 ((null)) # Event code 10 ((null)) # Event code 11 ((null)) # Event code 12 ((null)) # Event code 13 ((null)) # Event code 14 ((null)) # Event type 1 (EV_KEY) # Event code 272 (BTN_LEFT) # Event code 273 (BTN_RIGHT) # Event code 274 (BTN_MIDDLE) # Event code 275 (BTN_SIDE) # Event code 276 (BTN_EXTRA) # Event code 277 (BTN_FORWARD) # Event code 278 (BTN_BACK) # Event code 279 (BTN_TASK) # Event code 280 ((null)) # Event code 281 ((null)) # Event code 282 ((null)) # Event code 283 ((null)) # Event code 284 ((null)) # Event code 285 ((null)) # Event code 286 ((null)) # Event code 287 ((null))
# Event type 2 (EV_REL)
# Event code 6 (REL_HWHEEL)
# Event code 8 (REL_WHEEL)
# Event type 3 (EV_ABS)
# Event code 0 (ABS_X)
# Value 12344 # Min 0 # Max 32767 # Fuzz 0 # Flat 0 # Resolution 0 # Event code 1 (ABS_Y) # Value 16828 # Min 0 # Max 32767 # Fuzz 0 # Flat 0 # Resolution 0
# Event type 4 (EV_MSC)
# Event code 4 (MSC_SCAN)
# Properties:
N: VMware VMware Virtual USB Mouse
I: 0003 0e0f 0003 0110
P: 00 00 00 00 00 00 00 00
B: 00 0b 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 ff ff 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 02 40 01 00 00 00 00 00 00
B: 03 03 00 00 00 00 00 00 00
B: 04 10 00 00 00 00 00 00 00
B: 05 00 00 00 00 00 00 00 00
B: 11 00 00 00 00 00 00 00 00
B: 12 00 00 00 00 00 00 00 00
B: 14 00 00 00 00 00 00 00 00
B: 15 00 00 00 00 00 00 00 00
B: 15 00 00 00 00 00 00 00 00
A: 00 0 32767 0 0 0
A: 01 0 32767 0 0 0
PATCH 2/2 input/vmmouse: Fix Kconfig help text
In reply to Thomas HellstromThe vmmouse Kconfig help text was referring to an incorrect user-space driver version. Fix this.
--- drivers/input/mouse/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/mouse/Kconfig +1 -1
@@ -156,7 +156,7 @@ config MOUSE_PS2_VMMOUSE Say Y here if you are running under control of VMware hypervisor (ESXi, Workstation or Fusion). Also make sure that when you enable this option, you remove the xf86-input-vmmouse user-space driver - or upgrade it to at least xf86-input-vmmouse 13.0.1, which doesn't + or upgrade it to at least xf86-input-vmmouse 13.1.0, which doesn't load in the presence of an in-kernel vmmouse driver. If unsure, say N.
Signature · 1 line
2.1.0