From 3bbcffe488b0095c711cab6025da5fa0d826fd94 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 30 Jun 2015 14:26:11 +1000 Subject: [PATCH] touchpad: default to a 69x50mm sized touchpad The previous approach of using the axis ranges and approximating parameters based on the x/y axis range clutters up the code and is generally unreliable. If we look at Synaptics touchpads, the resolution ranges from 42 to 130 while the axes stay the same axis range. Other touchpads likely have a similar variation across the various models. Let's make this simpler in code: unless we know otherwise, simply assume a default-sized touchpad. Anything that deviates from that can be fixed with the new hwdb entries to provide a more correct setting. Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- src/evdev-mt-touchpad.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 3f5dabac..11fc03b8 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -1558,6 +1558,43 @@ error: return -1; } +static int +tp_init_default_resolution(struct tp_dispatch *tp, + struct evdev_device *device) +{ + const int touchpad_width_mm = 69, /* 1 under palm detection */ + touchpad_height_mm = 50; + int xres, yres; + + if (!device->abs.fake_resolution) + return 0 ; + + /* we only get here if + * - the touchpad provides no resolution + * - the udev hwdb didn't override the resoluion + * - no ATTR_SIZE_HINT is set + * + * The majority of touchpads that triggers all these conditions + * are old ones, so let's assume a small touchpad size and assume + * that. + */ + log_info(tp_libinput_context(tp), + "%s: no resolution or size hints, assuming a size of %dx%dmm\n", + device->devname, + touchpad_width_mm, + touchpad_height_mm); + + xres = device->abs.dimensions.x/touchpad_width_mm; + yres = device->abs.dimensions.y/touchpad_height_mm; + libevdev_set_abs_resolution(device->evdev, ABS_X, xres); + libevdev_set_abs_resolution(device->evdev, ABS_Y, yres); + libevdev_set_abs_resolution(device->evdev, ABS_MT_POSITION_X, xres); + libevdev_set_abs_resolution(device->evdev, ABS_MT_POSITION_Y, yres); + device->abs.fake_resolution = 0; + + return 0; +} + static int tp_init(struct tp_dispatch *tp, struct evdev_device *device) @@ -1571,6 +1608,9 @@ tp_init(struct tp_dispatch *tp, if (tp_sanity_check(tp, device) != 0) return -1; + if (tp_init_default_resolution(tp, device) != 0) + return -1; + if (tp_init_slots(tp, device) != 0) return -1;