diff options
author | Hans de Goede <hdegoede@redhat.com> | 2015-04-17 16:48:07 +0200 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2015-05-03 13:46:48 -0400 |
commit | c17bf408252681edd095ba9e2c38d0caf3c386ba (patch) | |
tree | a9575f39ab0d2b0522e0dcd5e150021f9c31c37b /src | |
parent | eb38f78d79c0339f6cad782320689a07351b157b (diff) |
udev: keyboard-builtin: Add support for setting IBM trackpoint sensitivity
IBM / Lenovo trackpoints allow specifying a sensitivity setting through a
ps/2 command, which changes the range of the deltas sent when using the
trackpoint.
On some models with normal usage only deltas of 1 or 2 are send, resulting in
there only being 2 mouse cursor movement speeds, rather than the expected fluid
scale. Changing the sensitivity to a higher level than the bootup default fixes
this.
This commit adds support for setting a POINTINGSTICK_SENSITIVITY value
in hwdb to allow changing the sensitivity on boot through udev / hwdb.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/udev/udev-builtin-keyboard.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c index cd13e4aa3d..2d2037fe1b 100644 --- a/src/udev/udev-builtin-keyboard.c +++ b/src/udev/udev-builtin-keyboard.c @@ -150,6 +150,32 @@ static void override_abs(int fd, const char *devnode, log_error_errno(errno, "Unable to EVIOCSABS device \"%s\"", devnode); } +static void set_trackpoint_sensitivity(struct udev_device *dev, const char *value) +{ + struct udev_device *pdev; + char val_s[DECIMAL_STR_MAX(int)]; + int r, val_i; + + /* The sensitivity sysfs attr belongs to the serio parent device */ + pdev = udev_device_get_parent_with_subsystem_devtype(dev, "serio", NULL); + if (!pdev) { + log_warning("Failed to get serio parent for '%s'", udev_device_get_devnode(dev)); + return; + } + + r = safe_atoi(value, &val_i); + if (r < 0) { + log_error("Unable to parse POINTINGSTICK_SENSITIVITY '%s' for '%s'", value, udev_device_get_devnode(dev)); + return; + } + + xsprintf(val_s, "%d", val_i); + + r = udev_device_set_sysattr_value(pdev, "sensitivity", val_s); + if (r < 0) + log_error_errno(r, "Failed to write 'sensitivity' attribute for '%s': %m", udev_device_get_devnode(pdev)); +} + static int open_device(const char *devnode) { int fd; @@ -227,6 +253,8 @@ static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo } override_abs(fd, node, evcode, udev_list_entry_get_value(entry)); + } else if (streq(key, "POINTINGSTICK_SENSITIVITY")) { + set_trackpoint_sensitivity(dev, udev_list_entry_get_value(entry)); } } |