diff --git a/doc/pointer-acceleration.dox b/doc/pointer-acceleration.dox index 5e300998..652c72c6 100644 --- a/doc/pointer-acceleration.dox +++ b/doc/pointer-acceleration.dox @@ -153,70 +153,4 @@ Pointer acceleration for relative motion on tablet devices is a flat acceleration, with the speed setting slowing down or speeding up the pointer motion by a constant factor. Tablets do not allow for switchable profiles. -@section ptraccel-device-speed Speed-dependent acceleration curve - -When the @ref LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE profile is -selected, it is the caller's responsibility to load an acceleration profile -into the device that maps the device's movement into an accelerated -movement. - -This profile maps input speed in **device units** to an acceleration -factor. libinput calculates the device's speed based on the deltas and their -timestamps and applies the factor provided by the acceleration profile to -the current delta. - -@note This profile uses data in device units, an acceleration curve loaded -by the caller only applies to that device and will not behave the same way -for other devices. - -@dot -digraph -{ - rankdir="LR"; - node [shape="box";] - subgraph cluster0 { - history[shape=record,label=" delta(t-1)| delta(t-2)| delta(t-3)| ..."]; - label = "motion history"; - } - delta[label="delta"]; - velocity[shape="ellipse"]; - factor[shape="ellipse"]; - accel[label="accelerated delta"]; - curve[label="acceleration curve"]; - - delta->velocity; - delta->factor; - factor->accel; - history->velocity; - - velocity->curve; - curve->factor; -} -@enddot - -For example, assume the current delta is (2, 4) which maps to a current -movement velocity of 10 units per microsecond. libinput looks up the custom -acceleration function for 10 which may return 3. The accelerated delta thus -becomes (6, 12). - -The profile itself is a curve defined by a number of points on the curve -mapping speed to an acceleration factor. Between each two curve points, -libinput provides linear interpolation, most acceleration profiles will thus -only need to provide a handful of curve points. The following illustration -shows the acceleration curve defined for the points (10, 0.25), (20, 0.4) -and (35, 3.0). - -@image html ptraccel-curve-example.svg "Interpolation of the acceleration curve for three defined points" - -As seen in the picture above: given an acceleration factor f(x) and a curve -defined by the caller for the points -a, b, and c where a < b < c: -- if x <= a, f(x) == f(a) -- if x >= c, f(x) == f(c) -- if a < x < b: f(x) == the the linear interpolation value between f(a) and f(b) -- if b < x < c: f(x) == the the linear interpolation value between f(b) and f(c) - -The behavior of a a curve is implementation-defined until the caller sets -curve points. - */ diff --git a/doc/svg/ptraccel-curve-example.svg b/doc/svg/ptraccel-curve-example.svg deleted file mode 100644 index b098e142..00000000 --- a/doc/svg/ptraccel-curve-example.svg +++ /dev/null @@ -1,290 +0,0 @@ - - - -Gnuplot -Produced by GNUPLOT 5.0 patchlevel 6 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - - - - - 0.5 - - - - - 1 - - - - - 1.5 - - - - - 2 - - - - - 2.5 - - - - - 3 - - - - - 3.5 - - - - - 0 - - - - - 5 - - - - - 10 - - - - - 15 - - - - - 20 - - - - - 25 - - - - - 30 - - - - - 35 - - - - - 40 - - - - - - - - - acceleration factor - - - - - speed (device units/ms) - - - - - factor - - - factor - - - - - - - - - - - - - - - - - diff --git a/meson.build b/meson.build index 9d2cb444..5f3d35bc 100644 --- a/meson.build +++ b/meson.build @@ -166,7 +166,6 @@ dep_libinput_util = declare_dependency(link_with : libinput_util) ############ libfilter.a ############ src_libfilter = [ 'src/filter.c', - 'src/filter-custom.c', 'src/filter-flat.c', 'src/filter-low-dpi.c', 'src/filter-mouse.c', diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 69a4892b..02b75531 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -2612,8 +2612,26 @@ tp_init_slots(struct tp_dispatch *tp, static uint32_t tp_accel_config_get_profiles(struct libinput_device *libinput_device) { - return LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE | - LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE; + return LIBINPUT_CONFIG_ACCEL_PROFILE_NONE; +} + +static enum libinput_config_status +tp_accel_config_set_profile(struct libinput_device *libinput_device, + enum libinput_config_accel_profile profile) +{ + return LIBINPUT_CONFIG_STATUS_UNSUPPORTED; +} + +static enum libinput_config_accel_profile +tp_accel_config_get_profile(struct libinput_device *libinput_device) +{ + return LIBINPUT_CONFIG_ACCEL_PROFILE_NONE; +} + +static enum libinput_config_accel_profile +tp_accel_config_get_default_profile(struct libinput_device *libinput_device) +{ + return LIBINPUT_CONFIG_ACCEL_PROFILE_NONE; } static bool @@ -2650,9 +2668,12 @@ tp_init_accel(struct tp_dispatch *tp) evdev_device_init_pointer_acceleration(tp->device, filter); - /* override the profile hooks for get_profile because we don't - * have the flat profile on touchpads */ + /* we override the profile hooks for accel configuration with hooks + * that don't allow selection of profiles */ device->pointer.config.get_profiles = tp_accel_config_get_profiles; + device->pointer.config.set_profile = tp_accel_config_set_profile; + device->pointer.config.get_profile = tp_accel_config_get_profile; + device->pointer.config.get_default_profile = tp_accel_config_get_default_profile; return true; } 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 -#include -#include -#include -#include -#include -#include - -#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); @@ -107,9 +104,6 @@ typedef double (*accel_profile_func_t)(struct motion_filter *filter, uint64_t time); /* Pointer acceleration types */ -struct motion_filter * -create_pointer_accelerator_filter_custom_device_speed(void); - struct motion_filter * create_pointer_accelerator_filter_flat(int dpi); @@ -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] * @@ -4548,44 +4542,6 @@ libinput_device_config_accel_get_speed(struct libinput_device *device); double 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 */ @@ -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; diff --git a/test/test-pointer.c b/test/test-pointer.c index 300c428b..d6ff4ffe 100644 --- a/test/test-pointer.c +++ b/test/test-pointer.c @@ -1365,23 +1365,11 @@ START_TEST(pointer_accel_direction_change) } END_TEST -static inline void -verify_set_profile(struct libinput_device *device, - enum libinput_config_accel_profile profile) -{ - enum libinput_config_accel_profile p; - enum libinput_config_status status; - - status = libinput_device_config_accel_set_profile(device, profile); - ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS); - p = libinput_device_config_accel_get_profile(device); - ck_assert_int_eq(profile, p); -} - START_TEST(pointer_accel_profile_defaults) { struct litest_device *dev = litest_current_device(); struct libinput_device *device = dev->libinput_device; + enum libinput_config_status status; enum libinput_config_accel_profile profile; uint32_t profiles; @@ -1396,18 +1384,25 @@ START_TEST(pointer_accel_profile_defaults) profiles = libinput_device_config_accel_get_profiles(device); ck_assert(profiles & LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); ck_assert(profiles & LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT); - ck_assert(profiles & LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE); - verify_set_profile(device, LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT); + status = libinput_device_config_accel_set_profile(device, + LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT); + ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS); + profile = libinput_device_config_accel_get_profile(device); + ck_assert_int_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT); profile = libinput_device_config_accel_get_default_profile(device); ck_assert_int_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); - verify_set_profile(device, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); + status = libinput_device_config_accel_set_profile(device, + LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); + ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS); + profile = libinput_device_config_accel_get_profile(device); + ck_assert_int_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); } END_TEST -START_TEST(pointer_accel_profile_defaults_touchpad) +START_TEST(pointer_accel_profile_defaults_noprofile) { struct litest_device *dev = litest_current_device(); struct libinput_device *device = dev->libinput_device; @@ -1418,26 +1413,25 @@ START_TEST(pointer_accel_profile_defaults_touchpad) ck_assert(libinput_device_config_accel_is_available(device)); profile = libinput_device_config_accel_get_default_profile(device); - ck_assert_int_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); + ck_assert_int_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_NONE); profile = libinput_device_config_accel_get_profile(device); - ck_assert_int_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); + ck_assert_int_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_NONE); profiles = libinput_device_config_accel_get_profiles(device); - ck_assert(profiles & LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); - ck_assert(profiles & LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE); + ck_assert_int_eq(profiles, LIBINPUT_CONFIG_ACCEL_PROFILE_NONE); - verify_set_profile(device, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); - verify_set_profile(device, LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE); - profile = libinput_device_config_accel_get_default_profile(device); - ck_assert_int_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); - - verify_set_profile(device, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); status = libinput_device_config_accel_set_profile(device, LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT); ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED); profile = libinput_device_config_accel_get_profile(device); - ck_assert_int_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); + ck_assert_int_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_NONE); + + status = libinput_device_config_accel_set_profile(device, + LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); + ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED); + profile = libinput_device_config_accel_get_profile(device); + ck_assert_int_eq(profile, LIBINPUT_CONFIG_ACCEL_PROFILE_NONE); } END_TEST @@ -2583,7 +2577,7 @@ TEST_COLLECTION(pointer) litest_add("pointer:accel", pointer_accel_defaults_absolute_relative, LITEST_ABSOLUTE|LITEST_RELATIVE, LITEST_ANY); litest_add("pointer:accel", pointer_accel_direction_change, LITEST_RELATIVE, LITEST_POINTINGSTICK); litest_add("pointer:accel", pointer_accel_profile_defaults, LITEST_RELATIVE, LITEST_TOUCHPAD); - litest_add("pointer:accel", pointer_accel_profile_defaults_touchpad, LITEST_TOUCHPAD, LITEST_ANY); + litest_add("pointer:accel", pointer_accel_profile_defaults_noprofile, LITEST_TOUCHPAD, LITEST_ANY); litest_add("pointer:accel", pointer_accel_profile_invalid, LITEST_RELATIVE, LITEST_ANY); litest_add("pointer:accel", pointer_accel_profile_noaccel, LITEST_ANY, LITEST_TOUCHPAD|LITEST_RELATIVE|LITEST_TABLET); litest_add("pointer:accel", pointer_accel_profile_flat_motion_relative, LITEST_RELATIVE, LITEST_TOUCHPAD); diff --git a/tools/libinput-debug-events.man b/tools/libinput-debug-events.man index 07674990..8a63821e 100644 --- a/tools/libinput-debug-events.man +++ b/tools/libinput-debug-events.man @@ -68,11 +68,6 @@ Enable or disable middle button emulation .B \-\-enable\-dwt|\-\-disable\-dwt Enable or disable disable-while-typing .TP 8 -.B \-\-set\-accel-curve-points="x1:y1;x2:y2" -Sets the curve points for the \fIcustom-speed\fR acceleration profile. The -set of curve points is a semicolon-separate lists of key-value pairs, each -separated by a colon. Each value is a non-negative double. -.TP 8 .B \-\-set\-click\-method=[none|clickfinger|buttonareas] Set the desired click method .TP 8 @@ -82,9 +77,8 @@ Set the desired scroll method .B \-\-set\-scroll\-button=BTN_MIDDLE Set the button to the given button code .TP 8 -.B \-\-set\-profile=[adaptive|flat|custom-speed] -Set pointer acceleration profile. If the \fIcustom-speed\fR profile is -selected, use \fB\-\-set-accel-curve-points\fR to specify the curve points. +.B \-\-set\-profile=[adaptive|flat] +Set pointer acceleration profile .TP 8 .B \-\-set\-speed= Set pointer acceleration speed. The allowed range is [-1, 1]. diff --git a/tools/libinput-list-devices.c b/tools/libinput-list-devices.c index 060d4b29..aa225ca0 100644 --- a/tools/libinput-list-devices.c +++ b/tools/libinput-list-devices.c @@ -205,13 +205,11 @@ accel_profiles(struct libinput_device *device) profile = libinput_device_config_accel_get_default_profile(device); xasprintf(&str, - "%s%s %s%s %s%s", + "%s%s %s%s", (profile == LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT) ? "*" : "", (profiles & LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT) ? "flat" : "", (profile == LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE) ? "*" : "", - (profiles & LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE) ? "adaptive" : "", - (profile == LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE) ? "*" : "", - (profiles & LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE) ? "custom-speed" : ""); + (profiles & LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE) ? "adaptive" : ""); return str; } diff --git a/tools/ptraccel-debug.c b/tools/ptraccel-debug.c index a98b615d..670f0457 100644 --- a/tools/ptraccel-debug.c +++ b/tools/ptraccel-debug.c @@ -161,12 +161,11 @@ print_accel_func(struct motion_filter *filter, printf("# set style data lines\n"); printf("# plot \"gnuplot.data\" using 1:2 title 'accel factor'\n"); printf("#\n"); - printf("# data: velocity(mm/s) factor velocity(units/us) velocity(units/ms)\n"); + printf("# data: velocity(mm/s) factor velocity(units/us)\n"); for (mmps = 0.0; mmps < 1000.0; mmps += 1) { double units_per_us = mmps_to_upus(mmps, dpi); - double units_per_ms = units_per_us * 1000; double result = profile(filter, NULL, units_per_us, 0 /* time */); - printf("%.8f\t%.4f\t%.8f\t%.8f\n", mmps, result, units_per_us, units_per_ms); + printf("%.8f\t%.4f\t%.8f\n", mmps, result, units_per_us); } } @@ -244,7 +243,6 @@ main(int argc, char **argv) const char *filter_type = "linear"; accel_profile_func_t profile = NULL; int tp_range_max = 20; - const char *curve_points = NULL; enum { OPT_HELP = 1, @@ -256,7 +254,6 @@ main(int argc, char **argv) OPT_DPI, OPT_FILTER, OPT_TRACKPOINT_RANGE, - OPT_CURVE_POINTS, }; while (1) { @@ -272,7 +269,6 @@ main(int argc, char **argv) {"dpi", 1, 0, OPT_DPI }, {"filter", 1, 0, OPT_FILTER }, {"trackpoint-range", 1, 0, OPT_TRACKPOINT_RANGE }, - {"curve-points", 1, 0, OPT_CURVE_POINTS }, {0, 0, 0, 0} }; @@ -333,9 +329,6 @@ main(int argc, char **argv) case OPT_TRACKPOINT_RANGE: tp_range_max = strtod(optarg, NULL); break; - case OPT_CURVE_POINTS: - curve_points = optarg; - break; default: usage(); exit(1); @@ -358,24 +351,6 @@ main(int argc, char **argv) } else if (streq(filter_type, "trackpoint")) { filter = create_pointer_accelerator_filter_trackpoint(tp_range_max); profile = NULL; /* trackpoint is special */ - } else if (streq(filter_type, "custom-speed")) { - struct key_value_double *points; - ssize_t npoints; - - filter = create_pointer_accelerator_filter_custom_device_speed(); - profile = custom_accel_profile; - - npoints = kv_double_from_string(curve_points, ";", ":", &points); - if (npoints <= 0) - return 1; - - for (ssize_t idx = 0; idx < npoints; idx++){ - filter_set_curve_point(filter, - points[idx].key, - points[idx].value); - } - - free(points); } else { fprintf(stderr, "Invalid filter type %s\n", filter_type); return 1; diff --git a/tools/shared.c b/tools/shared.c index 85c0d739..c1ce6473 100644 --- a/tools/shared.c +++ b/tools/shared.c @@ -218,17 +218,6 @@ tools_parse_option(int option, "%s", optarg); break; - case OPT_CURVE_POINTS: - if (!optarg) - return 1; - - options->ncurve_points = kv_double_from_string( - optarg, - ";", ":", - &options->curve_points); - if (options->ncurve_points < 0) - return 1; - break; } return 0; @@ -397,16 +386,6 @@ tools_device_apply_config(struct libinput_device *device, libinput_device_config_send_events_set_mode(device, LIBINPUT_CONFIG_SEND_EVENTS_DISABLED); } - - if (libinput_device_config_accel_get_profile(device) == - LIBINPUT_CONFIG_ACCEL_PROFILE_DEVICE_SPEED_CURVE) { - for (ssize_t idx = 0; idx < options->ncurve_points; idx++) { - double x = options->curve_points[idx].key, - fx = options->curve_points[idx].value; - - libinput_device_config_accel_set_curve_point(device, x, fx); - } - } } static char* diff --git a/tools/shared.h b/tools/shared.h index dc61b5b7..55e15409 100644 --- a/tools/shared.h +++ b/tools/shared.h @@ -50,7 +50,6 @@ enum configuration_options { OPT_SPEED, OPT_PROFILE, OPT_DISABLE_SENDEVENTS, - OPT_CURVE_POINTS, }; #define CONFIGURATION_OPTIONS \ @@ -74,8 +73,7 @@ enum configuration_options { { "set-scroll-button", required_argument, 0, OPT_SCROLL_BUTTON }, \ { "set-profile", required_argument, 0, OPT_PROFILE }, \ { "set-tap-map", required_argument, 0, OPT_TAP_MAP }, \ - { "set-speed", required_argument, 0, OPT_SPEED }, \ - { "set-accel-curve-points", required_argument, 0, OPT_CURVE_POINTS } + { "set-speed", required_argument, 0, OPT_SPEED } enum tools_backend { BACKEND_DEVICE, @@ -97,9 +95,6 @@ struct tools_options { int dwt; enum libinput_config_accel_profile profile; char disable_pattern[64]; - - struct key_value_double *curve_points; - ssize_t ncurve_points; }; void tools_init_options(struct tools_options *options);