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>
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);
}
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);
}