mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-03 14:40:26 +01:00
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 <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
fcd7af86e2
commit
3bbcffe488
1 changed files with 40 additions and 0 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue