ValveSoftware / SteamOS

SteamOS community tracker
1.59k stars 70 forks source link

SteamOS connected keyboard ignores settings #798

Open KS-HTK opened 2 years ago

KS-HTK commented 2 years ago

Your system information

Please describe your issue in as much detail as possible:

I connected a keyboard/mouse combo to usb c (lenovo keyboard with trackpoint). Everything worked as expected. Keyboard can type mouse is useable, scrolling works. But the issue is that the keyboard is in the english layout. My steamdecks on-screen-keyboard (osk) is set to german, desktop mode is set to german-neo2. And in desktop mode the keyboard uses the neo2 layout, as expected. But in gaming mode any layout set in the settings is ignored for the physikal keyboard. This is only mildly annoying for german as ö ä ü ß dont exist on english layouts. But it sure must be frustrting if your primary language uses, for example, the greek alphabet, as those can only be typed with the osk.

Steps for reproducing this issue:

  1. connect a physikal keyboard to the steamdeck
  2. set any layout in the settings
  3. observe the osk changing and the physikal keyboard still using english layout

related issue:


A Workaround has been found:

To set the keyboard layout for gaming mode edit /etc/environment file. Example:

XKB_DEFAULT_MODEL=pc104
XKB_DEFAULT_LAYOUT=de
XKB_DEFAULT_VARIANT=neo
XKB_DEFAULT_OPTIONS=caps:none

It is sufficient to only set layout

For a list of available values use

class101 commented 2 years ago

Same problem Steam Deck with Logitech Mx Keys Mini Bluetooth. In KDE, works, in SteamOS it does not respect keyboard layout.

Issue has been reported in SteamOS in 2017 and your release today a device carrying the same problem.

Valve Time

KS-HTK commented 2 years ago

Same problem Steam Deck with Logitech Mx Keys Mini Bluetooth. In KDE, works, in SteamOS it does not respect keyboard layout.

Issue has been reported in SteamOS in 2017 and your release today a device carrying the same problem.

Valve Time

I could not find the issue from 2017, what issue number is it? It is most likely not the same Issue as the underlying Distribution has changed. In 2017 SteamOS was built on Debian (Buster if I am not mistaken) now it is built on ArchLinux.

class101 commented 2 years ago

If you search SteamOS keyboard layout you will find a number of reports

https://steamcommunity.com/groups/steamuniverse/discussions/1/1496741765143025641/ https://github.com/ValveSoftware/steam-for-linux/issues/5188

The issues are clearly connected imo because the users are reporting the exact same behavior we notice, works in Desktop mode, fail in SteamOS to en_US

and i think it has nothing to do with the distribution but SteamOS (Steam with steamos launcher arguments)

I'm even more disappointed when I see the upcoming SteamOS 3.3 changelog not even mentioning a thing about it

@kisak-valve whats happening with this issue ?

Edit: Yet I found a workaround which is to run the gaming mode from command line, but it is not perfect because it does not closes the KDE session, ideally gaming mode is exclusive full screen, without an opened KDE session and with the correct desktop layout

class101 commented 2 years ago

@KS-HTK

If you need to tinker and possibly find a better workaround you could open Steam Gaming mode Windowed by running

´´´ bash /home/deck/.local/share/Steam/steam.sh -steamdeck -steamos3 -steampal -steamdeck -gamepadui ´´´

I will let you know if I find anything better

KS-HTK commented 2 years ago

Thank for the workaround and linking the original issue. Seems they are somewhat related. More testing is required to figure out why the keyboard is not set correctly, but I have the suspicion that it is only set in the KDE session and not as a system setting. This would result in it only being used when Steam is launched from the session.

class101 commented 2 years ago

Hey

@KS-HTK

Made some advance on the subject.

I think the connected issue is https://github.com/Plagman/gamescope/issues/203

But I advise you, your Steam Deck may fail to boot

IIf you want to give a try, I posted here instructions on how to recover from this boot failure

I think because gamescope initiate the session with teh keyboard to US, ours is too in gaming mode because the gaming mode layout is respected when lanched windowed in a kde session, must be at the level of gamescope running outside a desktop session at the boot, it is the very first process to initiate the gaming mode session

:)

KS-HTK commented 2 years ago

