From 128f98c43b4b4da0b78b759ae8722249fc06e886 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Mon, 17 Feb 2014 13:42:52 -0500 Subject: [PATCH] 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 Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- src/evdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index 3fe28e4f..beec75ed 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -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); }