[PATCH synaptics 09/11] Reshuffle default value initialization.

Peter Hutterer peter.hutterer at who-t.net
Tue Jun 15 17:21:26 PDT 2010


No functional changes, just code structure. The eventcomm backened is the
only one with a real probe function right now. So provide a default query
proc that reads the touchpad coordinates in. The values provided are the
ones that then will give us the right edge settings in concordance with the
default we had before.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/alpscomm.c     |    2 +-
 src/ps2comm.c      |    2 +-
 src/psmcomm.c      |    2 +-
 src/synaptics.c    |  129 ++++++++++++++++++++++++++--------------------------
 src/synapticsstr.h |    3 +
 5 files changed, 70 insertions(+), 68 deletions(-)

diff --git a/src/alpscomm.c b/src/alpscomm.c
index e1a059c..c58c405 100644
--- a/src/alpscomm.c
+++ b/src/alpscomm.c
@@ -255,5 +255,5 @@ struct SynapticsProtocolOperations alps_proto_operations = {
     ALPSQueryHardware,
     ALPSReadHwState,
     ALPSAutoDevProbe,
-    NULL /* ReadDevDimensions */
+    SynapticsDefaultDimensions
 };
diff --git a/src/ps2comm.c b/src/ps2comm.c
index 9d9e8a9..b9420bf 100644
--- a/src/ps2comm.c
+++ b/src/ps2comm.c
@@ -787,5 +787,5 @@ struct SynapticsProtocolOperations psaux_proto_operations = {
     PS2QueryHardware,
     PS2ReadHwState,
     PS2AutoDevProbe,
-    NULL /* ReadDevDimensions */
+    SynapticsDefaultDimensions
 };
diff --git a/src/psmcomm.c b/src/psmcomm.c
index 6664c93..8a96101 100644
--- a/src/psmcomm.c
+++ b/src/psmcomm.c
@@ -188,5 +188,5 @@ struct SynapticsProtocolOperations psm_proto_operations = {
     PSMQueryHardware,
     PSMReadHwState,
     PSMAutoDevProbe,
-    NULL /* ReadDevDimensions */
+    SynapticsDefaultDimensions
 };
diff --git a/src/synaptics.c b/src/synaptics.c
index 46faf1d..2d47089 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -179,6 +179,35 @@ _X_EXPORT XF86ModuleData synapticsModuleData = {
 /*****************************************************************************
  *	Function Definitions
  ****************************************************************************/
+/**
+ * Fill in default dimensions for backends that cannot query the hardware.
+ * Eventually, we want the edges to be 1900/5400 for x, 1900/4000 for y.
+ * These values are based so that calculate_edge_widths() will give us the
+ * right values.were based
+ *
+ * The default values 1900, etc. come from the dawn of time, when men where
+ * men, or possibly apes.
+ */
+void
+SynapticsDefaultDimensions(LocalDevicePtr local)
+{
+    SynapticsPrivate *priv = (SynapticsPrivate *)local->private;
+
+    priv->minx = 1615;
+    priv->maxx = 5685;
+    priv->resx = 0;
+
+    priv->miny = 1729;
+    priv->maxy = 4171;
+    priv->resx = 0;
+
+    priv->minp = 0;
+    priv->maxp = 256;
+
+    priv->minw = 0;
+    priv->maxw = 16;
+
+}
 
 static void
 SetDeviceAndProtocol(LocalDevicePtr local)
@@ -375,6 +404,7 @@ static void set_default_parameters(LocalDevicePtr local)
     Bool vertTwoFingerScroll, horizTwoFingerScroll;
     int horizResolution = 1;
     int vertResolution = 1;
+    int width, height, diag, range;
 
     /* read the parameters */
     if (priv->synshm)
@@ -390,72 +420,41 @@ static void set_default_parameters(LocalDevicePtr local)
      * If the range was autodetected, apply these edge widths to all four
      * sides.
      */
-    if (priv->minx < priv->maxx && priv->miny < priv->maxy)
-    {
-        int width, height, diag;
-
-        width = abs(priv->maxx - priv->minx);
-        height = abs(priv->maxy - priv->miny);
-        diag = sqrt(width * width + height * height);
-
-        calculate_edge_widths(priv, &l, &r, &t, &b);
+    if (priv->minx > priv->maxx || priv->miny < priv->maxy)
+        SynapticsDefaultDimensions(local);
 
-        /* Again, based on typical x/y range and defaults */
-        horizScrollDelta = diag * .020;
-        vertScrollDelta = diag * .020;
-        tapMove = diag * .044;
-        edgeMotionMinSpeed = 1;
-        edgeMotionMaxSpeed = diag * .080;
-        accelFactor = 50.0 / diag;
-    } else {
-        l = 1900;
-        r = 5400;
-        t = 1900;
-        b = 4000;
-
-        horizScrollDelta = 100;
-        vertScrollDelta = 100;
-        tapMove = 220;
-        edgeMotionMinSpeed = 1;
-        edgeMotionMaxSpeed = 400;
-        accelFactor = 0.010;
-    }
-
-    if (priv->minp < priv->maxp) {
-	int range = priv->maxp - priv->minp;
-
-	/* scaling based on defaults below and a pressure of 256 */
-	fingerLow = priv->minp + range * (25.0/256);
-	fingerHigh = priv->minp + range * (30.0/256);
-	fingerPress = priv->minp + range * 1.000;
-	emulateTwoFingerMinZ = priv->minp + range * (282.0/256);
-	edgeMotionMinZ = priv->minp + range * (30.0/256);
-	edgeMotionMaxZ = priv->minp + range * (160.0/256);
-	pressureMotionMinZ = priv->minp + range * (30.0/256);
-	pressureMotionMaxZ = priv->minp + range * (160.0/256);
-	palmMinZ = priv->minp + range * (200.0/256);
-    } else {
-	fingerLow = 25;
-	fingerHigh = 30;
-	fingerPress = 256;
-	emulateTwoFingerMinZ = 257;
-	edgeMotionMinZ = 30;
-	edgeMotionMaxZ = 160;
-	pressureMotionMinZ = 30;
-	pressureMotionMaxZ = 160;
-	palmMinZ = 200;
-    }
-
-    if (priv->minw < priv->maxw) {
-	int range = priv->maxw - priv->minw;
-
-	/* scaling based on defaults below and a tool width of 16 */
-	palmMinWidth = priv->minw + range * (10.0/16);
-	emulateTwoFingerMinW = priv->minw + range * (7.0/16);
-    } else {
-	palmMinWidth = 10;
-	emulateTwoFingerMinW = 7;
-    }
+    width = abs(priv->maxx - priv->minx);
+    height = abs(priv->maxy - priv->miny);
+    diag = sqrt(width * width + height * height);
+
+    calculate_edge_widths(priv, &l, &r, &t, &b);
+
+    /* Again, based on typical x/y range and defaults */
+    horizScrollDelta = diag * .020;
+    vertScrollDelta = diag * .020;
+    tapMove = diag * .044;
+    edgeMotionMinSpeed = 1;
+    edgeMotionMaxSpeed = diag * .080;
+    accelFactor = 50.0 / diag;
+
+    range = priv->maxp - priv->minp;
+
+    /* scaling based on defaults and a pressure of 256 */
+    fingerLow = priv->minp + range * (25.0/256);
+    fingerHigh = priv->minp + range * (30.0/256);
+    fingerPress = priv->minp + range * 1.000;
+    emulateTwoFingerMinZ = priv->minp + range * (282.0/256);
+    edgeMotionMinZ = priv->minp + range * (30.0/256);
+    edgeMotionMaxZ = priv->minp + range * (160.0/256);
+    pressureMotionMinZ = priv->minp + range * (30.0/256);
+    pressureMotionMaxZ = priv->minp + range * (160.0/256);
+    palmMinZ = priv->minp + range * (200.0/256);
+
+    range = priv->maxw - priv->minw;
+
+    /* scaling based on defaults below and a tool width of 16 */
+    palmMinWidth = priv->minw + range * (10.0/16);
+    emulateTwoFingerMinW = priv->minw + range * (7.0/16);
 
     /* Enable tap if we don't have a phys left button */
     tapButton1 = priv->has_left ? 0 : 1;
diff --git a/src/synapticsstr.h b/src/synapticsstr.h
index d123257..a63df23 100644
--- a/src/synapticsstr.h
+++ b/src/synapticsstr.h
@@ -237,4 +237,7 @@ typedef struct _SynapticsPrivateRec
     enum TouchpadModel model;          /* The detected model */
 } SynapticsPrivate;
 
+
+extern void SynapticsDefaultDimensions(LocalDevicePtr local);
+
 #endif /* _SYNAPTICSSTR_H_ */
-- 
1.7.0.1



More information about the xorg-devel mailing list