[systemd-devel] [PATCH] hwdb: add a new db for the DPI/frequency settings of mice

Peter Hutterer peter.hutterer at who-t.net
Tue Nov 25 13:30:51 PST 2014


On Tue, Nov 25, 2014 at 02:56:31PM +0100, Zbigniew Jędrzejewski-Szmek wrote:
> On Tue, Nov 25, 2014 at 09:35:16PM +1000, Peter Hutterer wrote:
> > Pointer acceleration for relative input devices (mice, trackballs, etc.)
> > applies to the deltas of the device. Alas, those deltas have no physical
> > reference point - a delta of 10 may be caused by a large movement of a low-dpi
> > mouse or by a minute movement of a high-dpi mouse.
> > Which makes pointer acceleration a bit useless and high-dpi devices
> > essentially unusable.
> > 
> > In an ideal world, we could read the DPI from the device directly and work
> > with that. In the world we actually live in, we need to compile this list
> > manually. This patch introduces the database, with the usual match formats and
> > a single property to be set on a device: MOUSE_DPI
> > 
> > That is either a single value for most mice, or a list of values for mice that
> > can change resolution at runtime. The exact format is detailed in the hwdb
> > file.
> > 
> > Note that we're explicitly overshooting the requirements we have for libinput
> > atm. Frequency could be detected in software and we don't actually use the
> > list of multiple resolutions (because we can't detect when they change
> > anyway). However, we might as well collect those values from the get-go,
> > adding/modifying what will eventually amount to hundreds of entries is a
> > bit cumbersome.
> > 
> > Note: we rely on the input_id builtin to tag us as mouse first, ordering of
> > the rules is important.
> > ---
> >  Makefile.am          |  4 ++-
> >  rules/70-mouse.hwdb  | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  rules/70-mouse.rules | 15 +++++++++
> >  3 files changed, 110 insertions(+), 1 deletion(-)
> >  create mode 100644 rules/70-mouse.hwdb
> >  create mode 100644 rules/70-mouse.rules
> > 
> > diff --git a/Makefile.am b/Makefile.am
> > index 3f9f3fa..d2b0d02 100644
> > --- a/Makefile.am
> > +++ b/Makefile.am
> > @@ -3285,6 +3285,7 @@ dist_udevrules_DATA += \
> >  	rules/50-udev-default.rules \
> >  	rules/60-drm.rules \
> >  	rules/60-keyboard.rules \
> > +	rules/70-mouse.rules \
> >  	rules/60-persistent-storage-tape.rules \
> >  	rules/60-persistent-serial.rules \
> >  	rules/60-persistent-input.rules \
> > @@ -3311,7 +3312,8 @@ dist_udevhwdb_DATA = \
> >  	hwdb/20-acpi-vendor.hwdb \
> >  	hwdb/20-OUI.hwdb \
> >  	hwdb/20-net-ifname.hwdb \
> > -	hwdb/60-keyboard.hwdb
> > +	hwdb/60-keyboard.hwdb \
> > +	hwdb/70-mouse.hwdb
> Wouldn't 60-mouse be more appropriate? It is very similar to 60-keyboard.

I had that at first but 60-mouse sorts before 60-persistent-input.rules and
we partially rely on that, specifically the line
SUBSYSTEMS=="usb", ENV{ID_BUS}=="", IMPORT{builtin}="usb_id"

Want me to add that line to this ruleset here, or should we leave the
sorting as-is?

> >  udevconfdir = $(sysconfdir)/udev
> >  dist_udevconf_DATA = \
> > diff --git a/rules/70-mouse.hwdb b/rules/70-mouse.hwdb
> > new file mode 100644
> > index 0000000..75e8755
> > --- /dev/null
> > +++ b/rules/70-mouse.hwdb
> > @@ -0,0 +1,92 @@
> > +# This file is part of systemd.
> > +#
> > +# Database for the DPI setting of mice, trackballs, other pointer devices that
> > +# cannot be queried directly.
> > +#
> > +# The lookup keys are composed in:
> > +#   60-mouse.rules
> Typo (if you elect not to use change to 60 ;))

damn those last-minute changes :)

Cheers,
   Peter

