test for getdevices ignoring evdev.UInput stuff from key-mapper

This commit is contained in:
sezanzeb 2020-11-19 00:22:22 +01:00
parent beee72431f
commit 0abd5b60c4
3 changed files with 14 additions and 1 deletions

View File

@ -61,6 +61,10 @@ class _GetDevicesProcess(multiprocessing.Process):
# "Logitech USB Keyboard" and "Logitech USB Keyboard Consumer Control"
grouped = {}
for device in devices:
if device.phys.startswith('key-mapper'):
# injector device, not really periphery
continue
# only keyboard devices
# https://www.kernel.org/doc/html/latest/input/event-codes.html
capabilities = device.capabilities().keys()
@ -80,7 +84,7 @@ class _GetDevicesProcess(multiprocessing.Process):
if grouped.get(usb) is None:
grouped[usb] = []
logger.debug('Adding %s', device.path)
logger.debug('Found "%s", %s, %s', device.name, device.path, usb)
grouped[usb].append((device.name, device.path))

View File

@ -108,6 +108,7 @@ class KeycodeInjector:
keymapper_device = evdev.UInput(
name=f'key-mapper {device.name}',
phys='key-mapper',
events=capabilities
)

View File

@ -114,6 +114,14 @@ def patch_evdev():
'phys': 'usb-0000:03:00.0-3/input1',
'name': 'device 3'
},
# key-mapper devices are also ignored, another instance of key-mapper
# started injecting apparently.
'/dev/input/event40': {
'capabilities': {evdev.ecodes.EV_KEY: []},
'phys': 'key-mapper/input1',
'name': 'key-mapper device 2'
},
}
def list_devices():