diff options
author | Quytelda Kahja <quytelda@tamalin.org> | 2021-07-25 19:23:06 -0700 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2021-08-02 16:45:22 +1000 |
commit | 108f580dc1bf05a41d37056845f2b59f25a65ce4 (patch) | |
tree | 087810272ccd0a0d8a9ffdfc098a0ccb0a181ee2 | |
parent | 62b10a79b81b4f56d5d02300838b859ba3032a1d (diff) | |
download | libinput-108f580dc1bf05a41d37056845f2b59f25a65ce4.tar.gz |
quirks: Add tablet smoothing attribute.
https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/512 disables
input smoothing for AES devices. However, some AES devices produce
segmented/wobbly curves without smoothing. This change introduces an
`AttrTabletSmoothing` boolean property, which overrides the default smoothing
behavior.
See #632
Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
(cherry picked from commit e6c4b1d16ead9c40599dcea30c1598ecb9760b7d)
-rw-r--r-- | doc/user/device-quirks.rst | 3 | ||||
-rw-r--r-- | src/evdev-tablet.c | 39 | ||||
-rw-r--r-- | src/quirks.c | 12 | ||||
-rw-r--r-- | src/quirks.h | 1 | ||||
-rw-r--r-- | tools/shared.c | 1 |
5 files changed, 48 insertions, 8 deletions
diff --git a/doc/user/device-quirks.rst b/doc/user/device-quirks.rst index 32d299c6..3d4fe83b 100644 --- a/doc/user/device-quirks.rst +++ b/doc/user/device-quirks.rst @@ -190,3 +190,6 @@ AttrInputPropEnable=INPUT_PROP_BUTTONPAD;INPUT_PROP_POINTER; AttrPointingStickIntegration=internal|external Indicates the integration of the pointing stick. This is a string enum. Only needed for external pointing sticks. These are rare. +AttrTabletSmoothing=1|0 + Enables (1) or disables (0) input smoothing for tablet devices. Smoothing is enabled + by default, except on AES devices. diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index e3cf658b..3b77b47c 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -2344,18 +2344,17 @@ tablet_init_left_handed(struct evdev_device *device) tablet_change_to_left_handed); } -static void -tablet_init_smoothing(struct evdev_device *device, - struct tablet_dispatch *tablet) +static bool +tablet_is_aes(struct evdev_device *device, + struct tablet_dispatch *tablet) { - size_t history_size = ARRAY_LENGTH(tablet->history.samples); + bool is_aes = false; #if HAVE_LIBWACOM const char *devnode; WacomDeviceDatabase *db; WacomDevice *libwacom_device = NULL; const int *stylus_ids; int nstyli; - bool is_aes = false; int vid = evdev_device_get_id_vendor(device); /* Wacom-specific check for whether smoothing is required: @@ -2384,12 +2383,36 @@ tablet_init_smoothing(struct evdev_device *device, } } - if (is_aes) - history_size = 1; - libwacom_destroy(libwacom_device); + out: #endif + return is_aes; +} + +static void +tablet_init_smoothing(struct evdev_device *device, + struct tablet_dispatch *tablet) +{ + size_t history_size = ARRAY_LENGTH(tablet->history.samples); + struct quirks_context *quirks = NULL; + struct quirks *q = NULL; + bool use_smoothing = true; + + quirks = evdev_libinput_context(device)->quirks; + q = quirks_fetch_for_device(quirks, device->udev_device); + + /* By default, always enable smoothing except on AES devices. + * AttrTabletSmoothing can override this, if necessary. + */ + if (!q || !quirks_get_bool(q, QUIRK_ATTR_TABLET_SMOOTHING, &use_smoothing)) + use_smoothing = !tablet_is_aes(device, tablet); + + /* Setting the history size to 1 means we never do any actual smoothing. */ + if (!use_smoothing) + history_size = 1; + + quirks_unref(q); tablet->history.size = history_size; } diff --git a/src/quirks.c b/src/quirks.c index 5216e5b8..b556a9ab 100644 --- a/src/quirks.c +++ b/src/quirks.c @@ -280,6 +280,7 @@ quirk_get_name(enum quirk q) case QUIRK_ATTR_TRACKPOINT_MULTIPLIER: return "AttrTrackpointMultiplier"; case QUIRK_ATTR_THUMB_PRESSURE_THRESHOLD: return "AttrThumbPressureThreshold"; case QUIRK_ATTR_USE_VELOCITY_AVERAGING: return "AttrUseVelocityAveraging"; + case QUIRK_ATTR_TABLET_SMOOTHING: return "AttrTabletSmoothing"; case QUIRK_ATTR_THUMB_SIZE_THRESHOLD: return "AttrThumbSizeThreshold"; case QUIRK_ATTR_MSC_TIMESTAMP: return "AttrMscTimestamp"; case QUIRK_ATTR_EVENT_CODE_DISABLE: return "AttrEventCodeDisable"; @@ -796,6 +797,17 @@ parse_attr(struct quirks_context *ctx, p->type = PT_BOOL; p->value.b = b; rc = true; + } else if (streq(key, quirk_get_name(QUIRK_ATTR_TABLET_SMOOTHING))) { + p->id = QUIRK_ATTR_TABLET_SMOOTHING; + if (streq(value, "1")) + b = true; + else if (streq(value, "0")) + b = false; + else + goto out; + p->type = PT_BOOL; + p->value.b = b; + rc = true; } else if (streq(key, quirk_get_name(QUIRK_ATTR_THUMB_PRESSURE_THRESHOLD))) { p->id = QUIRK_ATTR_THUMB_PRESSURE_THRESHOLD; if (!safe_atou(value, &v)) diff --git a/src/quirks.h b/src/quirks.h index 9a11df67..4a970b90 100644 --- a/src/quirks.h +++ b/src/quirks.h @@ -103,6 +103,7 @@ enum quirk { QUIRK_ATTR_TRACKPOINT_MULTIPLIER, QUIRK_ATTR_THUMB_PRESSURE_THRESHOLD, QUIRK_ATTR_USE_VELOCITY_AVERAGING, + QUIRK_ATTR_TABLET_SMOOTHING, QUIRK_ATTR_THUMB_SIZE_THRESHOLD, QUIRK_ATTR_MSC_TIMESTAMP, QUIRK_ATTR_EVENT_CODE_DISABLE, diff --git a/tools/shared.c b/tools/shared.c index 65c1c7ce..096fcbed 100644 --- a/tools/shared.c +++ b/tools/shared.c @@ -732,6 +732,7 @@ tools_list_device_quirks(struct quirks_context *ctx, callback(userdata, buf); break; case QUIRK_ATTR_USE_VELOCITY_AVERAGING: + case QUIRK_ATTR_TABLET_SMOOTHING: snprintf(buf, sizeof(buf), "%s=1", name); callback(userdata, buf); break; |