evdev: fix device_transform_ functions

X and Y are li_fixed_t, which is 24.8 fixed point real number.
li_fixed_t max is thus ~8388607.

On a touchscreen with a range of 32767 values (like a 3M sensor), and
mapped on monitor with a resolution of 1920x1080, we currently have:
(x - li_fixed_from_int(device->abs.min_x)) * width == 62912640

which is 7 times bigger than li_fixed_t max.

Force a cast to uint64_t to keep the precision of the sensor.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Benjamin Tissoires 2014-02-17 13:42:52 -05:00 committed by Peter Hutterer
parent ad24bc07f8
commit 128f98c43b

View file

@ -91,7 +91,7 @@ evdev_device_transform_x(struct evdev_device *device,
li_fixed_t x,
uint32_t width)
{
return (x - li_fixed_from_int(device->abs.min_x)) * width /
return ((uint64_t)x - li_fixed_from_int(device->abs.min_x)) * width /
(device->abs.max_x - device->abs.min_x + 1);
}
@ -100,7 +100,7 @@ evdev_device_transform_y(struct evdev_device *device,
li_fixed_t y,
uint32_t height)
{
return (y - li_fixed_from_int(device->abs.min_y)) * height /
return ((uint64_t)y - li_fixed_from_int(device->abs.min_y)) * height /
(device->abs.max_y - device->abs.min_y + 1);
}