[PATCH synaptics 2/4] Move delta calculation for trackstick out.

Peter Hutterer peter.hutterer at who-t.net
Wed Feb 16 17:19:22 PST 2011


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/synaptics.c |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/synaptics.c b/src/synaptics.c
index b033067..541dd1c 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -1713,6 +1713,20 @@ estimate_delta(double x0, double x1, double x2, double x3)
     return x0 * 0.3 + x1 * 0.1 - x2 * 0.1 - x3 * 0.3;
 }
 
+static void
+get_delta_for_trackstick(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
+                         double *dx, double *dy)
+{
+    SynapticsParameters *para = &priv->synpara;
+    double dtime = (hw->millis - HIST(0).millis) / 1000.0;
+
+    *dx = (hw->x - priv->trackstick_neutral_x);
+    *dy = (hw->y - priv->trackstick_neutral_y);
+
+    *dx = *dx * dtime * para->trackstick_speed;
+    *dy = *dy * dtime * para->trackstick_speed;
+}
+
 static int
 ComputeDeltas(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
 	      edge_type edge, int *dxP, int *dyP, Bool inside_area)
@@ -1763,14 +1777,9 @@ ComputeDeltas(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
     if (priv->count_packet_finger <= 3) /* min. 3 packets */
         goto skip; /* skip the lot */
 
-
-    if (priv->moving_state == MS_TRACKSTICK) {
-        dx = (hw->x - priv->trackstick_neutral_x);
-        dy = (hw->y - priv->trackstick_neutral_y);
-
-        dx = dx * dtime * para->trackstick_speed;
-        dy = dy * dtime * para->trackstick_speed;
-    } else if (moving_state == MS_TOUCHPAD_RELATIVE) {
+    if (priv->moving_state == MS_TRACKSTICK)
+        get_delta_for_trackstick(priv, hw, &dx, &dy);
+    else if (moving_state == MS_TOUCHPAD_RELATIVE) {
         dx = estimate_delta(hw->x, HIST(0).x, HIST(1).x, HIST(2).x);
         dy = estimate_delta(hw->y, HIST(0).y, HIST(1).y, HIST(2).y);
 
-- 
1.7.3.5



More information about the xorg-devel mailing list