From 512e96466129cfc859c1f5f671810998318dfa54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Mon, 3 Feb 2014 23:35:24 +0100 Subject: [PATCH] evdev: Fix absolute coordinate transform formula MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the device min/max x/y coordinates are inclusive, to get the width/height one need to add one to (min x/y - max x/y). Signed-off-by: Jonas Ã…dahl --- src/evdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index cb83a1f8..2bc301b8 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -91,8 +91,8 @@ evdev_device_transform_x(struct evdev_device *device, li_fixed_t x, uint32_t width) { - return (x - device->abs.min_x) * width / - (device->abs.max_x - device->abs.min_x); + return (x - li_fixed_from_int(device->abs.min_x)) * width / + (device->abs.max_x - device->abs.min_x + 1); } li_fixed_t @@ -100,8 +100,8 @@ evdev_device_transform_y(struct evdev_device *device, li_fixed_t y, uint32_t height) { - return (y - device->abs.min_y) * height / - (device->abs.max_y - device->abs.min_y); + return (y - li_fixed_from_int(device->abs.min_y)) * height / + (device->abs.max_y - device->abs.min_y + 1); } static void