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

View File

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

View File

@ -114,6 +114,14 @@ def patch_evdev():
'phys': 'usb-0000:03:00.0-3/input1', 'phys': 'usb-0000:03:00.0-3/input1',
'name': 'device 3' '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(): def list_devices():