48 lines
1.1 KiB
Python
Executable File
48 lines
1.1 KiB
Python
Executable File
#!/bin/python
|
|
import evdev
|
|
from evdev import InputDevice, UInput
|
|
from select import select
|
|
import time
|
|
|
|
iDevices = map(evdev.InputDevice, (evdev.list_devices()))
|
|
iDevices = {dev.fd: dev for dev in iDevices if 1 in dev.capabilities()}
|
|
uDevices = {}
|
|
for fd in iDevices:
|
|
dev = iDevices[fd]
|
|
cap = dev.capabilities()
|
|
del cap[0]
|
|
uDevices[fd] = UInput(
|
|
cap,
|
|
dev.name,
|
|
dev.info.vendor,
|
|
# dev.info.product,
|
|
# dev.version,
|
|
# dev.info.bustype,
|
|
# '/dev/uinput'
|
|
)
|
|
|
|
i = 0
|
|
while i < 1000:
|
|
r, w, x = select(iDevices, [], [])
|
|
if r != []:
|
|
i += 1
|
|
for fd in r:
|
|
for event in iDevices[fd].read():
|
|
if event.code != 30: # a
|
|
print('Devicename:'+ iDevices[fd].name + ' Devicepath:' + iDevices[fd].fn + ' Events:' + str(iDevices[fd].active_keys(verbose=True)) + ' Value:' + str(event.value))
|
|
else:
|
|
print('this key is consumed')
|
|
break
|
|
break
|
|
|
|
for fd in iDevices:
|
|
iDevices[fd].close()
|
|
uDevices[fd].close()
|
|
|
|
|
|
iDevices.clear()
|
|
uDevices.clear()
|
|
|
|
|
|
|