[PATCH libinput 10/13] tools: switch the ptraccel-debug printf to use mm/s

Peter Hutterer peter.hutterer at who-t.net
Mon Dec 19 05:21:01 UTC 2016


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 tools/ptraccel-debug.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/tools/ptraccel-debug.c b/tools/ptraccel-debug.c
index 4ecb7e8..4fcb45f 100644
--- a/tools/ptraccel-debug.c
+++ b/tools/ptraccel-debug.c
@@ -141,19 +141,31 @@ print_ptraccel_sequence(struct motion_filter *filter,
 	}
 }
 
+/* mm/s → units/µs */
+static inline double
+mmps_to_upus(double mmps, int dpi)
+{
+	return mmps * (dpi/25.4) / 1e6;
+}
+
 static void
-print_accel_func(struct motion_filter *filter, accel_profile_func_t profile)
+print_accel_func(struct motion_filter *filter,
+		 accel_profile_func_t profile,
+		 int dpi)
 {
-	double vel;
+	double mmps;
 
 	printf("# gnuplot:\n");
-	printf("# set xlabel \"speed\"\n");
+	printf("# set xlabel \"speed (mm/s)\"\n");
 	printf("# set ylabel \"raw accel factor\"\n");
 	printf("# set style data lines\n");
-	printf("# plot \"gnuplot.data\" using 1:2\n");
-	for (vel = 0.0; vel < 0.004; vel += 0.0000001) {
-		double result = profile(filter, NULL, vel, 0 /* time */);
-		printf("%.8f\t%.4f\n", vel, result);
+	printf("# plot \"gnuplot.data\" using 1:2 title 'accel factor'\n");
+	printf("#\n");
+	printf("# data: velocity(mm/s) factor velocity(units/us)\n");
+	for (mmps = 0.0; mmps < 300.0; mmps += 1) {
+		double units_per_us = mmps_to_upus(mmps, dpi);
+		double result = profile(filter, NULL, units_per_us, 0 /* time */);
+		printf("%.8f\t%.4f\t%.8f\n", mmps, result, units_per_us);
 	}
 }
 
@@ -338,7 +350,7 @@ main(int argc, char **argv)
 	}
 
 	if (print_accel)
-		print_accel_func(filter, profile);
+		print_accel_func(filter, profile, dpi);
 	else if (print_delta)
 		print_ptraccel_deltas(filter, step);
 	else if (print_motion)
-- 
2.9.3



More information about the wayland-devel mailing list