[PATCH v3 14/23] More accurate extrapolated fake motion events

Daniel Stone daniel at fooishbar.org
Thu Jun 23 15:12:49 PDT 2011


From: Derek Foreman <derek.foreman at collabora.co.uk>

Use better time estimates so we can provide better fake motion events.
This reduces the difference between motion with one and two fingers down
to be almost imperceptible, despite the reporting rate being halved on
PS/2 devices.

Signed-off-by: Derek Foreman <derek.foreman at collabora.co.uk>
Reviewed-by: Daniel Stone <daniel at fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/synaptics.c    |   12 ++++++------
 src/synapticsstr.h |    1 +
 2 files changed, 7 insertions(+), 6 deletions(-)

v3: Changed last_motion_millis to CARD32.

diff --git a/src/synaptics.c b/src/synaptics.c
index 7725cdf..b7f4b8f 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -1789,7 +1789,7 @@ get_edge_speed(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
  * history and return relative co-ordinates.
  */
 static void regress(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
-                    double *dx, double *dy)
+                    double *dx, double *dy, CARD32 start_time)
 {
     int i;
     int packet_count = MIN(priv->count_packet_finger, 3);
@@ -1838,13 +1838,13 @@ static void regress(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
      * Here we use the slope component (b1) of the regression line as a speed
      * estimate, and calculate how far the contact would have moved between
      * the current time (hw->millis) and the last time we output a delta
-     * (from the history).
+     * (start_time).
      *
      * The negative is because the slope is going the exact wrong direction
      * (see above).
      */
-    *dx = -xb1 * (HIST(0).millis - hw->millis);
-    *dy = -yb1 * (HIST(0).millis - hw->millis);
+    *dx = -xb1 * (start_time - hw->millis);
+    *dy = -yb1 * (start_time - hw->millis);
     return;
 }
 
@@ -1860,7 +1860,8 @@ get_delta(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
     int y_edge_speed = 0;
 
     /* regress() performs the actual motion prediction. */
-    regress(priv, hw, dx, dy);
+    regress(priv, hw, dx, dy, priv->last_motion_millis);
+    priv->last_motion_millis = hw->millis;
 
     if ((priv->tap_state == TS_DRAG) || para->edge_motion_use_always)
         get_edge_speed(priv, hw, edge, &x_edge_speed, &y_edge_speed);
@@ -2665,7 +2666,6 @@ HandleState(InputInfoPtr pInfo, struct SynapticsHwState *hw, CARD32 now,
     /* generate a history of the absolute positions */
     if (inside_active_area && !from_timer)
 	store_history(priv, hw->x, hw->y, hw->millis);
-
     return delay;
 }
 
diff --git a/src/synapticsstr.h b/src/synapticsstr.h
index f981573..42abef5 100644
--- a/src/synapticsstr.h
+++ b/src/synapticsstr.h
@@ -199,6 +199,7 @@ typedef struct _SynapticsPrivateRec
     int button_delay_millis;		/* button delay for 3rd button emulation */
     Bool prev_up;			/* Previous up button value, for double click emulation */
     enum FingerState finger_state;	/* previous finger state */
+    CARD32 last_motion_millis;	        /* time of the last motion */
 
     enum TapState tap_state;		/* State of tap processing */
     int tap_max_fingers;		/* Max number of fingers seen since entering start state */
-- 
1.7.5.4



More information about the xorg-devel mailing list