input-remapper
input-remapper copied to clipboard
undefined behaviour if multiple devices in the same group have similar capabilities (beta)
The Sony DualSense controller has a mouse-pad which reports ABS_X and ABS_Y as well as the standard controller layout which also reports ABS_X and ABS_Y events.
When a mapping uses one of those events as input both the joystick and the mouse-pad can trigger this mapping.
This leads to all sorts of issues, especially because the absinfo are not the same for those axis.
https://github.com/sezanzeb/input-remapper/pull/375/commits/a622037834a824d534c8736203e3799538c9fd0b mitigates this partially by only grabbing one of the devices. This however does not help if both devices are grabbed by different mappings.
@sezanzeb I think we need to include the origin of each event for a mapping. Otherwise we will not be able to fix both, this issue and #517
You know evdev better than I do. Is there any good parameter we can use to identify a input-device, which is unique to each device in a group but stays always the same?
I wrote some relevant stuff down at some point: https://github.com/sezanzeb/input-remapper/blob/b3e1e4ca1976bb420017c737525151ac37099e6e/inputremapper/groups.py#L209
# - device.phys is empty sometimes and varies across virtual
# subdevices
# - device.version varies across subdevices
# - device.uniq is empty most of the time, I don't know what this is
# supposed to be
- Maybe create a hash from all three of them
- Or sort them and use an index
You know evdev better than I do
I actually barely know stuff about it. I just use the things it provides
This needs a better solution than my attempt from above. #517 demonstrates a different failure mode rooted in the ambiguity of just using the event type, code and group name to identify a input.
A proper solution needs to identify a input event by type, code, group-name and sub-device.
preset config
{
"1,4,1+1,6,1+1,7,1+1,8,1": {
"target_uinput": "keyboard"
"output_symbol": "sfdgsdfgsdfgh",
"mapping_type": "key_macro"
},
}
to
[
{
"target_uinput": "keyboard"
"combination": [
{"type": 1, "code": 4, "value": 1, "device": "foo"},
{"type": 1, "code": 6, "value": 1, "device": "foo"},
{"type": 1, "code": 7, "value": 1, "device": "foo"},
{"type": 1, "code": 8, "value": 1, "device": "bar"}
],
"output_symbol": "sfdgsdfgsdfgh",
"mapping_type": "key_macro"
}
]
?
some more examples for the device attributes:
{'phys': 'usb-0000:28:00.3-2.3/input1', 'uniq': '', 'version': 65537, 'name': 'Logitech USB Keyboard System Control'}
{'phys': 'usb-0000:28:00.3-2.3/input1', 'uniq': '', 'version': 65537, 'name': 'Logitech USB Keyboard Consumer Control'}
{'phys': 'usb-0000:28:00.3-2.3/input0', 'uniq': '', 'version': 65537, 'name': 'Logitech USB Keyboard'}
{'phys': 'usb-0000:06:00.0-3/input0', 'uniq': '', 'version': 65537, 'name': 'Wacom Intuos5 M Pad'}
{'phys': 'usb-0000:06:00.0-3/input0', 'uniq': '', 'version': 65537, 'name': 'Wacom Intuos5 M Pen'}
I don't have the razer naga trinity anymore, so I can't test that one.
In order to identify them, the name would work well for those two.
I haven't seen the attributes of the DualSense controller.
I don't know if the attributes stay constant after system upgrades or reboots.
the name will not work for a razer naga trinity, but at least the phys is unique
phys = 'usb-0000:29:00.3-1/input0', uniq = '00000000001A', version = 65537, name = 'Razer Razer Naga Trinity'
phys = 'usb-0000:29:00.3-1/input1', uniq = '00000000001A', version = 65537, name = 'Razer Razer Naga Trinity'
phys = 'usb-0000:29:00.3-1/input2', uniq = '00000000001A', version = 65537, name = 'Razer Razer Naga Trinity'
It honestly looks like the different devices are just a hot mess. I am currently considering to use:
hash(str(InputDevice.capabilities()))
given the high amount of parameters in capabilities I would guess that this is always unique. At least for all my devices this is always unique.
[ { "target_uinput": "keyboard" "combination": [ {"type": 1, "code": 4, "value": 1, "device": "foo"}, {"type": 1, "code": 6, "value": 1, "device": "foo"}, {"type": 1, "code": 7, "value": 1, "device": "foo"}, {"type": 1, "code": 8, "value": 1, "device": "bar"} ], "output_symbol": "sfdgsdfgsdfgh", "mapping_type": "key_macro" } ]
yeah, I was thinking something like this as well.
yeah. Since this only happens once when the injection starts, the complexity of the hash generation doesn't matter.
hash(str(InputDevice.capabilities()) + InputDevice.phys + InputDevice.name)