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 <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2019-11-11 15:47:10 +10:00
parent eef00ff3c6
commit 558cc3f11c

View file

@ -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) {