Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two DualShocks connected via bluetooth - only one is remapped #766

Open
mfauvain opened this issue Sep 5, 2023 · 22 comments
Open

Two DualShocks connected via bluetooth - only one is remapped #766

mfauvain opened this issue Sep 5, 2023 · 22 comments
Labels

Comments

@mfauvain
Copy link

mfauvain commented Sep 5, 2023

Hi, first, thx for input-remapper, brilliant work.
I am trying to apply the same preset to 2 connected DualShock4.
When only one is connected (doesn't matter which one) it works perfect. However when 2 are connected, only one gets the remapping.
Anyway to get 2 controllers remapped at the same time?

@mfauvain mfauvain changed the title Two DualShocks connected Two DualShocks connected - only one is remapped Sep 5, 2023
@mfauvain
Copy link
Author

mfauvain commented Sep 7, 2023

So, when the DS4 are connected via USB (and bluetooth is off) input-remapper does see 2 devices and remap the 2 correctly.
When they are connected via bluetooth however, input-remapper sees only 1 device.
(and Steam, for ex, sees the 2 with 2 different IDs).

Is this a bluetooth config error on my side or something to be implemented in input-remapper?

@sezanzeb
Copy link
Owner

Hi, first, thx for input-remapper, brilliant work.

You're welcome

Run input-remapper-gtk -d and post the output here after it fully started. There are logs like this one:

17:05:08.679915 13734 reader-service DEBUG groups.py:402: Found keyboard "input-remapper keyboard" at "/dev/input/event2", hash "e2ae6745dffa005b153960484a342d8f", key "3_1_1_input-remapper"
...

which might help identify the problem

@mfauvain
Copy link
Author

Hello, here is the output with the 2 DS4 connected via USB
DS4 via USB.txt

and here is the one when connected via bluetooth
DS4 via Bluetooth.txt

in both cases, 10 devices are 'received' : DEBUG reader_client.py:287: Received 10 devices
but when connected via bluetooth, there seems to be a conflict and only one DS4 device is 'added'

USB:
19:34:23.855580 12214 GUI DEBUG device_groups.py:102: adding Sony Interactive Entertainment Wireless Controller to device selection
19:34:23.856224 12214 GUI DEBUG device_groups.py:102: adding Sony Interactive Entertainment Wireless Controller 2 to device selection

Bluetooth:
19:43:00.606289 12587 GUI DEBUG device_groups.py:102: adding Wireless Controller to device selection

Thank you!

@sezanzeb
Copy link
Owner

sezanzeb commented Nov 5, 2023

The problem is, that quite often one hardware-device is represented by multiple uinputs in /dev/input, each one of them reporting different kinds of events. To avoid confusion in the gui, they are grouped together. When recording inputs, they are recorded from all those devices at the same time.

Your two gamepads appear to be grouped together in that fashion. input-remapper fails to figure out that they are actually two distinct gamepads.

This happens in get_unique_key

No idea how an easy fix for this could look like.

Try running this small python script with sudo:

import evdev

for path in evdev.list_devices():
    input_device = evdev.InputDevice(path)
    print(input_device.name)
    print('uniq', input_device.uniq)
    print('phys', input_device.phys)
    print('info', input_device.info)
    print('version', input_device.version)
    print('path', input_device.path)
    print()

The info printed here is what we have to work with.

@sezanzeb sezanzeb changed the title Two DualShocks connected - only one is remapped Two DualShocks connected via bluetooth - only one is remapped Nov 5, 2023
@sezanzeb sezanzeb added the bug label Nov 5, 2023
@KWWPiDev
Copy link

KWWPiDev commented Nov 8, 2023

I want to echo OP: input-remapper is amazing, thank you so much for this.

I have this same problem with simultaneously using two Logitech MX Ergo Mice:

input-remapper 2.0.1 a012746
Description: Ubuntu 22.04.3 LTS

python script from above:

Logitech MX Ergo
uniq 68-53-a7-00
phys usb-0000:0e:00.3-2/input2:1
info bus: 0003, vendor 046d, product 406f, version 0111
version 65537
path /dev/input/event7

Logitech MX Ergo
uniq 51-5a-c7-e2
phys usb-0000:0e:00.3-2/input2:3
info bus: 0003, vendor 046d, product 406f, version 0111
version 65537
path /dev/input/event6

Let me know how I can help here with any debugging/testing/other info that could be helpful.

Note: this used to work and stopped working a while back, but I don't remember when it stopped working.

Also fun: which mouse works changes often :)

