[PATCH evdev] Fix absolute events with swapped axes

Paulo Zanoni przanoni at gmail.com
Thu Dec 15 06:33:51 PST 2011


Hi

2011/12/14 Chase Douglas <chase.douglas at canonical.com>:
> Would it be better to remove the evdev axis swap property?
>
> If we still want it around, it would probably be easier to have it set
> the transformation matrix under the covers. It would make the
> transformation matrix and evdev axis swapping properties dependent, but
> I doubt anyone is really wanting to mix the two.

So I went and tried to use the transformation matrix code, but it also had a
bug: a similar one, but slightly different. I wrote a patch to fix it, but I
believe it changes the input ABI. I'll paste it in the end of the email (and
gmail will probably mess with the white spaces). We should probably still signal
the ABI change if needed. Or, if you know a better way to implement this, please
tell me.

While I was looking at this, I also tested the relative devices. It seems the
evdev property had the same bug, so I fixed it and sent the patch. Then I tried
to set a transformation matrix and it Just Didn't Work (tm): the
matrix is ignored.
For absolute devices we have the transformAbsolute function. Don't we
also need a
transformRelative one? Can't we use the same? We just can't remove the evdev
property while we can't have transformation matrices for relative devices.

And here is the patch. Depending on your comments I can send a next
version using git-send-email.

diff --git a/dix/getevents.c b/dix/getevents.c
index 8798f64..73cf72d 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1078,12 +1078,12 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
     if (valuator_mask_isset(mask, 0))
         ox = x = valuator_mask_get_double(mask, 0);
     else
-        ox = x = dev->last.valuators[0];
+        ox = x = dev->last.untransformedValuators[0];

     if (valuator_mask_isset(mask, 1))
         oy = y = valuator_mask_get_double(mask, 1);
     else
-        oy = y = dev->last.valuators[1];
+        oy = y = dev->last.untransformedValuators[1];

     transform(&dev->transform, &x, &y);

@@ -1167,6 +1167,8 @@ fill_pointer_events(InternalEvent *events,
DeviceIntPtr pDev, int type,
     RawDeviceEvent *raw;
     double screenx = 0.0, screeny = 0.0; /* desktop coordinate system */
     double devx = 0.0, devy = 0.0; /* desktop-wide in device coords */
+    double untransformedAxesValues[2] = {0.0, 0.0};
+    int untransformedAxesIsset[2] = {0, 0};
     ValuatorMask mask;
     ScreenPtr scr;

@@ -1207,6 +1209,11 @@ fill_pointer_events(InternalEvent *events,
DeviceIntPtr pDev, int type,
         set_raw_valuators(raw, &mask, raw->valuators.data_raw);
     }

+    untransformedAxesIsset[0] = valuator_mask_isset(&mask, 0);
+    untransformedAxesIsset[1] = valuator_mask_isset(&mask, 1);
+    untransformedAxesValues[0] = valuator_mask_get(&mask, 0);
+    untransformedAxesValues[1] = valuator_mask_get(&mask, 1);
+
     /* valuators are in driver-native format (rel or abs) */

     if (flags & POINTER_ABSOLUTE)
@@ -1242,6 +1249,10 @@ fill_pointer_events(InternalEvent *events,
DeviceIntPtr pDev, int type,
         pDev->last.valuators[0] = devx;
     if (valuator_mask_isset(&mask, 1))
         pDev->last.valuators[1] = devy;
+    if (untransformedAxesIsset[0])
+        pDev->last.untransformedValuators[0] = untransformedAxesValues[0];
+    if (untransformedAxesIsset[1])
+        pDev->last.untransformedValuators[1] = untransformedAxesValues[1];

     for (i = 2; i < valuator_mask_size(&mask); i++)
     {
diff --git a/include/inputstr.h b/include/inputstr.h
index 5634f3c..a18fd23 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -538,6 +538,7 @@ typedef struct _DeviceIntRec {
      * desktop
      * for master devices, valuators is in desktop coordinates.
      * see dix/getevents.c
+     * untransformedValuators is used by the transformation matrix property
      * remainder supports acceleration
      */
     struct {
@@ -545,6 +546,7 @@ typedef struct _DeviceIntRec {
         int             numValuators;
         DeviceIntPtr    slave;
         ValuatorMask    *scroll;
+        double          untransformedValuators[2];
     } last;

     /* Input device property handling. */


Cheers,
Paulo


-- 
Paulo Zanoni


More information about the xorg-devel mailing list