|
|
@ -64,24 +64,16 @@ 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()
|
|
|
|
if evdev.ecodes.EV_KEY not in capabilities:
|
|
|
|
if evdev.ecodes.EV_KEY not in capabilities:
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
not config.may_modify_movement_devices()
|
|
|
|
|
|
|
|
and evdev.ecodes.EV_REL in capabilities
|
|
|
|
|
|
|
|
):
|
|
|
|
|
|
|
|
# TODO add checkbox to automatically load
|
|
|
|
|
|
|
|
# a preset on login
|
|
|
|
|
|
|
|
logger.debug(
|
|
|
|
|
|
|
|
'Skipping %s to avoid impairing mouse movement',
|
|
|
|
|
|
|
|
device.path
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
usb = device.phys.split('/')[0]
|
|
|
|
usb = device.phys.split('/')[0]
|
|
|
|
if grouped.get(usb) is None:
|
|
|
|
if grouped.get(usb) is None:
|
|
|
|
grouped[usb] = []
|
|
|
|
grouped[usb] = []
|
|
|
@ -117,7 +109,7 @@ def refresh_devices():
|
|
|
|
return get_devices()
|
|
|
|
return get_devices()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_devices(include_keymapper=False):
|
|
|
|
def get_devices():
|
|
|
|
"""Group devices and get relevant infos per group.
|
|
|
|
"""Group devices and get relevant infos per group.
|
|
|
|
|
|
|
|
|
|
|
|
Returns a list containing mappings of
|
|
|
|
Returns a list containing mappings of
|
|
|
@ -128,6 +120,10 @@ def get_devices(include_keymapper=False):
|
|
|
|
paths is a list of files in /dev/input that belong to the devices.
|
|
|
|
paths is a list of files in /dev/input that belong to the devices.
|
|
|
|
|
|
|
|
|
|
|
|
They are grouped by usb port.
|
|
|
|
They are grouped by usb port.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Since this needs to do some stuff with /dev and spawn processes the
|
|
|
|
|
|
|
|
result is cached. Use refresh_devices if you need up to date
|
|
|
|
|
|
|
|
devices.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
global _devices
|
|
|
|
global _devices
|
|
|
|
if _devices is None:
|
|
|
|
if _devices is None:
|
|
|
@ -141,13 +137,4 @@ def get_devices(include_keymapper=False):
|
|
|
|
names = [f'"{name}"' for name in _devices]
|
|
|
|
names = [f'"{name}"' for name in _devices]
|
|
|
|
logger.info('Found %s', ', '.join(names))
|
|
|
|
logger.info('Found %s', ', '.join(names))
|
|
|
|
|
|
|
|
|
|
|
|
# filter the result
|
|
|
|
return _devices
|
|
|
|
result = {}
|
|
|
|
|
|
|
|
for device in _devices.keys():
|
|
|
|
|
|
|
|
if include_keymapper and device.startswith('key-mapper'):
|
|
|
|
|
|
|
|
result[device] = _devices[device]
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result[device] = _devices[device]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|