So this is basically what I figured but did not want to test on the Deck itself. Tried to install HoloIso on my tower but have not succeeded yet. Wanted to test there. Did not want to test on the Deck because I did not want to go trough the hassel of reinstalling the OS. So thank you for the tip with the system backups.

I had a similar issue on Arch a while back where the login manager did not use my set keyboard layout. I figured it is only loaded after session starts. (In this case the kde session) So I wanted to try set XKBLAYOUT in /etc/default/keyboard. Or using dpkg-reconfigure if available. Also worth a try would be setxkbmap in .bashrc but i am unsure if this gets loaded in the gaming mode.

KS-HTK commented 2 years ago

OK, so after knowing how to recover without to much hassle I did some testing. Here are some results: localectl shows n/a as keymap, I don't know why. But using localectl set-keymap has no effect on the gaming mode anyway and setting it in desktop is not the issue

/etc/default/keyboard is ignored by gaming mode. Did not test if desktop uses it.

But what does work is /etc/environment @class101 you were setting incorrect key names which resulted in not being able to boot. To set neo2 you can add these two lines to /etc/environment

XKB_DEFAULT_LAYOUT=de
XKB_DEFAULT_VARIANT=neo

This will set the keyboard layout for gaming and desktop mode. Although desktop mode should get set by KDE's settings with a higher priority.

Available values can be found with:

For more info see the ArchWiki


I have not tested the following, but it should work. Also available are XKB_DEFAULT_MODEL and XKB_DEFAULT_OPTIONS

To configure multiple layouts:

XKB_DEFAULT_LAYOUT=de,de,en
XKB_DEFAULT_VARIANT=neo,,us

TL;DR

It is possible to set the Keyboard layout for connected keyboards in /etc/environment

This issue is thereby now semi resolved. It would be great if there is an option in gaming mode setting to set the keyboard layout of a connected keyboard without having to manually set them in /etc/environment as a typo there will likely result in a boot error.

class101 commented 2 years ago

Yes my initial error was

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)

To test the layout/variants without risking to crash gamescope I'm running the following command in a KDE session

XKBLAYOUT=fr XKBVARIANT=azerty XKB_DEFAULT_LAYOUT=fr XKB_DEFAULT_VARIANT=azerty gamescope --generate-drm-mode fixed --xwayland-count 2 -w 1280 -h 800 --default-touch-mode 4 --hide-cursor-delay 3000 --max-scale 2 --fade-out-duration 200 -e -R /run/user/1000/gamescope.G596Hrd/startup.socket -T /run/user/1000/gamescope.G596Hrd/stats.pipe -O *,eDP-1 --cursor-hotspot 5,3 --cursor /usr/share/steamos/steamos-cursor.png

But yeah I think the only place we could inject env variable to gamescope is /etc/environment, it doesn't load a bash in login mode and so on, not reading anything from /etc/bash.bashrc

This is great, it looks like to work now as intended :)

PS :

I set XKBLAYOUT and XKBVARIANT too but in bashrc, it works when you open a new shell Ctrl+Alt+F4|F5|F6

class101 commented 2 years ago

Hey @KS-HTK

Have you searched about enabling wake up on Bluetooth ?

I searched around but unfortunately, enabling wake on Bluetooth on the system has not the expected behavior; the Steam Deck automatically wakes up after a suspend haha :D

I'm digging into this actually and I believe it requires a few udev rules to ignore some events and has you are experienced we can maybe find something together

I know this is requested by a few users but currently no solution is found;, well I will dig into I think because I also need this so I leave here my steam if you want to communicate here and not be off topic in the ticket : class101 :)

octoxan commented 1 year ago

Just wanted to say this fixed it for me as well, this really needs to be documented, or automated.

Fuziius commented 1 year ago

Hey, I have the same problem. However, I do not know at all, with such commands, Linux or anything else. But I would also like to use the German keyboard layout ingame. Can someone possibly explain to me step by step how and where I have to use these commands? Preferably so that it really understands every idiot? haha

eponra commented 1 year ago

PXL_20230830_090549311~3 @Fuziius

Im sorry to say that i think its still bugged.

What every other post here is missing btw, is that you first have to go to desktop mode, and to

and add the layout that you want (in yours and mine its de german).

