Erratic cursor movement when using "Coordinate Transformation Matrix"

Bug #774938 reported by Stefan Löffler on 2011-05-01
80
This bug affects 12 people
Affects Status Importance Assigned to Milestone
xorg-server (Ubuntu)
Medium
Chase Douglas
Natty
Undecided
Unassigned

Bug Description

SRU Justification:
==================
In previous releases of xserver-xorg-input-evdev there was an option to invert and/or swap axes. This allowed for simple screen rotation support. In the latest version of the module in Ubuntu, this option has been deprecated in favor of the server-side input coordinate transformation matrix support. See https://wiki.ubuntu.com/X/InputCoordinateTransformation for details. Unfortunately, the XInput 2.1 changes caused the input coordinate transformation matrix support to cause erratic pointer behavior. Without a fix, users cannot reliably use a rotated touchscreen.

The fix involves maintaining and using the proper previous states of the X and Y event coordinates when performing the input coordinate transformation. If one coordinate is updated but not the other, the other's previous untransformed coordinate must be used to compute the correct new transformed coordinates. Then, the new transformed coordinates must be compared to the previous transformed coordinates to see if they should be reported to the client. Unchanged values are not reported in some XI 1.x and 2.x events. The current X server conflates the previous untransformed and previous transformed values and ends up calculating the new transformed values incorrectly.

TEST CASE:
To reproduce, use xinput to set a new coordinate transformation matrix with a rotation. For example, use a 90 degree turn by setting the input coordinate transformation matrix to 0 -1 1 1 0 0 0 0 1. See the above wiki page for details on how to set the matrix. Then, try to touch the touchscreen and move the cursor. The cursor will jump arround erratically when moving in pure horizontal or pure vertical motions.

The risk of regression is minimal because the only time the fix will cause a change is when the transformation matrix has been modified from the identity matrix to a matrix including some amount of rotation. The patch was also tested in the xorg-edgers ppa for a few weeks before it was even uploaded to Oneiric.

Original Bug Report:
====================

When using something like `xinput set-float-prop $INPUTDEV "Coordinate Transformation Matrix" 0.0 -1.0 1.0 1.0 0.0 0.0 0.0 0.0 1.0` to match the coordinates of a touchscreen/tablet to a rotated (transformed) screen, the cursor moves around erratically.

From the original report of david-dklevine (https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-input-evdev/+bug/742567/comments/32):
when a horizontal or vertical drag is performed the cursor jumps wildly - it appears to jump between what it should be according to the coordinate transformation and what it would be if x=0 and y=1 (that is if the second line of the matrix was the identity). With a diagonal drag or a touch the cursor appears where it should be.

In addition to the Cando Multi Touch Panel reported at https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-input-evdev/+bug/742567/comments/32, it also affects me with a AsusTek, Inc. MultiTouch(TTI) (on Asus EeePC T101MT)

lsb_release -rd
Description: Ubuntu 11.04
Release: 11.04

$ apt-cache policy xserver-xorg-input-evdev
xserver-xorg-input-evdev:
  Installed: 1:2.6.0-1ubuntu12
  Candidate: 1:2.6.0-1ubuntu12
  Version table:
 *** 1:2.6.0-1ubuntu12 0
        500 http://gd.tuwien.ac.at/opsys/linux/ubuntu/archive/ natty/main amd64 Packages
        100 /var/lib/dpkg/status

Changed in xserver-xorg-input-evdev (Ubuntu):
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → Chase Douglas (chasedouglas)
Changed in xserver-xorg-input-evdev (Ubuntu):
status: In Progress → Fix Committed
affects: xserver-xorg-input-evdev (Ubuntu) → xorg-server (Ubuntu)
Chase Douglas (chasedouglas) wrote :
description: updated
bugbot (bugbot) on 2011-05-17
tags: added: edgers
tags: added: patch
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package xorg-server - 2:1.10.1-1ubuntu2

