Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

German Keyboard not mapped correctly #2

Open
f-fritz opened this issue Mar 19, 2022 · 28 comments
Open

German Keyboard not mapped correctly #2

f-fritz opened this issue Mar 19, 2022 · 28 comments

Comments

@f-fritz
Copy link

f-fritz commented Mar 19, 2022

Hey,

I just installed Asahi Linux on my MacBook Pro with standard German Keyboard Layout and it looks like two Keys are swapped on the standard Layer:
The button left to the "1" Key should be ^ and ° but is < and >
While the button left to the "Y" Key should be < and > but is ^ and °

There are various wrong mappings on the OPT layer as well as the OPT + SHIFT layer

See Screenshots of the macOS Accessibility (onscreen) Keyboard for the desired mapping below:

Neither OPT or SHIFT pressed:
Key lower
SHIFT pressed:
Key shift
OPT pressed:
Key opt
OPT + SHIFT pressed:
Key opt shift

All keys which are mapped wrong when using Linux are annotated with a red square.

Let me know, if a notation other than screenshots is desired

@f-fritz
Copy link
Author

f-fritz commented Mar 19, 2022

Maybe this is more helpful for identifying the desired characters?

Explanation

KEY       : This is what's printed on the key(board)
EXPECTED  : This is the character generated while using macOS when pressing the respective key together with OPT or SHIFT + OPT (see group header) 

OPT pressed

KEY       ^ 1 2 3 4 5 6 7 8 9 0 ß ´
EXPECTED  „ ¡ “ ¶ ¢ [ ] | { } ≠ ¿ '

KEY       q w e r t z u i o p ü +
EXPECTED  « ∑ € ® † Ω ¨  ⁄ ø π • ±

KEY       a s d f g h j k l ö ä #
EXPECTED  Å ‚ ∂ ƒ © ª º ∆ @ œ æ ‘

KEY       < y x c v b n m , . -
EXPECTED  ≤ ¥ ≈ ç √ ∫ ~ µ ∞ … –

OPT + SHIFT pressed

KEY       ^ 1 2 3 4 5 6 7 8 9 0 ß ´
EXPECTED  “ ¬ ” # £ fi ^ \ ˜ · ¯ ˙ ˚

KEY       q w e r t z u i o p ü +
EXPECTED  » „ ‰ ¸ ˝ ˇ Á Û Ø ∏ ° 

KEY       a s d f g h j k l ö ä #
EXPECTED  Å Í ™ Ï Ì Ó ı ˆ fl Œ Æ ’

KEY       < y x c v b n m , . -
EXPECTED  ≥ ‡ Ù Ç ◊ ‹ › ˘ ˛ ÷ —

EDIT: updated explanation / legend

@Fl1tzi
Copy link

Fl1tzi commented Mar 20, 2022

I just created a pr and this should fix the error with the <> and ^° buttons. I think the other errors are because you are using the regular "de" layout. To fix this use the "de(mac)" layout. If you still find keys that are incorrect after this please post it here.

@f-fritz
Copy link
Author

f-fritz commented Mar 20, 2022

In System Settings > Hardware: Input Devices > Keyboard, the Keyboard Model is set to "Apple | MacBook/MacBook Pro" and when I check the "Configure layouts" checkbox on the Layouts Tab, it says Map: de, Layout: German, Variant: German (Macintosh).

I can also switch to "Apple | Apple Aluminium (ISO)" Keyboard Model and apply the change. But whatever I choose: When I type something, the mapping is still wrong as mentioned in the first post. However, OPT + L for "@" does work - so it can't be the standard German layout, can it?

Or is there a special trick or thing to do to apply the Keyboard Model change?
@Fl1tzi does it work on your machine?

@Fl1tzi
Copy link

Fl1tzi commented Mar 20, 2022

What is your output from cat /etc/X11/xorg.conf.d/00-keyboard.conf

@f-fritz
Copy link
Author

f-fritz commented Mar 20, 2022

What is your output from cat /etc/X11/xorg.conf.d/00-keyboard.conf

xxxxxx@asahi:~ -$ cat /etc/X11/xorg.conf.d/00-keyboard.conf
# Read and parsed by systemd-localed. It's probably wise not to edit this file
# manually too freely.
Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "de"
        Option "XkbVariant" "mac"
