From: Derek Foreman Date: Thu, 30 Oct 2014 21:34:15 +0000 (-0500) Subject: evdev: add DPI to evdev calculations X-Git-Tag: 0.7.0~87 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=79898da377ba58857be0bd104de694eb1e66f41f;p=platform%2Fupstream%2Flibinput.git evdev: add DPI to evdev calculations Assume "normal" mice are 400DPI, and that all calculations should be normalized to this before being fed into the filter. There isn't yet a way to configure a device's DPI. Signed-off-by: Peter Hutterer --- diff --git a/src/evdev.c b/src/evdev.c index 1f51b4af..3aa87a75 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -42,6 +42,8 @@ #define DEFAULT_AXIS_STEP_DISTANCE 10 #define DEFAULT_MIDDLE_BUTTON_SCROLL_TIMEOUT 200 +/* The HW DPI rate we normalize to before calculating pointer acceleration */ +#define DEFAULT_MOUSE_DPI 400 enum evdev_key_type { EVDEV_KEY_TYPE_NONE, @@ -205,8 +207,8 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time) case EVDEV_NONE: return; case EVDEV_RELATIVE_MOTION: - motion.dx = device->rel.dx; - motion.dy = device->rel.dy; + motion.dx = device->rel.dx / ((double)device->dpi / DEFAULT_MOUSE_DPI); + motion.dy = device->rel.dy / ((double)device->dpi / DEFAULT_MOUSE_DPI); device->rel.dx = 0; device->rel.dy = 0; @@ -1293,6 +1295,7 @@ evdev_device_create(struct libinput_seat *seat, device->devname = libevdev_get_name(device->evdev); device->scroll.threshold = 5.0; /* Default may be overridden */ device->scroll.direction = 0; + device->dpi = DEFAULT_MOUSE_DPI; matrix_init_identity(&device->abs.calibration); matrix_init_identity(&device->abs.usermatrix); diff --git a/src/evdev.h b/src/evdev.h index 9e846238..666c8dc8 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -136,6 +136,7 @@ struct evdev_device { void (*change_to_left_handed)(struct evdev_device *device); } buttons; + int dpi; /* HW resolution */ /* The number of times libevdev processes a SYN_DROPPED, so we can * stop logging them to avoid flooding the logs. */ int syn_drops_received;