Reputation: 409
I've been playing around with python-libevdev and noticed that event timestamps seem to wrap around. For example, when I ran the following script:
import libevdev as ev
with open('/dev/input/by-path/my-event-kbd', 'rb') as fd:
device = ev.Device(fd)
device.grab()
for e in device.events():
if e.matches(ev.EV_KEY):
if e.value == 0:
print('release', e.usec)
elif e.value == 1:
print('press ', e.usec)
I got:
press 285047
release 898527
press 383116
release 828000
press 164149
release 295935
press 929637
release 65158
press 593924
release 750227
press 81770
release 210363
press 533884
release 652184
press 949230
release 81242
and so on. The docs for InputEvent.usec
just say:
The timestamp, microseconds
Can anyone explain why/how the values wrap around? How would I use these values to calculate the time elapsed between a key being pressed and then released?
Upvotes: 0
Views: 63
Reputation: 409
Ah, I was confused. The full timestamp is given by InputEvent.sec
(seconds) plus InputEvent.usec
(microseconds).
Upvotes: 0