From 661301b0518e29e66ba944fae3e2b88b4716565b Mon Sep 17 00:00:00 2001 From: Thomas Hindoe Paaboel Andersen Date: Tue, 20 Jan 2015 00:44:40 +0100 Subject: [PATCH] Add "Resolution" option for mice to the evdev driver It can be used to scale the resolution of a mouse to that of a 1000 DPI mouse. This can be useful to make high resolution mice less sensitive without turning off acceleration. The target of 1000 DPI is used as the same default is used in libinput. If the option is not set no scaling will be done. https://bugs.freedesktop.org/show_bug.cgi?id=88134 --- man/evdev.man | 4 ++++ src/evdev.c | 7 +++++++ src/evdev.h | 3 +++ 3 files changed, 14 insertions(+) diff --git a/man/evdev.man b/man/evdev.man index 06613fc..7f35377 100644 --- a/man/evdev.man +++ b/man/evdev.man @@ -238,6 +238,10 @@ Default: "1". Property: "Evdev Scrolling Distance". .BI "Option \*qDialDelta\*q \*q" integer \*q The amount of motion considered one unit of turning the dial. Default: "1". Property: "Evdev Scrolling Distance". +.TP 7 +.BI "Option \*qResolution\*q \*q" integer \*q +Sets the resolution of the device in counts per inch. The resolution is used +to scale relative motion events from mouse devices to 1000 DPI resolution. .SH SUPPORTED PROPERTIES The following properties are provided by the diff --git a/src/evdev.c b/src/evdev.c index 2d99f07..039abc5 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -25,6 +25,7 @@ * Adam Jackson (ajax@redhat.com) * Peter Hutterer (peter.hutterer@redhat.com) * Oliver McFadden (oliver.mcfadden@nokia.com) + * Thomas H.P. Andersen (phomes@gmail.com) */ #ifdef HAVE_CONFIG_H @@ -462,6 +463,11 @@ EvdevProcessValuators(InputInfoPtr pInfo) deltaY = tmp; } + if (pEvdev->resolution > 0) { + deltaX *= (double)DEFAULT_MOUSE_DPI / pEvdev->resolution; + deltaY *= (double)DEFAULT_MOUSE_DPI / pEvdev->resolution; + } + if (pEvdev->invert_x) deltaX *= -1; if (pEvdev->invert_y) @@ -2327,6 +2333,7 @@ EvdevProbe(InputInfoPtr pInfo) pEvdev->invert_x = xf86SetBoolOption(pInfo->options, "InvertX", FALSE); pEvdev->invert_y = xf86SetBoolOption(pInfo->options, "InvertY", FALSE); pEvdev->swap_axes = xf86SetBoolOption(pInfo->options, "SwapAxes", FALSE); + pEvdev->resolution = xf86SetIntOption(pInfo->options, "Resolution", 0); str = xf86CheckStrOption(pInfo->options, "Calibration", NULL); if (str) { diff --git a/src/evdev.h b/src/evdev.h index 6e5bce9..cb17546 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -103,6 +103,8 @@ /* Number of longs needed to hold the given number of bits */ #define NLONGS(x) (((x) + LONG_BITS - 1) / LONG_BITS) +#define DEFAULT_MOUSE_DPI 1000 + /* Function key mode */ enum fkeymode { FKEYMODE_UNKNOWN = 0, @@ -183,6 +185,7 @@ typedef struct { BOOL swap_axes; BOOL invert_x; BOOL invert_y; + int resolution; unsigned int abs_queued, rel_queued, prox_queued; -- 2.1.0