Thanks again for all your hard work here! It is very much appreciated, you literally have made it possible for me to use my devices on linux, thank you.



input-remapper-gtk -d | grep -i -e "ergo" -e "event7" -e "event6" :

[...]
22:42:43.954335 159450 reader-service DEBUG groups.py:402: Found mouse "Logitech MX Ergo" at "/dev/input/event7", hash "490609b728e63cffb1ca85cf42b2426f", key "3_1133_16495_usb-0000:0e:00.3-2"
22:42:43.954585 159450 reader-service DEBUG groups.py:402: Found mouse "Logitech MX Ergo" at "/dev/input/event6", hash "490609b728e63cffb1ca85cf42b2426f", key "3_1133_16495_usb-0000:0e:00.3-2"
[...]
22:42:44.056069 159363 GUI INFO data_manager.py:297: Loading group "Logitech MX Ergo"
22:42:44.056945 159363 GUI INFO preset.py:147: Loading preset from "/home/user/.config/input-remapper-2/presets/Logitech MX Ergo/wheel-right-and-left.json"
22:42:44.058922 159363 GUI DEBUG device_groups.py:102: adding Logitech MX Ergo to device selection
22:42:44.059443 159363 GUI DEBUG message_broker.py:76: from data_manager.py:100: Signal=group: GroupData(group_key='Logitech MX Ergo', presets=('wheel-right-and-left',))
[...]
22:42:44.082972 159363 GUI DEBUG device_groups.py:102: adding Logitech MX Ergo to device selection




@mfauvain
Copy link
Author

mfauvain commented Nov 8, 2023

