[PATCH libinput] filter: fix constant acceleration for the X230
Peter Hutterer
peter.hutterer at who-t.net
Sun Aug 30 21:16:40 PDT 2015
The x230 has a special acceleration method that relies on the touchpad magic
slowdown. This was missing from commit c8da19b50a30d8, making two-finger
scroll motions unusably fast
https://bugs.freedesktop.org/show_bug.cgi?id=91819
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/filter.c | 33 +++++++++++++++++++++++----------
1 file changed, 23 insertions(+), 10 deletions(-)
diff --git a/src/filter.c b/src/filter.c
index 5df50d3..a646857 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -114,6 +114,8 @@ filter_get_speed(struct motion_filter *filter)
#define X230_THRESHOLD v_ms2us(0.4) /* in units/us */
#define X230_ACCELERATION 2.0 /* unitless factor */
#define X230_INCLINE 1.1 /* unitless factor */
+#define X230_MAGIC_SLOWDOWN 0.4 /* unitless */
+#define X230_TP_MAGIC_LOW_RES_FACTOR 4.0 /* unitless */
/*
* Pointer acceleration filter constants
@@ -421,6 +423,21 @@ accelerator_filter_x230(struct motion_filter *filter,
}
static struct normalized_coords
+accelerator_filter_constant_x230(struct motion_filter *filter,
+ const struct normalized_coords *unaccelerated,
+ void *data, uint64_t time)
+{
+ struct normalized_coords normalized;
+ const double factor =
+ X230_MAGIC_SLOWDOWN/X230_TP_MAGIC_LOW_RES_FACTOR;
+
+ normalized.x = factor * unaccelerated->x;
+ normalized.y = factor * unaccelerated->y;
+
+ return normalized;
+}
+
+static struct normalized_coords
touchpad_constant_filter(struct motion_filter *filter,
const struct normalized_coords *unaccelerated,
void *data, uint64_t time)
@@ -631,26 +648,22 @@ touchpad_lenovo_x230_accel_profile(struct motion_filter *filter,
double speed_in,
uint64_t time)
{
- /* Keep the magic factor from touchpad_accel_profile_linear. */
- const double X230_MAGIC_SLOWDOWN = 0.4; /* unitless */
-
/* Those touchpads presents an actual lower resolution that what is
* advertised. We see some jumps from the cursor due to the big steps
* in X and Y when we are receiving data.
* Apply a factor to minimize those jumps at low speed, and try
* keeping the same feeling as regular touchpads at high speed.
* It still feels slower but it is usable at least */
- const double TP_MAGIC_LOW_RES_FACTOR = 4.0; /* unitless */
double factor; /* unitless */
struct pointer_accelerator *accel_filter =
(struct pointer_accelerator *)filter;
double f1, f2; /* unitless */
const double max_accel = accel_filter->accel *
- TP_MAGIC_LOW_RES_FACTOR; /* unitless factor */
+ X230_TP_MAGIC_LOW_RES_FACTOR; /* unitless factor */
const double threshold = accel_filter->threshold /
- TP_MAGIC_LOW_RES_FACTOR; /* units/us */
- const double incline = accel_filter->incline * TP_MAGIC_LOW_RES_FACTOR;
+ X230_TP_MAGIC_LOW_RES_FACTOR; /* units/us */
+ const double incline = accel_filter->incline * X230_TP_MAGIC_LOW_RES_FACTOR;
/* Note: the magic values in this function are obtained by
* trial-and-error. No other meaning should be interpreted.
@@ -658,14 +671,14 @@ touchpad_lenovo_x230_accel_profile(struct motion_filter *filter,
* pointer_accel_profile_linear(), look at the git history of that
* function for an explaination of what the min/max/etc. does.
*/
- speed_in *= X230_MAGIC_SLOWDOWN / TP_MAGIC_LOW_RES_FACTOR;
+ speed_in *= X230_MAGIC_SLOWDOWN / X230_TP_MAGIC_LOW_RES_FACTOR;
f1 = min(1, v_us2ms(speed_in) * 5);
f2 = 1 + (v_us2ms(speed_in) - v_us2ms(threshold)) * incline;
factor = min(max_accel, f2 > 1 ? f2 : f1);
- return factor * X230_MAGIC_SLOWDOWN / TP_MAGIC_LOW_RES_FACTOR;
+ return factor * X230_MAGIC_SLOWDOWN / X230_TP_MAGIC_LOW_RES_FACTOR;
}
double
@@ -795,7 +808,7 @@ create_pointer_accelerator_filter_touchpad(int dpi)
struct motion_filter_interface accelerator_interface_x230 = {
.filter = accelerator_filter_x230,
- .filter_constant = accelerator_filter_noop,
+ .filter_constant = accelerator_filter_constant_x230,
.restart = accelerator_restart,
.destroy = accelerator_destroy,
.set_speed = accelerator_set_speed,
--
2.4.3
More information about the wayland-devel
mailing list