From c8ac08673cf5c779b8b7c3edf73b88d1f3dff7ed Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 21 Jun 2016 15:20:08 +1000 Subject: [PATCH libinput] tablet: make the tablet tools behave like a 1000dpi mouse The current code tried to emulate the relative motion to be equivalent to the absolute motion, except in screen coordinates. This is way too slow for the cursor tool that we want to behave like a mouse. Tablets have high resolution (e.g. an Intuos 4 is a 5080dpi mouse) and that motion is way too fast to be usable. Scale it down to match a 1000dpi device instead. Since the cursor and lens tool are still high precision devices leave them in a flat acceleration profile without actual acceleration. This also adds the missing bits for actually using the speed factor set through the config interface. Signed-off-by: Peter Hutterer --- src/evdev-tablet.c | 5 ++--- src/filter.c | 34 ++++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index 395e5a0..b02556c 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -393,9 +393,8 @@ tablet_process_delta(struct tablet_dispatch *tablet, { struct normalized_coords accel; - /* The tablet accel code uses mm as input */ - accel.x = 1.0 * delta->x/device->abs.absinfo_x->resolution; - accel.y = 1.0 * delta->y/device->abs.absinfo_y->resolution; + accel.x = 1.0 * delta->x; + accel.y = 1.0 * delta->y; if (normalized_is_zero(accel)) return accel; diff --git a/src/filter.c b/src/filter.c index cf8996d..2acb852 100644 --- a/src/filter.c +++ b/src/filter.c @@ -167,7 +167,8 @@ struct tablet_accelerator_flat { struct motion_filter base; double factor; - int xres, yres; + double xres_scale, /* 1000dpi : tablet res */ + yres_scale; /* 1000dpi : tablet res */ }; static void @@ -975,25 +976,29 @@ create_pointer_accelerator_filter_flat(int dpi) /* The tablet accel code uses mm as input */ static struct normalized_coords tablet_accelerator_filter_flat(struct motion_filter *filter, - const struct normalized_coords *mm, + const struct normalized_coords *units, void *data, uint64_t time) { struct tablet_accelerator_flat *accel_filter = (struct tablet_accelerator_flat *)filter; struct normalized_coords accelerated; - /* Tablet input is in mm, output is supposed to be in logical - * pixels roughly equivalent to a mouse/touchpad. - * - * This is a magical constant found by trial and error. On a 96dpi - * screen 0.4mm of movement correspond to 1px logical pixel which - * is almost identical to the tablet mapped to screen in absolute - * mode. Tested on a Intuos5, other tablets may vary. + /* + The input for and output of accel methods is usually a delta in + 1000dpi equivalents. Tablets are high res (Intuos 4 is 5080 dpi) + and unmodified deltas are way too high. Slow it down to the + equivalent of a 1000dpi mouse. The ratio of that is: + ratio = 1000/(resolution_per_mm * 25.4) + + i.e. on the Intuos4 it's a ratio of ~1/5. + */ - const double DPI_CONVERSION = 96.0/25.4 * 2.5; /* unitless factor */ - accelerated.x = mm->x * accel_filter->factor * DPI_CONVERSION; - accelerated.y = mm->y * accel_filter->factor * DPI_CONVERSION; + accelerated.x = units->x * accel_filter->xres_scale; + accelerated.y = units->y * accel_filter->yres_scale; + + accelerated.x *= accel_filter->factor; + accelerated.y *= accel_filter->factor; return accelerated; } @@ -1039,8 +1044,9 @@ create_tablet_filter_flat(int xres, int yres) if (filter == NULL) return NULL; - filter->xres = xres; - filter->yres = yres; + filter->factor = 1.0; + filter->xres_scale = DEFAULT_MOUSE_DPI/(25.4 * xres); + filter->yres_scale = DEFAULT_MOUSE_DPI/(25.4 * yres); return filter; } -- 2.7.4