ValveSoftware / gamescope

SteamOS session compositing window manager
Other
2.97k stars 197 forks source link

Import keyboard layout from parent session in nested mode #203

Open magicalraccoon opened 3 years ago

magicalraccoon commented 3 years ago

I'm normally a dvorak user, but when I use Gamescope the layout remains qwerty.

The keyboard mapping and layout should be imported from the current de/wm to create a seamless experience. Is this something the project could handle or will I need to get used to gaming with qwerty?

I'm currently using Fedora 33 with Gnome, if that helps.

emersion commented 3 years ago

This is definitely something gamescope should do. We need to set the correct layout on the wlr_keyboard.

emersion commented 3 years ago

Workaround: export XKB_DEFAULT_LAYOUT=<layout> before starting gamescope (see man xkeyboard-config for a list of layout names).

IDeathByte commented 3 years ago

not sure about create new issue, then i post here

as i understand, by default gamescope doesn't import layout from main session this take us problem with layout switch (en\ru) it didn't changes by switch-key (capslock on my Manjaro KDE config, wayland session if it important)

itspngu commented 2 years ago

Workaround: export XKB_DEFAULT_LAYOUT=<layout> before starting gamescope (see man xkeyboard-config for a list of layout names).

I can confirm that this works for gamescope itself, but when using it to run Steam's "Big Picture" mode the latter crashes, which might be a common source of confusion given gamescope's heritage. I can not type "@" in the Big Picture login mask (on German keyboards "@" is produced by holding AltGr and pressing Q) regardless of wether gamescope is running or not.

https://github.com/ValveSoftware/steam-for-linux/issues/5188

Figuera commented 2 years ago

I had some success by using XKB_DEFAULT_LAYOUT but that is not enough I also need to set the Layout Variant and setting XKB_DEFAULT_VARIANT do not seems to help.

It might be my bias, but it seems to me that the compositor would benefit greatly from a configuration file. These are stuff that should be easily managed there. I would also like to be able to customize the key bindings. Alt+F4 is fine but I use something else in my Desktop Environment and would be nice to be able to change it somewhere.

class101 commented 1 year ago

