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

Peter Hutterer peter.hutterer at who-t.net
Sun Nov 30 20:59:01 PST 2014


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;
+	}
+
+	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