unknownskl / greenlight

Greenlight is an open-source client for xCloud and Xbox home streaming made in Typescript.
MIT License
2.05k stars 117 forks source link

[Steam Deck] Using an external controller results in duplicate inputs #482

Open JosephMichels opened 1 year ago

JosephMichels commented 1 year ago

Using 2.0.0, but I also checked 1.2.0 and it happens there as well. If I connect an Xbox controller via bluetooth and then try to Remote play, the inputs from both the Xbox controller and from the steam deck controller get duplicated.

-Happens from GameMode and if I launch it from Desktop mode -Happens on the Deck itself and when using an external display

The only work around that I have found, is to go to desktop mode and manually close steam (I believe this kills steam input, and therefore the built in steam deck controller will no longer be detected). The external controller works fine in this case without any double inputs.

It guessing there is some issue relating to Steam Input. Have you seen this issue or know of any configuration that I can setup to potentially fix it.

JosephMichels commented 1 year ago

Actually after reviewing the code, it seems like maybe the issue is that when multiple controllers are connected, it is sending the input state for all of them as controller 0.

xbox-xcloud-player/blob/main/src/Driver/Gamepad.ts

    requestState() {
        const gamepads = navigator.getGamepads()
        for(let gamepad = 0; gamepad < gamepads.length; gamepad++){
            const gamepadState = gamepads[gamepad]

            if(gamepadState !== null){
                const state = this.mapStateLabels(gamepadState.buttons, gamepadState.axes)
                state.GamepadIndex = 0 // @TODO: Could we use a second gamepad this way?

                this._application?.getChannelProcessor('input').queueGamepadState(state)
            }
        }
    }

There it loops through all controllers and grabs all of the states and adds them to the queue. That is consistent with what I'm seeing where when I barely press a direction on the dpad, it acts as if it's been pressed many times, as the steam is sending 1,0,1,0,1,0,1,0 because one of the controllers is unused.

I guess the ideal fix would be an ability to specify which controller is active, or perhaps it could be automatically detected, but to never send input from multiple controllers in the same slice.

JosephMichels commented 1 year ago

I have created a Pull Request on xbox-xcloud-player with a fix. I submitted it against the release/0.2.0 branch, which may not have been the correct things to do. If you want me to make any changes or request it against a different branch, let me know.

I've tested on Windows with multiple controllers and it fixed the issue, but I don't have an easy way to building the appimage, so I haven't tested on the Steam Deck itself.

The fix basically just marks the first controller that registers a button press as the active controller and only sends input from that controller. If the active controller gets disconnected, it will go back to the state of looking for another controller.

macmus82 commented 1 year ago

I noticed same issue .. on multiple controllers.. The funny thing is that on SN30 pro that is not happening I dunno why.

Is there going to be an update for the app with the fix for steam deck ?

JosephMichels commented 1 year ago

The changes have been merged, but there hasn't been another official build since then.

If you are just looking for the SteamDeck app image, I uploaded an appimage on my fork. I've been using it on my SD and it has fixed the issue for me.

Gamepad Hotfix Build

macmus82 commented 1 year ago

Thanks. Unknowsking wrote he is going to release some build over the weekend. I hope it will have your fix.

unknownskl commented 1 year ago

Thank you very much for the contribution. Code has been merged and released in v2.0.0-beta2. Can you verify that the issue has been solved on your end?