microsoft / wslg

Enabling the Windows Subsystem for Linux to include support for Wayland and X server related scenarios
MIT License
10.07k stars 304 forks source link

0x00010407 German (IBM) Keyboard Mapping #517

Open rhemberger opened 2 years ago

rhemberger commented 2 years ago

Hello, I'm testing WSLg (Windows Subsystem for Linux GUI), https://github.com/microsoft/wslg, https://docs.microsoft.com/en-us/windows/wsl/store-release-notes. The Windows 0x00010407 German (IBM) Keyboard Layout maps to model=pc102 layout=de variant=qwerty options=(null) on the linux side. But this is still a qwertz layout, and as I understand freeRDP should not map this to https://github.com/FreeRDP/FreeRDP/blob/master/libfreerdp/locale/xkb_layout_ids.c#L352 KBD_GERMAN_IBM, instead handle this equal to 0x00000407 German / KBD_German.

Environment

Windows build number: Microsoft Windows [Version 10.0.22000.258]
Your Distribution version:Release:  20.04
Your WSLg version: 1.0.26

Steps to reproduce

WSL logs:

https://github.com/FreeRDP/FreeRDP/issues/7369

spronovo commented 2 years ago

Thanks @rhemberger,

It looks like the issue is in the Weston RDP backend which doesn't set the correct variant type for this keyboard layout. See https://github.com/microsoft/weston-mirror/commit/27b36f14bab2c8e6deb21e3a4307de60c90157e1 . We will merge this one once we are done with some refactoring preparing the code for upstream.

rhemberger commented 2 years ago

I always had trouble understanding xkb rules, but I believe there is no qwertz variant.

grep de: /usr/share/X11/xkb/rules/base.lst
  deadacute       de: German (dead acute)
  deadgraveacute  de: German (dead grave acute)
  nodeadkeys      de: German (no dead keys)
  T3              de: German (T3)
  ro              de: Romanian (Germany)
  ro_nodeadkeys   de: Romanian (Germany, no dead keys)
  dvorak          de: German (Dvorak)
  sundeadkeys     de: German (with Sun dead keys)
  neo             de: German (Neo 2)
  mac             de: German (Macintosh)
  mac_nodeadkeys  de: German (Macintosh, no dead keys)
  dsb             de: Lower Sorbian
  dsb_qwertz      de: Lower Sorbian (QWERTZ)
  qwerty          de: German (QWERTY)
  tr              de: Turkish (Germany)
  ru              de: Russian (Germany, phonetic)
  deadtilde       de: German (dead tilde)

Maybe {KBD_GERMAN_IBM, "de", 0} would be correct. The difference between this 0x10407 layout and the standard variant 0x407 is that with the Caps Lock key turned on, the top row still gives the numbers instead of the special characters.

spronovo commented 2 years ago

Thanks for pointing that out, i'll research this more.

rhemberger commented 2 years ago

@spronovo I just compared https://docs.microsoft.com/en-us/globalization/keyboards/kbdgr1 and https://docs.microsoft.com/en-us/globalization/keyboards/kbdgr. The latter is wrong, caps lock acts as shift lock with 0x0407

0x00010407 German (IBM) with Caps Lock: 1234567890ß
0x00000407 German with Caps Lock:       !"§$%&/()=?

Maybe you can pass this internally to the appropriate department?

rhemberger commented 2 years ago

Nevermind, I raised #https://github.com/MicrosoftDocs/globalization/issues/174

hideyukn88 commented 2 years ago

@rhemberger, thanks for reporting the issue. As you can reference /usr/share/X11/xkb/symbols/de. It looks the "basic" layout, or as you pointed out simply no variant "", seems the closest match with Windows's layout. Often xkb doesn't have exact match with Windows, thus closest possible is selected in current WSLg (and weston). You can workaround this by doing "setxkbmap de" and all X11 app (but not wayland app) should use qwertz layout. Please try out and let us know, thanks!

spronovo commented 2 years ago

Thanks @rhemberger, a few additional questions if you don't mind.

Would you mind taking a picture of your keyboard for our reference? :-). We'll also pass along the information you noted to our localization team.

Are all of the key mapping correct on Native Windows? Which exact language/keyboard settings are you using on the Windows side?

Do you happen to have any native Linux system or VM where the keyboard works great for you where you could generate an xkb file for us? (xkbcomp $DISPLAY should produce a file like server-0.xkb)

As Hideyuki mention, the next closest would be pure de with no variant... but that would effectively map to 407 and that looks wrong as well per your above comment, so not entirely sure of the right xkb dark magic to make things right.

rhemberger commented 2 years ago

https://github.com/microsoft/wslg/issues/517#issuecomment-952404595 @hideyukn88 Yes, setxkbmap de works for X11. But I prefer tilix over xterm ;). The quickest workaround is image as weston dynamically adjusts the layout.

The difference between 0x00000407 and 0x00010407 is on the same level as XKB de and de nodeadkeys and I can live well with the subtle differences, but when z and y are swapped is really disturbing.

partial alphanumeric_keys
xkb_symbols "qwerty" {

    // This layout should work exactly as a de with the exception 
    // of 'Z' and 'Y' keys, which are in the qwerty style (ie. swapped).
    // 2008 by Matej Košík <kosik@fiit.stuba.sk>

    include "de(basic)"

    name[Group1] = "German (QWERTY)";

    key <AB01>  { [         z,          Z,     leftarrow,         yen ] };
    key <AD06>  { [         y,          Y, guillemotleft,        less ] };
};
rhemberger commented 2 years ago

