From: Peter Hutterer Date: Mon, 11 Nov 2019 05:47:10 +0000 (+1000) Subject: tools: debug-events: offset timestamps by the first normal event X-Git-Tag: 1.14.901~35 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=558cc3f11cf96e7a262e4e5149d79081b8e33485;p=platform%2Fupstream%2Flibinput.git tools: debug-events: offset timestamps by the first normal event Start counting the timestamps from the first time we get something off the actual fd. This makes it easier to match up timestamps with the output from libinput record. Signed-off-by: Peter Hutterer --- diff --git a/tools/libinput-debug-events.c b/tools/libinput-debug-events.c index dd0c7ed0..d4f5914f 100644 --- a/tools/libinput-debug-events.c +++ b/tools/libinput-debug-events.c @@ -155,7 +155,7 @@ print_event_header(struct libinput_event *ev) static void print_event_time(uint32_t time) { - printq("%+6.2fs ", (time - start_time) / 1000.0); + printq("%+6.2fs ", start_time ? (time - start_time) / 1000.0 : 0); } static inline void @@ -908,8 +908,16 @@ mainloop(struct libinput *li) fprintf(stderr, "Expected device added events on startup but got none. " "Maybe you don't have the right permissions?\n"); - while (!stop && poll(&fds, 1, -1) > -1) - handle_and_print_events(li); + /* time offset starts with our first received event */ + if (poll(&fds, 1, -1) > -1) { + struct timespec tp; + + clock_gettime(CLOCK_MONOTONIC, &tp); + start_time = tp.tv_sec * 1000 + tp.tv_nsec / 1000000; + do { + handle_and_print_events(li); + } while (!stop && poll(&fds, 1, -1) > -1); + } printf("\n"); } @@ -923,16 +931,12 @@ int main(int argc, char **argv) { struct libinput *li; - struct timespec tp; enum tools_backend backend = BACKEND_NONE; const char *seat_or_device = "seat0"; bool grab = false; bool verbose = false; struct sigaction act; - clock_gettime(CLOCK_MONOTONIC, &tp); - start_time = tp.tv_sec * 1000 + tp.tv_nsec / 1000000; - tools_init_options(&options); while (1) {