Here is the result of the python script (I've removed the other devices)

input-remapper Wireless Controller forwarded
uniq 
phys py-evdev-uinput
info bus: 0005, vendor 054c, product 09cc, version 8100
version 65537
path /dev/input/event26

Wireless Controller
uniq 58:10:31:00:09:40
phys 14:75:5b:3e:91:7f
info bus: 0005, vendor 054c, product 09cc, version 8100
version 65537
path /dev/input/event25

Wireless Controller Motion Sensors
uniq 58:10:31:00:09:40
phys 14:75:5b:3e:91:7f
info bus: 0005, vendor 054c, product 09cc, version 8100
version 65537
path /dev/input/event24

Wireless Controller Touchpad
uniq 58:10:31:00:09:40
phys 14:75:5b:3e:91:7f
info bus: 0005, vendor 054c, product 09cc, version 8100
version 65537
path /dev/input/event23

input-remapper Sony Interactive Entertainment Wireless Controller forwarded
uniq 
phys py-evdev-uinput
info bus: 0003, vendor 054c, product 09cc, version 8111
version 65537
path /dev/input/event22

--- cut ---

Sony Interactive Entertainment Wireless Controller
uniq 58:10:31:00:43:38
phys usb-0000:00:14.0-6.2/input3
info bus: 0003, vendor 054c, product 09cc, version 8111
version 65537
path /dev/input/event7

Sony Interactive Entertainment Wireless Controller Motion Sensors
uniq 58:10:31:00:43:38
phys usb-0000:00:14.0-6.2/input3
info bus: 0003, vendor 054c, product 09cc, version 8111
version 65537
path /dev/input/event6

Sony Interactive Entertainment Wireless Controller Touchpad
uniq 58:10:31:00:43:38
phys usb-0000:00:14.0-6.2/input3
info bus: 0003, vendor 054c, product 09cc, version 8111
version 65537
path /dev/input/event5

--- cut ---

@sezanzeb
Copy link
Owner

sezanzeb commented Nov 8, 2023

I have some hopes that by including "uniq" into the function after all, this can be improved. For all of my devices uniq is just empty, but it looks like it could work for you.

Here is the result of the python script (I've removed the other devices)

is this with only one gamepad connected? What if you connect both of them via bluetooth and run the script?

I want to echo OP: input-remapper is amazing, thank you so much for this.

Thank you!

@sezanzeb
Copy link
Owner

sezanzeb commented Nov 9, 2023

There might be another problem. input-remapper creates generic target uinputs, and if you have two different gamepads and map buttons on each one of them to another button/macro (lets say Left-Trigger to BTN_A on gamepad 1, and Right-Trigger to BTN_B on gamepad 2), then BTN_A and BTN_B appear in the same generic gamepad output. It will look to the game as if a third gamepad is connected.

This would require the target selection to allow injecting them into the "forwarded" device. This is most likely easier said than done, due to the architecture.

@mfauvain
Copy link
Author

mfauvain commented Nov 9, 2023

This is with the 2 DS4 connected via bluetooth:

input-remapper Wireless Controller forwarded
uniq 
phys py-evdev-uinput
info bus: 0005, vendor 054c, product 09cc, version 8100
version 65537
path /dev/input/event29

Wireless Controller
uniq 58:10:31:00:43:38
phys 14:75:5b:3e:91:7f
info bus: 0005, vendor 054c, product 09cc, version 8100
version 65537
path /dev/input/event7

Wireless Controller Motion Sensors
uniq 58:10:31:00:43:38
phys 14:75:5b:3e:91:7f
info bus: 0005, vendor 054c, product 09cc, version 8100
version 65537
path /dev/input/event6

Wireless Controller Touchpad
uniq 58:10:31:00:43:38
phys 14:75:5b:3e:91:7f
info bus: 0005, vendor 054c, product 09cc, version 8100
version 65537
path /dev/input/event5

Wireless Controller
uniq 58:10:31:00:09:40
phys 14:75:5b:3e:91:7f
info bus: 0005, vendor 054c, product 09cc, version 8100
version 65537
path /dev/input/event25

Wireless Controller Motion Sensors
uniq 58:10:31:00:09:40
phys 14:75:5b:3e:91:7f
info bus: 0005, vendor 054c, product 09cc, version 8100
version 65537
path /dev/input/event24

Wireless Controller Touchpad
uniq 58:10:31:00:09:40
phys 14:75:5b:3e:91:7f
info bus: 0005, vendor 054c, product 09cc, version 8100
version 65537
path /dev/input/event23

input-remapper Sony Interactive Entertainment Wireless Controller forwarded
uniq 
phys py-evdev-uinput
info bus: 0003, vendor 054c, product 09cc, version 8111
version 65537
path /dev/input/event22

@sezanzeb
Copy link
Owner

Try the "uniq" branch. Let me know if you have trouble installing it: https://github.com/sezanzeb/input-remapper/tree/uniq

@mfauvain
Copy link
Author

Thx, so just pip install --no-binary :all: git+https://github.com/sezanzeb/input-remapper.git@uniq ?

@sezanzeb
Copy link
Owner

sezanzeb commented Nov 11, 2023

That might work for you, but you'll need to install it system-wide via sudo

For me, this doesn't work, because of this annoying issue: pypa/wheel#92.

try

git clone https://github.com/sezanzeb/input-remapper.git
cd input-remapper
git checkout uniq
sudo python3 setup.py install
input-remapper-control --version

should print

input-remapper 2.0.1 98822995c511f6ca51d463fee83a1c4b310f4e15 https://github.com/sezanzeb/input-remapper

@mfauvain
Copy link
Author

It 'sees' the 2 DS4 when connected via bluetooth
image

However, the controller 2 is not 'grabbed' when I try to Apply
image

@sezanzeb
Copy link
Owner

in a console, run

sudo pkill -f input-remapper-service && sudo input-remapper-service -d

then open the gui and try again. The resulting logs might tell us why

@mfauvain
Copy link
Author

So I tried different things and can confirm:

  • works when starting sudo input-remapper-service -d and then manually Applying the 2 presets
  • works when starting at boot with systemd (tried this just to confirm) and then manually Applying the 2 presets
    However,
  • does not work when 'autoload' is selected on 'Wireless Controller 2'

If I disable 'autoload' on both and then apply presets manually on both, it works.

@sezanzeb
Copy link
Owner

sezanzeb commented Nov 12, 2023

So the old version (without the patch from the uniq branch) was still running in the background, oops.

autoloading doesn't work, because input-remapper-control sends the device name, and nothing else. So the daemon will never know for which of your two controllers to autoload. This is an unfortunate problem. This needs adjusting in the dbus endpoints of the daemon and the the udev rule.

However, you might get around the issue by running input-remapper-control --command autoload --device "Wireless Controller 2" or something. If you automate this to run when you log in, it might just work fine for you.

@mfauvain
Copy link
Author

I tried running input-remapper-control --command start --device 'Wireless Controller' --preset 'DualShock' at login, but this only works when the DS4 are connected via bluetooth at login (which is usually not the case as they are usually charging via usb).
But I will try with a udev rule
KERNEL==”hidraw*”, SUBSYSTEM==”hidraw”, ATTRS{address}==”xx:xx:xx:xx:xx:xx”, RUN+=”script with input-remapper command”

@sezanzeb
Copy link
Owner

For the future, it might be better if instead of sending the device name, the device path is sent to input-remapper-service via dbus. the service could then probably figure out to which group this path belongs.

@KWWPiDev
Copy link

KWWPiDev commented Nov 17, 2023

UPDATE: after a reboot the "uniq" branch is auto loading for both of my Logitech MX Ergo mice without me doing a custom call to input-remapper-control, just the following startup application in Ubuntu 22:

bash -c "input-remapper-control --command stop-all && input-remapper-control --command autoload"

Original comment for reference:

Thanks for working on this! Updates for my 2 logitech mx ergo devices:

TL;DR: 'uniq' branch works for my 2 logitech ergo devices, but autostart now doesn't for all devices. I have to manually start, but that works, thank you so much for this.

Details in case this is useful, happy to do more testing, mention me in a comment/reply with anything you'd like me to try/test/report back on.

Long version:

Ubuntu 22.04 LTS with x11 (not Wayland):

  • cloned repo, switch to "uniq" branch, installed

  • ran "sudo pkill -f input-remapper-service && sudo input-remapper-service -d"

  • confirmed both mx ergo devices now appear in list

  • neither device has working button mappings (used to be one did and the other didn't)

  • ALSO: NO OTHER DEVICES are getting autoloaded remappings now, whereas before they worked. So all autoloads are broken on the 'uniq' branch regardless of if there is only one or there are multiple of the devices

  • Each device listed has the mappings listed

  • Each device NOW WORKS with button remapping but ONLY AFTER I manually click "Apply" for both

  • Confirmed both devices have "autoload" switched on

  • ran "sudo pkill -f input-remapper-service && sudo input-remapper-service -d" again

  • same as before: both devices listed, neither mapping autoloads, both work after manually clicking "Apply" for each

  • ran "sudo pkill -f input-remapper-service && sudo input-remapper-service -d" again

  • tried input-remapper-contro without sudo / root, failed (as is probably expected)

  • tried again with sudo:
    sudo input-remapper-control --command start --device 'Logitech MX Ergo' --preset 'wheel-right-and-left.json'
    sudo input-remapper-control --command start --device 'Logitech MX Ergo 2' --preset 'wheel-right-and-left.json'

neither worked because (I later learned from the deamon output) was using 'wheel-right-and-left.json' and it was looking for 'wheel-right-and-left.json.json'

both still worked after I go into the UI and manually click "apply" for each

  • tried without the .json in the preset name:

sudo input-remapper-control --command start --device 'Logitech MX Ergo' --preset 'wheel-right-and-left'
sudo input-remapper-control --command start --device 'Logitech MX Ergo 2' --preset 'wheel-right-and-left'

BOTH NOW WORK! Awesome progress :)

Disconnected both devices (but left logitech dongle, the mx ergo devices have a button that allows to switch between two different dongles, so I switched them both to the other computer to see if the preset loading works if the device isn't connected but the dongle is) -- and it worked!

  • restarted service:
    sudo pkill -f input-remapper-service && sudo input-remapper-service -d

  • confirmed neither mapping autoloads

  • rand the manual start commands again:
    sudo input-remapper-control --command start --device 'Logitech MX Ergo' --preset 'wheel-right-and-left'
    sudo input-remapper-control --command start --device 'Logitech MX Ergo 2' --preset 'wheel-right-and-left'

  • pressed button on each mx ergo and both have input mappsings working even tho they were not "connected" when I ran the command

BOTH NOW WORK! Awesome progress :)

Will need to manually run all the presets but I can set up a startup application script to do this.

Can't thank you enough, this is enough for me to be able to use both going forward. But it's still not ideal for others since the "autoload" switch is ignored for all devices on the "uniq" branch for me.

Happy to test any future updates, mention me and let me know if there's anything you want me to test for you with these logitech devices.

I expect this loading wouldn't work with a device disconnected like mfauvain DualShock problem above, but for me the logitech dongle is always plugged in and seems to not need the mouse actually connected to still have the mapping work.

Thanks so much for the quick work on this and for getting this to workable for me, so much appreciated :) :)

