An xkb keymap reader: the text a Wayland compositor sends for its keyboard, turned into what a key types. No libxkbcommon.
A compositor sends a resolved keymap: no includes and no rules. Of its
four sections the reader takes the key codes, the types, the compat
section's interpret blocks and the symbols, with modifier_map. It
skips every action, since the compositor tracks the modifier state and
sends it with each change.
The parts it computes, in the order xkbcommon computes them:
interpret that
matches a level's keysym and the key's real modifiers gives the key its
virtualModifier. The one that matches the first level of the first
group gives the key its repeat; a keysym no interpret matches repeats,
and a key with no keysym there does not. A key's own vmods= or
repeat= wins.A level that holds more than one keysym resolves to its first.
| Name | Signature |
|---|---|
| parse | parse(text) -> keymap, err |
| base | base(code) -> key |
parse(
text) ->keymap,err
Parse an xkb keymap
text is a resolved keymap: the text after xkb_keymap {, as a
compositor sends it, with or without the trailing NUL. Returns nil and an
error naming the line when the text does not parse, or when it holds an
include, which only an unresolved keymap has.
| keymap field or method | description |
|---|---|
km:key(code, depressed, latched, locked, group) | what the evdev code types under the four values of wl_keyboard.modifiers |
km:mods(depressed, latched, locked) | the named modifiers in force, the set km:key reports as mods |
km:repeats(code) | true when a held key repeats |
km.groups | the groups' names, km.groups[1] the first, as the keymap names them |
km.unknown | the count of keysym names the tables do not hold; each reads as NoSymbol |
km:key returns a table:
| field | description |
|---|---|
code | the evdev code |
keysym | the keysym at the level in force; 0 for none |
key | the key's name for a named keysym (ENTER, F1, KP_1, LEFT_SHIFT), else the character of the first level of the group |
shifted | the character of the second level, when it types one |
text | the character the key types now, or nil |
base | the key on a US layout: its character, or the key's name |
mods | a set of shift, caps_lock, ctrl, alt, super, hyper, meta, num_lock |
group, level | the group and the level in force, from 1 |
The group wraps: past the keymap's groups, then past the key's. The
level is the one the group's type maps the modifiers in force to. text
is nil for a control character, and while Ctrl is in force and the type
does not take it: the caller encodes Ctrl. Alt leaves the text. Caps Lock
changes a letter only through its type; xkbcommon's case change for a
type without Lock is not made. Meta on the same real modifier as Alt is
left out of mods, and Hyper on Super's.
base(
code) ->key
The key a physical key has on a US layout
The character on a US keyboard of the evdev code, for the keys that
type one; nil for any other. km:key falls back to the key's name.