so i have successfully been able to track both mouse and keyboard events using the following code
devices = map(InputDevice, ('/dev/input/event1', '/dev/input/event0'))
devices = {dev.fd: dev for dev in devices}
for dev in devices.values(): print(dev)
while True:
r, w, x = select(devices, [], [])
for fd in r:
for event in devices[fd].read():
print(event)
and the data i get from this code when pressing a key or moving the mouse is the following:
event at 1550702472.373994, code 00, type 00, val 00
event at 1550702472.389984, code 00, type 02, val -5
event at 1550702472.389984, code 01, type 02, val -2
event at 1550702472.389984, code 00, type 00, val 00
event at 1550702472.405988, code 00, type 02, val -3
event at 1550702472.405988, code 00, type 00, val 00
event at 1550702472.421987, code 00, type 02, val -2
my question is how can i convert this data or analyze the numbers to get a good output like an actual key. something like analyzing the 1550702472.xxx number to get a certain key or maybe the numbers following.
UPDATE: when i say print(categorize(event)) i get this:
key event at 1550703468.964836, 38 (KEY_L), down
synchronization event at 1550703468.964836, SYN_REPORT
event at 1550703469.052829, code 04, type 04, val 458767
key event at 1550703469.052829, 38 (KEY_L), up
synchronization event at 1550703469.052829, SYN_REPORT
relative axis event at 1550703472.093778, REL_Y
synchronization event at 1550703472.093778, SYN_REPORT
relative axis event at 1550703472.125780, REL_X
synchronization event at 1550703472.125780, SYN_REPORT
relative axis event at 1550703472.141764, REL_X
still the same question though, what array can i use to say if KEY_L do this.