[PATCH libinput 3/4] evdev: add DPI to evdev calculations
Derek Foreman
derekf at osg.samsung.com
Thu Oct 30 14:34:15 PDT 2014
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.
---
src/evdev.c | 6 ++++--
src/evdev.h | 2 ++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/evdev.c b/src/evdev.c
index 341f7d8..8efa21a 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -42,6 +42,7 @@
#define DEFAULT_AXIS_STEP_DISTANCE 10
#define DEFAULT_MIDDLE_BUTTON_SCROLL_TIMEOUT 200
+#define DEFAULT_MOUSE_DPI 400
enum evdev_key_type {
EVDEV_KEY_TYPE_NONE,
@@ -205,8 +206,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;
@@ -1282,6 +1283,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 c0d6577..81dc140 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -135,6 +135,8 @@ struct evdev_device {
/* Checks if buttons are down and commits the setting */
void (*change_to_left_handed)(struct evdev_device *device);
} buttons;
+
+ int dpi;
};
#define EVDEV_UNHANDLED_DEVICE ((struct evdev_device *) 1)
--
2.1.1
More information about the wayland-devel
mailing list