mirror of
https://github.com/sezanzeb/input-remapper
synced 2024-11-02 15:40:19 +00:00
improved device grouping
This commit is contained in:
parent
f3b9f4d866
commit
130281ebf7
@ -119,7 +119,13 @@ class _GetDevices(threading.Thread):
|
|||||||
name = device.name
|
name = device.name
|
||||||
path = device.path
|
path = device.path
|
||||||
|
|
||||||
info = str(device.info)
|
info = (
|
||||||
|
f'{device.info.bustype},'
|
||||||
|
f'{device.info.vendor},'
|
||||||
|
f'{device.info.product}'
|
||||||
|
# observed a case with varying versions within a device,
|
||||||
|
# so only use the other three as index
|
||||||
|
)
|
||||||
if grouped.get(info) is None:
|
if grouped.get(info) is None:
|
||||||
grouped[info] = []
|
grouped[info] = []
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ def read_write_history_pipe():
|
|||||||
# key-mapper is only interested in devices that have EV_KEY, add some
|
# key-mapper is only interested in devices that have EV_KEY, add some
|
||||||
# random other stuff to test that they are ignored.
|
# random other stuff to test that they are ignored.
|
||||||
phys_1 = 'usb-0000:03:00.0-1/input2'
|
phys_1 = 'usb-0000:03:00.0-1/input2'
|
||||||
info_1 = 'bus: 0001, vendor 0001, product 0001, version 0001'
|
info_1 = evdev.device.DeviceInfo(1, 1, 1, 1)
|
||||||
|
|
||||||
fixtures = {
|
fixtures = {
|
||||||
# device 1
|
# device 1
|
||||||
@ -124,7 +124,7 @@ fixtures = {
|
|||||||
'/dev/input/event20': {
|
'/dev/input/event20': {
|
||||||
'capabilities': {evdev.ecodes.EV_KEY: list(evdev.ecodes.keys.keys())},
|
'capabilities': {evdev.ecodes.EV_KEY: list(evdev.ecodes.keys.keys())},
|
||||||
'phys': 'usb-0000:03:00.0-2/input1',
|
'phys': 'usb-0000:03:00.0-2/input1',
|
||||||
'info': 'bus: 0002, vendor 0001, product 0002, version 0001',
|
'info': evdev.device.DeviceInfo(2, 1, 2, 1),
|
||||||
'name': 'device 2'
|
'name': 'device 2'
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ fixtures = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
'phys': 'usb-0000:03:00.0-3/input1',
|
'phys': 'usb-0000:03:00.0-3/input1',
|
||||||
'info': 'bus: 0003, vendor 0001, product 0003, version 0001',
|
'info': evdev.device.DeviceInfo(3, 1, 3, 1),
|
||||||
'name': 'gamepad'
|
'name': 'gamepad'
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ fixtures = {
|
|||||||
'/dev/input/event31': {
|
'/dev/input/event31': {
|
||||||
'capabilities': {evdev.ecodes.EV_SYN: []},
|
'capabilities': {evdev.ecodes.EV_SYN: []},
|
||||||
'phys': 'usb-0000:03:00.0-4/input1',
|
'phys': 'usb-0000:03:00.0-4/input1',
|
||||||
'info': 'bus: 0004, vendor 0001, product 0004, version 0001',
|
'info': evdev.device.DeviceInfo(4, 1, 4, 1),
|
||||||
'name': 'Power Button'
|
'name': 'Power Button'
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ fixtures = {
|
|||||||
'/dev/input/event40': {
|
'/dev/input/event40': {
|
||||||
'capabilities': {evdev.ecodes.EV_KEY: list(evdev.ecodes.keys.keys())},
|
'capabilities': {evdev.ecodes.EV_KEY: list(evdev.ecodes.keys.keys())},
|
||||||
'phys': 'key-mapper/input1',
|
'phys': 'key-mapper/input1',
|
||||||
'info': 'bus: 0005, vendor 0001, product 0005, version 0001',
|
'info': evdev.device.DeviceInfo(5, 1, 5, 1),
|
||||||
'name': 'key-mapper device 2'
|
'name': 'key-mapper device 2'
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -240,7 +240,7 @@ class InputDevice:
|
|||||||
self.path = path
|
self.path = path
|
||||||
fixture = fixtures.get(path, {})
|
fixture = fixtures.get(path, {})
|
||||||
self.phys = fixture.get('phys', 'unset')
|
self.phys = fixture.get('phys', 'unset')
|
||||||
self.info = fixture.get('info', 'unset')
|
self.info = fixture.get('info', evdev.device.DeviceInfo(None, None, None, None))
|
||||||
self.name = fixture.get('name', 'unset')
|
self.name = fixture.get('name', 'unset')
|
||||||
self.fd = self.name
|
self.fd = self.name
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ class TestDaemon(unittest.TestCase):
|
|||||||
fixtures[self.new_fixture] = {
|
fixtures[self.new_fixture] = {
|
||||||
'capabilities': {evdev.ecodes.EV_KEY: [ev[1]]},
|
'capabilities': {evdev.ecodes.EV_KEY: [ev[1]]},
|
||||||
'phys': '9876 phys',
|
'phys': '9876 phys',
|
||||||
'info': 'abcd',
|
'info': evdev.device.DeviceInfo(4, 5, 6, 7),
|
||||||
'name': device
|
'name': device
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user