summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2012-05-09 14:26:40 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2012-05-11 10:39:13 +1000
commitace20a02c371478f6a9d224dfd31ea219d91fc46 (patch)
treef4f8c575eae8e04e4e2b0be199954ed4b973090a
parent04d24116db59872d4cd00f38a0d1c87957fe4914 (diff)
Fix coasting speed trigger
CoastingSpeed is defined as scrolls/s. The previous code just used delta/seconds which depended on the device coordinate range and exceeded the default CoastingSpeed at almost any scroll event. Divide the estimated delta by the scroll distance to get the accurate scrolls/s number. Since that now changes the contents of what's in coast_speed_y, change the users of that too. http://bugzilla.redhat.com/813686 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> (cherry picked from commit 0de4445ff8e75aab208faf6383e76045934c6720)
-rw-r--r--src/synaptics.c16
-rw-r--r--src/synapticsstr.h6
2 files changed, 10 insertions, 12 deletions
diff --git a/src/synaptics.c b/src/synaptics.c
index ee627b3..30d79c5 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -2456,7 +2456,7 @@ start_coasting(SynapticsPrivate * priv, struct SynapticsHwState *hw,
double dy =
estimate_delta(HIST(0).y, HIST(1).y, HIST(2).y, HIST(3).y);
if (pkt_time > 0) {
- double scrolls_per_sec = dy / pkt_time;
+ double scrolls_per_sec = (dy / abs(para->scroll_dist_vert)) / pkt_time;
if (fabs(scrolls_per_sec) >= para->coasting_speed) {
priv->scroll.coast_speed_y = scrolls_per_sec;
@@ -2468,7 +2468,7 @@ start_coasting(SynapticsPrivate * priv, struct SynapticsHwState *hw,
double dx =
estimate_delta(HIST(0).x, HIST(1).x, HIST(2).x, HIST(3).x);
if (pkt_time > 0) {
- double scrolls_per_sec = dx / pkt_time;
+ double scrolls_per_sec = (dx / abs(para->scroll_dist_vert)) / pkt_time;
if (fabs(scrolls_per_sec) >= para->coasting_speed) {
priv->scroll.coast_speed_x = scrolls_per_sec;
@@ -2480,7 +2480,7 @@ start_coasting(SynapticsPrivate * priv, struct SynapticsHwState *hw,
double da = estimate_delta_circ(priv);
if (pkt_time > 0) {
- double scrolls_per_sec = da / pkt_time;
+ double scrolls_per_sec = (da / para->scroll_dist_circ) / pkt_time;
if (fabs(scrolls_per_sec) >= para->coasting_speed) {
if (vert) {
@@ -2738,10 +2738,9 @@ HandleScrolling(SynapticsPrivate * priv, struct SynapticsHwState *hw,
if (priv->scroll.coast_speed_y) {
double dtime = (hw->millis - priv->scroll.last_millis) / 1000.0;
- double ddy =
- para->coasting_friction * dtime * abs(para->scroll_dist_vert);
+ double ddy = para->coasting_friction * dtime;
- priv->scroll.delta_y += priv->scroll.coast_speed_y * dtime;
+ priv->scroll.delta_y += priv->scroll.coast_speed_y * dtime * para->scroll_dist_vert;
delay = MIN(delay, POLL_MS);
if (abs(priv->scroll.coast_speed_y) < ddy) {
priv->scroll.coast_speed_y = 0;
@@ -2755,9 +2754,8 @@ HandleScrolling(SynapticsPrivate * priv, struct SynapticsHwState *hw,
if (priv->scroll.coast_speed_x) {
double dtime = (hw->millis - priv->scroll.last_millis) / 1000.0;
- double ddx =
- para->coasting_friction * dtime * abs(para->scroll_dist_horiz);
- priv->scroll.delta_x += priv->scroll.coast_speed_x * dtime;
+ double ddx = para->coasting_friction * dtime;
+ priv->scroll.delta_x += priv->scroll.coast_speed_x * dtime * para->scroll_dist_vert;
delay = MIN(delay, POLL_MS);
if (abs(priv->scroll.coast_speed_x) < ddx) {
priv->scroll.coast_speed_x = 0;
diff --git a/src/synapticsstr.h b/src/synapticsstr.h
index 57ed4ba..dd6a09b 100644
--- a/src/synapticsstr.h
+++ b/src/synapticsstr.h
@@ -168,7 +168,7 @@ typedef struct _SynapticsParameters {
Bool palm_detect; /* Enable Palm Detection */
int palm_min_width; /* Palm detection width */
int palm_min_z; /* Palm detection depth */
- double coasting_speed; /* Coasting threshold scrolling speed */
+ double coasting_speed; /* Coasting threshold scrolling speed in scrolls/s */
double coasting_friction; /* Number of scrolls per second per second to change coasting speed */
int press_motion_min_z; /* finger pressure at which minimum pressure motion factor is applied */
int press_motion_max_z; /* finger pressure at which maximum pressure motion factor is applied */
@@ -216,8 +216,8 @@ struct _SynapticsPrivateRec {
double delta_y; /* accumulated vert scroll delta */
double last_a; /* last angle-scroll position */
CARD32 last_millis; /* time last scroll event posted */
- double coast_speed_x; /* Horizontal coasting speed */
- double coast_speed_y; /* Vertical coasting speed */
+ double coast_speed_x; /* Horizontal coasting speed in scrolls/s */
+ double coast_speed_y; /* Vertical coasting speed in scrolls/s */
double coast_delta_x; /* Accumulated horizontal coast delta */
double coast_delta_y; /* Accumulated vertical coast delta */
int packets_this_scroll; /* Events received for this scroll */