2016-08-09 20:09:49 -04:00
|
|
|
#!/bin/python
|
|
|
|
import evdev
|
|
|
|
from evdev import InputDevice, UInput
|
|
|
|
from select import select
|
|
|
|
import time
|
|
|
|
|
|
|
|
iDevices = map(evdev.InputDevice, (evdev.list_devices()))
|
2017-03-20 13:37:13 -04:00
|
|
|
iDevices = {dev.fd: dev for dev in iDevices if evdev.events.EV_KEY in dev.capabilities()}
|
|
|
|
|
2016-08-09 20:09:49 -04:00
|
|
|
uDevices = {}
|
|
|
|
for fd in iDevices:
|
|
|
|
dev = iDevices[fd]
|
2016-08-11 08:37:46 -04:00
|
|
|
cap = dev.capabilities()
|
|
|
|
del cap[0]
|
|
|
|
uDevices[fd] = UInput(
|
|
|
|
cap,
|
|
|
|
dev.name,
|
|
|
|
dev.info.vendor,
|
2016-08-09 20:09:49 -04:00
|
|
|
# dev.info.product,
|
|
|
|
# dev.version,
|
|
|
|
# dev.info.bustype,
|
2016-08-11 08:37:46 -04:00
|
|
|
# '/dev/uinput'
|
|
|
|
)
|
2016-09-13 03:47:27 -04:00
|
|
|
dev.grab()
|
|
|
|
|
2016-08-09 20:09:49 -04:00
|
|
|
|
|
|
|
i = 0
|
2016-09-13 03:47:27 -04:00
|
|
|
while i < 100:
|
2016-08-09 20:09:49 -04:00
|
|
|
r, w, x = select(iDevices, [], [])
|
|
|
|
if r != []:
|
|
|
|
i += 1
|
|
|
|
for fd in r:
|
|
|
|
for event in iDevices[fd].read():
|
2016-08-11 08:37:46 -04:00
|
|
|
if event.code != 30: # a
|
2016-10-08 16:08:38 -04:00
|
|
|
print(event)
|
2016-09-13 03:47:27 -04:00
|
|
|
uDevices[fd].write_event(event)
|
|
|
|
uDevices[fd].syn()
|
|
|
|
#print('Devicename:'+ devices[fd].name + ' Devicepath:' + devices[fd].fn + ' Events:' + str(devices[fd].active_keys(verbose=True)) + ' Value:' + str(event.value))
|
2016-08-11 08:37:46 -04:00
|
|
|
else:
|
|
|
|
print('this key is consumed')
|
2016-08-09 20:09:49 -04:00
|
|
|
|
|
|
|
for fd in iDevices:
|
2016-09-13 03:47:27 -04:00
|
|
|
iDevices[fd].ungrab()
|
2016-08-11 08:37:46 -04:00
|
|
|
iDevices[fd].close()
|
|
|
|
uDevices[fd].close()
|
|
|
|
|
|
|
|
|
|
|
|
iDevices.clear()
|
|
|
|
uDevices.clear()
|
|
|
|
|
2016-08-09 20:09:49 -04:00
|
|
|
|
|
|
|
|