From 9f8edc5fd880e0a9c482b36e6b4120ccc056ee0b Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 9 Mar 2015 15:51:12 +1000 Subject: [PATCH] evdev: add helper function to normalize delta coordinates No functional changes. Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- src/evdev.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index 70c60eea..645a36bf 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -224,6 +224,13 @@ evdev_device_transform_y(struct evdev_device *device, return scale_axis(device->abs.absinfo_y, y, height); } +static inline void +normalize_delta(struct evdev_device *device, double *dx, double *dy) +{ + *dx = *dx * (double)device->dpi / DEFAULT_MOUSE_DPI; + *dy = *dy * (double)device->dpi / DEFAULT_MOUSE_DPI; +} + static void evdev_flush_pending_event(struct evdev_device *device, uint64_t time) { @@ -243,10 +250,9 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time) case EVDEV_NONE: return; case EVDEV_RELATIVE_MOTION: - dx_unaccel = device->rel.dx / ((double) device->dpi / - DEFAULT_MOUSE_DPI); - dy_unaccel = device->rel.dy / ((double) device->dpi / - DEFAULT_MOUSE_DPI); + dx_unaccel = device->rel.dx; + dy_unaccel = device->rel.dy; + normalize_delta(device, &dx_unaccel, &dy_unaccel); device->rel.dx = 0; device->rel.dy = 0;