diff options
author | Hans de Goede <hdegoede@redhat.com> | 2015-04-01 11:03:19 +0200 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2015-04-22 09:35:28 +0200 |
commit | 5c671e0375cc03032fcac26efe4a7835a74c8bfc (patch) | |
tree | 3dbddf3164f5aa54fdda7f4c65a77c33d39b4460 /src/libinput-util.c | |
parent | f877ff2f96e79c8572949a7e8ba0f165300880e6 (diff) |
evdev: Add support for POINTINGSTICK_CONST_ACCEL udev property
There is quite a wide spread in the delta events generated by trackpoints,
some generate deltas of 1-2 under normal use, while others generate deltas
from 1-20.
It is desirable to normalize trackpoint deltas just like we are normalizing
mouse deltas to 1000 dpi, so as to give different model laptops aprox.
the same trackpoint cursor speed ootb.
Recent versions of udev + hwdb set a POINTINGSTICK_CONST_ACCEL udev property
which can be used to adjust trackpoints which are too slow / too fast
ootb, this commit implements support for that property.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src/libinput-util.c')
-rw-r--r-- | src/libinput-util.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/libinput-util.c b/src/libinput-util.c index 49e297a..4857435 100644 --- a/src/libinput-util.c +++ b/src/libinput-util.c @@ -29,6 +29,7 @@ #include "config.h" #include <ctype.h> +#include <locale.h> #include <stdarg.h> #include <stdbool.h> #include <stdio.h> @@ -201,3 +202,33 @@ parse_mouse_wheel_click_angle_property(const char *prop) return angle; } + +/** + * Helper function to parse the TRACKPOINT_CONST_ACCEL property from udev. + * Property is of the form: + * TRACKPOINT_CONST_ACCEL=<float> + * + * @param prop The value of the udev property (without the TRACKPOINT_CONST_ACCEL=) + * @return The acceleration, or 0.0 on error. + */ +double +parse_trackpoint_accel_property(const char *prop) +{ + locale_t c_locale; + double accel; + char *endp; + + /* Create a "C" locale to force strtod to use '.' as separator */ + c_locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0); + if (c_locale == (locale_t)0) + return 0.0; + + accel = strtod_l(prop, &endp, c_locale); + + freelocale(c_locale); + + if (*endp != '\0') + return 0.0; + + return accel; +} |