From 019f1851076c267002bf11673af69b5a0d48a301 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 10 Feb 2017 10:30:38 +1000 Subject: touchpad: add a hwdb quirk for (external) touchpad/keyboard combos Specify the layout of the combo so we know when to initialize palm detection. This allows us to drop palm detection on external touchpads otherwise, replacing the wacom-specific check with something more generic.. Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- src/evdev-mt-touchpad.c | 19 +++++++++++++++++-- src/libinput-util.c | 24 ++++++++++++++++++++++++ src/libinput-util.h | 7 +++++++ 3 files changed, 48 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index c5eeeac..1ac8413 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -2175,6 +2175,21 @@ tp_dwt_config_get_default(struct libinput_device *device) LIBINPUT_CONFIG_DWT_DISABLED; } +static inline bool +tp_is_tpkb_combo_below(struct evdev_device *device) +{ + const char *prop; + enum tpkbcombo_layout layout = TPKBCOMBO_LAYOUT_UNKNOWN; + + prop = udev_device_get_property_value(device->udev_device, + "LIBINPUT_ATTR_TPKBCOMBO_LAYOUT"); + if (!prop) + return false; + + return parse_tpkbcombo_layout_poperty(prop, &layout) && + layout == TPKBCOMBO_LAYOUT_BELOW; +} + static void tp_init_dwt(struct tp_dispatch *tp, struct evdev_device *device) @@ -2203,8 +2218,8 @@ tp_init_palmdetect(struct tp_dispatch *tp, tp->palm.right_edge = INT_MAX; tp->palm.left_edge = INT_MIN; - /* Wacom doesn't have internal touchpads */ - if (device->model_flags & EVDEV_MODEL_WACOM_TOUCHPAD) + if (device->tags & EVDEV_TAG_EXTERNAL_TOUCHPAD && + !tp_is_tpkb_combo_below(device)) return; evdev_device_get_size(device, &width, &height); diff --git a/src/libinput-util.c b/src/libinput-util.c index d75955c..351bbe4 100644 --- a/src/libinput-util.c +++ b/src/libinput-util.c @@ -335,6 +335,30 @@ parse_switch_reliability_property(const char *prop, return true; } +/** + * Parses a string with the allowed values: "below" + * The value refers to the position of the touchpad (relative to the + * keyboard, i.e. your average laptop would be 'below') + * + * @param prop The value of the property + * @param layout The layout + * @return true on success, false otherwise + */ +bool +parse_tpkbcombo_layout_poperty(const char *prop, + enum tpkbcombo_layout *layout) +{ + if (!prop) + return false; + + if (streq(prop, "below")) { + *layout = TPKBCOMBO_LAYOUT_BELOW; + return true; + } + + return false; +} + /** * Return the next word in a string pointed to by state before the first * separator character. Call repeatedly to tokenize a whole string. diff --git a/src/libinput-util.h b/src/libinput-util.h index 00ece58..d86ff12 100644 --- a/src/libinput-util.h +++ b/src/libinput-util.h @@ -379,6 +379,13 @@ double parse_trackpoint_accel_property(const char *prop); bool parse_dimension_property(const char *prop, size_t *width, size_t *height); bool parse_calibration_property(const char *prop, float calibration[6]); +enum tpkbcombo_layout { + TPKBCOMBO_LAYOUT_UNKNOWN, + TPKBCOMBO_LAYOUT_BELOW, +}; +bool parse_tpkbcombo_layout_poperty(const char *prop, + enum tpkbcombo_layout *layout); + enum switch_reliability { RELIABILITY_UNKNOWN, RELIABILITY_RELIABLE, -- cgit v1.2.3