-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmulti_dev.py
More file actions
26 lines (22 loc) · 803 Bytes
/
multi_dev.py
File metadata and controls
26 lines (22 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#from evdev import InputDevice
import evdev
from select import select
#DEVICE = ('/dev/input/event3', '/dev/input/event4')
DEVICE = ('/dev/input/event3')
print(type(DEVICE))
if isinstance(DEVICE, tuple):
devices = map(evdev.InputDevice, DEVICE)
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():
#if event.type == evdev.ecodes.EV_KEY or event.type == evdev.ecodes.EV_REL:
print(event)
else:
device = evdev.InputDevice(DEVICE)
print(device)
for event in device.read_loop():
#if event.type == evdev.ecodes.EV_KEY or event.type == evdev.ecodes.EV_REL:
print(event)