[PATCH V3 libinput] evdev: remove checks for fake_resolution
Peter Hutterer
peter.hutterer at who-t.net
Sun Jun 28 22:51:44 PDT 2015
On Thu, Jun 25, 2015 at 08:06:29AM -0700, spitzak at gmail.com wrote:
> From: Bill Spitzak <bill.spitzak at dreamworks.com>
>
> (changes from previous version: rounds the guess and changes 0 to 1,
> removed unused variables)
>
> Instead a default resolution is set if the device does not claim one.
> The selected value is a guess that the trackpad is 67 mm tall and
> that the device units are square.
>
> This estimate was arrived at by equating the results calculated when
> fake_resolution is on or off and computing the ratio of units to
> resolution and choosing the most popular value (yres = height / 66.666).
>
> Also fixes an apparent bug in computing motion_dist.scale_coeff, I
> believe the fake value was the reciprocal of the intended value.
>
> Unfortunately this patch has not been tested as I lack the ability to do so.
> It is unclear to me if the absinfo_x/y->maximum/minimum fields have been
> filled in before evdev_fix_abs_resolution is called, this patch
> assumes that.
> ---
> src/evdev-mt-touchpad-buttons.c | 59 +++++++++--------------------------------
> src/evdev-mt-touchpad.c | 32 +++++-----------------
> src/evdev.c | 16 ++++++++---
> 3 files changed, 31 insertions(+), 76 deletions(-)
>
[...]
> diff --git a/src/evdev.c b/src/evdev.c
> index cfcdc34..0bd19a4 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -1748,16 +1748,20 @@ evdev_configure_mt_device(struct evdev_device *device)
> int num_slots;
> int active_slot;
> int slot;
> + int guessed_resolution;
>
> if (!libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) ||
> !libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_Y))
> return 0;
>
> + guessed_resolution =
> + (device->abs.absinfo_y->maximum - device->abs.absinfo_y->minimum + 1 + 33) / 67;
> + if (guessed_resolution < 1) guessed_resolution = 1;
> if (evdev_fix_abs_resolution(device,
> ABS_MT_POSITION_X,
> ABS_MT_POSITION_Y,
> - EVDEV_FAKE_RESOLUTION,
> - EVDEV_FAKE_RESOLUTION))
> + guessed_resolution,
> + guessed_resolution))
> device->abs.fake_resolution = 1;
>
> device->abs.absinfo_x = libevdev_get_abs_info(evdev, ABS_MT_POSITION_X);
sigh. I understand that you may not have a device to trigger certain
conditions but that's exactly why we have a test suite. you didn't even run
that, otherwise you'd have noticed this segfaults immediately on every
touchpad - you're using absinfo 5 lines before it is assigned.
Cheers,
Peter
More information about the wayland-devel
mailing list