ValveSoftware / steam-for-linux

Issue tracking for the Steam for Linux beta client
4.23k stars 174 forks source link

Duplicated joystick events when using a DualSense with Steam Input and the Playstation configurator enabled #8042

Open Steffo99 opened 3 years ago

Steffo99 commented 3 years ago

Your system information

The issue in brief:

While using Steam Input with a DualSense, an emulated controller is created, but the original one is never disabled, causing some games to receive controller events twice from two different devices.

Please describe your issue in as much detail as possible:

Today I connected a DualSense controller and tried to play Hollow Knight using Steam Input, but I immediately noticed something was wrong: the game interpreted a â–¡ button press sometimes as a X press and sometimes as a Y press!

After some troubleshooting using sdl2-jstest, I found out that the game accepts input from all devices connected to the system, and that the DualSense sends two events with every button press: once through the original evdev device (/dev/input/device28) and once through Steam Input.

I tested more games, and found that the same problem appeared elsewhere, such as in Assault Android Cactus+, where two players are added to the game when start is pressed only once.

I then tested with different controllers: everything worked fine with:

I later asked a friend with a DualSense, Arch Linux and Hollow Knight to check if the same thing was happening to him and he encountered the same problem as me.

Steps for reproducing this issue:

  1. Connect a DualSense
  2. Enable the Playstation Configurator Support
  3. Try playing a game such as Hollow Knight

A temporary solution:

Scrolling through the Gamepad page on ArchWiki, which suggested using xboxdrv to obtain the same result as Steam Input, I read an interesting line:

Some apps, for example, Steam inside Geforce NOW inside web browser, may be confused with original joystick events, which shadow the newly created event source. Simply deletion of /dev/input/js0 works this around.

This gave me an idea: what would happen if I deleted the /dev/input/event* files of my DualSense?

# rm /dev/input/event28 /dev/input/event29 /dev/input/event30

Since Steam uses hidraw, the Steam Input controller kept working, while the evdev joystick was correctly disabled!

Wanting to find a cleaner solution, I found python-evdev, and was able to prevent the problem from happening by grab bing the problematic evdev devices:

import evdev
ev28 = evdev.device.InputDevice("/dev/input/event28")
ev28.grab()
ev29 = evdev.device.InputDevice("/dev/input/event29")
ev29.grab()
ev30 = evdev.device.InputDevice("/dev/input/event30")
ev30.grab()
slouken commented 3 years ago

How is the DualSense controller connected? USB or Bluetooth? It seems odd that you'd get 3 /dev/input devices for a single controller being connected.

Steffo99 commented 3 years ago

This happens both via USB and Bluetooth. Actually, I get 5 /dev/input devices by connecting the DualSense (they get listed in by-id only if I connect it via USB, though):

lrwxrwxrwx 1 root root  10  8 set 10.36 usb-Sony_Interactive_Entertainment_Wireless_Controller-event-if03 -> ../event29
lrwxrwxrwx 1 root root  10  8 set 10.36 usb-Sony_Interactive_Entertainment_Wireless_Controller-if03-event-joystick -> ../event28
lrwxrwxrwx 1 root root  10  8 set 10.36 usb-Sony_Interactive_Entertainment_Wireless_Controller-if03-event-mouse -> ../event30
lrwxrwxrwx 1 root root   6  8 set 10.36 usb-Sony_Interactive_Entertainment_Wireless_Controller-if03-joystick -> ../js0
lrwxrwxrwx 1 root root   9  8 set 10.36 usb-Sony_Interactive_Entertainment_Wireless_Controller-if03-mouse -> ../mouse2

I'm not sure, but I think that the event28, event29 and event30 devices correspond:

slouken commented 3 years ago

Interesting. I only get the joystick entries here. What kernel version are you running?

Steffo99 commented 3 years ago

I'm currently on 5.13.13-arch1-1.

slouken commented 3 years ago

Okay, I upgraded to 5.14.2, and I'm seeing the additional device entries and am seeing the same problem.

Thanks!

Steffo99 commented 3 years ago

I upgraded to 5.14.3-arch1-1, and the gamepad behaviour seems to have changed again.

Now it seems to... interpret each button differently? In Hollow Knight everything gets read as a "Back" button press, while Crawl seems to have the shuffled button mappings that Hollow Knight used to have.

The mouse-touchpad doesn't work anymore, and bluetooth connections are closed by the controller after a few seconds.

Interestingly enough, the controller works perfectly while wired and with Steam in Big Picture, having trouble only when a game is started...

slouken commented 3 years ago

Can you retry this in the current beta (dated Sep 23 or newer?)

Steffo99 commented 3 years ago

The first problem with Hollow Knight seems to be still happening, while Assault Android Cactus works correctly! :rocket:

Please tell me if there's any debug information I can provide to help diagnose the first bug :)

Steffo99 commented 3 years ago

I just tested with the Windows version of Hollow Knight (via Proton Experimental) and the controller works fine.

I'm starting to think that the first one is a bug with the Linux build of the game and not Steam Input...

