Mapping to ensure that it has the correct layout applied.
I think every OS should ask you to press a freshly generated sequence of keys when connecting a keyboard to prevent BadUSB attacks. Does any system do this?
Honestly, the mac approach makes much more sense from an ease of use perspective for non-experts. On other platforms, you have to know the layout to choose and hope things work until you do or have a second keyboard that's close enough tl the default to get by. On Mac, it just figures it out based on the information you tell it when the keyboard is connected. Much less error prone in the majority of cases.
I guess the moment has passed by now but I wish there were a USB HID protocol for keyboards to identify their layout, or even better yet make the keyboard protocol layout agnostic so that keyboards send the high-level unicode character / modifier instead of a physical key code.
See also the layout identifier manual-elsif/elsif/elsif workflow here, last updated November 2023:
they don't ask you to press random keys
Ah! Thanks for the stimulation. That's an interesting problem that I had not thought of before. In fact a few related problems.
What's the minimum set of requested key presses that will uniquely identify a keyboard layout from a set of known types.
Given a budget of k key strokes what's the most informative subset that will reduce the ambiguity about layout.
Given the measurement from the requested key strokes find the posterior over the set of known keyboard layouts.
Given that the user is typing some free form text in his language how soon can one nail the layout when the user's language, the layout and the text are unknown. Will make a good practice exercise for hobbyist codebreaking.