I just broke the boot of my Steam Deck :(

Tested the following lines in /etc/environment

XKBLAYOUT=fr
XKBVARIANT=fr
XKB_DEFAULT_LAYOUT=fr
XKB_DEFAULT_VARIANT=fr

Luckily I have been able to boot from an old save, edit revert, and it boots again

I was initially trying to find a solution on why the "fr" layout I set in Desktop mode is not preserved in gaming mode

But is respected in gaming mode IN a open KDE session

I can get my MX Key Mini bluetooth keyboard fr in desktop , fr in gaming mode, it is alwyas us in gaming mode :(

I'd expected to fix it with the variables, but its crashes at boot

class101 commented 1 year ago

Ok my mistake was to setup

XKB_DEFAULT_LAYOUT=fr
XKB_DEFAULT_VARIANT=fr

instead of

XKB_DEFAULT_LAYOUT=fr
XKB_DEFAULT_VARIANT=azerty

This resulted in the following gamescope crash

wlserver: Running compositor on wayland display gamescope-0
wlserver: [backend/headless/backend.c:18] Starting headless backend
xkbcommon: ERROR: Couldnt process include statement for fr(fr)
xkbcommon: ERROR: Abandoning symbols file (unnamed)
xkbcommon: ERROR: Failed to compile xkb_symbols
xkbcommon: ERROR: Failed to compile keymap
Segmentation fault (core dumped)

I have the feeling nobody in here is concerned about the fact, that, defining an environment variable could result in a gamescope crash and so on, a Steam Deck failure to boot, it sounds critical to fix.

emersion commented 1 year ago

Exiting with an error would be the expected behavior.

class101 commented 1 year ago

There is no possibility to default to US and log a warning ?

Glog78 commented 1 year ago

I tried on ADOM: XKB_DEFAULT_LAYOUT=de XKBLAYOUT=de gamescope -Y -e -W 1824 -H 1026 -r 60 -w 1920 -h 1080 -- %command%

still the keyboard is qwerty instead of qwertz ...

class101 commented 1 year ago

I tried on ADOM:

XKB_DEFAULT_LAYOUT=de XKBLAYOUT=de gamescope -Y -e -W 1824 -H 1026 -r 60 -w 1920 -h 1080 -- %command%

still the keyboard is qwerty instead of qwertz ...

I think you forgot to set XKB_DEFAULT_VARIANT=dsb_qwertz see here for more details https://github.com/ValveSoftware/SteamOS/issues/798

Glog78 commented 1 year ago

I tried on ADOM: XKB_DEFAULT_LAYOUT=de XKBLAYOUT=de gamescope -Y -e -W 1824 -H 1026 -r 60 -w 1920 -h 1080 -- %command% still the keyboard is qwerty instead of qwertz ...

I think you forgot to set XKB_DEFAULT_VARIANT=dsb_qwertz see here for more details ValveSoftware/SteamOS#798

Even my solution worked once i switched the steam language to german too ...

VladislavNekto commented 1 year ago

But, hey, what if i type in something like Cyrillic, that means, i need possibility to change layout, not just set russian when start

IDdozer commented 1 year ago

But, hey, what if i type in something like Cyrillic, that means, i need possibility to change layout, not just set russian when start

My launch parameters: XKB_DEFAULT_LAYOUT=ru,us XKB_DEFAULT_OPTIONS=grp:lctrl_lshift_toggle gamemoderun gamescope -e -f -H 1080 -O card0-DVI-D-1 -- %command%

left ctrl + left shift switches language

VoodaGod commented 1 year ago

I tried on ADOM: XKB_DEFAULT_LAYOUT=de XKBLAYOUT=de gamescope -Y -e -W 1824 -H 1026 -r 60 -w 1920 -h 1080 -- %command% still the keyboard is qwerty instead of qwertz ...

I think you forgot to set XKB_DEFAULT_VARIANT=dsb_qwertz see here for more details ValveSoftware/SteamOS#798

Even my solution worked once i switched the steam language to german too ...

have you had any luck without changing the steam language? i've set up

XKB_DEFAULT_LAYOUT=de
# initially without a variant, also tested with
XKB_DEFAULT_VARIANT=deadgraveacute

in /etc/environment but gamescope still is using qwerty for me :(

Glog78 commented 1 year ago

I tried on ADOM: XKB_DEFAULT_LAYOUT=de XKBLAYOUT=de gamescope -Y -e -W 1824 -H 1026 -r 60 -w 1920 -h 1080 -- %command% still the keyboard is qwerty instead of qwertz ...

I think you forgot to set XKB_DEFAULT_VARIANT=dsb_qwertz see here for more details ValveSoftware/SteamOS#798

Even my solution worked once i switched the steam language to german too ...

have you had any luck without changing the steam language? i've set up

XKB_DEFAULT_LAYOUT=de
# initially without a variant, also tested with
XKB_DEFAULT_VARIANT=deadgraveacute

in /etc/environment but gamescope still is using qwerty for me :(

i didn't needed to switch back. i don't mind my client to be in german too but yeah it's only half of a solution

pvdrz commented 1 year ago

:wave: I have a related issue with the latam keyboard layout. What happens is that gamescope doesn't recognize the < key at all. This key is called <LSGT> and it is assigned the 94 code. All the other keys and mappings of the layout work correctly when setting XKB_DEFAULT_LAYOUT=latam but for some odd reason this single key doesn't work. I tried setting XKB_DEFAULT_MODEL to both pc104 and pc105 without success either.

Has anyone experienced something similar or has any idea on how to debug this?

okfruit commented 1 year ago

What happens is that gamescope doesn't recognize the < key at all

Same here

Chris2000SP commented 1 year ago

I had that issue with a Steam Linux native game "X4 Foundations" using gamescope under wayland. That workaround with "XKB_DEFAULT_LAYOUT=de" in the Steam Launch option for X4 did work. Thanks for that. I dunno if that matters on Proton games too?

murlakatamenka commented 1 year ago

@Chris2000SP so you say if you launch Steam with XKB_DEFAULT_LAYOUT set, gamescope does properly inherit it and works as it should keyboard shortcuts wise, am I correct?

Chris2000SP commented 1 year ago

If i do not set this, use wayland and gamescope, i get "EN" querty layout in game. Here is what i set in X4 Foundations Launch Options: AMD_VULKAN_ICD=RADV XKB_DEFAULT_LAYOUT=de /usr/bin/gamescope -f -W 3840 -H 2160 -- /usr/bin/mangohud %command% With "XKB_DEFAULT_LAYOUT=de" fixes the wrong keyboard layout. I have Arch Linux and KDE by the way.

EDIT: If i login to Xorg i do not have that problem but i can do without gamescope in Xorg.

brndd commented 10 months ago

👋 I have a related issue with the latam keyboard layout. What happens is that gamescope doesn't recognize the < key at all. This key is called <LSGT> and it is assigned the 94 code. All the other keys and mappings of the layout work correctly when setting XKB_DEFAULT_LAYOUT=latam but for some odd reason this single key doesn't work. I tried setting XKB_DEFAULT_MODEL to both pc104 and pc105 without success either.

Has anyone experienced something similar or has any idea on how to debug this?

This problem should be fixed after this commit makes its way downstream to you: https://github.com/ValveSoftware/gamescope/pull/1009

Gpinchon commented 10 months ago

On OpenSUSE adding a export_kb_layout.sh to /etc/profile.d/ with this content fixes the issue

export XKB_DEFAULT_LAYOUT=fr
export XKB_DEFAULT_VARIANT=azerty
bljordan commented 9 months ago

I don't have a solution, but just adding another report of the issue.

I am in hyprland and trying the solutions above to no avail.

I am trying to set the equivalent of kb_options = caps:numlock by setting these env vars: XKB_DEFAULT_OPTIONS=caps:numlock or XKBOPTIONS=caps:numlock.

class101 commented 9 months ago

I don't have a solution, but just adding another report of the issue.

I am in hyprland and trying the solutions above to no avail.

I am trying to set the equivalent of kb_options = caps:numlock by setting these env vars: XKB_DEFAULT_OPTIONS=caps:numlock or XKBOPTIONS=caps:numlock.

Few things to try, use double quotes to prevent : from being interpreted

Else

Try to add in /etc/X11/xorg.conf.d/00-keyboard.conf

setxkbmap -option "caps:numlock"

To note that based on ArchWiki, setxkbmap is not persistent for external keyboards except if you specify the keyboard device Id, so it is possible that you can do it with setkbdmap manually without a xinit like execution

See Using setxkbmap

Gpinchon commented 9 months ago

I am in hyprland and trying the solutions above to no avail.

Yeah, it seems that it doesn't work anymore with the version 3.13.3-1.1, plus it's very buggy, The Sims 3 appears squished now... Looking as to how to restore 3.12.

[EDIT] I was adding XKB_DEFAULT_LAYOUT=fr XKB_DEFAULT_VARIANT=azerty to the launch command of The Sims 3 and it was messing with layout very oddly, typing text used AZERTY, but the keys were mapped as if it was using QWERTY (like, WASD to move the camera instead of ZQSD), removing the launch options to keep only the modified env works...

Martan404 commented 4 months ago

This is a big problem on the Steam Deck. When connecting a keyboard to the in Gamemode it will use US qwerty layout with no way of changing it in Gamemode. Works fine in Desktop mode