xref: /aosp_15_r20/external/libxkbcommon/doc/keymap-format-text-v1.md (revision 2b949d0487e80d67f1fda82db69e101e761f8064)
1*2b949d04SAndroid Build Coastguard Worker# The XKB keymap text format, V1
2*2b949d04SAndroid Build Coastguard Worker
3*2b949d04SAndroid Build Coastguard WorkerThis document describes the `XKB_KEYMAP_FORMAT_TEXT_V1` keymap format,
4*2b949d04SAndroid Build Coastguard Workeras implemented by libxkbcommon.
5*2b949d04SAndroid Build Coastguard Worker
6*2b949d04SAndroid Build Coastguard WorkerNOTE: This document is ever incomplete. Some additional resources are:
7*2b949d04SAndroid Build Coastguard Worker
8*2b949d04SAndroid Build Coastguard Worker- [Ivan Pascal's XKB documentation](https://web.archive.org/web/20190724015820/http://pascal.tsu.ru/en/xkb/)
9*2b949d04SAndroid Build Coastguard Worker- [An Unreliable Guide to XKB Configuration](https://www.charvolant.org/doug/xkb/html/index.html)
10*2b949d04SAndroid Build Coastguard Worker- [ArchWiki XKB page](https://wiki.archlinux.org/index.php/X_keyboard_extension)
11*2b949d04SAndroid Build Coastguard Worker
12*2b949d04SAndroid Build Coastguard WorkerA keymap consists of a single top-level `xkb_keymap` block, underwhich
13*2b949d04SAndroid Build Coastguard Workerare nested the following sections.
14*2b949d04SAndroid Build Coastguard Worker
15*2b949d04SAndroid Build Coastguard Worker
16*2b949d04SAndroid Build Coastguard Worker## The `xkb_keycodes` section
17*2b949d04SAndroid Build Coastguard Worker
18*2b949d04SAndroid Build Coastguard WorkerThis is the simplest section type, and is the first one to be
19*2b949d04SAndroid Build Coastguard Workercompiled. The purpose of this is mostly to map between the
20*2b949d04SAndroid Build Coastguard Workerhardware/evdev scancodes and xkb keycodes. Each key is given a name
21*2b949d04SAndroid Build Coastguard Workerby which it can be referred to later, e.g. in the symbols section.
22*2b949d04SAndroid Build Coastguard Worker
23*2b949d04SAndroid Build Coastguard Worker### Keycode statements
24*2b949d04SAndroid Build Coastguard Worker
25*2b949d04SAndroid Build Coastguard WorkerStatements of the form:
26*2b949d04SAndroid Build Coastguard Worker
27*2b949d04SAndroid Build Coastguard Worker    <TLDE> = 49;
28*2b949d04SAndroid Build Coastguard Worker    <AE01> = 10;
29*2b949d04SAndroid Build Coastguard Worker
30*2b949d04SAndroid Build Coastguard WorkerThe above would let 49 and 10 be valid keycodes in the keymap, and
31*2b949d04SAndroid Build Coastguard Workerassign them the names `TLDE` and `AE01` respectively. The format
32*2b949d04SAndroid Build Coastguard Worker`<WXYZ>` is always used to refer to a key by name.
33*2b949d04SAndroid Build Coastguard Worker
34*2b949d04SAndroid Build Coastguard Worker[The naming convention `<AE01>` just denotes the position of the key
35*2b949d04SAndroid Build Coastguard Workerin the main alphanumeric section of a standard QWERTY keyboard, with
36*2b949d04SAndroid Build Coastguard Workerthe two letters specifying the row and the two digits specifying the
37*2b949d04SAndroid Build Coastguard Workercolumn, from the bottom left.]
38*2b949d04SAndroid Build Coastguard Worker
39*2b949d04SAndroid Build Coastguard WorkerIn the common case this just maps to the evdev scancodes from
40*2b949d04SAndroid Build Coastguard Worker`/usr/include/linux/input.h`, e.g. the following definitions:
41*2b949d04SAndroid Build Coastguard Worker
42*2b949d04SAndroid Build Coastguard Worker     #define KEY_GRAVE            41
43*2b949d04SAndroid Build Coastguard Worker     #define KEY_1                2
44*2b949d04SAndroid Build Coastguard Worker
45*2b949d04SAndroid Build Coastguard Workercorrespond to the ones above. Similar definitions appear in the
46*2b949d04SAndroid Build Coastguard Workerxf86-input-keyboard driver. Note that in all current keymaps there's a
47*2b949d04SAndroid Build Coastguard Workerconstant offset of 8 (for historical reasons).
48*2b949d04SAndroid Build Coastguard Worker
49*2b949d04SAndroid Build Coastguard WorkerIf there's a conflict, like the same name given to different keycodes,
50*2b949d04SAndroid Build Coastguard Workeror same keycode given different names, it is resolved according to the
51*2b949d04SAndroid Build Coastguard Workermerge mode which applies to the definitions.
52*2b949d04SAndroid Build Coastguard Worker
53*2b949d04SAndroid Build Coastguard Worker### Alias statements
54*2b949d04SAndroid Build Coastguard Worker
55*2b949d04SAndroid Build Coastguard WorkerStatements of the form:
56*2b949d04SAndroid Build Coastguard Worker
57*2b949d04SAndroid Build Coastguard Worker    alias <MENU> = <COMP>;
58*2b949d04SAndroid Build Coastguard Worker
59*2b949d04SAndroid Build Coastguard WorkerAllows to refer to a previously defined key (here `<COMP>`) by another
60*2b949d04SAndroid Build Coastguard Workername (here `<MENU>`). Conflicts are handled similarly to keycode
61*2b949d04SAndroid Build Coastguard Workerstatements.
62*2b949d04SAndroid Build Coastguard Worker
63*2b949d04SAndroid Build Coastguard Worker### LED name statements
64*2b949d04SAndroid Build Coastguard Worker
65*2b949d04SAndroid Build Coastguard WorkerStatements of the form:
66*2b949d04SAndroid Build Coastguard Worker
67*2b949d04SAndroid Build Coastguard Worker    indicator 1 = "Caps Lock";
68*2b949d04SAndroid Build Coastguard Worker    indicator 2 = "Num Lock";
69*2b949d04SAndroid Build Coastguard Worker    indicator 3 = "Scroll Lock";
70*2b949d04SAndroid Build Coastguard Worker
71*2b949d04SAndroid Build Coastguard WorkerAssigns a name to the keyboard LED (AKA indicator) with the given
72*2b949d04SAndroid Build Coastguard Workerindex. The LED may be referred by this name later in the compat
73*2b949d04SAndroid Build Coastguard Workersection and by the user.
74*2b949d04SAndroid Build Coastguard Worker
75*2b949d04SAndroid Build Coastguard Worker
76*2b949d04SAndroid Build Coastguard Worker## The `xkb_types` section
77*2b949d04SAndroid Build Coastguard Worker
78*2b949d04SAndroid Build Coastguard WorkerThis section is the second to be processed, after `xkb_keycodes`.
79*2b949d04SAndroid Build Coastguard WorkerHowever, it is completely independent and could have been the first to
80*2b949d04SAndroid Build Coastguard Workerbe processed (it does not refer to specific keys as specified in the
81*2b949d04SAndroid Build Coastguard Worker`xkb_keycodes` section).
82*2b949d04SAndroid Build Coastguard Worker
83*2b949d04SAndroid Build Coastguard WorkerThis section defines key types, which, given a key and a keyboard
84*2b949d04SAndroid Build Coastguard Workerstate (i.e. modifier state and group), determine the shift level to be
85*2b949d04SAndroid Build Coastguard Workerused in translating the key to keysyms. These types are assigned to
86*2b949d04SAndroid Build Coastguard Workereach group in each key, in the `xkb_symbols` section.
87*2b949d04SAndroid Build Coastguard Worker
88*2b949d04SAndroid Build Coastguard WorkerKey types are called this way because, in a way, they really describe
89*2b949d04SAndroid Build Coastguard Workerthe "type" of the key (or more correctly, a specific group of the
90*2b949d04SAndroid Build Coastguard Workerkey). For example, an ordinary keymap will provide a type called
91*2b949d04SAndroid Build Coastguard Worker`KEYPAD`, which consists of two levels, with the second level being
92*2b949d04SAndroid Build Coastguard Workerchosen according to the state of the Num Lock (or Shift) modifiers.
93*2b949d04SAndroid Build Coastguard WorkerAnother example is a type called `ONE_LEVEL`, which is usually
94*2b949d04SAndroid Build Coastguard Workerassigned to keys such as Escape; these have just one level and are not
95*2b949d04SAndroid Build Coastguard Workeraffected by the modifier state. Yet more common examples are
96*2b949d04SAndroid Build Coastguard Worker`TWO_LEVEL` (with Shift choosing the second level), `ALPHABETIC`
97*2b949d04SAndroid Build Coastguard Worker(where Caps Lock may also choose the second level), etc.
98*2b949d04SAndroid Build Coastguard Worker
99*2b949d04SAndroid Build Coastguard Worker### Type definitions
100*2b949d04SAndroid Build Coastguard Worker
101*2b949d04SAndroid Build Coastguard WorkerStatements of the form:
102*2b949d04SAndroid Build Coastguard Worker
103*2b949d04SAndroid Build Coastguard Worker    type "FOUR_LEVEL" { ... }
104*2b949d04SAndroid Build Coastguard Worker
105*2b949d04SAndroid Build Coastguard WorkerThe above would create a new type named `FOUR_LEVEL`.
106*2b949d04SAndroid Build Coastguard WorkerThe body of the definition may include statements of the following
107*2b949d04SAndroid Build Coastguard Workerforms:
108*2b949d04SAndroid Build Coastguard Worker
109*2b949d04SAndroid Build Coastguard Worker#### `level_name` statements
110*2b949d04SAndroid Build Coastguard Worker
111*2b949d04SAndroid Build Coastguard Worker    level_name[Level1] = "Base";
112*2b949d04SAndroid Build Coastguard Worker
113*2b949d04SAndroid Build Coastguard WorkerMandatory for each level in the type.
114*2b949d04SAndroid Build Coastguard Worker
115*2b949d04SAndroid Build Coastguard WorkerGives each level in this type a descriptive name. It isn't used
116*2b949d04SAndroid Build Coastguard Workerfor anything.
117*2b949d04SAndroid Build Coastguard Worker
118*2b949d04SAndroid Build Coastguard WorkerNote: A level may be specified as Level[1-8] or just a number (can
119*2b949d04SAndroid Build Coastguard Workerbe more than 8).
120*2b949d04SAndroid Build Coastguard Worker
121*2b949d04SAndroid Build Coastguard Worker#### `modifiers` statement
122*2b949d04SAndroid Build Coastguard Worker
123*2b949d04SAndroid Build Coastguard Worker    modifiers = Shift+Lock+LevelThree;
124*2b949d04SAndroid Build Coastguard Worker
125*2b949d04SAndroid Build Coastguard WorkerMandatory, should be specified only once.
126*2b949d04SAndroid Build Coastguard Worker
127*2b949d04SAndroid Build Coastguard WorkerA mask of real and virtual modifiers. These are the only modifiers
128*2b949d04SAndroid Build Coastguard Workerbeing considered when matching the modifier state against the type.
129*2b949d04SAndroid Build Coastguard WorkerThe other modifiers, whether active or not, are masked out in the
130*2b949d04SAndroid Build Coastguard Workercalculation.
131*2b949d04SAndroid Build Coastguard Worker
132*2b949d04SAndroid Build Coastguard Worker#### `map` entry statements
133*2b949d04SAndroid Build Coastguard Worker
134*2b949d04SAndroid Build Coastguard Worker    map[Shift+LevelThree] = Level4;
135*2b949d04SAndroid Build Coastguard Worker
136*2b949d04SAndroid Build Coastguard WorkerShould have at least as many mappings as there are levels in the type.
137*2b949d04SAndroid Build Coastguard Worker
138*2b949d04SAndroid Build Coastguard WorkerIf the active modifiers, masked with the type's modifiers (as stated
139*2b949d04SAndroid Build Coastguard Workerabove), match (i.e. equal) the modifiers inside the `map[]` statement,
140*2b949d04SAndroid Build Coastguard Workerthen the level in the right hand side is chosen. For example, in the
141*2b949d04SAndroid Build Coastguard Workerabove, if in the current keyboard state the `Shift` and `LevelThree`
142*2b949d04SAndroid Build Coastguard Workermodifiers are active, while the `Lock` modifier is not, then the
143*2b949d04SAndroid Build Coastguard Workerkeysym(s) in the 4th level of the group will be returned to the user.
144*2b949d04SAndroid Build Coastguard Worker
145*2b949d04SAndroid Build Coastguard Worker#### `preserve` statements
146*2b949d04SAndroid Build Coastguard Worker
147*2b949d04SAndroid Build Coastguard Worker    map[Shift+Lock+LevelThree] = Level5;
148*2b949d04SAndroid Build Coastguard Worker    preserve[Shift+Lock+LevelThree] = Lock;
149*2b949d04SAndroid Build Coastguard Worker
150*2b949d04SAndroid Build Coastguard WorkerWhen a key type is used for keysym translation, its modifiers are said
151*2b949d04SAndroid Build Coastguard Workerto be "consumed". For example, in a simple US keymap, the "g" "g" key
152*2b949d04SAndroid Build Coastguard Workeris assigned an ordinary `ALPHABETIC` key type, whose modifiers are
153*2b949d04SAndroid Build Coastguard WorkerShift and Lock; then for the "g" key, these two modifiers are consumed
154*2b949d04SAndroid Build Coastguard Workerby the translation. This information is relevant for applications
155*2b949d04SAndroid Build Coastguard Workerwhich further process the modifiers, since by then the consumed
156*2b949d04SAndroid Build Coastguard Workermodifiers have already "done their part" and should be masked out.
157*2b949d04SAndroid Build Coastguard Worker
158*2b949d04SAndroid Build Coastguard WorkerHowever, sometimes even if a modifier had already affected the key
159*2b949d04SAndroid Build Coastguard Workertranslation through the type, it should *not* be reported as consumed,
160*2b949d04SAndroid Build Coastguard Workerfor various reasons. In this case, a `preserve[]` statement can be
161*2b949d04SAndroid Build Coastguard Workerused to augment the map entry. The modifiers inside the square
162*2b949d04SAndroid Build Coastguard Workerbrackets should match one of the map[] statements in the type (if
163*2b949d04SAndroid Build Coastguard Workerthere is no matching map entry, one mapping to Level1 is implicitly
164*2b949d04SAndroid Build Coastguard Workeradded). The right hand side should consists of modifiers from the
165*2b949d04SAndroid Build Coastguard Workertype's modifiers; these modifiers are then "preserved" and not
166*2b949d04SAndroid Build Coastguard Workerreported as consumed.
167*2b949d04SAndroid Build Coastguard Worker
168*2b949d04SAndroid Build Coastguard Worker
169*2b949d04SAndroid Build Coastguard Worker## The `xkb_compat` section
170*2b949d04SAndroid Build Coastguard Worker
171*2b949d04SAndroid Build Coastguard WorkerThis section is the third to be processed, after `xkb_keycodes` and
172*2b949d04SAndroid Build Coastguard Worker`xkb_types`.
173*2b949d04SAndroid Build Coastguard Worker
174*2b949d04SAndroid Build Coastguard Worker### Interpret statements
175*2b949d04SAndroid Build Coastguard Worker
176*2b949d04SAndroid Build Coastguard WorkerStatements of the form:
177*2b949d04SAndroid Build Coastguard Worker
178*2b949d04SAndroid Build Coastguard Worker    interpret Num_Lock+Any { ... }
179*2b949d04SAndroid Build Coastguard Worker    interpret Shift_Lock+AnyOf(Shift+Lock) { ... }
180*2b949d04SAndroid Build Coastguard Worker
181*2b949d04SAndroid Build Coastguard WorkerThe `xkb_symbols` section (see below) allows the keymap author to
182*2b949d04SAndroid Build Coastguard Workerperform, among other things, the following things for each key:
183*2b949d04SAndroid Build Coastguard Worker
184*2b949d04SAndroid Build Coastguard Worker- Bind an action, like SetMods or LockGroup, to the key. Actions, like
185*2b949d04SAndroid Build Coastguard Worker  symbols, are specified for each level of each group in the key
186*2b949d04SAndroid Build Coastguard Worker  separately.
187*2b949d04SAndroid Build Coastguard Worker
188*2b949d04SAndroid Build Coastguard Worker- Add a virtual modifier to the key's virtual modifier mapping
189*2b949d04SAndroid Build Coastguard Worker  (vmodmap).
190*2b949d04SAndroid Build Coastguard Worker
191*2b949d04SAndroid Build Coastguard Worker- Specify whether the key should repeat or not.
192*2b949d04SAndroid Build Coastguard Worker
193*2b949d04SAndroid Build Coastguard WorkerHowever, doing this for each key (or level) is tedious and inflexible.
194*2b949d04SAndroid Build Coastguard WorkerInterpret's are a mechanism to apply these settings to a bunch of
195*2b949d04SAndroid Build Coastguard Workerkeys/levels at once.
196*2b949d04SAndroid Build Coastguard Worker
197*2b949d04SAndroid Build Coastguard WorkerEach interpret specifies a condition by which it attaches to certain
198*2b949d04SAndroid Build Coastguard Workerlevels. The condition consists of two parts:
199*2b949d04SAndroid Build Coastguard Worker
200*2b949d04SAndroid Build Coastguard Worker- A keysym. If the level has a different (or more than one) keysym,
201*2b949d04SAndroid Build Coastguard Worker  the match fails. Leaving out the keysym is equivalent to using the
202*2b949d04SAndroid Build Coastguard Worker  `NoSymbol` keysym, which always matches successfully.
203*2b949d04SAndroid Build Coastguard Worker
204*2b949d04SAndroid Build Coastguard Worker- A modifier predicate. The predicate consists of a matching operation
205*2b949d04SAndroid Build Coastguard Worker  and a mask of (real) modifiers. The modifiers are matched against
206*2b949d04SAndroid Build Coastguard Worker  the key's modifier map (modmap). The matching operation can be one
207*2b949d04SAndroid Build Coastguard Worker  of the following:
208*2b949d04SAndroid Build Coastguard Worker
209*2b949d04SAndroid Build Coastguard Worker  * `AnyOfOrNone` - The modmap must either be empty or include at
210*2b949d04SAndroid Build Coastguard Worker    least one of the specified modifiers.
211*2b949d04SAndroid Build Coastguard Worker  * `AnyOf` - The modmap must include at least one of the specified
212*2b949d04SAndroid Build Coastguard Worker    modifiers.
213*2b949d04SAndroid Build Coastguard Worker  * `NoneOf` - The modmap must not include any of the specified
214*2b949d04SAndroid Build Coastguard Worker    modifiers.
215*2b949d04SAndroid Build Coastguard Worker  * `AllOf` - The modmap must include all of the specified modifiers
216*2b949d04SAndroid Build Coastguard Worker    (but may include others as well).
217*2b949d04SAndroid Build Coastguard Worker  * `Exactly` - The modmap must be exactly the same as the specified
218*2b949d04SAndroid Build Coastguard Worker    modifiers.
219*2b949d04SAndroid Build Coastguard Worker
220*2b949d04SAndroid Build Coastguard Worker  Leaving out the predicate is equivalent to using `AnyOfOrNone` while
221*2b949d04SAndroid Build Coastguard Worker  specifying all modifiers. Leaving out just the matching condition is
222*2b949d04SAndroid Build Coastguard Worker  equivalent to using `Exactly`.
223*2b949d04SAndroid Build Coastguard Worker
224*2b949d04SAndroid Build Coastguard WorkerAn interpret may also include `useModMapMods = level1;` - see below.
225*2b949d04SAndroid Build Coastguard Worker
226*2b949d04SAndroid Build Coastguard WorkerIf a level fulfils the conditions of several interprets, only the
227*2b949d04SAndroid Build Coastguard Workermost specific one is used:
228*2b949d04SAndroid Build Coastguard Worker
229*2b949d04SAndroid Build Coastguard Worker- A specific keysym will always match before a generic `NoSymbol`
230*2b949d04SAndroid Build Coastguard Worker  condition.
231*2b949d04SAndroid Build Coastguard Worker
232*2b949d04SAndroid Build Coastguard Worker- If the keysyms are the same, the interpret with the more specific
233*2b949d04SAndroid Build Coastguard Worker  matching operation is used. The above list is sorted from least to
234*2b949d04SAndroid Build Coastguard Worker  most specific.
235*2b949d04SAndroid Build Coastguard Worker
236*2b949d04SAndroid Build Coastguard Worker- If both the keysyms and the matching operations are the same (but the
237*2b949d04SAndroid Build Coastguard Worker  modifiers are different), the first interpret is used.
238*2b949d04SAndroid Build Coastguard Worker
239*2b949d04SAndroid Build Coastguard WorkerAs described above, once an interpret "attaches" to a level, it can bind
240*2b949d04SAndroid Build Coastguard Workeran action to that level, add one virtual modifier to the key's vmodmap,
241*2b949d04SAndroid Build Coastguard Workeror set the key's repeat setting. You should note the following:
242*2b949d04SAndroid Build Coastguard Worker
243*2b949d04SAndroid Build Coastguard Worker- The key repeat is a property of the entire key; it is not
244*2b949d04SAndroid Build Coastguard Worker  level-specific. In order to avoid confusion, it is only inspected
245*2b949d04SAndroid Build Coastguard Worker  for the first level of the first group; the interpret's repeat
246*2b949d04SAndroid Build Coastguard Worker  setting is ignored when applied to other levels.
247*2b949d04SAndroid Build Coastguard Worker
248*2b949d04SAndroid Build Coastguard Worker- If one of the above fields was set directly for a key in
249*2b949d04SAndroid Build Coastguard Worker  `xkb_symbols`, the explicit setting takes precedence over the
250*2b949d04SAndroid Build Coastguard Worker  interpret.
251*2b949d04SAndroid Build Coastguard Worker
252*2b949d04SAndroid Build Coastguard WorkerThe body of the statement may include statements of the following
253*2b949d04SAndroid Build Coastguard Workerforms (all of which are optional):
254*2b949d04SAndroid Build Coastguard Worker
255*2b949d04SAndroid Build Coastguard Worker#### `useModMapMods` statement
256*2b949d04SAndroid Build Coastguard Worker
257*2b949d04SAndroid Build Coastguard Worker    useModMapMods = level1;
258*2b949d04SAndroid Build Coastguard Worker
259*2b949d04SAndroid Build Coastguard WorkerWhen set to `level1`, the interpret will only match levels which are
260*2b949d04SAndroid Build Coastguard Workerthe first level of the first group of the keys. This can be useful in
261*2b949d04SAndroid Build Coastguard Workerconjunction with e.g. a `virtualModifier` statement.
262*2b949d04SAndroid Build Coastguard Worker
263*2b949d04SAndroid Build Coastguard Worker#### `action` statement
264*2b949d04SAndroid Build Coastguard Worker
265*2b949d04SAndroid Build Coastguard Worker    action = LockMods(modifiers=NumLock);
266*2b949d04SAndroid Build Coastguard Worker
267*2b949d04SAndroid Build Coastguard WorkerBind this action to the matching levels.
268*2b949d04SAndroid Build Coastguard Worker
269*2b949d04SAndroid Build Coastguard Worker#### `virtualModifier` statement
270*2b949d04SAndroid Build Coastguard Worker
271*2b949d04SAndroid Build Coastguard Worker    virtualModifier = NumLock;
272*2b949d04SAndroid Build Coastguard Worker
273*2b949d04SAndroid Build Coastguard WorkerAdd this virtual modifier to the key's vmodmap. The given virtual
274*2b949d04SAndroid Build Coastguard Workermodifier must be declared at the top level of the file with a
275*2b949d04SAndroid Build Coastguard Worker`virtual_modifiers` statement, e.g.:
276*2b949d04SAndroid Build Coastguard Worker
277*2b949d04SAndroid Build Coastguard Worker    virtual_modifiers NumLock;
278*2b949d04SAndroid Build Coastguard Worker
279*2b949d04SAndroid Build Coastguard Worker#### `repeat` statement
280*2b949d04SAndroid Build Coastguard Worker
281*2b949d04SAndroid Build Coastguard Worker    repeat = True;
282*2b949d04SAndroid Build Coastguard Worker
283*2b949d04SAndroid Build Coastguard WorkerSet whether the key should repeat or not. Must be a boolean value.
284*2b949d04SAndroid Build Coastguard Worker
285*2b949d04SAndroid Build Coastguard Worker### LED map statements
286*2b949d04SAndroid Build Coastguard Worker
287*2b949d04SAndroid Build Coastguard WorkerStatements of the form:
288*2b949d04SAndroid Build Coastguard Worker
289*2b949d04SAndroid Build Coastguard Worker    indicator "Shift Lock" { ... }
290*2b949d04SAndroid Build Coastguard Worker
291*2b949d04SAndroid Build Coastguard WorkerThis statement specifies the behavior and binding of the LED (AKA
292*2b949d04SAndroid Build Coastguard Workerindicator) with the given name ("Shift Lock" above). The name should
293*2b949d04SAndroid Build Coastguard Workerhave been declared previously in the `xkb_keycodes` section (see LED
294*2b949d04SAndroid Build Coastguard Workername statement), and given an index there. If it wasn't, it is created
295*2b949d04SAndroid Build Coastguard Workerwith the next free index.
296*2b949d04SAndroid Build Coastguard Worker
297*2b949d04SAndroid Build Coastguard WorkerThe body of the statement describes the conditions of the keyboard
298*2b949d04SAndroid Build Coastguard Workerstate which will cause the LED to be lit. It may include the following
299*2b949d04SAndroid Build Coastguard Workerstatements:
300*2b949d04SAndroid Build Coastguard Worker
301*2b949d04SAndroid Build Coastguard Worker#### `modifiers` statement
302*2b949d04SAndroid Build Coastguard Worker
303*2b949d04SAndroid Build Coastguard Worker    modifiers = ScrollLock;
304*2b949d04SAndroid Build Coastguard Worker
305*2b949d04SAndroid Build Coastguard WorkerIf the given modifiers are in the required state (see below), the
306*2b949d04SAndroid Build Coastguard WorkerLED is lit.
307*2b949d04SAndroid Build Coastguard Worker
308*2b949d04SAndroid Build Coastguard Worker#### `whichModState` statement
309*2b949d04SAndroid Build Coastguard Worker
310*2b949d04SAndroid Build Coastguard Worker    whichModState = Latched+Locked;
311*2b949d04SAndroid Build Coastguard Worker
312*2b949d04SAndroid Build Coastguard WorkerCan be any combination of:
313*2b949d04SAndroid Build Coastguard Worker
314*2b949d04SAndroid Build Coastguard Worker* `base`, `latched`, `locked`, `effective`
315*2b949d04SAndroid Build Coastguard Worker* `any` (i.e. all of the above)
316*2b949d04SAndroid Build Coastguard Worker* `none` (i.e. none of the above)
317*2b949d04SAndroid Build Coastguard Worker* `compat` (legacy value, treated as effective)
318*2b949d04SAndroid Build Coastguard Worker
319*2b949d04SAndroid Build Coastguard WorkerThis will cause the respective portion of the modifier state (see
320*2b949d04SAndroid Build Coastguard Worker`struct xkb_state`) to be matched against the modifiers given in the
321*2b949d04SAndroid Build Coastguard Worker`modifiers` statement.
322*2b949d04SAndroid Build Coastguard Worker
323*2b949d04SAndroid Build Coastguard WorkerHere's a simple example:
324*2b949d04SAndroid Build Coastguard Worker
325*2b949d04SAndroid Build Coastguard Workerindicator "Num Lock" {
326*2b949d04SAndroid Build Coastguard Worker    modifiers = NumLock;
327*2b949d04SAndroid Build Coastguard Worker    whichModState = Locked;
328*2b949d04SAndroid Build Coastguard Worker};
329*2b949d04SAndroid Build Coastguard Worker
330*2b949d04SAndroid Build Coastguard WorkerWhenever the NumLock modifier is locked, the Num Lock LED will light
331*2b949d04SAndroid Build Coastguard Workerup.
332*2b949d04SAndroid Build Coastguard Worker
333*2b949d04SAndroid Build Coastguard Worker#### `groups` statement
334*2b949d04SAndroid Build Coastguard Worker
335*2b949d04SAndroid Build Coastguard Worker    groups = All - group1;
336*2b949d04SAndroid Build Coastguard Worker
337*2b949d04SAndroid Build Coastguard WorkerIf the given groups are in the required state (see below), the LED is
338*2b949d04SAndroid Build Coastguard Workerlit.
339*2b949d04SAndroid Build Coastguard Worker
340*2b949d04SAndroid Build Coastguard Worker#### `whichGroupState` statement
341*2b949d04SAndroid Build Coastguard Worker
342*2b949d04SAndroid Build Coastguard Worker    whichGroupState = Effective;
343*2b949d04SAndroid Build Coastguard Worker
344*2b949d04SAndroid Build Coastguard WorkerCan be any combination of:
345*2b949d04SAndroid Build Coastguard Worker
346*2b949d04SAndroid Build Coastguard Worker* `base`, `latched`, `locked`, `effective`
347*2b949d04SAndroid Build Coastguard Worker* `any` (i.e. all of the above)
348*2b949d04SAndroid Build Coastguard Worker* `none` (i.e. none of the above)
349*2b949d04SAndroid Build Coastguard Worker
350*2b949d04SAndroid Build Coastguard WorkerThis will cause the respective portion of the group state (see
351*2b949d04SAndroid Build Coastguard Worker`struct xkb_state`) to be matched against the groups given in the
352*2b949d04SAndroid Build Coastguard Worker`groups` statement.
353*2b949d04SAndroid Build Coastguard Worker
354*2b949d04SAndroid Build Coastguard WorkerNote: the above conditions are disjunctive, i.e. if any of them are
355*2b949d04SAndroid Build Coastguard Workersatisfied the LED is lit.
356*2b949d04SAndroid Build Coastguard Worker
357*2b949d04SAndroid Build Coastguard Worker
358*2b949d04SAndroid Build Coastguard Worker## The `xkb_symbols` section
359*2b949d04SAndroid Build Coastguard Worker
360*2b949d04SAndroid Build Coastguard WorkerNOTE: The documentation of this section is incomplete.
361*2b949d04SAndroid Build Coastguard Worker
362*2b949d04SAndroid Build Coastguard WorkerThis section is the fourth to be processed, after `xkb_keycodes`, `xkb_types`
363*2b949d04SAndroid Build Coastguard Workerand `xkb_compat`.
364*2b949d04SAndroid Build Coastguard Worker
365*2b949d04SAndroid Build Coastguard WorkerStatements of the form:
366*2b949d04SAndroid Build Coastguard Worker
367*2b949d04SAndroid Build Coastguard Worker    xkb_symbols "basic" {
368*2b949d04SAndroid Build Coastguard Worker        ...
369*2b949d04SAndroid Build Coastguard Worker    }
370*2b949d04SAndroid Build Coastguard Worker
371*2b949d04SAndroid Build Coastguard WorkerDeclare a symbols map named `basic`. Statements inside the curly braces only
372*2b949d04SAndroid Build Coastguard Workeraffect the symbols map.
373*2b949d04SAndroid Build Coastguard Worker
374*2b949d04SAndroid Build Coastguard WorkerA map can have various flags applied to it above the statement, separated by
375*2b949d04SAndroid Build Coastguard Workerwhitespace:
376*2b949d04SAndroid Build Coastguard Worker
377*2b949d04SAndroid Build Coastguard Worker    partial alphanumeric_keys
378*2b949d04SAndroid Build Coastguard Worker    xkb_symbols "basic" {
379*2b949d04SAndroid Build Coastguard Worker        ...
380*2b949d04SAndroid Build Coastguard Worker    }
381*2b949d04SAndroid Build Coastguard Worker
382*2b949d04SAndroid Build Coastguard WorkerThe possible flags are:
383*2b949d04SAndroid Build Coastguard Worker
384*2b949d04SAndroid Build Coastguard Worker  * `partial` - Indicates that the map doesn't cover a complete keyboard.
385*2b949d04SAndroid Build Coastguard Worker  * `default` - Marks the symbol map as the default map in the file when no
386*2b949d04SAndroid Build Coastguard Worker    explicit map is specified. If no map is marked as a default, the first map
387*2b949d04SAndroid Build Coastguard Worker    in the file is the default.
388*2b949d04SAndroid Build Coastguard Worker  * `hidden` - Variant that can only be used internally
389*2b949d04SAndroid Build Coastguard Worker  * `alphanumeric_keys` - Indicates that the map contains alphanumeric keys
390*2b949d04SAndroid Build Coastguard Worker  * `modifier_keys` - Indicates that the map contains modifier keys
391*2b949d04SAndroid Build Coastguard Worker  * `keypad_keys` - Indicates that the map contains keypad keys
392*2b949d04SAndroid Build Coastguard Worker  * `function_keys` - Indicates that the map contains function keys
393*2b949d04SAndroid Build Coastguard Worker  * `alternate_group` - Indicates that the map contains keys for an alternate
394*2b949d04SAndroid Build Coastguard Worker    group
395*2b949d04SAndroid Build Coastguard Worker
396*2b949d04SAndroid Build Coastguard WorkerIf no `*_keys` flags are supplied, then the map is assumed to cover a complete
397*2b949d04SAndroid Build Coastguard Workerkeyboard.
398*2b949d04SAndroid Build Coastguard Worker
399*2b949d04SAndroid Build Coastguard WorkerAt present, except for `default`, none of the flags affect key processing in
400*2b949d04SAndroid Build Coastguard Workerlibxkbcommon, and only serve as metadata.
401*2b949d04SAndroid Build Coastguard Worker
402*2b949d04SAndroid Build Coastguard Worker### Name statements
403*2b949d04SAndroid Build Coastguard Worker
404*2b949d04SAndroid Build Coastguard WorkerStatements of the form:
405*2b949d04SAndroid Build Coastguard Worker
406*2b949d04SAndroid Build Coastguard Worker    name[Group1] = "US/ASCII";
407*2b949d04SAndroid Build Coastguard Worker    groupName[1] = "US/ASCII";
408*2b949d04SAndroid Build Coastguard Worker
409*2b949d04SAndroid Build Coastguard WorkerGives the name "US/ASCII" to the first group of symbols. Other groups can be
410*2b949d04SAndroid Build Coastguard Workernamed using a different group index (ex: `Group2`), and with a different name.
411*2b949d04SAndroid Build Coastguard WorkerA group must be named.
412*2b949d04SAndroid Build Coastguard Worker
413*2b949d04SAndroid Build Coastguard Worker`group` and `groupName` mean the same thing, and the `Group` in `Group1` is
414*2b949d04SAndroid Build Coastguard Workeroptional.
415*2b949d04SAndroid Build Coastguard Worker
416*2b949d04SAndroid Build Coastguard Worker### Include statements
417*2b949d04SAndroid Build Coastguard Worker
418*2b949d04SAndroid Build Coastguard WorkerStatements of the form:
419*2b949d04SAndroid Build Coastguard Worker
420*2b949d04SAndroid Build Coastguard Worker    include "nokia_vndr/rx-51(nordic_base)
421*2b949d04SAndroid Build Coastguard Worker
422*2b949d04SAndroid Build Coastguard WorkerWill include data from another `xkb_symbols` section, possibly located in
423*2b949d04SAndroid Build Coastguard Workeranother file. Here it would include the `xkb_symbols` section called
424*2b949d04SAndroid Build Coastguard Worker`nordic_base`, from the file `rx-51` located in the `nokia_vndr` folder, itself
425*2b949d04SAndroid Build Coastguard Workerlocated in an XKB include path.
426*2b949d04SAndroid Build Coastguard Worker
427*2b949d04SAndroid Build Coastguard Worker### Key statement
428*2b949d04SAndroid Build Coastguard Worker
429*2b949d04SAndroid Build Coastguard WorkerStatements of the form:
430*2b949d04SAndroid Build Coastguard Worker
431*2b949d04SAndroid Build Coastguard Worker    key <AD01> { [ q, Q ] };
432*2b949d04SAndroid Build Coastguard Worker
433*2b949d04SAndroid Build Coastguard WorkerDescribes the mapping of a keycode `<AD01>` to a given group of symbols. The
434*2b949d04SAndroid Build Coastguard Workerpossible keycodes are the keycodes defined in the `xkb_keycodes` section.
435*2b949d04SAndroid Build Coastguard Worker
436*2b949d04SAndroid Build Coastguard WorkerSymbols are named using the symbolic names from the
437*2b949d04SAndroid Build Coastguard Worker`xkbcommon/xkbcommon-keysyms.h` file. A group of symbols is enclosed in brackets
438*2b949d04SAndroid Build Coastguard Workerand separated by commas. Each element of the symbol arrays corresponds to a
439*2b949d04SAndroid Build Coastguard Workerdifferent modifier level. In this example, the symbol (keysym) `XKB_KEY_q` for
440*2b949d04SAndroid Build Coastguard Workerlevel 1 and `XKB_KEY_Q` for level 2.
441*2b949d04SAndroid Build Coastguard Worker
442*2b949d04SAndroid Build Coastguard Worker#### Groups
443*2b949d04SAndroid Build Coastguard Worker
444*2b949d04SAndroid Build Coastguard WorkerEach group represents a list of symbols mapped to a keycode:
445*2b949d04SAndroid Build Coastguard Worker
446*2b949d04SAndroid Build Coastguard Worker    name[Group1]= "US/ASCII";
447*2b949d04SAndroid Build Coastguard Worker    name[Group2]= "Russian";
448*2b949d04SAndroid Build Coastguard Worker    ...
449*2b949d04SAndroid Build Coastguard Worker    key <AD01> { [ q, Q ],
450*2b949d04SAndroid Build Coastguard Worker                 [ Cyrillic_shorti, Cyrillic_SHORTI ] };
451*2b949d04SAndroid Build Coastguard Worker
452*2b949d04SAndroid Build Coastguard WorkerA long-form syntax can also be used:
453*2b949d04SAndroid Build Coastguard Worker
454*2b949d04SAndroid Build Coastguard Worker    key <AD01> {
455*2b949d04SAndroid Build Coastguard Worker        symbols[Group1]= [ q, Q ],
456*2b949d04SAndroid Build Coastguard Worker        symbols[Group2]= [ Cyrillic_shorti, Cyrillic_SHORTI ]
457*2b949d04SAndroid Build Coastguard Worker    };
458*2b949d04SAndroid Build Coastguard Worker
459*2b949d04SAndroid Build Coastguard WorkerGroups can also be omitted, but the brackets must be present. The following
460*2b949d04SAndroid Build Coastguard Workerstatement only defines the Group3 of a mapping:
461*2b949d04SAndroid Build Coastguard Worker
462*2b949d04SAndroid Build Coastguard Worker    key <AD01> { [], [], [ q, Q ] };
463*2b949d04SAndroid Build Coastguard Worker
464*2b949d04SAndroid Build Coastguard Worker## Virtual modifier statements
465*2b949d04SAndroid Build Coastguard Worker
466*2b949d04SAndroid Build Coastguard WorkerStatements of the form:
467*2b949d04SAndroid Build Coastguard Worker
468*2b949d04SAndroid Build Coastguard Worker    virtual_modifiers LControl;
469*2b949d04SAndroid Build Coastguard Worker
470*2b949d04SAndroid Build Coastguard WorkerCan appear in the `xkb_types`, `xkb_compat`, `xkb_symbols` sections.
471*2b949d04SAndroid Build Coastguard Worker
472*2b949d04SAndroid Build Coastguard WorkerTODO
473