summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2018-05-21 12:09:42 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2018-05-21 12:15:25 +1000
commit33162632cb51e32851100013536f8566a68e0667 (patch)
treec21f9d03adf8efcd991d9e0e1cff7aec84797c48 /src
parenteae33ffcf0977d18df85ac09028497e010b5c939 (diff)
Revert "Expose a custom acceleration profile"
This looked good on paper but clearly no-one (including myself) ever tested this in a real-life situation or they would've noticed that the constant factor is missing, causing a segfault on the first two-finger scroll event, touchpad gesture or button scrolling. Adding the constant factor makes the API much worse and the benefit is unclear, so out of the window it goes. We can revisit this for libinput 1.12 but this isn't going to make the next release. This reverts commit d8bd650540e68e8b648e76180c5eee0f19a3b893. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r--src/evdev.c29
-rw-r--r--src/filter-custom.c216
-rw-r--r--src/filter-private.h2
-rw-r--r--src/filter.c9
-rw-r--r--src/filter.h12
-rw-r--r--src/libinput-private.h2
-rw-r--r--src/libinput.c14
-rw-r--r--src/libinput.h56
-rw-r--r--src/libinput.sym1
9 files changed, 2 insertions, 339 deletions
diff --git a/src/evdev.c b/src/evdev.c
index c6f76adb..2a7743e4 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -943,9 +943,7 @@ evdev_init_accel(struct evdev_device *device,
{
struct motion_filter *filter;
- if (which == LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE)
- filter = create_pointer_accelerator_filter_custom_device_speed();
- else if (which == LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT)
+ 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);
@@ -1004,8 +1002,7 @@ evdev_accel_config_get_profiles(struct libinput_device *libinput_device)
return LIBINPUT_CONFIG_ACCEL_PROFILE_NONE;
return LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE |
- LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT |
- LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE;
+ LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT;
}
static enum libinput_config_status
@@ -1054,27 +1051,6 @@ evdev_accel_config_get_default_profile(struct libinput_device *libinput_device)
return LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
}
-static enum libinput_config_status
-evdev_accel_config_set_curve_point(struct libinput_device *libinput_device,
- double a,
- double fa)
-{
- struct evdev_device *device = evdev_device(libinput_device);
- struct motion_filter *filter = device->pointer.filter;
-
- if (evdev_accel_config_get_profile(libinput_device) !=
- LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE)
- return LIBINPUT_CONFIG_STATUS_INVALID;
-
- if (a < 0 || a > 50000)
- return LIBINPUT_CONFIG_STATUS_INVALID;
-
- if (!filter_set_curve_point(filter, a, fa))
- return LIBINPUT_CONFIG_STATUS_INVALID;
-
- return LIBINPUT_CONFIG_STATUS_SUCCESS;
-}
-
void
evdev_device_init_pointer_acceleration(struct evdev_device *device,
struct motion_filter *filter)
@@ -1092,7 +1068,6 @@ evdev_device_init_pointer_acceleration(struct evdev_device *device,
device->pointer.config.set_profile = evdev_accel_config_set_profile;
device->pointer.config.get_profile = evdev_accel_config_get_profile;
device->pointer.config.get_default_profile = evdev_accel_config_get_default_profile;
- device->pointer.config.set_curve_point = evdev_accel_config_set_curve_point;
device->base.config.accel = &device->pointer.config;
default_speed = evdev_accel_config_get_default_speed(&device->base);
diff --git a/src/filter-custom.c b/src/filter-custom.c
deleted file mode 100644
index 7768aa2c..00000000
--- a/src/filter-custom.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright © 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"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#include "config.h"
-
-#include <assert.h>
-#include <float.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <limits.h>
-#include <math.h>
-
-#include "filter.h"
-#include "libinput-util.h"
-#include "filter-private.h"
-
-struct acceleration_curve_point {
- double x, fx;
-};
-
-struct custom_accelerator {
- struct motion_filter base;
- struct acceleration_curve_point points[32];
- size_t npoints;
-
- double last_velocity;
- struct pointer_trackers trackers;
-};
-
-double
-custom_accel_profile(struct motion_filter *filter,
- void *data,
- double speed_in, /* in device units/µs */
- uint64_t time)
-{
- struct custom_accelerator *f =
- (struct custom_accelerator*)filter;
- double fx = 1;
-
- speed_in *= 1000;
-
- if (f->npoints == 0)
- return 1.0;
-
- if (f->points[0].x >= speed_in)
- return f->points[0].fx;
-
- for (size_t i = 0; i < f->npoints - 1; i++) {
- double a, b, fa, fb;
- double k, d;
-
- if (f->points[i + 1].x < speed_in)
- continue;
-
- /*
- We haves points f(i), f(i+1), defining two points on the
- curve. linear function in the form y = kx+d:
-
- y = kx + d
-
- y1 = kx1 + d -> d = y1 - kx1
- y2 = kx2 + d -> d = y2 - kx2
-
- y1 - kx1 = y2 - kx2
- y1 - y2 = kx1 - kx2
- k = y1-y2/(x1 - x2)
-
- */
- a = f->points[i].x;
- fa = f->points[i].fx;
- b = f->points[i+1].x;
- fb = f->points[i+1].fx;
-
- k = (fa - fb)/(a - b);
- d = fa - k * a;
-
- fx = k * speed_in + d;
-
- return fx;
- }
-
- return f->points[f->npoints - 1].fx;
-}
-
-static struct normalized_coords
-custom_accelerator_filter(struct motion_filter *filter,
- const struct device_float_coords *units,
- void *data, uint64_t time)
-{
- struct custom_accelerator *f =
- (struct custom_accelerator*)filter;
- struct normalized_coords norm;
- double velocity; /* units/us in device-native dpi*/
- double accel_factor;
-
- trackers_feed(&f->trackers, units, time);
- velocity = trackers_velocity(&f->trackers, time);
- accel_factor = calculate_acceleration_simpsons(filter,
- custom_accel_profile,
- data,
- velocity,
- f->last_velocity,
- time);
- f->last_velocity = velocity;
-
- norm.x = accel_factor * units->x;
- norm.y = accel_factor * units->y;
-
- return norm;
-}
-
-static bool
-custom_accelerator_set_speed(struct motion_filter *filter,
- double speed_adjustment)
-{
- assert(speed_adjustment >= -1.0 && speed_adjustment <= 1.0);
-
- /* noop, this function has no effect in the custom interface */
-
- return true;
-}
-
-static void
-custom_accelerator_destroy(struct motion_filter *filter)
-{
- struct custom_accelerator *accel_filter =
- (struct custom_accelerator*)filter;
-
- trackers_free(&accel_filter->trackers);
- free(accel_filter);
-}
-
-static bool
-custom_accelerator_set_curve_point(struct motion_filter *filter,
- double a, double fa)
-{
- struct custom_accelerator *f =
- (struct custom_accelerator*)filter;
-
- if (f->npoints == ARRAY_LENGTH(f->points))
- return false;
-
- if (a < 0 || a > 50000)
- return false;
-
- if (f->npoints == 0) {
- f->points[0].x = a;
- f->points[0].fx = fa;
- f->npoints = 1;
- return true;
- } else if (f->points[f->npoints - 1].x < a) {
- f->points[f->npoints].x = a;
- f->points[f->npoints].fx = fa;
- f->npoints++;
- return true;
- }
-
- for (size_t i = 0; i < f->npoints; i++) {
- if (f->points[i].x == a) {
- f->points[i].fx = fa;
- break;
- } else if (f->points[i].x > a) {
- f->npoints++;
- for (size_t j = f->npoints - 1; j > i; j--)
- f->points[j] = f->points[j-1];
- f->points[i] = (struct acceleration_curve_point){ a, fa };
- break;
- }
- }
-
- return true;
-}
-
-struct motion_filter_interface accelerator_interface_custom = {
- .type = LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE,
- .filter = custom_accelerator_filter,
- .filter_constant = NULL,
- .restart = NULL,
- .destroy = custom_accelerator_destroy,
- .set_speed = custom_accelerator_set_speed,
- .set_curve_point = custom_accelerator_set_curve_point,
-};
-
-struct motion_filter *
-create_pointer_accelerator_filter_custom_device_speed(void)
-{
- struct custom_accelerator *filter;
-
- filter = zalloc(sizeof *filter);
- trackers_init(&filter->trackers);
-
- filter->base.interface = &accelerator_interface_custom;
-
- return &filter->base;
-}
diff --git a/src/filter-private.h b/src/filter-private.h
index 71415dd9..fa2fea40 100644
--- a/src/filter-private.h
+++ b/src/filter-private.h
@@ -44,8 +44,6 @@ struct motion_filter_interface {
void (*destroy)(struct motion_filter *filter);
bool (*set_speed)(struct motion_filter *filter,
double speed_adjustment);
- bool (*set_curve_point)(struct motion_filter *filter,
- double a, double fa);
};
struct motion_filter {
diff --git a/src/filter.c b/src/filter.c
index 15cbf44b..fe60c62a 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -90,15 +90,6 @@ filter_get_type(struct motion_filter *filter)
return filter->interface->type;
}
-bool
-filter_set_curve_point(struct motion_filter *filter, double a, double fa)
-{
- if (!filter->interface->set_curve_point)
- return false;
-
- return filter->interface->set_curve_point(filter, a, fa);
-}
-
void
trackers_init(struct pointer_trackers *trackers)
{
diff --git a/src/filter.h b/src/filter.h
index 22d98e09..506ab123 100644
--- a/src/filter.h
+++ b/src/filter.h
@@ -95,9 +95,6 @@ filter_set_speed(struct motion_filter *filter,
double
filter_get_speed(struct motion_filter *filter);
-bool
-filter_set_curve_point(struct motion_filter *filter, double a, double fa);
-
enum libinput_config_accel_profile
filter_get_type(struct motion_filter *filter);
@@ -108,9 +105,6 @@ typedef double (*accel_profile_func_t)(struct motion_filter *filter,
/* Pointer acceleration types */
struct motion_filter *
-create_pointer_accelerator_filter_custom_device_speed(void);
-
-struct motion_filter *
create_pointer_accelerator_filter_flat(int dpi);
struct motion_filter *
@@ -158,12 +152,6 @@ touchpad_lenovo_x230_accel_profile(struct motion_filter *filter,
double speed_in,
uint64_t time);
double
-custom_accel_profile(struct motion_filter *filter,
- void *data,
- double speed_in,
- uint64_t time);
-
-double
trackpoint_accel_profile(struct motion_filter *filter,
void *data,
double delta);
diff --git a/src/libinput-private.h b/src/libinput-private.h
index a6938ba6..d50154ef 100644
--- a/src/libinput-private.h
+++ b/src/libinput-private.h
@@ -213,8 +213,6 @@ struct libinput_device_config_accel {
enum libinput_config_accel_profile);
enum libinput_config_accel_profile (*get_profile)(struct libinput_device *device);
enum libinput_config_accel_profile (*get_default_profile)(struct libinput_device *device);
- enum libinput_config_status (*set_curve_point)(struct libinput_device *device,
- double a, double fa);
};
struct libinput_device_config_natural_scroll {
diff --git a/src/libinput.c b/src/libinput.c
index 1309ca18..78b54758 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -3708,19 +3708,6 @@ libinput_device_config_accel_get_default_speed(struct libinput_device *device)
return device->config.accel->get_default_speed(device);
}
-LIBINPUT_EXPORT enum libinput_config_status
-libinput_device_config_accel_set_curve_point(
- struct libinput_device *device,
- double a, double fa)
-{
- if (libinput_device_config_accel_get_profile(device) !=
- LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE) {
- return LIBINPUT_CONFIG_STATUS_INVALID;
- }
-
- return device->config.accel->set_curve_point(device, a, fa);
-}
-
LIBINPUT_EXPORT uint32_t
libinput_device_config_accel_get_profiles(struct libinput_device *device)
{
@@ -3755,7 +3742,6 @@ libinput_device_config_accel_set_profile(struct libinput_device *device,
switch (profile) {
case LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT:
case LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE:
- case LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE:
break;
default:
return LIBINPUT_CONFIG_STATUS_INVALID;
diff --git a/src/libinput.h b/src/libinput.h
index 857dcdfa..828cf6b4 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -4494,12 +4494,6 @@ libinput_device_config_accel_is_available(struct libinput_device *device);
* range. libinput picks the semantically closest acceleration step if the
* requested value does not match a discrete setting.
*
- * If the current acceleration profile is @ref
- * LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE, the behavior of the
- * device will not change but future calls to
- * libinput_device_config_accel_get_speed() will reflect the updated speed
- * setting.
- *
* @param device The device to configure
* @param speed The normalized speed, in a range of [-1, 1]
*
@@ -4550,44 +4544,6 @@ libinput_device_config_accel_get_default_speed(struct libinput_device *device);
/**
* @ingroup config
- *
- * Sets a curve point on the custom acceleration function for this device.
- * This function must be called after setting the type of the acceleration
- * to @ref LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE and sets
- * exactly one point on the device's acceleration curve.
- *
- * This function must be called multiple times to define a full acceleration
- * curve. libinput uses linear interpolation between each defined curve
- * point to calculate the appropriate factor. Any speed below or above the
- * lowest or highest point defined is capped to the factor at the lowest or
- * highest point, respectively. See @ref ptraccel-device-speed for a
- * detailed explanation on this behavior.
- *
- * The behavior of the acceleration function depends on the type of the
- * profile:
- * - @ref LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE : the input data
- * a is velocity in device units per millisecond, f(a) is a unitless
- * factor. This factor is applied to the incoming delta so that a delta
- * (x, y) is accelerated to the delta (f(a) * x, f(a) *y). The velocity
- * is calculated by libinput based on the current and previous deltas and
- * their timestamps. See @ref ptraccel-device-speed for details.
- *
- * @note libinput has a maximum limit for how many curve points may be set
- * and will quietly drop curve points exceeding this limit. This limit is
- * not expected to be hit by any reasonable caller.
- *
- * Submitting a curve point with the same value as a previous curve point
- * overwrites that value. There is no facility to remove curve points,
- * switch the device to a different profile and back again to reset.
- *
- * @return 0 on success or nonzero otherwise
- */
-enum libinput_config_status
-libinput_device_config_accel_set_curve_point(struct libinput_device *device,
- double a, double fa);
-
-/**
- * @ingroup config
*/
enum libinput_config_accel_profile {
/**
@@ -4609,11 +4565,6 @@ enum libinput_config_accel_profile {
* on the input speed. This is the default profile for most devices.
*/
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE = (1 << 1),
- /**
- * A custom user-provided profile. See
- * libinput_acceleration_profile_set_curve_point() for details.
- */
- LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE = (1 << 2),
};
/**
@@ -4635,13 +4586,6 @@ libinput_device_config_accel_get_profiles(struct libinput_device *device);
* Set the pointer acceleration profile of this pointer device to the given
* mode.
*
- * If the given profile is
- * @ref LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE and it is
- * different to the current profile, the acceleration curve is reset to an
- * implementation-defined curve. The caller should call
- * libinput_device_config_accel_set_curve_point() to
- * define the curve points of the acceleration profile.
- *
* @param device The device to configure
* @param mode The mode to set the device to.
*
diff --git a/src/libinput.sym b/src/libinput.sym
index f991aeea..aa2794e9 100644
--- a/src/libinput.sym
+++ b/src/libinput.sym
@@ -295,6 +295,5 @@ LIBINPUT_1.9 {
} LIBINPUT_1.7;
LIBINPUT_1.11 {
- libinput_device_config_accel_set_curve_point;
libinput_device_touch_get_touch_count;
} LIBINPUT_1.9;