(It wouldn't be the first: the Linux build also has broken cloud saves, no VSync or frame limit, and broken controller remapping...)

Steffo99 commented 3 years ago

Should I close this?

slouken commented 3 years ago

Yes, go ahead and close this. Thanks!

ammgws commented 2 years ago

@Steffo99 Has this regressed for you? I'm experiencing the same issue with a Bluetooth-connected DualSense, but with a different game (Lego Jurassic World).

The only thing I haven't checked yet is whether deleting/grabbing the specific /dev/input/event/* files for the controller fixes the issue, since I don't see any entries for the controller in the output of ls /dev/input/by-id/ or ls /dev/input/by-path/.

EDIT: Hmm, the controller shows up in /proc/bus/input/devices but deleting the corresponding entries in /dev/input/ didn't solve the issue, so I wonder if it's a different issue...

>cat /proc/bus/input/devices  | grep -P '^[NH]: ' | paste - - 
...
N: Name="Wireless Controller"   H: Handlers=event29 js2 
N: Name="Wireless Controller Motion Sensors"    H: Handlers=event30 js3 
N: Name="Wireless Controller Touchpad"  H: Handlers=event31 mouse2
Steffo99 commented 2 years ago

I can confirm that the problem seems to be back, but I haven't checked if the cause was the same or not.

I am reopening this issue so that the problem may hopefully be fixed.

Komoszek commented 2 years ago

I also can confirm that this issue is present on Manjaro 21.2.1 (kernel 5.15.12) with Steam Client ver. 1639697812. I experience issues in some unity games (namely Monster Prom and Monster Prom 2: Monster Camp) that access those original devices via UnityEngine.Input.GetJoystickNames(), which leads to incorrect behavior(incorrect controller to player assignment) or even crashes. Removing /dev/input/event* files fixes those issues but it's pretty ugly(using python-evdev to grab devices doesn't work).

Steffo99 commented 2 years ago

If it is helpful, I'm currently on the kernel 5.15.12-arch1-1.

Komoszek commented 2 years ago

After further testing I've found that on newer kernels (e.g. 5.15) hid-playstation module is automatically loaded when you connect DualSense controller. Blacklisting this module helps with some issues like duplicated touchpad movements in desktop, but it doesn't fix issues in Unity where DualSense gets listed twice when using UnityEngine.Input.GetJoystickNames() (which I think is more of a Steam and not Unity issue?).

hgaiser commented 2 years ago

I believe I'm having the same issue. In Rocket League for example, if I press the "Options" key on the PS4 controller it adds a second player. Interestingly if I go to the options, you see options for both players and the primary player has xbox button icons, the newly added player has playstation icons:

image

They both act simultaneously on the same press (for example pressing R1 moves both settings screens to the next tab).

I'm seeing similar issues in other games. Red Dead Redemption 2 shows xbox button icons but when I press something on the controller it switches to playstation icons, when I release, it switches back to xbox button icons.

Lovers in a Dangerous Spacetime shows two controllers as well.

My point is that it is not related to the game I chose, but how Steam / Linux handles input from this controller. My guess is that these games see both the original PS4 input device, as well as the simulated controller from Steam. I suppose steam is supposed to hide the original PS4 input device, but it doesn't seem to work? I'm fairly sure I had the exact same configuration earlier, which seemed to work. No clue what has changed.

I haven't really found a solution to this yet. I tried disabling the hid_sony kernel module, but then Steam is not aware of any controller connected. I tried disabling PlayStation Configuration Support in Steam which works quite well for most games (interestingly the icons are then still xbox icons; since it is passing the raw playstation controller as input I was expecting it would show playstation icons). However some games (Flat Heroes) seem to have completely wrong keybindings (R2 seems to be left / right for example). In addition I like the configuration I get within Steam, so I prefer to enable Playstation Configuration Support if possible.

My system: Arch Linux kernel: 5.16.4-arch1-1 (also tried LTS 5.15-18-1 and LTS 5.10.95-1). Steam (runtime) package versions: 1642451672 (also tried Steam Beta). PS4 DualSense4 controller over bluetooth (also tried USB).

Controller settings in Steam: image

(note: no double controllers are listed there)

JacobBrownAustin commented 11 months ago

Hi. I was told that your issue might be the same as mine. Please try this workaround. Edit the game properties for games having problems causes by steam input and add this environment variable.

'SDL_GAMECONTROLLER_IGNORE_DEVICES="0x054c/0x0268,0x2dc8/0x3106" %command%

The device ids can easily be found from lsusb. I don't know what it is for non-usb controllers.

Steffo99 commented 11 months ago

Will try soon, both without and with the workaround!

(I kinda have been wanting to get back to completing Hollow Knight...)

Steffo99 commented 11 months ago

Does not work without the workaround, but does work with the fix!

I wonder what the device id for Bluetooth devices is...

JacobBrownAustin commented 11 months ago

It's interesting to me that your tried multiple controllers and only see this with Dualsense. I've been using 2 Sixaxis controllers for many years and never ran into problems until I got an 8bitdo Ultimate and immediately had this problem. Once I found this sdl env variable workaround for it, my Sixaxis had the same problem even though I've never seen it before, so if I want to play multiplayer and my 8bitdo is plugged in, then I have to add both devices to the sdl env variable to ignore. I'm pretty sure that the big is inside steam somewhere in the steam input.