tools: record: fix broken event time stamp recording

event->time ended up being an uninitialized field. Introduced in 5dc1a7e, the
event here isn't a struct input event but rather our internal event struct.
Fix this and reshuffle the time handling a bit so it's a bit more obvious
here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2020-01-30 10:49:06 +10:00
parent fb1f0a6886
commit da9eace8db

View file

@ -279,18 +279,19 @@ handle_evdev_frame(struct record_context *ctx, struct record_device *d)
while (libevdev_next_event(evdev,
LIBEVDEV_READ_FLAG_NORMAL,
&e) == LIBEVDEV_READ_STATUS_SUCCESS) {
uint64_t time;
uint64_t time = input_event_time(&e);
if (ctx->offset == 0)
ctx->offset = input_event_time(&e);
ctx->offset = time;
else
time = time_offset(ctx, time);
if (d->nevents == d->events_sz)
resize(d->events, d->events_sz);
event = &d->events[d->nevents++];
event->type = EVDEV;
time = input_event_time(&e);
input_event_set_time(&e, time - ctx->offset);
event->time = time;
event->u.evdev = e;
count++;