1
2<chapter id='Keyboard_Geometry'>
3<title>Keyboard Geometry</title>
4
5<para>
6The XKB description of a keyboard includes an optional keyboard geometry which
7describes the physical appearance of the keyboard. Keyboard geometry describes
8the shape, location and color of all keyboard keys or other visible keyboard
9components such as indicators. The information contained in a keyboard geometry
10is sufficient to allow a client program to draw an accurate two-dimensional
11image of the keyboard.
12</para>
13
14
15<para>
16The components of the keyboard geometry include the following:
17</para>
18
19<itemizedlist>
20<listitem>
21  <para>A <emphasis>
22symbolic name</emphasis>
23 to help users identify the keyboard.
24  </para>
25</listitem>
26<listitem>
27  <para>The <emphasis>
28width</emphasis>
29 and <emphasis>
30height</emphasis>
31 of the keyboard, in <mediaobject>
32 <imageobject> <imagedata format="SVG" fileref="XKBproto-8.svg"/>
33 </imageobject>
34 </mediaobject>
35. For non-rectangular keyboards, the width and height describe the smallest
36bounding-box that encloses the outline of the keyboard.
37  </para>
38</listitem>
39<listitem>
40  <para>A list of up to <emphasis>
41MaxColors</emphasis>
42 (<emphasis>
4332</emphasis>
44) <emphasis>
45color names</emphasis>
46. A color name is a string whose interpretation is not specified by XKB. Other
47geometry components refer to colors using their indices in this list.
48  </para>
49</listitem>
50<listitem>
51  <para>The<emphasis>
52 base color</emphasis>
53 of the keyboard is the predominant color on the keyboard and is used as the
54default color for any components whose color is not explicitly specified.
55  </para>
56</listitem>
57<listitem>
58  <para>The <emphasis>
59label color</emphasis>
60 is the color used to draw the labels on most of the keyboard keys.
61  </para>
62</listitem>
63<listitem>
64  <para>The <emphasis>
65label font</emphasis>
66 is a string which describes the font used to draw labels on most keys; XKB
67does not specify a format or name space for font names.
68  </para>
69</listitem>
70<listitem>
71  <para>A list of <emphasis>
72geometry properties</emphasis>
73. A geometry property associates an arbitrary string with an equally arbitrary
74name. Geometry properties can be used to provide hints to programs that display
75images of keyboards, but they are not interpreted by XKB. No other geometry
76structures refer to geometry properties.
77  </para>
78</listitem>
79<listitem>
80  <para>A list of <emphasis>
81key aliases</emphasis>
82, as described in <link linkend='Symbolic_Names'>Symbolic
83Names</link>.
84  </para>
85</listitem>
86<listitem>
87  <para>A list of <emphasis>
88shapes</emphasis>
89; other keyboard components refer to shapes by their index in this list. A
90shape consists of a name and one or more closed-polygons called <emphasis>
91outlines</emphasis>
92. Shapes and outlines are described in detail in <link linkend='Shapes_and_Outlines'>Shapes and Outlines</link>.
93  </para>
94</listitem>
95</itemizedlist>
96
97<para>
98Unless otherwise specified, geometry measurements are in <mediaobject>
99 <imageobject> <imagedata format="SVG" fileref="XKBproto-9.svg"/>
100 </imageobject>
101 </mediaobject>
102
103 units. The origin (0,0) is in the top left corner of the keyboard image. Some
104geometry components can be drawn rotated; all such objects rotate about their
105origin in <mediaobject>
106 <imageobject> <imagedata format="SVG" fileref="XKBproto-10.svg"/>
107 </imageobject>
108 </mediaobject>
109
110 increments.
111</para>
112
113
114<para>
115All geometry components include a <emphasis>
116priority</emphasis>
117, which indicates the order in which overlapping objects should be drawn.
118Objects are drawn in order from highest priority (<emphasis>
1190</emphasis>
120) to lowest (<emphasis>
121255</emphasis>
122).
123</para>
124
125
126<para>
127The description of the actual appearance of the keyboard is subdivided into
128named <emphasis>
129sections</emphasis>
130 of related keys and <emphasis>
131doodads</emphasis>
132. A a <emphasis>
133doodad</emphasis>
134 describes some visible aspect of the keyboard that is not a key. A section is
135a collection of keys and doodads that are physically close together and
136logically related.
137</para>
138
139<sect1 id='Shapes_and_Outlines'>
140<title>Shapes and Outlines</title>
141
142<para>
143An outline is a list of one or more points which describes a single
144closed-polygon, as follows:
145</para>
146
147<itemizedlist>
148<listitem>
149  <para>A list with a single point describes a rectangle with one corner at the
150origin of the shape (<emphasis>
1510</emphasis>
152,<emphasis>
1530</emphasis>
154) and the opposite corner at the specified point.
155  </para>
156</listitem>
157<listitem>
158  <para>A list of two points describes a rectangle with one corner at the
159position specified by the first point and the opposite corner at the position
160specified by the second point.
161  </para>
162</listitem>
163<listitem>
164  <para>A list of three or more points describes an arbitrary polygon. If
165necessary, the polygon is automatically closed by connecting the last point in
166the list with the first.
167  </para>
168</listitem>
169<listitem>
170  <para>A non-zero value for the <emphasis>
171cornerRadius</emphasis>
172 field specifies that the corners of the polygon should be drawn as circles
173with the specified radius.
174  </para>
175</listitem>
176</itemizedlist>
177
178<para>
179All points in an outline are specified relative to the origin of the enclosing
180shape. Points in an outline may have negative values for the X and Y coordinate.
181</para>
182
183
184<para>
185One outline (usually the first) is the primary outline; a keyboard display
186application can generate a simpler but still accurate keyboard image by
187displaying only the primary outlines for each shape. Non-rectangular keys must
188include a rectangular <emphasis>
189approximation</emphasis>
190 as one of the outlines associated with the shape; the approximation is not
191normally displayed but can be used by very simple keyboard display applications
192to generate a recognizable but degraded image of the keyboard.
193</para>
194
195
196</sect1>
197<sect1 id='Sections'>
198<title>Sections</title>
199
200<para>
201Each section has its own coordinate system — if a section is rotated, the
202coordinates of any components within the section are interpreted relative to
203the edges that were on the top and left before rotation. The components that
204make up a section include:
205</para>
206
207<itemizedlist>
208<listitem>
209  <para>A list of <emphasis>
210rows</emphasis>
211. A row is a list of horizontally or vertically adjacent keys. Horizontal rows
212parallel the (pre-rotation) top of the section and vertical rows parallel the
213(pre-rotation) left of the section. All keys in a horizontal row share a common
214top coordinate; all keys in a vertical row share a left coordinate.
215  </para>
216<para>
217A key description consists of a key <emphasis>
218name</emphasis>
219, a <emphasis>
220shape</emphasis>
221, a key <emphasis>
222color</emphasis>
223, and a <emphasis>
224gap</emphasis>
225. The key <emphasis>
226name</emphasis>
227 should correspond to one of the keys named in the keyboard names description,
228the <emphasis>
229shape</emphasis>
230 specifies the appearance of the key, and the key <emphasis>
231color</emphasis>
232 specifies the color of the key (not the label on the key). Keys are normally
233drawn immediately adjacent to one another from left-to-right (or top-to-bottom)
234within a row. The <emphasis>
235gap</emphasis>
236 field specifies the distance between a key and its predecessor.
237  </para>
238</listitem>
239<listitem>
240  <para>An optional list of doodads; any type of doodad can be enclosed within
241a section. Position and angle of rotation are relative to the origin and angle
242of rotation of the sections that contain them. Priority is relative to the
243other components of the section, not to the keyboard as a whole.
244  </para>
245</listitem>
246<listitem>
247  <para>An optional list of <emphasis>
248overlay keys</emphasis>
249. Each overlay key definition indicates a key that can yield multiple scan
250codes and consists of a field named <emphasis>
251under</emphasis>
252, which specifies the primary name of the key and a field named <emphasis>
253over</emphasis>
254, which specifies the name for the key when the overlay keycode is selected.
255The key specified in <emphasis>
256under</emphasis>
257 must be a member of the section that contains the overlay key definition,
258while the key specified in over must not.
259  </para>
260</listitem>
261</itemizedlist>
262
263</sect1>
264<sect1 id='Doodads'>
265<title>Doodads</title>
266
267<para>
268Doodads can be global to the keyboard or part of a section. Doodads have
269symbolic names of arbitrary length. The only doodad name whose interpretation
270is specified by XKB is "Edges", which describes the outline of the entire
271keyboard, if present.
272</para>
273
274
275<para>
276All doodads report their origin in fields named <emphasis>
277left</emphasis>
278 and <emphasis>
279top</emphasis>
280. XKB supports five kinds of doodads:
281</para>
282
283<itemizedlist>
284<listitem>
285  <para>An <emphasis>
286indicator doodad</emphasis>
287 describes one of the physical keyboard indicators. Indicator doodads specify
288the shape of the indicator, the indicator color when it is lit (<emphasis>
289on_color</emphasis>
290) and the indicator color when it is dark (<emphasis>
291off_color</emphasis>
292).
293  </para>
294</listitem>
295<listitem>
296  <para>An <emphasis>
297outline doodad</emphasis>
298 describes some aspect of the keyboard to be drawn as one or more hollow,
299closed polygons. Outline doodads specify the shape, color, and angle of
300rotation about the doodad origin at which they should be drawn.
301  </para>
302</listitem>
303<listitem>
304  <para>A <emphasis>
305solid doodad</emphasis>
306 describes some aspect of the keyboard to be drawn as one or more filled
307polygons. Solid doodads specify the shape, color and angle of rotation about
308the doodad origin at which they should be drawn.
309  </para>
310</listitem>
311<listitem>
312  <para>A <emphasis>
313text doodad</emphasis>
314 describes a text label somewhere on the keyboard. Text doodads specify the
315label string, the font and color to use when drawing the label, and the angle
316of rotation of the doodad about its origin.
317  </para>
318</listitem>
319<listitem>
320  <para>A <emphasis>
321logo doodad</emphasis>
322 is a catch-all, which describes some other visible element of the keyboard. A
323logo doodad is essentially an outline doodad with an additional symbolic name
324that describes the element to be drawn.
325  </para>
326  <para>
327If a keyboard display program recognizes the symbolic name, it can draw
328something appropriate within the bounding region of the shape specified in the
329doodad. If the symbolic name does not describe a recognizable image, it should
330draw an outline using the specified shape, outline, and angle of rotation.
331  </para>
332  <para>
333The XKB extension does not specify the interpretation of logo names.
334  </para>
335</listitem>
336</itemizedlist>
337
338</sect1>
339<sect1 id='Keyboard_Geometry_Example'>
340<title>Keyboard Geometry Example</title>
341
342<para>
343Consider the following example keyboard:
344</para>
345
346<mediaobject>
347  <imageobject>
348    <imagedata format="SVG" fileref="XKBproto-11.svg"/>
349  </imageobject>
350</mediaobject>
351
352
353<para>
354This keyboard has six sections: The left and right function sections (at the
355very top) each have one horizontal row with eight keys. The left and right
356alphanumeric sections (the large sections in the middle) each have six vertical
357rows, with four or five keys in each row. The left and right editing sections
358each have three vertical rows with one to three keys per row; the left editing
359section is rotated 20° clockwise about its origin while the right editing
360section is rotated 20° counterclockwise.
361</para>
362
363
364<para>
365This keyboard has four global doodads: Three small, round indicators and a
366rectangular logo. The program which generated this image did not recognize the
367logo, so it displays an outline with an appropriate shape in its place.
368</para>
369
370
371<para>
372This keyboard has seven shapes: All of the keys in the two function sections
373use the "FKEY" shape. Most of the keys in the alphanumeric sections, as well as
374four of the keys in each of the editing sections use the "NORM" shape. The keys
375in the first column of the left alphanumeric section and the last column of the
376right alphanumeric section all use the "WIDE" shape. Two keys in each of the
377editing sections use the "TALL" shape. The "LED" shape describes the three
378small, round indicators between the function and alphabetic sections. The
379"LOGO" shape describes the keyboard logo, and the "EDGE" shape describes the
380outline of the keyboard as a whole.
381</para>
382
383
384<para>
385The keyboard itself is white, as are all of the keys except for the eight keys
386that make up the home row, which use the "grey20" color. It isn’t really
387visible in this picture, but the three indicators have an "on" color of "green"
388and are "green30" when they are turned off. The keys in the alphanumeric and
389editing sections all have a (vertical) gap of 0.5mm; the keys in the two
390function sections have a (horizontal) gap of 3mm.
391</para>
392
393
394<para>
395Many of the keys in the right alphanumeric section, and the rightmost key in
396the right editing section are drawn with two names in this image. Those are
397overlay keys; the bottom key name is the normal name while the overlay name is
398printed at the top. For example, the right editing section has a single overlay
399key entry, which specifies an <emphasis>
400under</emphasis>
401 name of <emphasis>
402&lt;SPCE&gt;</emphasis>
403 and an <emphasis>
404over</emphasis>
405 name of <emphasis>
406&lt;KP0&gt;</emphasis>
407, which indicates that the key in question is usually the shift key, but can
408behave like the <emphasis>
4090</emphasis>
410 key on the numeric keypad when an overlay is active.
411</para>
412</sect1>
413</chapter>
414