[PATCH libevdev 1/2] tools: move udev printf into the print_summary() helper

Peter Hutterer peter.hutterer at who-t.net
Tue Jan 17 04:51:34 UTC 2017


No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 tools/mouse-dpi-tool.c | 58 +++++++++++++++++++++++++-------------------------
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/tools/mouse-dpi-tool.c b/tools/mouse-dpi-tool.c
index 852ff07..13cefbc 100644
--- a/tools/mouse-dpi-tool.c
+++ b/tools/mouse-dpi-tool.c
@@ -193,8 +193,26 @@ mean_frequency(struct measurements *m)
 	return m->frequencies[idx];
 }
 
+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 = "virtual"; break;
+		default: bus = "unknown bus type"; break;
+	}
+
+	return bus;
+}
+
 static void
-print_summary(struct measurements *m)
+print_summary(struct libevdev *dev, struct measurements *m)
 {
 	int res;
 	int max_freq = (int)m->max_frequency,
@@ -222,24 +240,16 @@ print_summary(struct measurements *m)
 	printf("If your resolution is not in the list, calculate it with:\n"
 	       "\tresolution=%d/inches, or\n"
 	       "\tresolution=%d * 25.4/mm\n", m->distance, m->distance);
-}
 
-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 = "virtual"; break;
-		default: bus = "unknown bus type"; break;
-	}
-
-	return bus;
+	printf("\n");
+	printf("Entry for hwdb match (replace XXX with the resolution in DPI):\n"
+	       "mouse:%s:v%04xp%04x: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)m->max_frequency);
 }
 
 int
@@ -285,17 +295,7 @@ main (int argc, char **argv) {
 
 	printf("\n");
 
-	print_summary(&measurements);
-
-	printf("\n");
-	printf("Entry for hwdb match (replace XXX with the resolution in DPI):\n"
-	       "mouse:%s:v%04xp%04x: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.max_frequency);
+	print_summary(dev, &measurements);
 
 	libevdev_free(dev);
 	close(fd);
-- 
2.9.3



More information about the Input-tools mailing list