| 1 |
#!/usr/bin/env python3 |
| 2 |
import evdev |
| 3 |
from evdev import InputDevice |
| 4 |
from select import select |
| 5 |
import time |
| 6 |
|
| 7 |
devices = map(evdev.InputDevice, (evdev.list_devices())) |
| 8 |
devices = {dev.fd: dev for dev in devices} |
| 9 |
|
| 10 |
for fd in devices: |
| 11 |
for i in devices[fd].capabilities(True): |
| 12 |
print(devices[fd].fn,devices[fd].name,i) |
| 13 |
while True: |
| 14 |
r, w, x = select(devices, [], []) |
| 15 |
if r != []: |
| 16 |
for fd in r: |
| 17 |
for event in devices[fd].read(): |
| 18 |
print('Devicename:'+ devices[fd].name + ' Devicepath:' + devices[fd].fn + ' EventType: ' + str(event.type) + ' Events:' + str(devices[fd].active_keys(verbose=True)) + ' Value:' + str(event.value)) |
| 19 |
|
| 20 |
|