From 58014bbba84e207b9ca8afd98b20e3f1ffc06b33 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Fri, 26 Jul 2013 10:41:43 -0700 Subject: [PATCH] evdev: Use temporary x and y coordinates when applying calibration Don't overwrite device->abs.x halfway through the matrix multiplication. --- src/evdev.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index a554302..dd3e2c9 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -230,16 +230,21 @@ is_motion_event(struct input_event *e) static void transform_absolute(struct evdev_device *device) { + int32_t x, y; + if (!device->abs.apply_calibration) return; - device->abs.x = device->abs.x * device->abs.calibration[0] + - device->abs.y * device->abs.calibration[1] + - device->abs.calibration[2]; + x = device->abs.x * device->abs.calibration[0] + + device->abs.y * device->abs.calibration[1] + + device->abs.calibration[2]; + + y = device->abs.x * device->abs.calibration[3] + + device->abs.y * device->abs.calibration[4] + + device->abs.calibration[5]; - device->abs.y = device->abs.x * device->abs.calibration[3] + - device->abs.y * device->abs.calibration[4] + - device->abs.calibration[5]; + device->abs.x = x; + device->abs.y = y; } static void -- 2.7.4