anyc / steam-overlay

Gentoo overlay for Valve's Steam client and Steam-based games
GNU General Public License v2.0
200 stars 44 forks source link

games-util/steam-launcher: Fix desktop layout for controllers in wayland #339

Closed Nowa-Ammerlaan closed 1 year ago

Nowa-Ammerlaan commented 1 year ago

Upstream issue https://github.com/ValveSoftware/steam-for-linux/issues/4738

From what I understand Valve points to wayland, and wayland points to valve, in the meantime this has been broken for way too long with no fix in sight.

The problem originates in the lack of the X11 XTEST extension in wayland sessions. Luckily there now is a small library to fix this.

The first commit adds an ebuild for extest, and the second commit ensures that it is LD_PRELOAD'ed in wayland sessions as per extest upstream instructions. A new wayland USE flag is added to automatically pull in extest on systems with this flag enabled.

Signed-off-by: Andrew Ammerlaan andrewammerlaan@gentoo.org

chewi commented 1 year ago

Thanks! I hadn't noticed this issue, but I don't use the desktop layout.

I love Rust, but I bet some users will thank me for the new Rust dependency. :roll_eyes:

I wondered whether extext should go in the main repo, but it looks like it's only really useful for Steam.

Will test and merge later.

Nowa-Ammerlaan commented 1 year ago

I wondered whether extext should go in the main repo, but it looks like it's only really useful for Steam.

I considered this, but I couldn't find any use case for extest besides Steam. And having extest here instead of in ::gentoo makes it easier to remove it again later if/when the underlying problem gets fixed in the Steam client.

That being said, I'm open to adding and maintaining extest in ::gentoo if you prefer to do it that way.

chewi commented 1 year ago

Maybe I'm being dumb, but how do you actually use desktop layout? It's for navigating Steam itself, right? I have a Wii U Pro controller that works fine in Big Picture Mode, but it doesn't do anything in desktop mode, except the Home button switches back to Big Picture Mode. The input test in the settings works fine.

chewi commented 1 year ago

Ah, it only works with the Steam Controller? I thought that worked anyway, but maybe I never tried it under Wayland. I'll dig mine out tomorrow.

Nowa-Ammerlaan commented 1 year ago

Ah, it only works with the Steam Controller? I thought that worked anyway, but maybe I never tried it under Wayland. I'll dig mine out tomorrow.

It was my understanding that desktop mode should be available for all controllers, but I might be wrong.

The setting is available under Settings --> Controller --> Desktop Layout (and Guide Button Chord Layout). This should allow you to use e.g. the A/X button as "enter", L3 to open the on screen keyboard and Guide+Left stick up/down to control the volume.

Without extest I cannot use my Steam Controller to e.g. move the mouse when Steam is open. This works when Steam is closed (then it is detected as regular touchpad), but when steam is open it tries to map all the buttons to these shortcuts which works fine when playing a game and in big picture mode but fails on the wayland desktop without extest.

Note that 'desktop mode' only works when there is no game running and steam is not running in big picture mode. I have not tested any controller other then the Steam controller.

Nowa-Ammerlaan commented 1 year ago

Digging a bit deeper into this, there might be another way to make this work using libei: https://gitlab.freedesktop.org/xorg/xserver/-/commit/a13333427072dfb27792c5c9ff22ed145ede0f0a

This we have disabled now in the xwayland ebuild, I'll try enabling this to see if this also fixes the Steam Controller problem.

chewi commented 1 year ago

Cool, I was already interested in libei for another reason.

Nowa-Ammerlaan commented 1 year ago

Digging a bit deeper into this, there might be another way to make this work using libei: https://gitlab.freedesktop.org/xorg/xserver/-/commit/a13333427072dfb27792c5c9ff22ed145ede0f0a

This we have disabled now in the xwayland ebuild, I'll try enabling this to see if this also fixes the Steam Controller problem.

This is not completely finished, some changes in other packages still have to fall into place and end up in a new release. The status tracker is here: https://gitlab.freedesktop.org/libinput/libei/-/issues/1

I opened a PR with my changes to xwayland and xdg-desktop-portal anyway, this brings us a bit closer: https://github.com/gentoo/gentoo/pull/32946

For now we can use extest to get this working.

Nowa-Ammerlaan commented 1 year ago

I opened a PR with my changes to xwayland and xdg-desktop-portal anyway, this brings us a bit closer: gentoo/gentoo#32946

This is now merged. >=x11-base/xwayland-23.2.1[libei] should now be XTEST capable when using a compositor that also supports libei (currently only >=x11-wm/mutter-45.0). Therefore in Gnome it might work without extest, but I haven't tested this. In Plasma we definitely still need extest.

I've adjusted this PR to || () depend on either extest or xwayland[libei], and the launcher now only LD_PRELOAD's extest if it is installed.

WDYT?

chewi commented 1 year ago

I dug out my Steam controller and tried this under KDE Wayland. It works! With extest at least, as libei won't work there yet.

One request. I'm probably kidding myself if I think Steam works under prefix, but please could you make @@GENTOO_X86_LIBDIR@@ be ${EPREFIX}/usr/$(ABI=x86 get_libdir) as hprefixify doesn't catch this.

chewi commented 1 year ago

Oh and maybe we should put this behind the wayland AND the joystick flags to avoid people moaning about Rust.

Nowa-Ammerlaan commented 1 year ago

One request. I'm probably kidding myself if I think Steam works under prefix, but please could you make @@GENTOO_X86_LIBDIR@@ be ${EPREFIX}/usr/$(ABI=x86 get_libdir) as hprefixify doesn't catch this.

Fixed!

Oh and maybe we should put this behind the wayland AND the joystick flags to avoid people moaning about Rust.

This makes sense, also fixed!

Nowa-Ammerlaan commented 3 months ago

Quick status update: This now works without extest in KDE Plasma 6.1 since libei support was merged. Should work in Gnome too but haven't tested.

Still the extest package might be useful for other wayland desktops.

chewi commented 3 months ago

Nice! I'm on 6.1, but I haven't tried this yet. I'll keep extest a little while longer though.