Patch for xserver-xorg-input-synaptics to add a variable Orientation

Qfeng Chen qfeng.chen at gmail.com
Sat Nov 28 23:53:22 PST 2009


Hello, I patch the xserver-xorg-input-synaptics to make the
orientation of the touchpad can be changed to fit the orientation of
the screen, when the orientation of the screen is changed by using
xrandr. It is a very good function when you read paper on a netbook,
and I hope this patch can be add to official patch.
This patch is for xserver-xorg-input-synaptics-1.2.0.

The following is the patch.
Best regards,
Qfeng Chen

======
diff -ur xserver-xorg-input-synaptics-1.2.0.orig/include/synaptics-properties.h
xserver-xorg-input-synaptics-1.2.0/include/synaptics-properties.h
--- xserver-xorg-input-synaptics-1.2.0.orig/include/synaptics-properties.h
     2009-11-27
21:18:57.787643403 +0100
+++ xserver-xorg-input-synaptics-1.2.0/include/synaptics-properties.h
 2009-11-27
21:21:24.891639640 +0100
@@ -155,4 +155,7 @@
 /* 32 bit, 4 values, left, right, top, bottom */
 #define SYNAPTICS_PROP_AREA "Synaptics Area"

+/* 32 bit */
+#define SYNAPTICS_ORIENTATION "Synaptics Orientation"
+
 #endif /* _SYNAPTICS_PROPERTIES_H_ */
diff -ur xserver-xorg-input-synaptics-1.2.0.orig/src/eventcomm.c
xserver-xorg-input-synaptics-1.2.0/src/eventcomm.c
--- xserver-xorg-input-synaptics-1.2.0.orig/src/eventcomm.c     2009-11-27
21:18:57.795646655 +0100
+++ xserver-xorg-input-synaptics-1.2.0/src/eventcomm.c  2009-11-27
21:27:37.227644850 +0100
@@ -379,10 +379,28 @@
       case EV_ABS:
           switch (ev.code) {
           case ABS_X:
-               hw->x = ev.value;
+               if (para->orientation==0)
+                       hw->x = ev.value;
+               else if (para->orientation==2)
+                       hw->x = priv->maxx + priv->minx - ev.value;
+               else if (para->orientation==3)
+                       hw->y = (priv->maxx - ev.value) * (priv->maxy
- priv->miny) /
(priv->maxx - priv->minx) + priv->miny;
+               else if (para->orientation==1)
+                       hw->y = (ev.value - priv->minx) * (priv->maxy
- priv->miny) /
(priv->maxx - priv->minx) + priv->miny;
+               else
+                       hw->x = ev.value;
               break;
           case ABS_Y:
-               hw->y = ev.value;
+               if (para->orientation==0)
+                       hw->y = ev.value;
+               else if (para->orientation==2)
+                       hw->y = priv->maxy + priv->miny - ev.value;
+               else if (para->orientation==3)
+                       hw->x = (ev.value - priv->miny) * (priv->maxx
- priv->minx) /
(priv->maxy - priv->miny) + priv->minx;
+               else if (para->orientation==1)
+                       hw->x = (priv->maxy - ev.value) * (priv->maxx
- priv->minx) /
(priv->maxy - priv->miny) + priv->minx;
+               else
+                       hw->y = ev.value;
               break;
           case ABS_PRESSURE:
               hw->z = ev.value;
diff -ur xserver-xorg-input-synaptics-1.2.0.orig/src/properties.c
xserver-xorg-input-synaptics-1.2.0/src/properties.c
--- xserver-xorg-input-synaptics-1.2.0.orig/src/properties.c    2009-11-27
21:18:57.791647892 +0100
+++ xserver-xorg-input-synaptics-1.2.0/src/properties.c 2009-11-27
21:31:58.179646430 +0100
@@ -84,6 +84,7 @@
 Atom prop_capabilities          = 0;
 Atom prop_resolution            = 0;
 Atom prop_area                  = 0;
+Atom prop_orientation           = 0;

 static Atom
 InitAtom(DeviceIntPtr dev, char *name, int format, int nvalues, int *values)
@@ -274,6 +275,7 @@
    values[2] = para->area_top_edge;
    values[3] = para->area_bottom_edge;
    prop_area = InitAtom(local->dev, SYNAPTICS_PROP_AREA, 32, 4, values);
+       prop_orientation = InitAtom(local->dev, SYNAPTICS_ORIENTATION, 32,
1, &para->orientation);
 }

 int
