[systemd-devel] [PATCH v4 2/4] udev: keyboard-builtin: Add support for setting IBM trackpoint sensitivity

David Herrmann dh.herrmann at gmail.com
Mon Apr 20 01:23:42 PDT 2015


Hi

On Fri, Apr 17, 2015 at 4:48 PM, Hans de Goede <hdegoede at redhat.com> wrote:
> 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.
> ---
>  hwdb/70-pointingstick.hwdb       | 12 ++++++++++++
>  src/udev/udev-builtin-keyboard.c | 28 ++++++++++++++++++++++++++++
>  2 files changed, 40 insertions(+)
>
> diff --git a/hwdb/70-pointingstick.hwdb b/hwdb/70-pointingstick.hwdb
> index 8241181..c5bd92d 100644
> --- a/hwdb/70-pointingstick.hwdb
> +++ b/hwdb/70-pointingstick.hwdb
> @@ -41,6 +41,7 @@
>  #
>  # Allowed properties are:
>  #   POINTINGSTICK_CONST_ACCEL
> +#   POINTINGSTICK_SENSITIVITY
>  #
>  #########################################
>  #      POINTINGSTICK_CONST_ACCEL        #
> @@ -53,6 +54,17 @@
>  # by how much to multiply deltas generated by the pointingstick to get
>  # normalized deltas.
>  #
> +#########################################
> +#      POINTINGSTICK_SENSITIVITY        #
> +#########################################
> +#
> +# TPPS/2 IBM TrackPoint driver sensitivity sysfs setting
> +#    POINTINGSTICK_SENSITIVITY=<sensitivity>
> +#
> +# Where <sensitivity> is a number between 0 and 255, note this property
> +# only applies to TPPS/2 IBM TrackPoint devices, see
> +# drivers/input/mouse/trackpoint.c in the Linux kernel sources.
> +#
>
>  #
>  # Sort by by brand, model
> diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c
> index c7f7f84..e8cc4b8 100644
> --- a/src/udev/udev-builtin-keyboard.c
> +++ b/src/udev/udev-builtin-keyboard.c
> @@ -146,6 +146,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) + 1];

DECIMAL_STR_MAX already accounts for a zero byte (we really should fix
that one day..). But you can drop the "+ 1" here, if I'm not mistaken.

> +        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_error("Failed to get serio parent for '%s'", udev_device_get_devnode(dev));

log_warning()? I mean this will happen if you set a SENSITIVITY for an
unsupported device, which isn't necessarily an error.

Otherwise looks good to me. Please push!

Thanks
David

> +                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;
>
> @@ -223,6 +249,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));
>                  }
>          }
>
> --
> 2.3.5
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel


More information about the systemd-devel mailing list