[PATCH evemu] Record the delta time between SYN_REPORTS in the comments

Peter Hutterer peter.hutterer at who-t.net
Mon Jul 27 18:04:30 PDT 2015


Having a human-readable output of how far two events are spaced apart can help
with debugging.

Example output:

E: 3.151999 0000 0000 0000	# ------------ SYN_REPORT (0) ---------- +8ms
E: 3.160002 0002 0000 -018	# EV_REL / REL_X                -18
E: 3.160002 0002 0001 -005	# EV_REL / REL_Y                -5
E: 3.160002 0000 0000 0000	# ------------ SYN_REPORT (0) ---------- +9ms
E: 3.167999 0002 0000 -011	# EV_REL / REL_X                -11
E: 3.167999 0002 0001 -001	# EV_REL / REL_Y                -1
E: 3.167999 0000 0000 0000	# ------------ SYN_REPORT (0) ---------- +7ms
E: 3.176000 0002 0000 -002	# EV_REL / REL_X                -2
E: 3.176000 0000 0000 0000	# ------------ SYN_REPORT (0) ---------- +9ms
E: 3.183995 0002 0001 0004	# EV_REL / REL_Y                4
E: 3.183995 0000 0000 0000	# ------------ SYN_REPORT (0) ---------- +7ms
E: 3.192011 0002 0001 0009	# EV_REL / REL_Y                9
E: 3.192011 0000 0000 0000	# ------------ SYN_REPORT (0) ---------- +9ms
E: 3.199996 0002 0000 -002	# EV_REL / REL_X                -2

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evemu.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/evemu.c b/src/evemu.c
index 12a0038..8b149b0 100644
--- a/src/evemu.c
+++ b/src/evemu.c
@@ -696,19 +696,31 @@ out:
 	return rc;
 }
 
+static inline unsigned long millis(const struct timeval *tv)
+{
+	return tv->tv_sec * 1000 + tv->tv_usec/1000;
+}
+
 static int write_event_desc(FILE *fp, const struct input_event *ev)
 {
 	int rc;
+	static unsigned long last_ms = 0;
+	unsigned long time, dt;
 
 	if (ev->type == EV_SYN) {
-		if (ev->code == SYN_MT_REPORT)
+		if (ev->code == SYN_MT_REPORT) {
 			rc = fprintf(fp, "# ++++++++++++ %s (%d) ++++++++++\n",
 				     libevdev_event_code_get_name(ev->type, ev->code),
 				     ev->value);
-		else
-			rc = fprintf(fp, "# ------------ %s (%d) ----------\n",
+		} else {
+			time = millis(&ev->time);
+			dt = time - last_ms;
+			last_ms = time;
+			rc = fprintf(fp, "# ------------ %s (%d) ---------- +%ldms\n",
 				     libevdev_event_code_get_name(ev->type, ev->code),
-				     ev->value);
+				     ev->value,
+				     dt);
+		}
 	} else {
 		rc = fprintf(fp, "# %s / %-20s %d\n",
 			     libevdev_event_type_get_name(ev->type),
-- 
2.4.3



More information about the Input-tools mailing list