* [PATCH -fixes 0/2] vmmouse fixes @ 2015-05-19 11:37 Thomas Hellstrom 2015-05-19 11:37 ` [PATCH 1/2] input/joydev: Don't classify the vmmouse as a joystick Thomas Hellstrom 2015-05-19 11:37 ` [PATCH 2/2] input/vmmouse: Fix Kconfig help text Thomas Hellstrom 0 siblings, 2 replies; 5+ messages in thread From: Thomas Hellstrom @ 2015-05-19 11:37 UTC (permalink / raw) To: dmitry.torokhov, linux-input; +Cc: pv-drivers, linux-graphics-maintainer 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. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] input/joydev: Don't classify the vmmouse as a joystick 2015-05-19 11:37 [PATCH -fixes 0/2] vmmouse fixes Thomas Hellstrom @ 2015-05-19 11:37 ` Thomas Hellstrom 2015-05-20 22:23 ` Dmitry Torokhov 2015-05-19 11:37 ` [PATCH 2/2] input/vmmouse: Fix Kconfig help text Thomas Hellstrom 1 sibling, 1 reply; 5+ messages in thread From: Thomas Hellstrom @ 2015-05-19 11:37 UTC (permalink / raw) To: dmitry.torokhov, linux-input Cc: pv-drivers, linux-graphics-maintainer, 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. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> --- drivers/input/joydev.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c index f362883..1ad2fb1 100644 --- a/drivers/input/joydev.c +++ b/drivers/input/joydev.c @@ -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; } -- 2.1.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] input/joydev: Don't classify the vmmouse as a joystick 2015-05-19 11:37 ` [PATCH 1/2] input/joydev: Don't classify the vmmouse as a joystick Thomas Hellstrom @ 2015-05-20 22:23 ` Dmitry Torokhov 2015-05-21 8:14 ` Thomas Hellstrom 0 siblings, 1 reply; 5+ messages in thread From: Dmitry Torokhov @ 2015-05-20 22:23 UTC (permalink / raw) To: Thomas Hellstrom; +Cc: linux-input, pv-drivers, linux-graphics-maintainer Hi Thomas, On Tue, May 19, 2015 at 04:37:04AM -0700, Thomas Hellstrom wrote: > 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? > > Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> > --- > drivers/input/joydev.c | 40 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 40 insertions(+) > > diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c > index f362883..1ad2fb1 100644 > --- a/drivers/input/joydev.c > +++ b/drivers/input/joydev.c > @@ -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. 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? -- Dmitry Input: joydev - don't classify the vmmouse as a joystick From: Thomas Hellstrom <thellstrom@vmware.com> 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 <thellstrom@vmware.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> --- drivers/input/joydev.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c index f362883..1d247bc 100644 --- a/drivers/input/joydev.c +++ b/drivers/input/joydev.c @@ -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; } ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] input/joydev: Don't classify the vmmouse as a joystick 2015-05-20 22:23 ` Dmitry Torokhov @ 2015-05-21 8:14 ` Thomas Hellstrom 0 siblings, 0 replies; 5+ messages in thread From: Thomas Hellstrom @ 2015-05-21 8:14 UTC (permalink / raw) To: Dmitry Torokhov; +Cc: linux-input, pv-drivers, linux-graphics-maintainer [-- Attachment #1: Type: text/plain, Size: 1684 bytes --] On 05/21/2015 12:23 AM, Dmitry Torokhov wrote: > Hi Thomas, > > On Tue, May 19, 2015 at 04:37:04AM -0700, Thomas Hellstrom wrote: >> 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? 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... > > 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? > Yes, it works just fine. If there's a chance we can have that patch in 4.1GA that would be great. Thanks, Thomas [-- Attachment #2: usb_abs-1.desc --] [-- Type: text/plain, Size: 2431 bytes --] # 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] input/vmmouse: Fix Kconfig help text 2015-05-19 11:37 [PATCH -fixes 0/2] vmmouse fixes Thomas Hellstrom 2015-05-19 11:37 ` [PATCH 1/2] input/joydev: Don't classify the vmmouse as a joystick Thomas Hellstrom @ 2015-05-19 11:37 ` Thomas Hellstrom 1 sibling, 0 replies; 5+ messages in thread From: Thomas Hellstrom @ 2015-05-19 11:37 UTC (permalink / raw) To: dmitry.torokhov, linux-input Cc: pv-drivers, linux-graphics-maintainer, Thomas Hellstrom The vmmouse Kconfig help text was referring to an incorrect user-space driver version. Fix this. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> --- drivers/input/mouse/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig index 7462d2f..d7820d1 100644 --- a/drivers/input/mouse/Kconfig +++ b/drivers/input/mouse/Kconfig @@ -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. -- 2.1.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-05-21 8:15 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-05-19 11:37 [PATCH -fixes 0/2] vmmouse fixes Thomas Hellstrom 2015-05-19 11:37 ` [PATCH 1/2] input/joydev: Don't classify the vmmouse as a joystick Thomas Hellstrom 2015-05-20 22:23 ` Dmitry Torokhov 2015-05-21 8:14 ` Thomas Hellstrom 2015-05-19 11:37 ` [PATCH 2/2] input/vmmouse: Fix Kconfig help text Thomas Hellstrom
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).