summaryrefslogtreecommitdiff
path: root/src/evdev-mt-touchpad.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2017-04-19 13:45:34 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2017-04-26 12:38:15 +1000
commit8d5f4decb4086e2b7982c3cd1e24afd9c11f551f (patch)
treed2733cf0055bbb6c9d6929dee395c59f197f1715 /src/evdev-mt-touchpad.c
parent2d96d8f97c94eb5f0633962410129ec9cffc3aae (diff)
touchpad: move the pressure range to a hwdb entry
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src/evdev-mt-touchpad.c')
-rw-r--r--src/evdev-mt-touchpad.c44
1 files changed, 32 insertions, 12 deletions
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index eb950a2..99963e6 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -2372,8 +2372,9 @@ tp_init_pressure(struct tp_dispatch *tp,
struct evdev_device *device)
{
const struct input_absinfo *abs;
- unsigned int range;
unsigned int code = ABS_PRESSURE;
+ const char *prop;
+ int hi, lo;
if (tp->has_mt)
code = ABS_MT_PRESSURE;
@@ -2383,25 +2384,44 @@ tp_init_pressure(struct tp_dispatch *tp,
return;
}
- tp->pressure.use_pressure = true;
-
abs = libevdev_get_abs_info(device->evdev, code);
assert(abs);
- range = abs->maximum - abs->minimum;
+ prop = udev_device_get_property_value(device->udev_device,
+ "LIBINPUT_ATTR_PRESSURE_RANGE");
+ if (prop) {
+ if (!parse_pressure_range_property(prop, &hi, &lo)) {
+ evdev_log_bug_client(device,
+ "discarding invalid pressure range '%s'\n",
+ prop);
+ return;
+ }
- if (device->model_flags & EVDEV_MODEL_ELANTECH_TOUCHPAD) {
- tp->pressure.high = 24;
- tp->pressure.low = 10;
- } else if (device->model_flags & EVDEV_MODEL_CYAPA) {
- tp->pressure.high = 10;
- tp->pressure.low = 8;
+ if (hi == 0 && lo == 0) {
+ evdev_log_info(device,
+ "pressure-based touch detection disabled\n");
+ return;
+ }
} else {
+ unsigned int range = abs->maximum - abs->minimum;
+
/* Approximately the synaptics defaults */
- tp->pressure.high = abs->minimum + 0.12 * range;
- tp->pressure.low = abs->minimum + 0.10 * range;
+ hi = abs->minimum + 0.12 * range;
+ lo = abs->minimum + 0.10 * range;
+ }
+
+ if (hi > abs->maximum || hi < abs->minimum ||
+ lo > abs->maximum || lo < abs->minimum) {
+ evdev_log_bug_libinput(device,
+ "discarding out-of-bounds pressure range %d:%d\n",
+ hi, lo);
+ return;
}
+ tp->pressure.use_pressure = true;
+ tp->pressure.high = hi;
+ tp->pressure.low = lo;
+
evdev_log_debug(device,
"using pressure-based touch detection\n");
}