diff --git a/data/30-vendor-alps.quirks b/data/30-vendor-alps.quirks
index 2f020d1e..e4e5d47e 100644
--- a/data/30-vendor-alps.quirks
+++ b/data/30-vendor-alps.quirks
@@ -33,4 +33,4 @@ MatchBus=ps2
MatchVendor=0x0002
MatchProduct=0x0008
MatchVersion=0x0800
-AttrTrackpointRange=160
+AttrTrackpointMultiplier=0.125
diff --git a/data/50-system-dell.quirks b/data/50-system-dell.quirks
index c3026495..7e873edf 100644
--- a/data/50-system-dell.quirks
+++ b/data/50-system-dell.quirks
@@ -5,19 +5,44 @@ MatchName=* Touchpad
MatchDMIModalias=dmi:*svnDellInc.:*
ModelTouchpadVisibleMarker=1
-[Dell Lattitude E6220]
+[Dell Lattitude E6220 Touchpad]
MatchName=*AlpsPS/2 ALPS GlidePoint
MatchDMIModalias=dmi:*svnDellInc.:pnLatitudeE6220:*
AttrPressureRange=100:90
-[Dell XPS L322X]
+[Dell XPS L322X Touchpad]
MatchName=*CyPS/2 Cypress Trackpad
MatchDMIModalias=dmi:*svnDell*:XPSL322X*
AttrPressureRange=32:20
AttrPalmPressureThreshold=254
-[Dell XPS13 9333]
+[Dell XPS13 9333 Touchpad]
MatchName=*Synaptics s3203
MatchDMIModalias=dmi:*svnDellInc.:*pnXPS139333*
AttrPressureRange=15:10
AttrPalmPressureThreshold=150
+
+[Dell Latitude D620 Trackpoint]
+MatchName=*DualPoint Stick
+MatchDMIModalias=dmi:*svnDellInc.:pnLatitudeD620*
+AttrTrackpointMultiplier=0.5
+
+[Latitude E5570 Trackpoint]
+MatchName=*DualPoint Stick
+MatchDMIModalias=dmi:*svnDellInc.:pnLatitudeE5570*
+AttrTrackpointMultiplier=0.1
+
+[Latitude E6320 Trackpoint]
+MatchName=*DualPoint Stick
+MatchDMIModalias=dmi:*svnDellInc.:pnLatitudeE6320*
+AttrTrackpointMultiplier=2.0
+
+[Latitude E6400 Trackpoint]
+MatchName=*DualPoint Stick
+MatchDMIModalias=dmi:*svnDellInc.:pnLatitudeE6400*
+AttrTrackpointMultiplier=1.5
+
+[Latitude E7470 Trackpoint]
+MatchName=*DualPoint Stick
+MatchDMIModalias=dmi:*svnDellInc.:pnLatitudeE7470*
+AttrTrackpointMultiplier=0.6
diff --git a/data/50-system-lenovo.quirks b/data/50-system-lenovo.quirks
index 18a1adee..0969869a 100644
--- a/data/50-system-lenovo.quirks
+++ b/data/50-system-lenovo.quirks
@@ -20,20 +20,15 @@ MatchName=Synaptics tm2964-001
MatchDMIModalias=dmi:*svnLENOVO:*:pvrThinkPadT440p*
ModelLenovoT450Touchpad=1
-[Lenovo T440s Trackpoint]
-MatchName=TPPS/2 IBM TrackPoint
-MatchDMIModalias=dmi:*svnLENOVO:*:pvrThinkPadT440s*
-AttrTrackpointRange=30
+[Lenovo X200 Trackpoint]
+MatchName=*TPPS/2 IBM TrackPoint
+MatchDMIModalias=dmi:*svnLENOVO:*pvrThinkPadX20?:*
+AttrTrackpointMultiplier=1.25
-[Lenovo T440s Trackpoint]
-MatchName=TPPS/2 IBM TrackPoint
-MatchDMIModalias=dmi:*svnLENOVO:*:pvrThinkPadT450s*
-AttrTrackpointRange=50
-
-[Lenovo X270 Trackpoint]
-MatchName=TPPS/2 IBM TrackPoint
-MatchDMIModalias=dmi:*svnLENOVO:*:pvrThinkPadX270*
-AttrTrackpointRange=40
+[Lenovo X200x Trackpoint]
+MatchName=*TPPS/2 IBM TrackPoint
+MatchDMIModalias=dmi:*svnLENOVO:*pvrThinkPadX20??:*
+AttrTrackpointMultiplier=1.25
[Lenovo P50 Touchpad]
MatchName=SynPS/2 Synaptics TouchPad
@@ -66,11 +61,6 @@ MatchVendor=0x17EF
MatchProduct=0x6047
AttrKeyboardIntegration=external
-[Lenovo X280 Trackpoint]
-MatchName=*ALPS TrackPoint*
-MatchDMIModalias=dmi:*svnLENOVO:*:pvrThinkPadX280:*
-AttrTrackpointRange=70
-
# Lenovo Thinkpad Yoga (not the consumer versions) disables the keyboard
# mechanically. We must not disable the keyboard because some keys are
# still accessible on the screen and volume rocker.
@@ -90,3 +80,9 @@ ModelLenovoCarbonX16th=1
MatchName=AT Translated Set 2 keyboard
MatchDMIModalias=dmi:*svnIBM:*pvrThinkPadX41Tablet:*
ModelTabletModeNoSuspend=1
+
+[Lenovo UltraNav SK-8845 (USB keyboard) Trackpoint]
+MatchBus=usb
+MatchVendor=0x06CB
+MatchProduct=0x0009
+AttrTrackpointMultiplier=2.5
diff --git a/doc/meson.build b/doc/meson.build
index 39b0cde8..a42a2e0d 100644
--- a/doc/meson.build
+++ b/doc/meson.build
@@ -105,6 +105,7 @@ src_doxygen = files(
'svg/thumb-detection.svg',
'svg/top-software-buttons.svg',
'svg/touchscreen-gestures.svg',
+ 'svg/trackpoint-delta-illustration.svg',
'svg/twofinger-scrolling.svg',
# style files
'style/header.html',
diff --git a/doc/pointer-acceleration.dox b/doc/pointer-acceleration.dox
index 6b2177c3..1d93dbdc 100644
--- a/doc/pointer-acceleration.dox
+++ b/doc/pointer-acceleration.dox
@@ -114,31 +114,24 @@ that trackpoint speed is a function of pressure rather than moving speed.
But trackpoint hardware is quite varied in how it reacts to user pressure
and unlike other devices it cannot easily be normalized for physical
properties. Measuring pressure objectively across a variety of hardware is
-nontrivial.
+nontrivial. See @ref trackpoints for more details.
-libinput's pointer acceleration is a function of the total available
-pressure range on a device. See @ref trackpoint_range for details.
+The deltas for trackpoints are converted units/ms but there is no common
+physical reference point for a unit. Thus, the same pressure on different
+trackpoints will generate different speeds and thus different acceleration
+behaviors. Additionally, some trackpoints provide the ability to adjust the
+sensitivity in hardware by modifying a sysfs file on the serio node. A
+higher sensitivity results in higher deltas, thus changing the definition of
+what is a unit again.
-libinput relies on some system-wide configured properties, specifically the
-@ref udev_config. The property that influences trackpoint acceleration is
-`LIBINPUT_ATTR_TRACKPOINT_RANGE` which specifies the total delta range for
-the trackpoint. See @ref trackpoint_range for details.
-
-Additionally, some trackpoints provide the ability to adjust the sensitivity in
-hardware by modifying a sysfs file on the serio node. The udev property
-`POINTINGSTICK_SENSITIVITY` indicates the desired value, a udev
-builtin is expected to apply this to the device, i.e. libinput does not
-handle this property. Once applied, the sensitivity adjusts the deltas
-coming out of the hardware. When the sensitivity changes, the trackpoint
-range changes and thus the `LIBINPUT_ATTR_TRACKPOINT_RANGE` property
-becomes invalid.
-
-As of version 1.9, libinput does not parse the `POINTINGSTICK_CONST_ACCEL` property anymore.
+libinput attempts to normalize unit data to the best of its abilities, see
+@ref trackpoint_multiplier. Beyond this, it is not possible to have
+consistent behavior across different touchpad devices.
@image html ptraccel-trackpoint.svg "Pointer acceleration curves for trackpoints"
-The image above shows the trackpoint acceleration profile for each input
-delta.
+The image above shows the trackpoint acceleration profile for the speed in
+units/ms.
@section ptraccel-profile-flat The flat pointer acceleration profile
diff --git a/doc/svg/trackpoint-delta-illustration.svg b/doc/svg/trackpoint-delta-illustration.svg
new file mode 100644
index 00000000..8423dfa2
--- /dev/null
+++ b/doc/svg/trackpoint-delta-illustration.svg
@@ -0,0 +1,126 @@
+
+
diff --git a/doc/trackpoints.dox b/doc/trackpoints.dox
index 5cdc64d2..8bd6c680 100644
--- a/doc/trackpoints.dox
+++ b/doc/trackpoints.dox
@@ -26,128 +26,144 @@ multiple laptops.
The values provided by a trackpoint are motion deltas, usually corresponding
to the pressure applied to the trackstick. For example, pressure towards the
-screen on a laptop provides negative y deltas at a fixed rate (e.g. every
-10ms). As the pressure increases, the delta increases too. As the pressure
-decreases, the delta decreases until it hits the neutral state.
+screen on a laptop provides negative y deltas. The reporting rate increases
+as the pressure increases and once events are reported at the maximum rate,
+the delta values increase. The figure below shows a rough illustration of
+this concept. As the pressure
+decreases, the delta decrease first, then the reporting rate until the
+trackpoint is in a neutral state and no events are reported. Trackpoint data
+is hart to generalize, see
+
+Observations on trackpoint input data for more details.
+
+@image html trackpoint-delta-illustration.svg Illustration of the relationship between reporting rate and delta values on a trackpoint
The delta range itself can vary greatly between laptops, some devices send a
-maximum delta value of 30, others can go beyond 100. To normalize the motion
-trackpoint, libinput uses the available delta range and fits its
-acceleration curve into this range. This requires calibration by the user,
-see @ref trackpoint_range_measure.
+maximum delta value of 30, others can go beyond 100. However, the useful
+delta range is a fraction of the maximum range. It is uncomfortable to exert
+sufficient pressure to even get close to the maximum ranges.
+
+@section trackpoint_multiplier The magic trackpoint multiplier
+
+To accomodate for the wildly different input data on trackpoint, libinput
+uses a multiplier that is applied to input deltas. Trackpoints that send
+comparatively high deltas can be "slowed down", trackpoints that send low
+deltas can be "sped up" to match the expected range. The actual acceleration
+profile is applied to these pre-multiplied deltas.
+
+Given a trackpoint delta (dx, dy), a multiplier M and a pointer acceleration
+function f(dx, dy) → (dx', dy'), the algorithm is effectively:
+@verbatim
+f(M * dx, M * dy) → (dx', dy')
+@endverbatim
+
+The magic trackpoint multiplier **is not user visible configuration**. It is
+part of the @ref device-quirks system and provided once per device.
+User-specific preferences can be adjusted with the pointer acceleration speed
+setting libinput_device_config_accel_set_speed().
+
+@subsection trackpoint_multiplier_adjustment Adjusting the magic trackpoint multiplier
+
+This section only applies if:
+- the trackpoint default speed (speed setting 0) is unusably slow or
+ unusably fast, **and**
+- the lowest speed setting (-1) is still too fast **or** the highest speed
+ setting is still too slow, **and**
+- the @ref device-quirks for this device do not list a trackpoint multiplier
+ (see @ref device-quirks-debugging)
+
+If the only satisfactory speed settings are less than -0.75 or greater than
+0.75, a multiplier *may* be required.
+
+A specific multiplier will apply to **all users with the same laptop
+model**, so proceed with caution. You must be capable/willing to adjust
+device quirks, build libinput from source and restart the session frequently
+to adjust the multiplier. If this does not apply, wait for someone else with
+the same hardware to do this.
+
+Finding the correct multiplier is difficult and requires some trial and
+error. The default multiplier is always 1.0. A value between 0.0 and 1.0
+slows the trackpoint down, a value above 1.0 speeds the trackpoint up.
+Values below zero are invalid.
+
+@note The multiplier is not a configuration to adjust to personal
+preferences. The multiplier normalizes the input data into a range that can
+then be configured with the speed setting.
+
+To adjust the local multiplier, first @ref building_libinput
+"build libinput from git master". It is not required to install libinput
+from git. The below assumes that all @ref building_dependencies are already
+installed.
+
+@verbatim
+$ cd path/to/libinput.git
+
+# Use an approximate multiplier in the quirks file
+$ cat > data/99-trackpont-override.quirks <estimate the appropriate trackpoint range. For example, let's look at
-the histogram below:
-
-@verbatim
-Histogram for x axis deltas, in counts of 5
- -30:
- -29:
- -28: +
- -27: +
- -26: ++
- -25: ++++
- -24: +++++
- -23: ++
- -22: ++++++
- -21: +++
- -20: ++++
- -19: +++++++
- -18: ++++++++++++
- -17: ++++++++++++
- -16: ++++++++++++
- -15: ++++
- -14: +++++
- -13: +++++
- -12: ++++++
- -11: +++++
- -10: +++
- -9: ++++
- -8: +++++++
- -7: +++++++
- -6: ++++++++++++
- -5: ++++++++++++
- -4: ++++++++++++
- -3: +++++++++
- -2: +++++++++
- -1: ++++++++
- 0: +++++++
- 1: +++++
- 2: +++++
- 3: ++++++
- 4: ++++++
- 5: +++++++
- 6: ++++
- 7: ++
- 8: +++
- 9: +++
- 10: +++
- 11: +++
- 12: +++
- 13: ++++
- 14: ++++++
- 15: ++++
- 16: ++++
- 17: ++++
- 18: ++++++
- 19: +++++++
- 20: ++++
- 21: ++++++
- 22: ++++++
- 23: ++++++
- 24: ++++++
- 25: +++++++++
- 26: +++++++
- 27: ++++++++
- 28: +++++
- 29: ++
- 30: ++
- 31: +
- 32:
- 33:
- 34:
-@endverbatim
-
-The 0 delta is the neutral state, each + represents 5 events with that
-delta value. Note how the curve is distributed, it's not a classic bell
-curve. That can be a factor of the input provided or the firmware-based
-pointer acceleration.
-
-Overall, the majority of events appear to be in the 0-25 range with a few
-outliers. So the trackpoint range libinput should use for this particular
-device would be 25. Note how there is a fair bit of guesswork involved, a
-trackpoint's data is never clean enough to get a definitive value. It is
-generally better to take a (slightly) smaller range than one too large.
-
-The device quirk set is `AttrTrackpointRange=25`. See @ref
-device-quirks for details on how to apply device quirks.
+If using libinput version 1.11.x or earlier, please see
+
+the 1.11.0 documentation
*/
diff --git a/src/evdev.c b/src/evdev.c
index 9fb11d83..2b729342 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -956,7 +956,7 @@ evdev_init_accel(struct evdev_device *device,
if (which == LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT)
filter = create_pointer_accelerator_filter_flat(device->dpi);
else if (device->tags & EVDEV_TAG_TRACKPOINT)
- filter = create_pointer_accelerator_filter_trackpoint(device->trackpoint_range);
+ filter = create_pointer_accelerator_filter_trackpoint(device->trackpoint_multiplier);
else if (device->dpi < DEFAULT_MOUSE_DPI)
filter = create_pointer_accelerator_filter_linear_low_dpi(device->dpi);
else
@@ -1176,59 +1176,36 @@ evdev_read_wheel_tilt_props(struct evdev_device *device)
return flags;
}
-static inline int
-evdev_get_trackpoint_range(struct evdev_device *device)
+static inline double
+evdev_get_trackpoint_multiplier(struct evdev_device *device)
{
struct quirks_context *quirks;
struct quirks *q;
- const char *prop;
- uint32_t range = DEFAULT_TRACKPOINT_RANGE;
+ double multiplier = 1.0;
if (!(device->tags & EVDEV_TAG_TRACKPOINT))
- return DEFAULT_TRACKPOINT_RANGE;
+ return 1.0;
quirks = evdev_libinput_context(device)->quirks;
q = quirks_fetch_for_device(quirks, device->udev_device);
- if (q && quirks_get_uint32(q, QUIRK_ATTR_TRACKPOINT_RANGE, &range)) {
- goto out;
+ if (q) {
+ quirks_get_double(q, QUIRK_ATTR_TRACKPOINT_MULTIPLIER, &multiplier);
+ quirks_unref(q);
}
- evdev_log_info(device,
- "trackpoint does not have a specified range, "
- "guessing... see %strackpoints.html\n",
- HTTP_DOC_LINK);
-
- prop = udev_device_get_property_value(device->udev_device,
- "POINTINGSTICK_SENSITIVITY");
- if (prop) {
- int sensitivity;
-
- if (!safe_atoi(prop, &sensitivity) ||
- (sensitivity < 0.0 || sensitivity > 255)) {
- evdev_log_error(device,
- "trackpoint sensitivity property is present but invalid, "
- "using %d instead\n",
- DEFAULT_TRACKPOINT_SENSITIVITY);
- sensitivity = DEFAULT_TRACKPOINT_SENSITIVITY;
- }
- range = 1.0 * DEFAULT_TRACKPOINT_RANGE *
- sensitivity/DEFAULT_TRACKPOINT_SENSITIVITY;
-
- evdev_log_debug(device,
- "trackpoint udev sensitivity is %d\n",
- sensitivity);
+ if (multiplier <= 0.0) {
+ evdev_log_bug_libinput(device,
+ "trackpoint multiplier %.2f is invalid\n",
+ multiplier);
+ multiplier = 1.0;
}
-out:
- quirks_unref(q);
+ if (multiplier != 1.0)
+ evdev_log_info(device,
+ "trackpoint device set to range %.2f\n",
+ multiplier);
- if (range == 0) {
- evdev_log_bug_libinput(device, "trackpoint range is zero\n");
- range = DEFAULT_TRACKPOINT_RANGE;
- }
-
- evdev_log_info(device, "trackpoint device set to range %d\n", range);
- return range;
+ return multiplier;
}
static inline int
@@ -1749,7 +1726,7 @@ evdev_configure_device(struct evdev_device *device)
evdev_tag_external_mouse(device, device->udev_device);
evdev_tag_trackpoint(device, device->udev_device);
device->dpi = evdev_read_dpi_prop(device);
- device->trackpoint_range = evdev_get_trackpoint_range(device);
+ device->trackpoint_multiplier = evdev_get_trackpoint_multiplier(device);
device->seat_caps |= EVDEV_DEVICE_POINTER;
diff --git a/src/evdev.h b/src/evdev.h
index 82094824..3757dff3 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -189,7 +189,7 @@ struct evdev_device {
bool is_mt;
bool is_suspended;
int dpi; /* HW resolution */
- int trackpoint_range; /* trackpoint max delta */
+ double trackpoint_multiplier; /* trackpoint constant multiplier */
struct ratelimit syn_drop_limit; /* ratelimit for SYN_DROPPED logging */
struct ratelimit nonpointer_rel_limit; /* ratelimit for REL_* events from non-pointer devices */
uint32_t model_flags;
diff --git a/src/filter-trackpoint.c b/src/filter-trackpoint.c
index 760f0e6e..1b926268 100644
--- a/src/filter-trackpoint.c
+++ b/src/filter-trackpoint.c
@@ -1,7 +1,7 @@
/*
* Copyright © 2006-2009 Simon Thum
* Copyright © 2012 Jonas Ådahl
- * Copyright © 2014-2015 Red Hat, Inc.
+ * Copyright © 2014-2018 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -36,121 +36,41 @@
#include "libinput-util.h"
#include "filter-private.h"
-/* Trackpoint acceleration */
-#define TRACKPOINT_DEFAULT_MAX_ACCEL 2.0 /* in units/us */
-#define TRACKPOINT_DEFAULT_MAX_DELTA 120
-/* As measured on a Lenovo T440 at kernel-default sensitivity 128 */
-#define TRACKPOINT_DEFAULT_RANGE 20 /* max value */
-
-struct tablet_accelerator_flat {
- struct motion_filter base;
-
- double factor;
- int xres, yres;
- double xres_scale, /* 1000dpi : tablet res */
- yres_scale; /* 1000dpi : tablet res */
-};
-
struct trackpoint_accelerator {
struct motion_filter base;
- struct device_float_coords history[4];
- size_t history_size;
+ struct pointer_trackers trackers;
+ double speed_factor;
- double scale_factor;
- double max_accel;
- double max_delta;
-
- double incline; /* incline of the function */
- double offset; /* offset of the function */
+ double multiplier;
};
double
trackpoint_accel_profile(struct motion_filter *filter,
void *data,
- double delta)
+ double velocity,
+ uint64_t time)
{
struct trackpoint_accelerator *accel_filter =
(struct trackpoint_accelerator *)filter;
- const double max_accel = accel_filter->max_accel;
double factor;
- delta = fabs(delta);
+ velocity = v_us2ms(velocity); /* make it units/ms */
- /* This is almost the equivalent of the xserver acceleration
- at sensitivity 128 and speed 0.0 */
- factor = delta * accel_filter->incline + accel_filter->offset;
- factor = min(factor, max_accel);
+ /* Just a nice-enough curve that provides fluid factor conversion
+ * from the minimum speed up to the real maximum. Generated by
+ * https://www.mycurvefit.com/ with input data
+ * 0 0.3
+ * 0.1 1
+ * 0.4 3
+ * 0.6 4
+ */
+ factor = 10.06254 + (0.3 - 10.06254)/(1 + pow(velocity/0.9205459, 1.15363));
+ factor *= accel_filter->speed_factor;
return factor;
}
-/**
- * Average the deltas, they are messy and can provide sequences like 7, 7,
- * 9, 8, 14, 7, 9, 8 ... The outliers cause unpredictable jumps, so average
- * them out.
- */
-static inline struct device_float_coords
-trackpoint_average_delta(struct trackpoint_accelerator *filter,
- const struct device_float_coords *unaccelerated)
-{
- size_t i;
- struct device_float_coords avg = {0};
-
- memmove(&filter->history[1],
- &filter->history[0],
- sizeof(*filter->history) * (filter->history_size - 1));
- filter->history[0] = *unaccelerated;
-
- for (i = 0; i < filter->history_size; i++) {
- avg.x += filter->history[i].x;
- avg.y += filter->history[i].y;
- }
- avg.x /= filter->history_size;
- avg.y /= filter->history_size;
-
- return avg;
-}
-
-/**
- * Undo any system-wide magic scaling, so we're behaving the same regardless
- * of the trackpoint hardware. This way we can apply our profile independent
- * of any other configuration that messes with things.
- */
-static inline struct device_float_coords
-trackpoint_normalize_deltas(const struct trackpoint_accelerator *accel_filter,
- const struct device_float_coords *delta)
-{
- struct device_float_coords scaled = *delta;
-
- scaled.x *= accel_filter->scale_factor;
- scaled.y *= accel_filter->scale_factor;
-
- return scaled;
-}
-
-/**
- * We set a max delta per event, to avoid extreme jumps once we exceed the
- * expected pressure. Trackpoint hardware is inconsistent once the pressure
- * gets high, so we can expect sequences like 30, 40, 35, 55, etc. This may
- * be caused by difficulty keeping up high consistent pressures or just
- * measuring errors in the hardware. Either way, we cap to a max delta so
- * once we hit the high pressures, movement is capped and consistent.
- */
-static inline struct normalized_coords
-trackpoint_clip_to_max_delta(const struct trackpoint_accelerator *accel_filter,
- struct normalized_coords coords)
-{
- const double max_delta = accel_filter->max_delta;
-
- if (abs(coords.x) > max_delta)
- coords.x = copysign(max_delta, coords.x);
- if (abs(coords.y) > max_delta)
- coords.y = copysign(max_delta, coords.y);
-
- return coords;
-}
-
static struct normalized_coords
trackpoint_accelerator_filter(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
@@ -158,23 +78,20 @@ trackpoint_accelerator_filter(struct motion_filter *filter,
{
struct trackpoint_accelerator *accel_filter =
(struct trackpoint_accelerator *)filter;
- struct device_float_coords scaled;
- struct device_float_coords avg;
+ struct device_float_coords multiplied;
struct normalized_coords coords;
double f;
- double delta;
+ double velocity;
- scaled = trackpoint_normalize_deltas(accel_filter, unaccelerated);
- avg = trackpoint_average_delta(accel_filter, &scaled);
+ multiplied.x = unaccelerated->x * accel_filter->multiplier;
+ multiplied.y = unaccelerated->y * accel_filter->multiplier;
- delta = hypot(avg.x, avg.y);
+ trackers_feed(&accel_filter->trackers, &multiplied, time);
+ velocity = trackers_velocity(&accel_filter->trackers, time);
- f = trackpoint_accel_profile(filter, data, delta);
-
- coords.x = avg.x * f;
- coords.y = avg.y * f;
-
- coords = trackpoint_clip_to_max_delta(accel_filter, coords);
+ f = trackpoint_accel_profile(filter, data, velocity, time);
+ coords.x = multiplied.x * f;
+ coords.y = multiplied.y * f;
return coords;
}
@@ -184,90 +101,74 @@ trackpoint_accelerator_filter_noop(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
{
-
struct trackpoint_accelerator *accel_filter =
(struct trackpoint_accelerator *)filter;
- struct device_float_coords scaled;
- struct device_float_coords avg;
struct normalized_coords coords;
- scaled = trackpoint_normalize_deltas(accel_filter, unaccelerated);
- avg = trackpoint_average_delta(accel_filter, &scaled);
-
- coords.x = avg.x;
- coords.y = avg.y;
-
- coords = trackpoint_clip_to_max_delta(accel_filter, coords);
+ coords.x = unaccelerated->x * accel_filter->multiplier;
+ coords.y = unaccelerated->y * accel_filter->multiplier;
return coords;
}
+/* Maps the [-1, 1] speed setting into a constant acceleration
+ * range. This isn't a linear scale, we keep 0 as the 'optimized'
+ * mid-point and scale down to 0 for setting -1 and up to 5 for
+ * setting 1. On the premise that if you want a faster cursor, it
+ * doesn't matter as much whether you have 0.56789 or 0.56790,
+ * but for lower settings it does because you may lose movements.
+ * *shrug*.
+ *
+ * Magic numbers calculated by MyCurveFit.com, data points were
+ * 0.0 0.0
+ * 0.1 0.1 (because we need 4 points)
+ * 1 1
+ * 2 5
+ *
+ * This curve fits nicely into the range necessary.
+ */
+static inline double
+speed_factor(double s)
+{
+ s += 1; /* map to [0, 2] */
+ return 435837.2 + (0.04762636 - 435837.2)/(1 + pow(s/240.4549,
+ 2.377168));
+}
+
static bool
trackpoint_accelerator_set_speed(struct motion_filter *filter,
double speed_adjustment)
{
struct trackpoint_accelerator *accel_filter =
(struct trackpoint_accelerator*)filter;
- double incline, offset, max;
assert(speed_adjustment >= -1.0 && speed_adjustment <= 1.0);
- /* Helloooo, magic numbers.
-
- These numbers were obtained by finding an acceleration curve that
- provides precision at slow speeds but still provides a good
- acceleration at higher pressure - and a quick ramp-up to that
- acceleration.
-
- Trackpoints have built-in acceleration curves already, so we
- don't put a new function on top, we merely scale the output from
- those curves (re-calculating the pressure values from the
- firmware-defined curve and applying a new curve is unreliable).
-
- For that basic scaling, we assume a constant factor f based on
- the speed setting together with a maximum factor m (for this
- speed setting). Delta acceleration is thus:
- factor = max(m, f)
- accelerated_delta = delta * factor;
-
- Trial and error showed a couple of pairs that work well for the
- various speed settings (Lenovo T440, sensitivity 128):
-
- -1.0: f = 0.3, m = 1
- -0.5: f = 0.6, m = 2
- 0.0: f = 1.0, m = 6
- 0.5: f = 1.4, m = 8
- 1.0: f = 1.9, m = 15
-
- Note: if f >= 2.0, some pixels are unaddressable
-
- Those pairs were fed into the linear/exponential regression tool
- at http://www.xuru.org/rt/LR.asp and show two functions that map
- speed settings to the respective f and m.
- Given a speed setting s in [-1.0, 1.0]
- f(s) = 0.8 * s + 1.04
- m(s) = 4.6 * e**(1.2 * s)
- These are close enough to the tested pairs.
- */
-
- max = 4.6 * pow(M_E, 1.2 * speed_adjustment);
- incline = 0.8 * speed_adjustment + 1.04;
- offset = 0;
-
- accel_filter->max_accel = max;
- accel_filter->incline = incline;
- accel_filter->offset = offset;
filter->speed_adjustment = speed_adjustment;
+ accel_filter->speed_factor = speed_factor(speed_adjustment);
+
return true;
}
+static void
+trackpoint_accelerator_restart(struct motion_filter *filter,
+ void *data,
+ uint64_t time)
+{
+ struct trackpoint_accelerator *accel =
+ (struct trackpoint_accelerator *) filter;
+
+ trackers_reset(&accel->trackers, time);
+}
+
static void
trackpoint_accelerator_destroy(struct motion_filter *filter)
{
struct trackpoint_accelerator *accel_filter =
(struct trackpoint_accelerator *)filter;
+ trackers_free(&accel_filter->trackers);
free(accel_filter);
}
@@ -275,40 +176,37 @@ struct motion_filter_interface accelerator_interface_trackpoint = {
.type = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE,
.filter = trackpoint_accelerator_filter,
.filter_constant = trackpoint_accelerator_filter_noop,
- .restart = NULL,
+ .restart = trackpoint_accelerator_restart,
.destroy = trackpoint_accelerator_destroy,
.set_speed = trackpoint_accelerator_set_speed,
};
struct motion_filter *
-create_pointer_accelerator_filter_trackpoint(int max_hw_delta)
+create_pointer_accelerator_filter_trackpoint(double multiplier)
{
struct trackpoint_accelerator *filter;
+ assert(multiplier > 0.0);
+
/* Trackpoints are special. They don't have a movement speed like a
- * mouse or a finger, instead they send a constant stream of events
- * based on the pressure applied.
+ * mouse or a finger, instead they send a stream of events based on
+ * the pressure applied.
*
* Physical ranges on a trackpoint are the max values for relative
- * deltas, but these are highly device-specific.
+ * deltas, but these are highly device-specific and unreliable to
+ * measure.
*
+ * Instead, we just have a constant multiplier we have in the quirks
+ * system.
*/
filter = zalloc(sizeof *filter);
if (!filter)
return NULL;
- filter->history_size = ARRAY_LENGTH(filter->history);
- filter->max_accel = TRACKPOINT_DEFAULT_MAX_ACCEL;
- filter->max_delta = TRACKPOINT_DEFAULT_MAX_DELTA;
+ filter->multiplier = multiplier;
- filter->scale_factor = 1.0 * TRACKPOINT_DEFAULT_RANGE / max_hw_delta;
-
- /* Crop to a maximum 1.0 for the scale factor, otherwise we scale up
- * events from low-res trackpoints when really we should just take
- * those as-is.
- */
- filter->scale_factor = min(1.0, filter->scale_factor);
+ trackers_init(&filter->trackers);
filter->base.interface = &accelerator_interface_trackpoint;
diff --git a/src/filter.h b/src/filter.h
index 506ab123..7e001d2f 100644
--- a/src/filter.h
+++ b/src/filter.h
@@ -122,7 +122,7 @@ struct motion_filter *
create_pointer_accelerator_filter_lenovo_x230(int dpi);
struct motion_filter *
-create_pointer_accelerator_filter_trackpoint(int max_delta);
+create_pointer_accelerator_filter_trackpoint(double multiplier);
struct motion_filter *
create_pointer_accelerator_filter_tablet(int xres, int yres);
@@ -154,5 +154,6 @@ touchpad_lenovo_x230_accel_profile(struct motion_filter *filter,
double
trackpoint_accel_profile(struct motion_filter *filter,
void *data,
- double delta);
+ double delta,
+ uint64_t time);
#endif /* FILTER_H */
diff --git a/src/libinput-util.h b/src/libinput-util.h
index fadf11c2..c68b888a 100644
--- a/src/libinput-util.h
+++ b/src/libinput-util.h
@@ -54,7 +54,6 @@
/* The HW DPI rate we normalize to before calculating pointer acceleration */
#define DEFAULT_MOUSE_DPI 1000
-#define DEFAULT_TRACKPOINT_RANGE 20
#define DEFAULT_TRACKPOINT_SENSITIVITY 128
#define ANSI_HIGHLIGHT "\x1B[0;1;39m"
diff --git a/src/quirks.c b/src/quirks.c
index c74ecbb4..951c76bc 100644
--- a/src/quirks.c
+++ b/src/quirks.c
@@ -54,6 +54,7 @@ enum property_type {
PT_BOOL,
PT_DIMENSION,
PT_RANGE,
+ PT_DOUBLE,
};
/**
@@ -74,6 +75,7 @@ struct property {
char *s;
struct quirk_dimensions dim;
struct quirk_range range;
+ double d;
} value;
};
@@ -262,7 +264,7 @@ quirk_get_name(enum quirk q)
case QUIRK_ATTR_PRESSURE_RANGE: return "AttrPressureRange";
case QUIRK_ATTR_PALM_PRESSURE_THRESHOLD: return "AttrPalmPressureThreshold";
case QUIRK_ATTR_RESOLUTION_HINT: return "AttrResolutionHint";
- case QUIRK_ATTR_TRACKPOINT_RANGE: return "AttrTrackpointRange";
+ case QUIRK_ATTR_TRACKPOINT_MULTIPLIER: return "AttrTrackpointMultiplier";
case QUIRK_ATTR_THUMB_PRESSURE_THRESHOLD: return "AttrThumbPressureThreshold";
default:
abort();
@@ -640,6 +642,7 @@ parse_attr(struct quirks_context *ctx,
struct quirk_dimensions dim;
struct quirk_range range;
unsigned int v;
+ double d;
if (streq(key, quirk_get_name(QUIRK_ATTR_SIZE_HINT))) {
p->id = QUIRK_ATTR_SIZE_HINT;
@@ -705,12 +708,12 @@ parse_attr(struct quirks_context *ctx,
p->type = PT_DIMENSION;
p->value.dim = dim;
rc = true;
- } else if (streq(key, quirk_get_name(QUIRK_ATTR_TRACKPOINT_RANGE))) {
- p->id = QUIRK_ATTR_TRACKPOINT_RANGE;
- if (!safe_atou(value, &v))
+ } else if (streq(key, quirk_get_name(QUIRK_ATTR_TRACKPOINT_MULTIPLIER))) {
+ p->id = QUIRK_ATTR_TRACKPOINT_MULTIPLIER;
+ if (!safe_atod(value, &d))
goto out;
- p->type = PT_UINT;
- p->value.u = v;
+ p->type = PT_DOUBLE;
+ p->value.d = d;
rc = true;
} else if (streq(key, quirk_get_name(QUIRK_ATTR_THUMB_PRESSURE_THRESHOLD))) {
p->id = QUIRK_ATTR_THUMB_PRESSURE_THRESHOLD;
@@ -1434,6 +1437,24 @@ quirks_get_uint32(struct quirks *q, enum quirk which, uint32_t *val)
return true;
}
+bool
+quirks_get_double(struct quirks *q, enum quirk which, double *val)
+{
+ struct property *p;
+
+ if (!q)
+ return false;
+
+ p = quirk_find_prop(q, which);
+ if (!p)
+ return false;
+
+ assert(p->type == PT_DOUBLE);
+ *val = p->value.d;
+
+ return true;
+}
+
bool
quirks_get_string(struct quirks *q, enum quirk which, char **val)
{
diff --git a/src/quirks.h b/src/quirks.h
index 36e1e14b..c5d38b24 100644
--- a/src/quirks.h
+++ b/src/quirks.h
@@ -93,7 +93,7 @@ enum quirk {
QUIRK_ATTR_PRESSURE_RANGE,
QUIRK_ATTR_PALM_PRESSURE_THRESHOLD,
QUIRK_ATTR_RESOLUTION_HINT,
- QUIRK_ATTR_TRACKPOINT_RANGE,
+ QUIRK_ATTR_TRACKPOINT_MULTIPLIER,
QUIRK_ATTR_THUMB_PRESSURE_THRESHOLD,
};
@@ -216,6 +216,19 @@ quirks_get_int32(struct quirks *q,
enum quirk which,
int32_t *val);
+/**
+ * Get the value of the given quirk, as double.
+ * This function will assert if the quirk type does not match the
+ * requested type. If the quirk is not set for this device, val is
+ * unchanged.
+ *
+ * @return true if the quirk value is valid, false otherwise.
+ */
+bool
+quirks_get_double(struct quirks *q,
+ enum quirk which,
+ double *val);
+
/**
* Get the value of the given quirk, as string.
* This function will assert if the quirk type does not match the
diff --git a/tools/make-ptraccel-graphs.sh b/tools/make-ptraccel-graphs.sh
index 2e6c73af..bfb3f917 100755
--- a/tools/make-ptraccel-graphs.sh
+++ b/tools/make-ptraccel-graphs.sh
@@ -69,20 +69,19 @@ plot for [s in speeds] fname(s) using 1:2 title s, \
EOF
outfile="ptraccel-trackpoint"
-$tool --mode=accel --dpi=1000 --filter=linear > $outfile-mouse.gnuplot
for speed in $speeds; do
$tool --mode=accel --speed=$speed --filter=trackpoint > $outfile-$speed.gnuplot
done
$gnuplot < ... in motion and delta modes only. Increase dx by step each round\n"
"--speed= ... accel speed [-1, 1], default 0\n"
"--dpi= ... device resolution in DPI (default: 1000)\n"
- "--trackpoint-range= ... range of the trackpoint deltas (default: 20)\n"
"--filter= \n"
" linear ... the default motion filter\n"
" low-dpi ... low-dpi filter, use --dpi with this argument\n"
@@ -253,7 +235,6 @@ main(int argc, char **argv)
OPT_SPEED,
OPT_DPI,
OPT_FILTER,
- OPT_TRACKPOINT_RANGE,
};
while (1) {
@@ -268,7 +249,6 @@ main(int argc, char **argv)
{"speed", 1, 0, OPT_SPEED },
{"dpi", 1, 0, OPT_DPI },
{"filter", 1, 0, OPT_FILTER },
- {"trackpoint-range", 1, 0, OPT_TRACKPOINT_RANGE },
{0, 0, 0, 0}
};
@@ -326,9 +306,6 @@ main(int argc, char **argv)
case OPT_FILTER:
filter_type = optarg;
break;
- case OPT_TRACKPOINT_RANGE:
- tp_range_max = strtod(optarg, NULL);
- break;
default:
usage();
exit(1);
@@ -350,7 +327,7 @@ main(int argc, char **argv)
profile = touchpad_lenovo_x230_accel_profile;
} else if (streq(filter_type, "trackpoint")) {
filter = create_pointer_accelerator_filter_trackpoint(tp_range_max);
- profile = NULL; /* trackpoint is special */
+ profile = trackpoint_accel_profile;
} else {
fprintf(stderr, "Invalid filter type %s\n", filter_type);
return 1;
@@ -381,10 +358,7 @@ main(int argc, char **argv)
switch (mode) {
case ACCEL:
- if (!profile) /* trackpoint */
- print_accel_func_trackpoint(filter, tp_range_max);
- else
- print_accel_func(filter, profile, dpi);
+ print_accel_func(filter, profile, dpi);
break;
case DELTA:
print_ptraccel_deltas(filter, step);
diff --git a/tools/shared.c b/tools/shared.c
index 3cda4573..b2f895cb 100644
--- a/tools/shared.c
+++ b/tools/shared.c
@@ -615,7 +615,7 @@ tools_list_device_quirks(struct quirks_context *ctx,
QUIRK_ATTR_PRESSURE_RANGE,
QUIRK_ATTR_PALM_PRESSURE_THRESHOLD,
QUIRK_ATTR_RESOLUTION_HINT,
- QUIRK_ATTR_TRACKPOINT_RANGE,
+ QUIRK_ATTR_TRACKPOINT_MULTIPLIER,
QUIRK_ATTR_THUMB_PRESSURE_THRESHOLD,
};
enum quirk *q;
@@ -630,6 +630,7 @@ tools_list_device_quirks(struct quirks_context *ctx,
struct quirk_range r;
uint32_t v;
char *s;
+ double d;
if (!quirks_has_quirk(quirks, *q))
continue;
@@ -682,7 +683,6 @@ tools_list_device_quirks(struct quirks_context *ctx,
break;
case QUIRK_ATTR_PALM_SIZE_THRESHOLD:
case QUIRK_ATTR_PALM_PRESSURE_THRESHOLD:
- case QUIRK_ATTR_TRACKPOINT_RANGE:
case QUIRK_ATTR_THUMB_PRESSURE_THRESHOLD:
quirks_get_uint32(quirks, *q, &v);
snprintf(buf, sizeof(buf), "%s=%u", name, v);
@@ -695,6 +695,11 @@ tools_list_device_quirks(struct quirks_context *ctx,
snprintf(buf, sizeof(buf), "%s=%s", name, s);
callback(userdata, buf);
break;
+ case QUIRK_ATTR_TRACKPOINT_MULTIPLIER:
+ quirks_get_double(quirks, *q, &d);
+ snprintf(buf, sizeof(buf), "%s=%0.2f\n", name, d);
+ callback(userdata, buf);
+ break;
}
}