Else the settings in the environment seem to have no effect.

If you then add these lines in etc/environment, you can reboot your device and as long as you're in desktopmode, you will have the de layout (so QWERTZ instead of QWERTY).

BUT in gaming mode that layout changed for me to "XLCWK"-layout. So, whatever that is, its not useable. I dont need the external keyboard at all, im just testing this for my gf. But as long as that is not fixed, im not touching hers. ;-)

class101 commented 1 year ago

@eponra

By deduction, we knows gamescope reads from /etc/environment so if you don't notice changes, it is wrongly edited ( what is wrong then is the problem )

Ideally , get ride of the environment file in the formula and set the variables before calling gamescope on command line, I showed a few examples in the previous posts if I remember

A mistake in the environment file can make your system unbootable

eponra commented 1 year ago

@class101 i notice changes. :-) The changes i notice is that its not loading a proper layout. Correction: in gamemode(!). Its loading the proper layout when i switch to desktop, and the wrong one again if i go back to gamemode.

Ninjaedit: i saw in your posts that you added XKBLAYOUT=fr XKBVARIANT=azerty

and then

XKB_DEFAULT_LAYOUT=fr XKB_DEFAULT_VARIANT=azerty

but to what seems to be a bash-command?

Maybe i should try these too...

Fuziius commented 1 year ago

@eponra I only changed my layout in the system settings and that was enough to keep my keyboard layout in-game at the german (QWERTZ) one, as long as I stayed in the Desktop-Mode. Only the in-game layout at the Game-Mode keeps switching back to the english (QWERTY) one.

I can´t finde the etc/environment. I searched for it in Dolphin. But I just can´t find it at all.

Where can I find it?

Did u fix ur keyboard layout in Game-Mode?

KS-HTK commented 1 year ago

@Fuziius In the first Post to this issue I documented the workaround that worked for me (using neo2 instead of QWERTZ). If the file does not exist you can simply create it using touch /etc/environment. Please make sure it does not exist. You wrote etc/environment but the Path should be /etc/environment. To make sure the file does not exist you can use ls /etc/ | grep environment if no output is returned go ahead and create the file with the contents you need. See my first post to find valid values for the settings.

cryptogeek13 commented 1 year ago

Valve please, you are selling me a dock but don't support changing the layout of a connected keyboard? This issue is open for so long now and a really basic feature missing for your dock to be usable. I'm getting kinda frustrated by this.

Stoffss commented 1 year ago

Pls, this is quite huge for us non-native english speaking countries.... would be so easy to fix Valve!

Thank you for the work around until... makes life easier for my kids!

Stoffss commented 1 year ago

TL;DR

It is possible to set the Keyboard layout for connected keyboards in /etc/environment

This issue is thereby now semi resolved. It would be great if there is an option in gaming mode setting to set the keyboard layout of a connected keyboard without having to manually set them in /etc/environment as a typo there will likely result in a boot error.

Could someone with knowledge create a Decky Loader plugin for this?

tonivj5 commented 1 year ago

TL;DR

It is possible to set the Keyboard layout for connected keyboards in /etc/environment

This issue is thereby now semi resolved. It would be great if there is an option in gaming mode setting to set the keyboard layout of a connected keyboard without having to manually set them in /etc/environment as a typo there will likely result in a boot error.

Could someone with knowledge create a Decky Loader plugin for this?

@Stoffss like this one? https://github.com/Loidbae/SDH-KLang :wink:

eponra commented 1 year ago

Could someone with knowledge create a Decky Loader plugin for this?

@Stoffss like this one? https://github.com/Loidbae/SDH-KLang 😉

@tonivj5 This has sadly been discontinued a while ago.

RodoMa92 commented 1 year ago

Upping this issue, another one affected by this. Luckily it is easily workaroundable, but still.

alpasy commented 11 months ago

For Russian i used:

XKB_DEFAULT_LAYOUT=us,ru
XKB_DEFAULT_OPTIONS=grp:ctrl_shift_toggle
XkbLayout=us,ru
XkbOptions=grp:ctrl_shift_toggle

Not sure which ones worked, default or not, but switching layouts with Ctrl+Shift works in gaming mode now too. Valve plz

Martan404 commented 7 months ago

