sezanzeb / input-remapper

🎮 ⌨ An easy to use tool to change the behaviour of your input devices.
GNU General Public License v3.0
3.72k stars 153 forks source link

Unable to configure devices with the same name independently #93

Closed jose1711 closed 3 years ago

jose1711 commented 3 years ago

I have two wireless SpeedLink gamepads - each has its own USB receiver. In the output of evtest I can see both of them.

$ evtest 2>&1|grep SPEED
/dev/input/event5:  SPEEDLINK TORID
/dev/input/event24: SPEEDLINK TORID

key-mapper is only showing single SPEEDLINK TORID entry receiving events from either controllers. This prevents from configuring them separately.

sezanzeb commented 3 years ago

I started working on it. Please run

sudo python3
import evdev
for path in evdev.list_devices():
     device = evdev.InputDevice(path)
     print(device.name, device.uniq)

to see if uniq has the correct uniqueness for this. I don't have two devices of the same model at home

jose1711 commented 3 years ago

device.uniq seems to be empty string for all detected devices. hmm..

>>> import evdev
>>> for path in evdev.list_devices():
...   device = evdev.InputDevice(path)
...   print(device.name, device.uniq)
... 
Microsoft X-Box 360 pad 
SPEEDLINK TORID 
Microsoft X-Box 360 pad 
..
HDA NVidia HDMI/DP,pcm=3 
SPEEDLINK TORID 
..
PC Speaker 
Eee PC WMI hotkeys 
Power Button 
Power Button 
sezanzeb commented 3 years ago

oh. Then maybe we have more luck with splitting device.phys, which can be empty as well though.

sudo python3
import evdev
for path in evdev.list_devices():
     device = evdev.InputDevice(path)
     print(device.name, device.phys)
jose1711 commented 3 years ago

Yeah, that looks promising:

>>> import evdev
>>> for path in evdev.list_devices():
...   device = evdev.InputDevice(path)
...   if 'SPEEDLINK' not in device.name: continue
...   print(device.name, device.phys)
... 
SPEEDLINK TORID usb-0000:0c:00.3-3.1/input0
SPEEDLINK TORID usb-0000:0c:00.3-4/input0
>>> 
sezanzeb commented 3 years ago

Please try the "getdevices-duplicate-2" branch.

It also has unittests already

jose1711 commented 3 years ago

Thank you for your pro-support, tested in Broforce and it works nicely.

sezanzeb commented 3 years ago

nice. I'll continue working a bit on improving the architecture in that regard though and will let you know once it is in main.

because currently getdevices contains a global variable with a bunch of helper function to access it. It should be a proper class instead.

sezanzeb commented 3 years ago

No I think there is an issue

Will it store the preset for the second device in a different location? i.e. do you have two different sets of presets for each one of them?

jose1711 commented 3 years ago

I get two separate files:

find .config/key-mapper/presets/SPEEDLINK\ TORID* -type f -ls
 90048293      4 -rw-------   1 jose     users         278 apr 13 23:32 .config/key-mapper/presets/SPEEDLINK\ TORID/move\ or\ die.json
 50860257      4 -rw-------   1 jose     users         191 apr 13 23:33 .config/key-mapper/presets/SPEEDLINK\ TORID\ 2/move_or_die.json
sezanzeb commented 3 years ago

Yeah, I'll be refactoring quite some stuff in that regard because the data structure and how things are being indexed is getting ridiculous. Will take a little bit more time


sezanzeb commented 3 years ago

I didn't fix the issue yet, but made a lot of changes that I would love to get tested by somebody else as well.

Please install the latest changes on the getdevices-duplicate-2 branch and check if it still works like it used to

it might actually already show two entries in the dropdown though, but that aspect is not tested at all. all old unittests are passing.

jose1711 commented 3 years ago

I didn't fix the issue yet

Sorry, which issue? I mean.. I was already getting two separate files per each device which I think is the way it's supposed to work. Or am I missing something?

sezanzeb commented 3 years ago

If you got two keyboards of the same type and configure two presets on day 1, and connect only one of them on day 2, the gui will only list one of the presets

Instead what I want to do is show all of them. Since they fit the device

i.e. all of the available presets for "keyboard foo" should also be available for "keyboard foo 2". It should put the preset .json files for both devices into a single directory.

autoloading should probably make a difference between "keyboard foo" and "keyboard foo 2", so that the second device can get a different preset applied automatically.

jose1711 commented 3 years ago

Thank you, that makes perfect sense. Will try to test in the following days.

sezanzeb commented 3 years ago

I'm finished with my work on the "getdevices-duplicate-2" branch, I expect it to correctly handle devices of the same model now.

It's not yet pushed to main

jose1711 commented 3 years ago

Sorry, did not have a chance to test it yet and I am traveling during weekend. I suggest you push to main and if there are any issues I will reopen.