diff options
author | Michael Brown <mcb30@ipxe.org> | 2022-02-15 11:28:57 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2022-02-15 13:37:41 +0000 |
commit | c7d78192919bfa62fde33650e1506e902816eec3 (patch) | |
tree | 15718c529fa1643c325bee89d62c1b021cc67f36 /src/util | |
parent | e1cedbc0d4fdb0e16818f6b722f4873a50780761 (diff) | |
download | ipxe-c7d78192919bfa62fde33650e1506e902816eec3.zip ipxe-c7d78192919bfa62fde33650e1506e902816eec3.tar.gz ipxe-c7d78192919bfa62fde33650e1506e902816eec3.tar.bz2 |
[console] Treat dead keys as producing their ASCII equivalents
Treat dead keys in target keymaps as producing the closest equivalent
ASCII character, since many of these characters are otherwise
unrepresented on the keyboard.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/util')
-rwxr-xr-x | src/util/genkeymap.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/util/genkeymap.py b/src/util/genkeymap.py index ff5ff0a..42ccee1 100755 --- a/src/util/genkeymap.py +++ b/src/util/genkeymap.py @@ -54,6 +54,14 @@ class KeyType(IntEnum): UNKNOWN = 0xf0 +class DeadKey(IntEnum): + """Dead keys""" + + GRAVE = 0 + CIRCUMFLEX = 2 + TILDE = 3 + + class KeyModifiers(Flag): """Key modifiers""" @@ -96,6 +104,13 @@ class Key: KeyType.LETTER} """Key types with direct ASCII values""" + DEAD_KEYS: ClassVar[Mapping[int, str]] = { + DeadKey.GRAVE: '`', + DeadKey.CIRCUMFLEX: '^', + DeadKey.TILDE: '~', + } + """Dead key replacement ASCII values""" + @property def keytype(self) -> Optional[KeyType]: """Key type""" @@ -112,11 +127,14 @@ class Key: @property def ascii(self) -> Optional[str]: """ASCII character""" - if self.keytype in self.ASCII_TYPES: - value = self.value + keytype = self.keytype + value = self.value + if keytype in self.ASCII_TYPES: char = chr(value) if value and char.isascii(): return char + if keytype == KeyType.DEAD: + return self.DEAD_KEYS.get(value) return None |