EndSection

@Fl1tzi
Copy link

Fl1tzi commented Mar 20, 2022

When you run setxkbmap -layout "de(mac)" is then you're layout right?

@f-fritz
Copy link
Author

f-fritz commented Mar 20, 2022

No. Even logged out and -in again. (But all open windows came back - would changes really be applied then?)

KEY       ^ 1 2 3 4 5 6 7 8 9 0 ß ´
OPT       | ¡ ² ³ ¼ [ ] | { } } \ ¸
EXPECTED  „ ¡ “ ¶ ¢ [ ] | { } ≠ ¿ ' 

@Fl1tzi
Copy link

Fl1tzi commented Mar 20, 2022

Oh you are right. I did not notice the little commands only the major ones. The same applies for me. sry

@f-fritz
Copy link
Author

f-fritz commented Mar 20, 2022

Ah, too bad - I hoped I just did it the wrong way 😅
No problem! :)

@Fl1tzi
Copy link

Fl1tzi commented Mar 20, 2022

So there are some new changes to be made. I think the de(mac) layout is probably pretty old now and needs an upgrade.

That seems to be the current one and it probably needs an update:

// Copied from macintosh_vndr/de
// [email protected]   very close to MacOS map

partial alphanumeric_keys
xkb_symbols "mac" {

    include "de"
    name[Group1]= "German (Macintosh)";

    key <AE01>	{ [         1,     exclam,   exclamdown,           at ]	};
    key <AE05>	{ [         5,    percent,  bracketleft       ]	};
    key <AE06>	{ [         6,  ampersand, bracketright       ]	};
    key <AE07>	{ [         7,      slash,          bar,    backslash ]	};
    key <AE08>	{ [         8,  parenleft,    braceleft,   asciitilde ]	};
    key <AE09>	{ [         9, parenright,   braceright       ]	};
    key <AD01>	{ [         q,          Q, guillemotleft, guillemotright ]	};
    key <AD04>	{ [         r,          R,   registered       ]	};
    key <AD07>	{ [         u,          U,    diaeresis,       Aacute ]	};
    key <AD08>	{ [         i,          I,        slash,  Ucircumflex ]	};
    key <AD11>	{ [ udiaeresis, Udiaeresis, periodcentered,    degree ]	};
    key <AD12>	{ [      plus,   asterisk,   asciitilde       ]	};
    key <AC01>	{ [         a,          A,        aring,        Aring ]	};
    key <AC05>	{ [         g,          G,    copyright       ]	};
    key <AC06>	{ [         h,          H,  ordfeminine       ]	};
    key <AC09>	{ [         l,          L,           at       ]	};
    key <AC10>	{ [ odiaeresis, Odiaeresis,  dead_acute       ]	};
    key <AB06>	{ [         n,          N,   asciitilde       ]	};
};```

@Fl1tzi
Copy link

Fl1tzi commented Mar 20, 2022

I guess I have something to do now.

@Fl1tzi
Copy link

Fl1tzi commented Mar 20, 2022

I would work after your expectation that you posted if they are correct. Can you confirm that they are like this in macOS?

@Fl1tzi
Copy link

Fl1tzi commented Mar 21, 2022

Okay I think I managed to configure it right. The left option key seems to not work properly but the right one does. Could you test it out? To do so replace this file with the /usr/share/X11/xkb/symbols/de file. Use at your own risk. Just run setxkbmap -layout "de(mac)" to select it at runtime.

@f-fritz
Copy link
Author

f-fritz commented Mar 21, 2022

Looks very good already 👍 But a few characters are not right yet:

KEY       What is printed on the key(board)
EXPECTED  is what macOS outputs when pressed
NEW       is what appears on screen when using your gist file
TODO      is a visual indicator for NEW and EXPECTED not matching

# OPT

KEY       ^ 1 2 3 4 5 6 7 8 9 0 ß ´
EXPECTED  „ ¡ “ ¶ ¢ [ ] | { } ≠ ¿ '
NEW       ≤ ¡ “ ¶ ¢ [ ] | { } ≠ ˙ '
TODO      x                     x 

KEY       q w e r t z u i o p ü +
EXPECTED  « ∑ € ® † Ω ¨ ⁄ ø π • ±
NEW       « ∑ € ® † Ω ¨ / ø Π · ±
TODO                    x   x x

KEY       a s d f g h j k l ö ä #
EXPECTED  å ‚ ∂ ƒ © ª º ∆ @ œ æ ‘
NEW       å , ∂ đ © ª º ∆ @ ´ æ ‘
TODO            x           x    

KEY       < y x c v b n m , . -
EXPECTED  ≤ ¥ ≈ ç √ ∫ ~ µ ∞ … –
NEW       ” ¥ ≈ ç √ ∫ ~ µ ∞ … –
TODO      x

^  + OPT should be "double low-9 quotation mark" U+201E
ß + OPT and ß + OPT + SHIFT are swapped ("dot above" and "inverted question mark")
i + OPT should be the "fraction slash" (not regular) U+2044
p + OPT should be lowercase \pi U+03C0
ü + OPT should be "bullet" U+2022
f + OPT should be "latin small letter f with hook" U+0192
ö + OPT should be "latin small ligature oe" U+0153
< + OPT should be \leq U+2264

# OPT + SHIFT

KEY       ^ 1 2 3 4 5 6 7 8 9 0 ß ´
EXPECTED  “ ¬ ” # £ fi ^ \ ˜ · ¯ ˙ ˚
NEW       ≥ @ ” # £ fi ^ \ ~ · ¯ ¿ °
TODO      x x             x       x

KEY       q w e r t z u i o p ü +
EXPECTED  » „ ‰ ¸ ˝ ˇ Á Û Ø ∏ ° 
NEW       » ” ‰ ¸ ˝ ˇ Á Û Ø ∏ ° π
TODO        x                   x

KEY       a s d f g h j k l ö ä #
EXPECTED  Å Í ™ Ï Ì Ó ı ˆ fl Œ Æ ’
NEW       Å Í ™ ª Ŋ Ó ı ^ ffi Œ Æ ’
TODO            x x     x x

KEY       < y x c v b n m , . -
EXPECTED  ≥ ‡ Ù Ç ◊ ‹ › ˘ ˛ ÷ —
NEW       “ ‡ Ù Ç ◊ ‹ › ˘ ˛ ÷ — 
TODO      x

^ + OPT + SHIFT should be "left double quotation mark" U+201C
1 + OPT + SHIFT should be "not sign" U+00AC
8 + OPT + SHIFT should be "small tilde" U+02DC
´ + OPT + SHIFT should be "ring above" U+02DA
W + OPT + SHIFT should be "double low-9 quotation mark"  U+201E
+ + OPT + SHIFT should be "apple icon" U+F8FF
F + OPT + SHIFT should be "latin capital letter i with diaeresis" U+00CF
G + OPT + SHIFT should be "latin capital letter i with grave" U+00CC
K + OPT + SHIFT should be "modifier letter circumflex accent" U+02C6
L + OPT + SHIFT should be "latin small ligature fl" U+FB02
< + OPT + SHIFT should be \geq U+2265

I hope I got everything correct. I pasted the characters on https://unicodelookup.com to obtain their name (as some of them look very similar). Not sure though, whether the Unicode Hex Code (U+XXXX) is of any help to you

@Fl1tzi
Copy link

Fl1tzi commented Mar 21, 2022

Okay thanks. The unicode really helps. I will probably move the config over to symbols/macintosh_vndr/de. It just seems like its more mac specific. But that should be just another keyboard layout name to set then. I will work on it and I will probably be ready today.

EDIT: I did not

@Fl1tzi
Copy link

Fl1tzi commented Mar 21, 2022

We should probably not use the apple icon, because it is not supported on linux and just prints out an somewhat pi character: .

@Fl1tzi
Copy link

Fl1tzi commented Mar 21, 2022

The gist should be updated now.

@f-fritz
Copy link
Author

f-fritz commented Mar 21, 2022

Looks good 👍
Just one mistake in Line 614:

-     key <AC10>  { [ odiaeresis, Odiaeresis,  dead_acute, oe    ]        };
+     key <AC10>  { [ odiaeresis, Odiaeresis,  oe, OE    ]        };

(and ^/° and </> still swapped)

@Fl1tzi
Copy link

Fl1tzi commented Mar 21, 2022

Eh but I already switched it. Look at the difference in the symbols file and my gist. It is also switched on the keyboard for me.

@Fl1tzi
Copy link

Fl1tzi commented Mar 21, 2022

The mistake in Line 614 should be fixed now.

@f-fritz
Copy link
Author

f-fritz commented Mar 22, 2022

Eh but I already switched it. Look at the difference in the symbols file and my gist. It is also switched on the keyboard for me.

Ah, I see. Tried it only via Parallels yesterday and it looks like it's somehow still swapped there. But it does indeed work with Asahi Linux.

Thanks a lot!

@Fl1tzi
Copy link

Fl1tzi commented Mar 22, 2022

Eh but I already switched it. Look at the difference in the symbols file and my gist. It is also switched on the keyboard for me.

Ah, I see. Tried it only via Parallels yesterday and it looks like it's somehow still swapped there. But it does indeed work with Asahi Linux.

Thanks a lot!

I will probably look over it another time and check everything and then I will probably commit it so it will be useable for everybody in the next update.

@mixi
Copy link

mixi commented Mar 23, 2022

The tilde <-> greater- / less-than issue seems to already have a workaround in the kernel driver under the parameter name iso_layout:

$ modinfo hid-apple 
name:           hid_apple
filename:       (builtin)
license:        GPL
file:           drivers/hid/hid-apple
parm:           fnmode:Mode of fn key on Apple keyboards (0 = disabled, [1] = fkeyslast, 2 = fkeysfirst) (uint)
parm:           iso_layout:Swap the backtick/tilde and greater-than/less-than keys. ([-1] = auto, 0 = disabled, 1 = enabled) (int)
parm:           swap_opt_cmd:Swap the Option ("Alt") and Command ("Flag") keys. (For people who want to keep Windows PC keyboard muscle memory. [0] = as-is, Mac layout. 1 = swapped, Windows layout.) (uint)
parm:           swap_fn_leftctrl:Swap the Fn and left Control keys. (For people who want to keep PC keyboard muscle memory. [0] = as-is, Mac layout, 1 = swapped, PC layout) (uint)

So that one could possibly be caused by wrong autodetection on the default "auto" mode.

You can test this at runtime with:

echo 1 > /sys/module/hid_apple/parameters/iso_layout

@Fl1tzi
Copy link

Fl1tzi commented Mar 23, 2022

I posted an issue here: AsahiLinux/linux#21

@mkurz
Copy link

mkurz commented May 30, 2022

Did you make sure that in the "IBus Preferences" in the "Advanced" tab you enabled "use system keyboard layout"?
I just wanted to mention this here, because I had problems that firefox did not pick up my custom system wide keyboard layout without having this enabled.

@Fl1tzi
Copy link

Fl1tzi commented May 30, 2022

Could you specify which menu you mean? This is not an issue with Firefox but with the system wide keyboard. And we already know that the error is coming from the driver not having the fix included. So is your answer related to the driver or to Firefox?

@mkurz
Copy link

mkurz commented May 30, 2022

The point I want to make is that it can happen that even when you choose the correct keyboard/layout/variant/... and even if the configs in /usr/share/X11/xkb/ are "correct", it could happen that some applications use the keyboard layout which is configured via IBus. For example: I modified some xkb config files (I even created a new variant) and used that as my keyboard layout, however some applications did not pick that up. Don't ask my how and why, but these applications (e.g. Firefox) get their inputs from IBus, so it turned out I had to set following config to make sure also those application receive the correct keys:
image

I just want to say be aware of this, so you don't fall into a trap thinking you are testing the changes in your xkb configs, but the application you use for testing does not even use that layout you are currently modifing because IBus e.g. defaults to english e.g. but you modify the german layout.
I hope you get what a mean. It's just a hint to be aware of that.

@Fl1tzi
Copy link

Fl1tzi commented Dec 27, 2022

Fixed in AsahiLinux/linux#21 as it seems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants