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.
Yes, but this doesn’t answer why I only have to do this on Mac and not windows/linux, where I have literally never run into an issue as a result of not doing it.
Most non-Apple branded keyboards are NOT tested with mac; so it doesn't trust any electronic tags/labels, nor does it keep a database. Easiest thing to make it work 100% without asking the user to identify their layout, is to press random keys so the mac knows where things are mapped.
Windows and Linux both ask for your language and locale during setup and default to the typical matching keyboard. I'm nearly sure Debian also asks you to confirm the keyboard it picked, but it's always the right one so I just hit enter.
If you're using a US English keyboard layout, it's the default and you won't have to deal with changing it.
The most likely reason it would be a problem then would be that some Raspberry Pi images have defaulted to British English keyboard layouts. Otherwise you may be sailing through life unburdened by what can be a major pain to anyone anywhere else in the world, like a resident of Arizona wondering why the rest of the world keeps messing with their clocks.
I assume for some nonzero percentage of folks it doesn't work right and they have to manually go and set their keyboard layout.
Of course, when you're setting up your OS initially, it will ask you questions about language and keyboard layout. I suspect most people don't switch keyboards after install, and of those who do, the most common case is another keyboard with a compatible layout.
Apple has to make it annoying to use a non-Apple device with your Apple device. That sort of friction probably nets them 2% in keyboard sales per year.
How are they not arbitrary? Apple tells you a specific key to press, which is a choice. It is by definition arbitrary.
Edit: perhaps you're making the case that the user doesn't choose which key. This is true—but the important point is that one of the two parties did choose the specific key to press.
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?
That would break credit card readers, barcode scanners, and special purpose keyboards (like video workstations).
I suppose you could rely on a binary code, where the user is instructed to press any two keys to repeat the code, or if there is only one key (or it's a barcode scanner), to enter the same input multiple times, separated by long and short pauses.
Still seems like it would be difficult for the average user.
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.
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.
Mapping to ensure that it has the correct layout applied.
Yes, but this doesn’t answer why I only have to do this on Mac and not windows/linux, where I have literally never run into an issue as a result of not doing it.
Most non-Apple branded keyboards are NOT tested with mac; so it doesn't trust any electronic tags/labels, nor does it keep a database. Easiest thing to make it work 100% without asking the user to identify their layout, is to press random keys so the mac knows where things are mapped.
Windows and Linux both ask for your language and locale during setup and default to the typical matching keyboard. I'm nearly sure Debian also asks you to confirm the keyboard it picked, but it's always the right one so I just hit enter.
If you're using a US English keyboard layout, it's the default and you won't have to deal with changing it.
The most likely reason it would be a problem then would be that some Raspberry Pi images have defaulted to British English keyboard layouts. Otherwise you may be sailing through life unburdened by what can be a major pain to anyone anywhere else in the world, like a resident of Arizona wondering why the rest of the world keeps messing with their clocks.
Do you live in a country where the default always maps correctly? My UK keyboards will always have specific keys wrong.
I assume you have a standard US keyboard.
I assume for some nonzero percentage of folks it doesn't work right and they have to manually go and set their keyboard layout.
Of course, when you're setting up your OS initially, it will ask you questions about language and keyboard layout. I suspect most people don't switch keyboards after install, and of those who do, the most common case is another keyboard with a compatible layout.
Apple has to make it annoying to use a non-Apple device with your Apple device. That sort of friction probably nets them 2% in keyboard sales per year.
Random ≠ arbitrary
> Random ≠ arbitrary
Sure, though if you're looking to be pedantic, the keys they're asking you to press are neither random nor arbitrary
How are they not arbitrary? Apple tells you a specific key to press, which is a choice. It is by definition arbitrary.
Edit: perhaps you're making the case that the user doesn't choose which key. This is true—but the important point is that one of the two parties did choose the specific key to press.
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?
That would break credit card readers, barcode scanners, and special purpose keyboards (like video workstations).
I suppose you could rely on a binary code, where the user is instructed to press any two keys to repeat the code, or if there is only one key (or it's a barcode scanner), to enter the same input multiple times, separated by long and short pauses.
Still seems like it would be difficult for the average user.
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.
Why does it sometimes ask when connecting a HDMI projector?
See also the layout identifier manual-elsif/elsif/elsif workflow here, last updated November 2023:
https://support.apple.com/en-us/102743
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.
they don't ask you to press random keys