[PATCH libevdev] tools: print the hwdb match line from the dpi tool

Benjamin Tissoires benjamin.tissoires at gmail.com
Mon Dec 1 08:07:19 PST 2014


Hi Peter,

On Sun, Nov 30, 2014 at 11:59 PM, Peter Hutterer
<peter.hutterer at who-t.net> wrote:
> Let's make this as easy as possible
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  tools/mouse-dpi-tool.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
>
> diff --git a/tools/mouse-dpi-tool.c b/tools/mouse-dpi-tool.c
> index f063028..65403de 100644
> --- a/tools/mouse-dpi-tool.c
> +++ b/tools/mouse-dpi-tool.c
> @@ -183,6 +183,23 @@ print_summary(struct measurements *m)
>         }
>  }
>
> +static inline const char*
> +bustype(int bustype)
> +{
> +       const char *bus;
> +
> +       switch(bustype) {
> +               case BUS_PCI: bus = "pci"; break;
> +               case BUS_ISAPNP: bus = "isapnp"; break;
> +               case BUS_USB: bus = "usb"; break;
> +               case BUS_HIL: bus = "hil"; break;
> +               case BUS_BLUETOOTH: bus = "bluetooth"; break;
> +               case BUS_VIRTUAL: bus = "pci"; break;

Are you sure we should return "pci" for BUS_VIRTUAL?

Also, we may need a "default" case here or I can not guarantee the
content of bus.

The rest is fine for me.

Cheers,
Benjamin

> +       }
> +
> +       return bus;
> +}
> +
>  int
>  main (int argc, char **argv) {
>         int rc;
> @@ -228,6 +245,16 @@ main (int argc, char **argv) {
>
>         print_summary(&measurements);
>
> +       printf("\n");
> +       printf("Entry for hwdb match (replace XXX with the resolution in DPI):\n"
> +              "mouse:%s:v%4xp%4x:name:%s:\n"
> +              " MOUSE_DPI=XXX@%d\n",
> +              bustype(libevdev_get_id_bustype(dev)),
> +              libevdev_get_id_vendor(dev),
> +              libevdev_get_id_product(dev),
> +              libevdev_get_name(dev),
> +              (int)measurements.frequency);
> +
>         libevdev_free(dev);
>         close(fd);
>
> --
> 2.1.0
>


More information about the Input-tools mailing list