@@ -642,7 +644,12 @@
        para->area_right_edge  = area[1];
        para->area_top_edge    = area[2];
        para->area_bottom_edge = area[3];
-    }
+    } else if (property == prop_orientation)
+       {
+        if (prop->size != 1 || prop->format != 32 || prop->type != XA_INTEGER)
+            return BadMatch;
+               para->orientation = *(INT32*)prop->data;
+       }

    return Success;
 }
diff -ur xserver-xorg-input-synaptics-1.2.0.orig/src/synaptics.c
xserver-xorg-input-synaptics-1.2.0/src/synaptics.c
--- xserver-xorg-input-synaptics-1.2.0.orig/src/synaptics.c     2009-11-27
21:18:57.795646655 +0100
+++ xserver-xorg-input-synaptics-1.2.0/src/synaptics.c  2009-11-27
21:32:44.043668111 +0100
@@ -534,6 +534,7 @@
    pars->tap_and_drag_gesture = xf86SetBoolOption(opts,
"TapAndDragGesture", TRUE);
    pars->resolution_horiz = xf86SetIntOption(opts,
"HorizResolution", horizResolution);
    pars->resolution_vert = xf86SetIntOption(opts, "VertResolution",
vertResolution);
+       pars->orientation = xf86SetIntOption(opts, "Orientation", 0);

    /* Warn about (and fix) incorrectly configured TopEdge/BottomEdge
parameters */
    if (pars->top_edge > pars->bottom_edge) {
diff -ur xserver-xorg-input-synaptics-1.2.0.orig/src/synapticsstr.h
xserver-xorg-input-synaptics-1.2.0/src/synapticsstr.h
--- xserver-xorg-input-synaptics-1.2.0.orig/src/synapticsstr.h  2009-11-27
21:18:57.795646655 +0100
+++ xserver-xorg-input-synaptics-1.2.0/src/synapticsstr.h       2009-11-27
21:25:04.859939388 +0100
@@ -149,6 +149,7 @@
    unsigned int resolution_horiz;          /* horizontal resolution
of touchpad in units/mm */
    unsigned int resolution_vert;           /* vertical resolution of
touchpad in units/mm */
    int area_left_edge, area_right_edge, area_top_edge,
area_bottom_edge; /* area coordinates absolute */
+       int orientation; /*Orientation of touchpad*/
 } SynapticsParameters;


diff -ur xserver-xorg-input-synaptics-1.2.0.orig/tools/synclient.c
xserver-xorg-input-synaptics-1.2.0/tools/synclient.c
--- xserver-xorg-input-synaptics-1.2.0.orig/tools/synclient.c   2009-11-27
21:18:57.835906380 +0100
+++ xserver-xorg-input-synaptics-1.2.0/tools/synclient.c        2009-11-27
21:35:10.583640297 +0100
@@ -143,6 +143,7 @@
    {"AreaRightEdge",         PT_INT,    0, 10000,
SYNAPTICS_PROP_AREA,        32,     1},
    {"AreaTopEdge",           PT_INT,    0, 10000,
SYNAPTICS_PROP_AREA,        32,     2},
    {"AreaBottomEdge",        PT_INT,    0, 10000,
SYNAPTICS_PROP_AREA,        32,     3},
+       {"Orientation",           PT_INT,    0, 3,
SYNAPTICS_ORIENTATION, 32, 0},
    { NULL, 0, 0, 0, 0 }
 };


More information about the xorg-devel mailing list