summaryrefslogtreecommitdiff
path: root/src
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:38:20 +1000
commit0de4445ff8e75aab208faf6383e76045934c6720 (patch)
treeff344c3c869ef9e7ec85f644fd4041d12b491858 /src
parenta1d6784d790f081f8a6ea3a10d3cfa578aa10d5b (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>
Diffstat (limited to 'src')
-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 a4507c6..e792977 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -2109,7 +2109,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;
@@ -2121,7 +2121,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;
@@ -2133,7 +2133,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) {
@@ -2391,10 +2391,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;
@@ -2408,9 +2407,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 4bc2ed5..5b0120a 100644
--- a/src/synapticsstr.h
+++ b/src/synapticsstr.h
@@ -169,7 +169,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 */
@@ -213,8 +213,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 */