summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorMichael Brown2022-02-15 12:28:57 +0100
committerMichael Brown2022-02-15 14:37:41 +0100
commitc7d78192919bfa62fde33650e1506e902816eec3 (patch)
tree15718c529fa1643c325bee89d62c1b021cc67f36 /src/util
parent[console] Support AltGr to access ASCII characters via remapping (diff)
downloadipxe-c7d78192919bfa62fde33650e1506e902816eec3.tar.gz
ipxe-c7d78192919bfa62fde33650e1506e902816eec3.tar.xz
ipxe-c7d78192919bfa62fde33650e1506e902816eec3.zip
[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-xsrc/util/genkeymap.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/util/genkeymap.py b/src/util/genkeymap.py
index ff5ff0a8..42ccee17 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