@KWWPiDev
Copy link

UPDATE: after a reboot the "uniq" branch is auto loading for both of my Logitech MX Ergo mice without me doing a custom call to input-remapper-control. I do have the following startup application on Ubuntu:

bash -c "input-remapper-control --command stop-all && input-remapper-control --command autoload"

Thanks so much for this work! Let me know if there's anything I can do to help test further.

@sezanzeb
Copy link
Owner

sezanzeb commented Nov 21, 2023

I do have the following startup application on Ubuntu:
bash -c "input-remapper-control --command stop-all && input-remapper-control --command autoload"

yeah, this is included by default: https://github.com/sezanzeb/input-remapper/blob/main/data/input-remapper-autoload.desktop

ran "sudo pkill -f input-remapper-service && sudo input-remapper-service -d" again
same as before: both devices listed, neither mapping autoloads, both work after manually clicking "Apply" for each

The daemon won't attempt to autoload. It will only do so when input-remapper-control communicates with it, because the daemon runs as root and therefore doesn't know for which user to autoload. So this is fine

after a reboot the "uniq" branch is auto loading for both of my Logitech MX Ergo mice without me doing a custom call to input-remapper-control

It still won't autoload when you disconnect and reconnect one of your mice, right? I honestly don't remember the details well, but I'm assuming input-remapper-control --command autoload tells the daemon to go through its own complete list of device keys, which includes Logitech MX Ergo 2, and therefore autoloads for it. So therefore, if both mice are already connected when you log in, it will autoload the preset for both of them.

@KWWPiDev
Copy link

It still won't autoload when you disconnect and reconnect one of your mice, right?

So one of the things I like about these Logitech MX Ergo mice (besides the ergonomics, highly recommended) is that there is a dongle that seems to keep the device info and I have one dongle in one computer, and another dongle in another, and the button on the mice let's me switch between. So I think that there's no "disconnecting" since the dongle is reporting the devices not the devices themselves.

So far every reboot since both Logitech MX Ergo mice have their mappings auto-loading regardless of if they were connected to this computer's dongle at boot (which is exactly what I want).

I haven't tested manually unplugging the dongle and rebooting to see if the autoload still works, I can do that if you'd like.

I honestly don't remember the details well, but I'm assuming input-remapper-control --command autoload tells the daemon to go through its own complete list of device keys, which includes Logitech MX Ergo 2, and therefore autoloads for it. So therefore, if both mice are already connected when you log in, it will autoload the preset for both of them.

Again, I think this is becasue the dongle is always present and reporting the devices even if not plugged in.

Let me know if there are specific things you'd like me to test with these or other devices (I have a few other ones I use with input-remapper, too, but they don't have duplicate devices so they always just work on both the master and the uniq branches)

Thanks again for all your time and effort here!!! So very much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants