You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: adafruit_hid/keyboard_layout_base.py
+25-7Lines changed: 25 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -21,16 +21,34 @@ class KeyboardLayoutBase:
21
21
Non-supported characters and most control characters will raise an exception.
22
22
"""
23
23
24
-
# We use the top bit of each byte (0x80) to indicate
25
-
# that the shift key should be pressed
26
24
SHIFT_FLAG=0x80
25
+
"""Bit set in any keycode byte if the shift key is required for the character."""
27
26
ALTGR_FLAG=0x80
27
+
"""Bit set in the combined keys table if altgr is required for the first key."""
28
28
SHIFT_CODE=0xE1
29
+
"""The SHIFT keycode, to avoid dependency to the Keycode class."""
29
30
RIGHT_ALT_CODE=0xE6
31
+
"""The ALTGR keycode, to avoid dependency to the Keycode class."""
30
32
ASCII_TO_KEYCODE= ()
31
-
NEED_ALTGR=""
33
+
"""Bytes string of keycodes for low ASCII characters, indexed by the ASCII value. Keycodes use the `SHIFT_FLAG` if needed. Dead keys are excluded by assigning the keycode 0."""
32
34
HIGHER_ASCII= {}
35
+
"""Dictionary that associates the ord() int value of high ascii and utf8 characters
36
+
to their keycode. Keycodes use the `SHIFT_FLAG` if needed."""
37
+
NEED_ALTGR=""
38
+
"""Characters in `ASCII_TO_KEYCODE` and `HIGHER_ASCII` that need the ALTGR key pressed to type."""
33
39
COMBINED_KEYS= {}
40
+
"""
41
+
Dictionary of characters (indexed by ord() value) that can be accessed by typing first
42
+
a dead key followed by a regular key, like ``ñ`` as ``~ + n``. The value is a 2-bytes int:
43
+
the high byte is the dead-key keycode (including SHIFT_FLAG), the low byte is the ascii code
44
+
of the second character, with ALTGR_FLAG set if the dead key (the first key) needs ALTGR.
45
+
46
+
The combined-key codes bits are: ``0b SDDD DDDD AKKK KKKK``:
47
+
``S`` is the shift flag for the **first** key,
48
+
``DDD DDDD`` is the keycode for the **first** key,
49
+
``A`` is the altgr flag for the **first** key,
50
+
``KKK KKKK`` is the (low) ASCII code for the second character.
0 commit comments