[PATCH 3/7] evdev: move scale_axis to evdev.h header
Peter Hutterer
peter.hutterer at who-t.net
Wed Jun 10 23:05:28 PDT 2015
On Wed, Jun 10, 2015 at 04:09:13PM +0200, Andreas Pokorny wrote:
> To be used inside pressure and orientation access functions of
> libinput.c
> ---
> src/evdev.c | 11 ++---------
> src/evdev.h | 7 +++++++
> 2 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/src/evdev.c b/src/evdev.c
> index af507d6..6f68554 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -224,19 +224,12 @@ transform_absolute(struct evdev_device *device,
> matrix_mult_vec(&device->abs.calibration, &point->x, &point->y);
> }
>
> -static inline double
> -scale_axis(const struct input_absinfo *absinfo, double val, double to_range)
> -{
> - return (val - absinfo->minimum) * to_range /
> - (absinfo->maximum - absinfo->minimum + 1);
> -}
> -
> double
> evdev_device_transform_x(struct evdev_device *device,
> double x,
> uint32_t width)
> {
> - return scale_axis(device->abs.absinfo_x, x, width);
> + return evdev_scale_axis(device->abs.absinfo_x, x, width);
> }
>
> double
> @@ -244,7 +237,7 @@ evdev_device_transform_y(struct evdev_device *device,
> double y,
> uint32_t height)
> {
> - return scale_axis(device->abs.absinfo_y, y, height);
> + return evdev_scale_axis(device->abs.absinfo_y, y, height);
> }
>
> static inline void
> diff --git a/src/evdev.h b/src/evdev.h
> index b8ef599..8e67e5d 100644
> --- a/src/evdev.h
> +++ b/src/evdev.h
> @@ -419,6 +419,13 @@ evdev_convert_to_mm(const struct input_absinfo *absinfo, double v)
> return value/absinfo->resolution;
> }
>
> +static inline double
> +evdev_scale_axis(const struct input_absinfo *absinfo, double val, double to_range)
> +{
> + return (val - absinfo->minimum) * to_range /
> + (absinfo->maximum - absinfo->minimum + 1);
> +}
nope, this won't work for normal normalisation, the +1 is for an [min, max[
range which you need for screen scaling, but for normalization you'd want
[min, max]. best to leave the scale_axis in place and make a
evdev_normalize_axis helper.
except for orientation (if in degrees), that's where you need a [min, max[
range too :)
for the tablet/buttonset branches we ended up with separate functions per
axis, so a normalize_major_minor, normalize_orientation, etc. is ok.
Cheers,
Peter
> +
> int
> evdev_init_left_handed(struct evdev_device *device,
> void (*change_to_left_handed)(struct evdev_device *));
> --
> 2.1.4
>
More information about the wayland-devel
mailing list