mirror of
https://github.com/sezanzeb/input-remapper
synced 2024-11-13 19:10:50 +00:00
#78 filtering yubikey devices
This commit is contained in:
parent
e8196f2048
commit
3bb3d09d74
@ -22,6 +22,7 @@
|
|||||||
"""Device and evdev stuff that is independent from the display server."""
|
"""Device and evdev stuff that is independent from the display server."""
|
||||||
|
|
||||||
|
|
||||||
|
import re
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
@ -168,6 +169,28 @@ def classify(device):
|
|||||||
return UNKNOWN
|
return UNKNOWN
|
||||||
|
|
||||||
|
|
||||||
|
DENYLIST = [
|
||||||
|
('Yubico', r'.*YubiKey.*')
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def is_denylisted(device):
|
||||||
|
"""Check if a device should not be used in key-mapper.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
device : InputDevice
|
||||||
|
"""
|
||||||
|
for vendor, name in DENYLIST:
|
||||||
|
if not re.match(vendor, str(device.info.vendor), re.IGNORECASE):
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not re.match(name, str(device.name), re.IGNORECASE):
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
class _GetDevices(threading.Thread):
|
class _GetDevices(threading.Thread):
|
||||||
"""Process to get the devices that can be worked with.
|
"""Process to get the devices that can be worked with.
|
||||||
|
|
||||||
@ -217,6 +240,9 @@ class _GetDevices(threading.Thread):
|
|||||||
# skip devices that don't provide buttons that can be mapped
|
# skip devices that don't provide buttons that can be mapped
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if is_denylisted(device):
|
||||||
|
continue
|
||||||
|
|
||||||
name = device.name
|
name = device.name
|
||||||
path = device.path
|
path = device.path
|
||||||
|
|
||||||
|
@ -212,6 +212,14 @@ fixtures = {
|
|||||||
'info': evdev.device.DeviceInfo(5, 1, 5, 1),
|
'info': evdev.device.DeviceInfo(5, 1, 5, 1),
|
||||||
'name': 'key-mapper device 2'
|
'name': 'key-mapper device 2'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
# denylisted
|
||||||
|
'/dev/input/event51': {
|
||||||
|
'capabilities': {evdev.ecodes.EV_KEY: keyboard_keys},
|
||||||
|
'phys': 'usb-0000:03:00.0-5/input1',
|
||||||
|
'info': evdev.device.DeviceInfo(6, 'YuBiCo', 6, 1),
|
||||||
|
'name': 'fooYuBiKeYbar'
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user