https://github.com/microsoft/wslg/issues/517#issuecomment-952538210 Es nervt mich langsam, dass MS seine eigenen i18n Tastaturlayouts nicht kennt. @spronovo As I have already tried to explain, there is only one physical German keyboard layout. I use standard german desktop keyboards. image The difference between 0x00000407 and 0x00010407 is virtual, as if you switch between de(basic), de(deadgraveacute) or de(nodeadkeys) on your linux box. If you chose 0x00000407, CAPS acts as Shift Lock: all the keys are shifted, If you chose 0x00010407, CAPS acts as Caps Lock: all letters are shifted to capital letters, all number keys and special characters remain unshifted. Putting this behavior into a new XKB Layout is not worth the effort in my opinion. AND above all Linux also handles CAPS as Case-lock, not as shift-lock. This works perfectly with WSLg. de(basic) would be as good a match as it gets for 0x00010407. But with de(qwerty) z and y are swapped and that is really disturbing.

from /usr/share/X11/xkb/symbols/de

partial alphanumeric_keys
xkb_symbols "qwerty" {

    // This layout should work exactly as a de with the exception 
    // of 'Z' and 'Y' keys, which are in the qwerty style (ie. swapped).
    // 2008 by Matej Košík <kosik@fiit.stuba.sk>

    include "de(basic)"

    name[Group1] = "German (QWERTY)";

    key <AB01>  { [         z,          Z,     leftarrow,         yen ] };
    key <AD06>  { [         y,          Y, guillemotleft,        less ] };
};

And as I mentioned in MicrosoftDocs/globalization#174 the guy behind http://kbdlayout.info/ seems to have really deep knowledge of MS I18n Keyboard Layouts. You can play with the different shift states: http://kbdlayout.info/kbdgr/shiftstates+virtualkeys/base http://kbdlayout.info/kbdgr/shiftstates+virtualkeys/VK_SHIFT http://kbdlayout.info/kbdgr/shiftstates+virtualkeys/VK_CAPITAL vs, http://kbdlayout.info/kbdgr1/shiftstates+virtualkeys/base http://kbdlayout.info/kbdgr1/shiftstates+virtualkeys/VK_SHIFT http://kbdlayout.info/kbdgr1/shiftstates+virtualkeys/VK_CAPITAL

rhemberger commented 2 years ago

https://de.wikipedia.org/wiki/Tastaturbelegung#Umschalttasten ⇪ (Schweiz: Caps Lock) Feststell/Shift-Lock/Capslock: hat meist eine Kontroll-Leuchtdiode rechts oben und fixiert entweder die Tastatur-Zweitbelegung oder nur Groß-/Kleinschreibung. Kurioserweise ist diese Taste beim deutschen Windows standardmäßig stets eine Umschalt-Feststelltaste, während sie auf allen anderen Systemen (Apple, Unix, Atari, Linux) stets eine Groß-/Kleinschrift-Umschalttaste war und ist.

⇪ (Swiss: Caps Lock) Capslock: usually has a light-emitting diode in the upper right corner and locks either the second keyboard layout or only upper/lower case. Curiously, on German Windows this key is always a shift-lock key by default, while on all other systems (Apple, Unix, Atari, Linux) it was and is always a case-switch key.

rhemberger commented 2 years ago

@spronovo Please compare https://en.wikipedia.org/wiki/German_keyboard_layout#Caps_lock https://en.wikipedia.org/wiki/ISO/IEC_9995#Function_keys https://en.wikipedia.org/wiki/Caps_Lock#Behaviour In most cases, the status of the Caps Lock key only changes the meaning of the alphabet keys, not that of any other key. Microsoft Windows enforces this behavior only when a keyboard layout for a Latin-based script is active, e.g. the "English (United States)" layout but not the "Persian" layout. However, on certain non-QWERTY keyboard layouts, such as the French AZERTY and the German QWERTZ, Caps Lock still behaves like a traditional Shift lock, i.e., the keyboard behaves as if the Shift key is held down, causing the keyboard to input the alternative values of the keys; example the "5" key generates a "%" when Caps Lock is pressed. This is not true for the layout "German (IBM)". or https://de.wikipedia.org/wiki/Tastaturbelegung#Umschalttasten Kurioserweise ist diese Taste beim deutschen Windows standardmäßig stets eine Umschalt-Feststelltaste, während sie auf allen anderen Systemen (Apple, Unix, Atari, Linux) stets eine Groß-/Kleinschrift-Umschalttaste war und ist. "Curiously, on German Windows this key is always a shift-lock key by default, while on all other systems (Apple, Unix, Atari, Linux) it was and is always a case-switch key."

https://de.wikipedia.org/wiki/Feststelltaste: Auf deutschen Computertastaturen fungiert die Taste in der Regel als Umschaltsperre, auf schweizerischen oder amerikanischen Tastaturen als Feststelltaste. Windows folgt dieser Konvention und ändert die Funktion der Taste entsprechend der aktiven Tastaturbelegung. Allerdings kann in den Spracheinstellungen eine Tastaturbelegung „Deutsch (IBM)-Tastatur“ (früher auch „Deutsch (EDV)“ genannt) gewählt werden. Bei dieser Einstellung bewirkt die Taste, dass die Buchstaben großgeschrieben werden, aber z. B. die Zahlen weiterhin normal erreichbar sind. Unter macOS fungiert die Taste standardmäßig als Feststelltaste. "On German computer keyboards the key usually functions as a shift lock, on Swiss or American keyboards as a Caps Lock key. Windows follows this convention and changes the function of the key according to the active keyboard layout. However, a keyboard layout "German (IBM) keyboard" (formerly also called "German ( EDV)") can be selected in the language settings. With this setting, the key causes the letters to be capitalized, but the numbers, for example, can still be reached normally. Under macOS, the key acts as a Caps Lock key by default."

Translated with www.DeepL.com/Translator (free version)

Strangely enough the German Wikipedia ignores the German DIN norm and calls the German Standard curious.