summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-02-09 15:55:41 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-02-17 11:10:51 +1000
commit736b32cadd55b05d67c4988bec96dc8df7ebb51c (patch)
treed408dcc83b39a9ff206bddad04ee51413e5c0b2b
parentf2cbd47caebd85904dd0c480d9a3128c55fec56c (diff)
Move delta calculation for trackstick out.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chris Bagwell <chris@cnpbagwell.com>
-rw-r--r--src/synaptics.c25
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);