[PATCH libinput] evdev: parse LIBINPUT_ATTR_RESOLUTION_HINT
Peter Hutterer
peter.hutterer at who-t.net
Thu Jul 9 23:29:45 PDT 2015
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 <peter.hutterer at who-t.net>
---
Until the kernel/systemd are sorted in all distributions, this is the easy
fix. This API is internal anyway, so we can remove it at any time.
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 3d19ee7..a833de5 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1552,6 +1552,23 @@ evdev_read_model(struct evdev_device *device)
}
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,
size_t *size_y)
@@ -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 730b115..eec00b6 100644
--- a/udev/90-libinput-model-quirks.hwdb
+++ b/udev/90-libinput-model-quirks.hwdb
@@ -35,6 +35,12 @@ libinput:touchpad:input:b0005v05ACp*
LIBINPUT_ATTR_SIZE_HINT=104x75
##########################################
+# Elantech
+##########################################
+libinput:name:*ETPS/2 Elantech Touchpad*:dmi:*
+ LIBINPUT_ATTR_RESOLUTION_HINT=31x31
+
+##########################################
# Google
##########################################
--
2.4.3
More information about the wayland-devel
mailing list