We need a fix for this. Valve needs to implement something to check the default Desktop Mode keyboard layout and use it in Game Mode as well or just allow us to change layout directly from Game Mode.

It's a huge problem that we can not use our keyboards in Game Mode properly

Rudokhvist commented 7 months ago

I am affected by this issue too. We need ability to set keyboard shortcut for changing layout from physical keyboard in gaming mode without need to tinker with config files.

AlexFolland commented 6 months ago

Is there a workaround for Dvorak? I have multiple games with all my binds set to Dvorak binds and can't reasonably switch between qwerty and Dvorak binds, as the games in question store bind settings in Steam Cloud.

I'm expecting it would be this in /etc/environment, but that file is owned by root, which means it'll be overwritten with each update:

XKB_DEFAULT_LAYOUT=us
XKB_DEFAULT_VARIANT=dvorak

I tried these environment variables in the Steam game command line, but that didn't have any effect. I also heard that if /etc/environment has any "wrong" values for these variables, the system won't boot, and I don't want to risk that.

Can we please get a dropdown in the keyboard settings for physical keyboard layout so I can choose Dvorak?

Martan404 commented 5 months ago

It's guessing it's related to this issue https://github.com/ValveSoftware/gamescope/issues/203 and the fact that we can not change the keyboard layout inside Gamemode at all.

KS-HTK commented 5 months ago

It's guessing it's related to this issue ValveSoftware/gamescope#203 and the fact that we can not change the keyboard layout inside Gamemode at all.

This was already mentioned as a simple search would have shown. See this Comment above.

AlexFolland commented 5 months ago

Yes, so back to my questions:

See my comment above for additional rationale for asking these questions.

KS-HTK commented 5 months ago

@AlexFolland to answer some of you're Questions:

Yes, so back to my questions:

* Is there a workaround for Dvorak?

Yes, the same workaround I use for Neo2 should also work for Dvorak.

  • Any viable workaround that satisfactorily answers this question must not involve editing a file owned by root (which will be overwritten with each update) or risking boot prevention. Well then you might not find the workaround viable as it may prevent booting, which can be solved via the recovery if it does.
    • Can we please get a dropdown in the keyboard settings for physical keyboard layout so I can choose Dvorak? Thats what this issue is for, but i do not expect anybody from Valve to answer to that Question anytime soon, as this Issue is already 2 Years old.

I do also not agree that a viable workaround should not include any risk of boot prevention, as this is a recoverable problem and we are talking about workarounds, not solutions. For a permanent solution to this issue I do agree that it should not include that risk for the end user, but if you really want to use a different keyboard layout while no permanent solution is in place the minor risk of a temporary boot issue should not be regarded as a no go. Like stated before it can be recoverd without reinstalling the whole system.

AlexFolland commented 5 months ago

Thanks for your response. However, one oversight seems to be that /etc/environment is still owned by root and will therefore be subject to overwriting every time the system updates. Do you have a workaround that you've employed for that?

alpasy commented 5 months ago

Thanks for your response. However, one oversight seems to be that /etc/environment is still owned by root and will therefore be subject to overwriting every time the system updates. Do you have a workaround that you've employed for that?

It doesn't though. I fixed this issue on my deck via /etc/environment in November 2023, and after numerous system updates it stays fixed.

Labestiajake commented 2 months ago

For Spanish i add:

XKB_DEFAULT_MODEL=pc104 XKB_DEFAULT_LAYOUT=es

Reboot Steam Deck and work 100%.

cebe89 commented 3 weeks ago

Hello, thank you, the solutions worked for me, having recently added a bluetooth keyboard. And I can confirm that this issue still remains. I had to add "XKB_DEFAULT_LAYOUT=de" for my quertz keyboard to work also as quertz in gaming mode. I also had to set right alt as the compose key in the choose 3rd level setting in the desktop settings to get buttons like @ work correctly.

To anyone else keep in mind to RESTART your deck to apply the env settings, and not just change back to gaming mode. It made me make a big mistake in adding a nonexistant quertz variant to the file, which caused my deck to crash gamescope whenever I entered a text-field in gaming mode: ValveSoftware/gamescope/issues/1571 Considering I crashed gamescope that way, this issue is more belonging to the gamescope repo than the steamOS one?