From a13d936d7416ce678e5f10157ffd75e97d7b82e4 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 10 Jul 2015 13:59:06 +1000 Subject: [PATCH] evdev: parse LIBINPUT_ATTR_RESOLUTION_HINT For Elantech touchpads, we know that the resolution is 31u/mm (800dpi) for v1-v3 firmware. Set this as a hint until we get either the kernel or systemd to set this for us. Signed-off-by: Peter Hutterer --- src/evdev.c | 24 +++++++++++++++++++++--- udev/90-libinput-model-quirks.hwdb | 6 ++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index 3d19ee73..a833de5e 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1551,6 +1551,23 @@ evdev_read_model(struct evdev_device *device) return m->model; } +static inline int +evdev_read_attr_res_prop(struct evdev_device *device, + size_t *xres, + size_t *yres) +{ + struct udev_device *udev; + const char *res_prop; + + udev = device->udev_device; + res_prop = udev_device_get_property_value(udev, + "LIBINPUT_ATTR_RESOLUTION_HINT"); + if (!res_prop) + return false; + + return parse_dimension_property(res_prop, xres, yres); +} + static inline int evdev_read_attr_size_prop(struct evdev_device *device, size_t *size_x, @@ -1578,8 +1595,8 @@ evdev_fix_abs_resolution(struct evdev_device *device, struct libevdev *evdev = device->evdev; const struct input_absinfo *absx, *absy; size_t widthmm = 0, heightmm = 0; - int xres = EVDEV_FAKE_RESOLUTION, - yres = EVDEV_FAKE_RESOLUTION; + size_t xres = EVDEV_FAKE_RESOLUTION, + yres = EVDEV_FAKE_RESOLUTION; if (!(xcode == ABS_X && ycode == ABS_Y) && !(xcode == ABS_MT_POSITION_X && ycode == ABS_MT_POSITION_Y)) { @@ -1600,7 +1617,8 @@ evdev_fix_abs_resolution(struct evdev_device *device, * property is only for general size hints where we can make * educated guesses but don't know better. */ - if (evdev_read_attr_size_prop(device, &widthmm, &heightmm)) { + if (!evdev_read_attr_res_prop(device, &xres, &yres) && + evdev_read_attr_size_prop(device, &widthmm, &heightmm)) { xres = (absx->maximum - absx->minimum)/widthmm; yres = (absy->maximum - absy->minimum)/heightmm; } diff --git a/udev/90-libinput-model-quirks.hwdb b/udev/90-libinput-model-quirks.hwdb index 730b115a..eec00b62 100644 --- a/udev/90-libinput-model-quirks.hwdb +++ b/udev/90-libinput-model-quirks.hwdb @@ -34,6 +34,12 @@ libinput:touchpad:input:b0005v05ACp* LIBINPUT_MODEL_APPLE_TOUCHPAD=1 LIBINPUT_ATTR_SIZE_HINT=104x75 +########################################## +# Elantech +########################################## +libinput:name:*ETPS/2 Elantech Touchpad*:dmi:* + LIBINPUT_ATTR_RESOLUTION_HINT=31x31 + ########################################## # Google ##########################################