---------------
xorg-server (2:1.10.1-1ubuntu2) oneiric; urgency=low

  * Fix masked transformed valuator handling (LP: #774938)
    - Added debian/patches/503_fix_masked_transformed_valuators.patch
 -- Bryce Harrington <email address hidden> Tue, 17 May 2011 14:44:58 -0700

Changed in xorg-server (Ubuntu):
status: Fix Committed → Fix Released
description: updated

Accepted xorg-server into natty-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in xorg-server (Ubuntu Natty):
status: New → Fix Committed
tags: added: verification-needed
Stephen M. Webb (bregma) wrote :

Bug reproduced on a Dell Latitude XT2 and fix verified with no apparent regression in regular use testing.

Martin Pitt (pitti) on 2011-05-25
tags: added: verification-done
removed: verification-needed
Stefan Löffler (st.loeffler) wrote :

I can also confirm that the patch works.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package xorg-server - 2:1.10.1-1ubuntu1.1

---------------
xorg-server (2:1.10.1-1ubuntu1.1) natty-proposed; urgency=low

  [ Chase Douglas ]
  * Fix masked transformed valuator handling (LP: #774938)
    - Added debian/patches/503_fix_masked_transformed_valuators.patch

  [ Timo Aaltonen ]
  * Add 218_randr-check-rotated-virtual-size-limits-correctly.diff
    - Fix rotation with nvidia driver. (LP: #740933)
 -- Timo Aaltonen <email address hidden> Wed, 18 May 2011 20:23:56 +0300

Changed in xorg-server (Ubuntu Natty):
status: Fix Committed → Fix Released
dart (dart-v85) wrote :

After I installed this update on my system, the pointer is behaving really weird and accuracy have dropped. Every pointer movement have become oversensitive and erratic . How can i downgrade to earlier xorg-server?

dart (dart-v85) wrote :

Should I use force version from Synaptic package manager?

Jon Szymaniak (jon-szymaniak) wrote :

Hi there. I've got a touchscreen here with an eGalax Inc. USB TouchController, which requires an axes swap. After switching to 11.04 I began experiencing the symptoms described in the original bug report -- the pointer would "jump" between a desired coordinate (x,y) to (x,0) or (0,y).

After applying the xorg-server 2:1.10.1-1ubuntu1.1 update, I'm still experiencing this "jumping" cursor functionality when the evdev axes swap option is enabled. I'm not entirely sure what additional information would be useful to provide -- please let me know and I'll dig up whatever is necessary to debug this. Thanks!

tags: added: verification-failed
removed: verification-done
Jon Szymaniak (jon-szymaniak) wrote :

Quick Update:

I think I'm a bit confused about this -- from what I understand, the evdev SwapAxes option has been deprecated in favor of the coordinate transform matrix. I was interpreting to mean that in my xorg.conf.d script, I could still set the "SwapAxes" in my xorg.conf.d script, and the coordinate transformation matrix would be now be used under the hood. Below is what I was using:

/usr/share/X11/xorg.conf.d/99-calibration.conf:
Section "InputClass"
  Identifier "calibration"
  MatchProduct "eGalax"
  Option "Calibration" "76 1895 129 1852"
  Option "SwapAxes" "1"
EndSection

The above configuration is what still causes the erratic movement. However, I found that to setting "SwapAxes" to "0" and using xinput to set the devices coordinate transform matrix to [ 0 1 0; 1 0 0; 0 0 1] swapped the axes without the erratic movement, but definitely requires further calibration.

I suspect this bugfix to affect the PAD device on the Wacom Intuos4. When I touch any button or the scrollwheel on said device, the cusor goes to 0/0 (x/y). Tested with current oneiric, but I suppose it affects natty too.

tags: added: testcase

This issue is present on 12.04.
Has the fix been applied to Precise's Xorg package?
(I can't find it in http://changelogs.ubuntu.com/changelogs/pool/main/x/xorg/xorg_7.6+12ubuntu1/changelog)

Marcelo (mmtsales) wrote :

I confirm this bug is present in 12.04. And I see this bug is also not fixed upstream (there are opened bugs about this in freedesktop.org). What exactly have been fixed? If there is a patch, it would be nice to send it upstream.

sm8ps (sm8ps) wrote :

I would like to second the above statements about the bug still being present in (L)Ubuntu 12.04 with Xorg-Server 2:1.11.4. I am using a eGalax Inc. USB TouchController like Jon Szymaniak. So I had a script calling xinput to set-props 'Evdev Axis Inversion' as well as 'Coordinate Transformation Matrix'. However, even without the axis inversion, the pointer erratically jumps around the location pressed. So it definitively seems to be an issue with applying the transformation matrix.

Using the combined "xinput set-props 'EvdevAxis Inversion' 1 0" and 'Option "Calibration" "105 1927 190 1857"' in xorg.conf.d/99.conf however gives me a decently calibrated, working touch screen without the flickering pointer.

Darryl Moore (ubuntubcom) wrote :

Help. I am having this exact same issue as well. I am using 12.04 with all updates to today, but no joy. Can anybody tell me what I can do to make this work again? Is there a patch which actually works? Can I use older code or code from another source which still has "Swap Axes" working.

Please any help would be very much appreciated.

Zachary Salzbank (zsalzbank) wrote :

Please see https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/1005321 for how I solved the cursor jumping issue on 12.04.

The solution for the CTM problem (which is what causes the wacky cursor jumping) is this patch, which was accepted into upstream on 19 Nov 2012; it is not yet in precise-proposed, but I was able to rebuild xorg-server-1.13.0 (from 12.10) with this patch and the problem went away:

http://<email address hidden>/msg33742.html

There is another version of the patch floating around somewhere if you want to fix 12.04.

IMHO, there is no good reason to break evdev's swap and invert properties, though. For the simple rotation case, they seem like the obvious right thing to use. Why should they not work?

Oops, sorry, I mean quantal-proposed. (Though of course it's not in precise-proposed, either.)

Magnes (magnesus2) wrote :

I'm using latest Ubuntu 12.10 and still have the CTM problem (cursor jumps to 0,0 or 0,y or x,0 coordinates, making my work in MyPaint really, really hard). :( Was the patch not accepted or sth?

Mark (mark-a-mester) wrote :
Yaroslav Sterkhov (ellanteres) wrote :

@Cris: probably because of it's not clear in which order they will be applied if matrix also used.

Can you suggest link to distro which got it included, I need test it aap, as I have important project hanging which incdues about hundred devices with multiple screens and touchscreens. Was fighting issue about year and a half and is near to deadline..

Personally I think that matrix should be internal thing.. As settings we should have "visual" parameters for matrix calculation, origin point, minx, maxx, miny, maxy, rotation angle. TransformationMatrix isn't even documented properly that it may also rotate and invert axes, heh, info in man is very.. lacking. Had to look into vector math books, at least I had proper education to know that such thing exist (I'm not IT by education, I'm engineer\industrial machinery designer). Normal user or average IT? They wouldn't know.

Yaroslav Sterkhov (ellanteres) wrote :

Addition to bug info:
> Without a fix, users cannot reliably use a rotated touchscreen.

Without fix users unable to use serveral screens one or more of which are touchscreens, on systems or drivers which do not support separate coordinate systems for each physical screen, e.g. ATI FireGL or NVIDIA adapters with two or more displays attached to single adapter, because that requires set a scaling+transition CTM.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers