Skip to content

Commit 6ec052b

Browse files
committed
Simplify and make Python 3.x compatible
1 parent 8ab9f81 commit 6ec052b

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

evdev/uinput.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,12 @@ def from_device(cls, *devices, **kwargs):
5252
dev = device.InputDevice(str(dev))
5353
device_instances.append(dev)
5454

55-
# merge device capabilities
56-
all_capabilities = defaultdict(list)
55+
all_capabilities = defaultdict(set)
56+
57+
# Merge the capabilities of all devices into one dictionary.
5758
for dev in device_instances:
58-
dev_caps = dev.capabilities()
59-
for ev_type, ev_codes in dev_caps.iteritems():
60-
all_capabilities[ev_type].extend(ev_codes)
61-
# remove duplicate ev_codes
62-
all_capabilities[ev_type] = list(set(all_capabilities[ev_type]))
59+
for ev_type, ev_codes in dev.capabilities().items():
60+
all_capabilities[ev_type].update(ev_codes)
6361

6462
del all_capabilities[ecodes.EV_SYN]
6563

0 commit comments

Comments
 (0)