Skip to content

Commit fd0ecf2

Browse files
committed
Make excluded event types configurable and exclude EV_FF by default
1 parent 6ec052b commit fd0ecf2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

evdev/uinput.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class UInput(EventIO):
3232
)
3333

3434
@classmethod
35-
def from_device(cls, *devices, **kwargs):
35+
def from_device(cls, *devices, filtered_types=(ecodes.EV_SYN, ecodes.EV_FF), **kwargs):
3636
'''
3737
Create an UInput device with the capabilities of one or more input
3838
devices.
@@ -42,6 +42,9 @@ def from_device(cls, *devices, **kwargs):
4242
devices : InputDevice|str
4343
Varargs of InputDevice instances or paths to input devices.
4444
45+
filtered_types : Tuple[event type codes]
46+
Event types to exclude from the capabilities of the uinput device.
47+
4548
**kwargs
4649
Keyword arguments to UInput constructor (i.e. name, vendor etc.).
4750
'''
@@ -59,7 +62,8 @@ def from_device(cls, *devices, **kwargs):
5962
for ev_type, ev_codes in dev.capabilities().items():
6063
all_capabilities[ev_type].update(ev_codes)
6164

62-
del all_capabilities[ecodes.EV_SYN]
65+
for evtype in filtered_types:
66+
del all_capabilities[evtype]
6367

6468
return cls(events=all_capabilities, **kwargs)
6569

0 commit comments

Comments
 (0)