|
|
|
|
|
by dasyatidprime
982 days ago
|
|
This is contrary to my understanding of mainstream keyboard technology. Scancodes, like what you're looking at with Linux input, mainly refer to physical positions relative to a “standard” keyboard, and the labels in the header file for the alphabetic section are based on assuming the keyboard is QWERTY. A keyboard that comes from the manufacturer with different-layout keycaps on it will still output physical-position-based scancodes, and KEY_Q in the header file is not normally generated by the key that the manufacturer shipped a cap labeled Q on; it's the key in the position that would output Q if it were a QWERTY keyboard. (Though there's a few edge cases around e.g. ANSI vs ISO layout.) This idea is corroborated if you look in the USB HID Usage Tables that the Linux input event codes are based on. From https://usb.org/document-library/hid-usage-tables-14: > Note: A general note on Usages and languages: Due to the variation of keyboards from language to language, it is not feasible to specify exact key mappings for every language. Where this list is not specific for a key function in a language, the closest equivalent key position should be used, so that a keyboard may be modified for a different language by simply printing different keycaps. One example is the Y key on a North American keyboard. In Germany this is typically Z. Rather than changing the keyboard firmware to put the Z Usage into that place in the descriptor list, the vendor should use the Y Usage on both the North American and German keyboards. This continues to be the existing practice in the industry, in order to minimize the number of changes to the electronics to accommodate other languages. This can get somewhat more complicated when you get into keyboards with custom remapping firmware where they do actually shift the scancodes around, but that creates other potential issues, and users who are doing that basically just have to deal with their own integration tradeoffs. Similar considerations apply to keyboards with non-mainstream physical layouts. |
|
Imo it makes sense to support defining mappings according to both modes of reference, and even allow mixing them into a single config. Neither way of thinking seems inherently better or worse to me. Just depends on preference, intuition, and expectations.
--
1: https://www.man7.org/linux/man-pages/man5/keymaps.5.html