diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2017-05-16 13:01:32 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2017-07-20 11:53:01 +1000 |
commit | 3669fa10dff95371658647272ef7ac7a3ef29a61 (patch) | |
tree | 7a2de139d2f2679641807546534b4debd11d7938 /src/evdev.c | |
parent | 87b5682824b3137101f520b3b29fe396f80f57a8 (diff) |
trackpoint: drop handling of CONST_ACCEL and undo SENSITIVITY
This was to counteract hardware that doesn't work well out of the box,
resulting in quite different behavior across devices. Specifically, only
some trackpoints even have the sensitivity setting.
Change to take over all of the pointer acceleration on trackpoints, so we can
control the actual behavior mostly independent of the system setting. So we
drop the CONST_ACCEL parsing (which never was handled as const accel anyway)
and undo the effect that the SENSITIVITY udev property has. [1]
We take a default range at the default sensitivity and multiply it by the
proportion of the current sensitivity. This seems to be accurate enough.
[1] In the future, we should read not only the property but also the sysfs file to
make sure we're handling the right value, but for now this will do.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src/evdev.c')
-rw-r--r-- | src/evdev.c | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/src/evdev.c b/src/evdev.c index 4166091c..f9f26a64 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -2208,32 +2208,32 @@ evdev_read_wheel_tilt_props(struct evdev_device *device) } static inline int -evdev_get_trackpoint_dpi(struct evdev_device *device) +evdev_get_trackpoint_range(struct evdev_device *device) { - const char *trackpoint_accel; - double accel = DEFAULT_TRACKPOINT_ACCEL; + const char *prop; + int range = DEFAULT_TRACKPOINT_RANGE; - /* - * parse the sensitivity property, and undo whatever it does. - */ + if (!(device->tags & EVDEV_TAG_TRACKPOINT)) + return DEFAULT_TRACKPOINT_RANGE; - trackpoint_accel = udev_device_get_property_value( - device->udev_device, "POINTINGSTICK_CONST_ACCEL"); - if (trackpoint_accel) { - accel = parse_trackpoint_accel_property(trackpoint_accel); - if (accel == 0.0) { + prop = udev_device_get_property_value(device->udev_device, + "POINTINGSTICK_SENSITIVITY"); + if (prop) { + int sensitivity; + + if (!safe_atoi(prop, &sensitivity) || + (sensitivity < 0.0 || sensitivity > 255)) { evdev_log_error(device, - "trackpoint accel property is present but invalid, " - "using %.2f instead\n", - DEFAULT_TRACKPOINT_ACCEL); - accel = DEFAULT_TRACKPOINT_ACCEL; + "trackpoint sensitivity property is present but invalid, " + "using %d instead\n", + DEFAULT_TRACKPOINT_SENSITIVITY); + sensitivity = DEFAULT_TRACKPOINT_SENSITIVITY; } - evdev_log_info(device, "set to const accel %.2f\n", accel); + range = 1.0 * DEFAULT_TRACKPOINT_RANGE * + sensitivity/DEFAULT_TRACKPOINT_SENSITIVITY; } - device->trackpoint_range = 20; /* FIXME */ - - return DEFAULT_MOUSE_DPI / accel; + return range; } static inline int @@ -2242,13 +2242,8 @@ evdev_read_dpi_prop(struct evdev_device *device) const char *mouse_dpi; int dpi = DEFAULT_MOUSE_DPI; - /* - * Trackpoints do not have dpi, instead hwdb may contain a - * POINTINGSTICK_CONST_ACCEL value to compensate for sensitivity - * differences between models, we translate this to a fake dpi. - */ if (device->tags & EVDEV_TAG_TRACKPOINT) - return evdev_get_trackpoint_dpi(device); + return DEFAULT_MOUSE_DPI; mouse_dpi = udev_device_get_property_value(device->udev_device, "MOUSE_DPI"); @@ -2666,6 +2661,7 @@ evdev_configure_device(struct evdev_device *device) evdev_tag_external_mouse(device, device->udev_device); evdev_tag_trackpoint(device, device->udev_device); device->dpi = evdev_read_dpi_prop(device); + device->trackpoint_range = evdev_get_trackpoint_range(device); device->seat_caps |= EVDEV_DEVICE_POINTER; |