> Otherwise looks OK.
> 
> Zbyszek
> 
> > +# Note: The format of the "mouse:" prefix match key is a
> > +# contract between the rules file and the hardware data, it might
> > +# change in later revisions to support more or better matches, it
> > +# is not necessarily expected to be a stable ABI.
> > +#
> > +# Match string format:
> > +# mouse:<subsystem>:v<vid>p<pid>:name:<name>:
> > +#
> > +# Supported subsystems: usb, bluetooth
> > +# vid/pid as 4-digit hex lowercase vendor/product
> > +#
> > +# if vid/pid is unavailable, use
> > +# mouse:*:name:<name>:
> > +# if name is unavailable, use
> > +# mouse:<subsystem>:v<vid>p<pid>:*
> > +#
> > +# For example, the following 5 matches all match the same mouse:
> > +# mouse:usb:v17efp6019:name:Lenovo Optical USB Mouse:
> > +# mouse:usb:*:name:Lenovo Optical USB Mouse:
> > +# mouse:usb:v17efp6019:*
> > +# mouse:*:name:Lenovo Optical USB Mouse:
> > +#
> > +# DPI settings are specified as
> > +#    MOUSE_DPI=<dpi>[@<frequency>]
> > +#
> > +# Where <dpi> is the resolution in dots per inch, and <frequency> the
> > +# optional sampling frequency in Hz.
> > +#
> > +# The value of MOUSE_DPI is:
> > +# - a single integer for single-resolution mice, e.g.
> > +#   MOUSE_DPI=800
> > +#   or, if the frequency is known:
> > +#   MOUSE_DPI=800 at 120
> > +# - a space-separated list of resolutions for multi-resolution mice.
> > +#   The default resolution must be prefixed by an asterisk, the resultions
> > +#   in the database must be as shipped by the manufacturer. e.g.
> > +#   MOUSE_DPI=400 *800 2000
> > +#
> > +#   The order of resolutions is as configured by the HW manufacturer or in
> > +#   ascending order, whichever appropriate.
> > +#
> > +#   The frequency must be given to either none or all resolutions. If the
> > +#   device supports multiple frequencies, the order of items is
> > +#   MOUSE_DPI=r1 at f1 r2 at f1 r3 at f1 r1 at f2 r2 at f2 r3 at f2
> > +#
> > +#   If the default manufacturer-set resolution is unclear, a resolution of
> > +#   800 or 1000 should be set as default, if available. If neither is
> > +#   available, choose the "middle" resolution value of those available.
> > +#
> > +#   The list may contain a single item which must be marked with an
> > +#   asterisk.
> > +#
> > +# Local changes to the a non-default resolution of the mouse (e.g. through
> > +# third-party software) must not be entered into this file, use a local
> > +# hwdb instead.
> > +#
> > +# To add local entries, create a new file
> > +#   /etc/udev/hwdb.d/60-mouse.hwdb
> > +# and add your rules there. To load the new rules execute (as root):
> > +#   udevadm hwdb --update
> > +#   udevadm trigger /dev/input/eventXX
> > +# where /dev/input/eventXX is the mouse in question. If in
> > +# doubt, simply use /dev/input/event* to reload all input rules.
> > +#
> > +# If your changes are generally applicable, open a bug report on
> > +#   http://bugs.freedesktop.org/enter_bug.cgi?product=systemd
> > +# and include your new rules, a description of the device, and the
> > +# output of
> > +#   udevadm info /dev/input/eventXX
> > +# (or /dev/input/event*).
> > +
> > +##########################################
> > +# Lenovo
> > +##########################################
> > +
> > +mouse:usb:v17efp6019:name:Lenovo Optical USB Mouse:
> > +  MOUSE_DPI=1000 at 125
> > +
> > +##########################################
> > +# Logitech
> > +##########################################
> > +
> > +mouse:usb:v046dpc24e:name:Logitech G500s Laser Gaming Mouse:
> > + MOUSE_DPI=400 at 500 *800 at 500 2000 at 500
> > diff --git a/rules/70-mouse.rules b/rules/70-mouse.rules
> > new file mode 100644
> > index 0000000..0e359e8
> > --- /dev/null
> > +++ b/rules/70-mouse.rules
> > @@ -0,0 +1,15 @@
> > +# do not edit this file, it will be overwritten on update
> > +
> > +ACTION=="remove", GOTO="mouse_end"
> > +KERNEL!="event*", GOTO="mouse_end"
> > +ENV{ID_INPUT_MOUSE}=="", GOTO="mouse_end"
> > +
> > +# mouse:<subsystem>:v<vid>p<pid>:name:<name>:*
> > +KERNELS=="input*", ENV{ID_BUS}=="usb", \
> > +        IMPORT{builtin}="hwdb 'mouse:$env{ID_BUS}:v$attr{id/vendor}p$attr{id/product}:name:$attr{name}:'", \
> > +        GOTO="mouse_end"
> > +KERNELS=="input*", ENV{ID_BUS}=="bluetooth", \
> > +        IMPORT{builtin}="hwdb 'mouse:$env{ID_BUS}:v$attr{id/vendor}p$attr{id/product}:name:$attr{name}:'", \
> > +        GOTO="mouse_end"
> > +
> > +LABEL="mouse_end"
> > -- 
> > 2.1.0
> > 
> > _______________________________________________
> > 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