[PATCH synaptics 15/21] More accurate extrapolated fake motion events

Daniel Kurtz djkurtz at google.com
Tue Jun 14 21:41:54 PDT 2011


On Wed, Jun 15, 2011 at 1:06 AM, Daniel Stone <daniel at fooishbar.org> wrote:
>
> 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    |   10 +++++-----
>  src/synapticsstr.h |    1 +
>  2 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/src/synaptics.c b/src/synaptics.c
> index cfd1384..a68a6fd 100644
> --- a/src/synaptics.c
> +++ b/src/synaptics.c
> @@ -1808,7 +1808,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, unsigned long start_time)
>  {
>     const SynapticsParameters *pars = &priv->synpara;
>     int i, j;
> @@ -1841,8 +1841,8 @@ static void regress(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
>     xb1 = xb1n/b1d;
>     yb1 = yb1n/b1d;
>
> -    *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);

Why not like this... it is slightly easier on the brain, at least for me:

+    *dx = xb1 * (hw->millis - start_time);
+    *dy = yb1 * (hw->millis - start_time);


>     return;
>
>  filtered:
> @@ -1864,7 +1864,8 @@ get_delta(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
>     Bool outlier = FALSE;
>
>     /* 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);
> @@ -2673,7 +2674,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 1290dc1..cdb6d99 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 */
> +    unsigned long 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.3
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel


More information about the xorg-devel mailing list