tools: libinput-replay: handle a nonzero offset for the first event

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2018-04-19 14:29:07 +10:00
parent aca0e3729a
commit c819b4f956

View file

@ -107,6 +107,7 @@ def replay(device, verbose):
uinput = device['__uinput']
offset = time.time()
handled_first_event = False
# each 'evdev' set contains one SYN_REPORT so we only need to check for
# the time offset once per event
@ -118,6 +119,12 @@ def replay(device, verbose):
(sec, usec, evtype, evcode, value) = evdev[0]
# The first event may have a nonzero offset but we want to replay
# immediately regardless.
if not handled_first_event:
offset -= sec + usec/1.e6
handled_first_event = True
evtime = sec + usec/1e6 + offset
now = time.time()