mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-04 10:30:28 +01:00
Move scale_axis to a utility header so we can re-use it better
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1013>
This commit is contained in:
parent
49bbef6468
commit
df242c108d
2 changed files with 8 additions and 8 deletions
10
src/evdev.c
10
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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue