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 <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
Peter Hutterer 2017-02-10 10:30:38 +10:00
parent be30b28a12
commit 019f185107
6 changed files with 65 additions and 3 deletions

View file

@ -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);

View file

@ -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.

View file

@ -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,

View file

@ -933,11 +933,15 @@ touchpad_has_palm_detect_size(struct litest_device *dev)
{
double width, height;
unsigned int vendor;
unsigned int bustype;
int rc;
vendor = libinput_device_get_id_vendor(dev->libinput_device);
bustype = libevdev_get_id_bustype(dev->evdev);
if (vendor == VENDOR_ID_WACOM)
return 0;
if (bustype == BUS_BLUETOOTH)
return 0;
if (vendor == VENDOR_ID_APPLE)
return 1;

View file

@ -59,6 +59,13 @@ libinput:touchpad:input:b0003v05ACp021A*
libinput:name:*ETPS/2 Elantech Touchpad*:dmi:*svnASUSTeKCOMPUTERINC.:pnX555LAB:*
LIBINPUT_MODEL_TOUCHPAD_VISIBLE_MARKER=1
##########################################
# Chicony
##########################################
# Acer Hawaii Keyboard, uses Chicony VID
libinput:touchpad:input:b0003v04F2p1558*
LIBINPUT_ATTR_TPKBCOMBO_LAYOUT=below
##########################################
# Cyborg
##########################################

View file

@ -107,7 +107,12 @@ def property_grammar():
Suppress('=') -
reliability_tags('VALUE')]
grammar = Or(model_props + size_props + reliability)
tpkbcombo_tags = Or(('below'))
tpkbcombo = [Literal('LIBINPUT_ATTR_TPKBCOMBO_LAYOUT')('NAME') -
Suppress('=') -
tpkbcombo_tags('VALUE')]
grammar = Or(model_props + size_props + reliability + tpkbcombo)
return grammar