From: Peter Hutterer Date: Thu, 13 Jun 2024 03:09:44 +0000 (+1000) Subject: Move scale_axis to a utility header so we can re-use it better X-Git-Tag: 1.27.0~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df242c108d26917586420105194a30e6bf231456;p=platform%2Fupstream%2Flibinput.git Move scale_axis to a utility header so we can re-use it better Part-of: --- diff --git a/src/evdev.c b/src/evdev.c index 15e338ac..3a336a1e 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -383,18 +383,12 @@ evdev_transform_relative(struct evdev_device *device, matrix_mult_vec(&rel_matrix, &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_range(absinfo); -} - double evdev_device_transform_x(struct evdev_device *device, double x, uint32_t width) { - return scale_axis(device->abs.absinfo_x, x, width); + return absinfo_scale_axis(device->abs.absinfo_x, x, width); } double @@ -402,7 +396,7 @@ evdev_device_transform_y(struct evdev_device *device, double y, uint32_t height) { - return scale_axis(device->abs.absinfo_y, y, height); + return absinfo_scale_axis(device->abs.absinfo_y, y, height); } void diff --git a/src/util-input-event.h b/src/util-input-event.h index c9b02ab8..b7910215 100644 --- a/src/util-input-event.h +++ b/src/util-input-event.h @@ -84,3 +84,9 @@ absinfo_normalize(const struct input_absinfo *abs) { return absinfo_normalize_value(abs, abs->value); } + +static inline double +absinfo_scale_axis(const struct input_absinfo *absinfo, double val, double to_range) +{ + return (val - absinfo->minimum) * to_range / absinfo_range(absinfo); +}