aboutsummaryrefslogtreecommitdiff
path: root/libX11/specs/XKB/ch12.xml
blob: 928d8382891965792b0abbb43e0b1e64b7dae74c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
<chapter id='Interpreting_Key_Events'>
<title>Interpreting Key Events</title>

<para>
Xkb provides functions to help developers interpret key events without having
to directly interpret Xkb data structures. Xkb also modifies the behavior of
several core X library functions.
</para>

<sect1 id='Effects_of_Xkb_on_the_Core_X_Library'>
<title>Effects of Xkb on the Core X Library</title>

<para>
When support for Xkb is built into the X library, the <emphasis>
XOpenDisplay</emphasis>
 function looks for a compatible version of Xkb on the server. If it finds a
compatible version, it initializes the extension and enables <emphasis>
implicit support</emphasis>
 for Xkb in a number of X library functions. This makes it possible for clients
to take advantage of nearly all Xkb features without having to be rewritten or
even recompiled, if they are built with shared libraries. This implicit support
is invisible to most clients, but it can have side effects, so the extension
includes ways to control or disable it.
</para>


<sect2 id='Effects_of_Xkb_on_Event_State'>
<title>Effects of Xkb on Event State</title>

<para>
Because <emphasis>
XOpenDisplay</emphasis>
 initializes Xkb, some events contain an Xkb description of the keyboard state
instead of that normally used by the core protocol. See section 17.1.1 for more
information about the differences between Xkb keyboard state and that reported
by the core protocol.
</para>


</sect2>
<sect2 id='Effects_of_Xkb_on_MappingNotify_Events'>
<title>Effects of Xkb on MappingNotify Events</title>

<para>
When Xkb is missing or disabled, the X library tracks changes to the keyboard
mapping using <emphasis>
MappingNotify</emphasis>
 events. Whenever the keyboard mapping is changed, the server sends all clients
a <emphasis>
MappingNotify</emphasis>
 event to report the change. When a client receives a <emphasis>
MappingNotify</emphasis>
 event, it is supposed to call <emphasis>
XRefreshKeyboardMapping</emphasis>
 to update the keyboard description used internally by the X library.
</para>


<para>
The X Keyboard Extension uses <emphasis>
XkbMapNotify</emphasis>
 and <emphasis>
XkbNewKeyboardNotify</emphasis>
 events to track changes to the keyboard mapping. When an Xkb-aware client
receives either event, it should call <emphasis>
XkbRefreshKeyboardMapping</emphasis>
 to update the keyboard description used internally by the X library. To avoid
duplicate events, the X server does not send core protocol <emphasis>
MappingNotify</emphasis>
 events to a client that has selected for <emphasis>
XkbMapNotify</emphasis>
 events.
</para>


<para>
The implicit support for Xkb selects for <emphasis>
XkbMapNotify</emphasis>
 events. This means that clients that do not explicitly use Xkb but that are
using a version of the X library that has implicit support for Xkb do not
receive <emphasis>
MappingNotify</emphasis>
 events over the wire. Clients that were not written with Xkb in mind do not
recognize or properly handle the new Xkb events, so the implicit support
converts them to <emphasis>
MappingNotify</emphasis>
 events that report approximately the same information, unless the client has
explicitly selected for the Xkb version of the event.
</para>


<para>
An Xkb-capable X server does not send events from keys that fall outside the
legal range of keycodes expected by that client. Once the server sends a client
an <emphasis>
XkbNewKeyboardNotify</emphasis>
 event, it reports events from all keys because it assumes that any client that
has receieved an <emphasis>
XkbNewKeyboardNotify</emphasis>
 event expects key events from the new range of keycodes. The implicit support
for Xkb asks for <emphasis>
XkbNewKeyboardNotify</emphasis>
 events, so the range of keycodes reported to the client might vary without the
client’s knowledge. Most clients don’t really care about the range of legal
keycodes, but some clients maintain information about each key and might have
problems with events that come from unexpected keys. Such clients can set the
<emphasis>
XkbLC_IgnoreNewKeyboards</emphasis>
 library control (see section 11.3.1) to prevent the implicit support from
requesting notification of changes to the legal range of keycodes.
</para>


</sect2>
<sect2 id='X_Library_Functions_Affected_by_Xkb'>
<title>X Library Functions Affected by Xkb</title>

<para>
The following X library functions are modified by Xkb:
</para>

<para><programlisting>
     <emphasis>XKeycodeToKeysym</emphasis>
     <emphasis>XKeysymToKeycode</emphasis>
     <emphasis>XLookupKeysym</emphasis>
     <emphasis>XLookupString</emphasis>
     <emphasis>XRefreshKeyboardMapping</emphasis>
     <emphasis>XRebindKeysym</emphasis>
</programlisting></para>

<para>
The implicit support for Xkb replaces a number of X library functions with
versions that understand and use the X Keyboard Extension. In most cases, the
semantics of the new versions are identical to those of the old, but there are
occasional visible differences. This section lists all of the functions that
are affected and the differences in behavior, if any, that are visible to
clients.
</para>


<para>
The <emphasis>
XKeycodeToKeysym</emphasis>
 function reports the keysym associated with a particular index for a single
key. The index specifies a column of symbols in the core keyboard mapping (that
is, as reported by the core protocol <emphasis>
GetKeyboardMapping</emphasis>
 request). The order of the symbols in the core mapping does not necessarily
correspond to the order of the symbols used by Xkb; section 17.1.3 describes
the differences.
</para>


<para>
The <emphasis>
XKeysymToKeycode</emphasis>
 function reports a keycode to which a particular keysym is bound. When Xkb is
missing or disabled, this function looks in each column of the core keyboard
mapping in turn and returns the lowest numbered key that matches in the lowest
numbered group. When Xkb is present, this function uses the Xkb ordering for
symbols instead.
</para>


<para>
The <emphasis>
XLookupKeysym</emphasis>
 function reports the symbol in a specific column of the key associated with an
event. Whether or not Xkb is present, the column specifies an index into the
core symbol mapping.
</para>


<para>
The <emphasis>
XLookupString</emphasis>
 function reports the symbol and string associated with a key event, taking
into account the keycode and keyboard state as reported in the event. When Xkb
is disabled or missing, <emphasis>
XLookupString</emphasis>
 uses the rules specified by the core protocol and reports only ISO Latin-1
characters. When Xkb is present, <emphasis>
XLookupString</emphasis>
 uses the explicit keyboard group, key types, and rules specified by Xkb. When
Xkb is present, <emphasis>
XLookupString</emphasis>
 is allowed, but not required, to return strings in character sets other than
ISO Latin-1, depending on the current locale. If any key bindings are defined,
<emphasis>
XLookupString</emphasis>
 does not use any consumed modifiers (see sections 11.1.2 and 15.2) to
determine matching bindings.
</para>


<para>
The <emphasis>
XRefreshKeyboardMapping</emphasis>
 function updates the X library’s internal representation of the keyboard to
reflect changes reported via <emphasis>
MappingNotify</emphasis>
 events. When Xkb is missing or disabled, this function reloads the entire
modifier map or keyboard mapping. When Xkb is present, the implicit Xkb support
keeps track of the changed components reported by each <emphasis>
XkbMapNotify</emphasis>
 event and updates only those pieces of the keyboard description that have
changed. If the implicit support has not noted any keyboard mapping changes,
<emphasis>
XRefreshKeyboardMapping</emphasis>
 updates the entire keyboard description.
</para>


<para>
The <emphasis>
XRebindKeysym</emphasis>
 function associates a string with a keysym and a set of modifiers. Xkb does
not directly change this function, but it does affect the way that the state
reported in the event is compared to the state specified to <emphasis>
XRebindKeysym</emphasis>
. When Xkb is missing or disabled, <emphasis>
XLookupString</emphasis>
 returns the specified string if the modifiers in the event exactly match the
modifiers from this call. When Xkb is present, any modifiers used to determine
the keysym are consumed and are not used to look up the string.
</para>


</sect2>
</sect1>
<sect1 id='Xkb_Event_and_Keymap_Functions'>
<title>Xkb Event and Keymap Functions</title>

<para>
To find the keysym bound to a particular key at a specified group and shift
level, use <emphasis>XkbKeycodeToKeysym</emphasis>.
</para>

<informaltable frame='none'>
<tgroup cols='1'>
<colspec colsep='0'/>
<tbody>
  <row rowsep='0'>
    <entry role='functiondecl'>
KeySym <emphasis>
XkbKeycodeToKeysym</emphasis>
(<emphasis>
dpy, kc, group, level</emphasis>
)
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
Display *            dpy;            /* connection to X server */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
KeyCode            kc;            /* key of interest */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
unsigned int            group;            /* group of interest */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
unsigned int            level;            /* shift level of interest */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

<para>
<emphasis>
XkbKeycodeToKeysym</emphasis>
 returns the keysym bound to a particular group and shift level for a
particular key on the core keyboard. If <emphasis>
kc</emphasis>
 is not a legal keycode for the core keyboard, or if <emphasis>
group</emphasis>
 or <emphasis>
level</emphasis>
 are out of range for the specified key, <emphasis>
XkbKeycodeToKeysym</emphasis>
 returns <emphasis>
NoSymbol</emphasis>
.
</para>


<para>
To find the set of modifiers bound to a particular keysym on the core keyboard,
use <emphasis>
XkbKeysymToModifiers</emphasis>
.
</para>


<informaltable frame='none'>
<tgroup cols='1'>
<colspec colsep='0'/>
<tbody>
  <row rowsep='0'>
    <entry role='functiondecl'>
unsigned<emphasis>
 </emphasis>
int <emphasis>
XkbKeysymToModifiers</emphasis>
(<emphasis>
dpy</emphasis>
,<emphasis>
 ks</emphasis>
)
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
Display *<emphasis>
            dpy</emphasis>
;            /* connection to X server */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
KeySym <emphasis>
            ks</emphasis>
;            /* keysym of interest */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

<para>
<emphasis>
XkbKeysymToModifiers</emphasis>
 finds the set of modifiers currently bound to the keysym <emphasis>
ks</emphasis>
 on the core keyboard. The value returned is the mask of modifiers bound to the
keysym <emphasis>
ks</emphasis>
. If no modifiers are bound to the keysym, <emphasis>
XkbKeysymToModifiers</emphasis>
 returns zero; otherwise, it returns the inclusive OR of zero or more of the
following: <emphasis>
ShiftMask</emphasis>
, <emphasis>
ControlMask</emphasis>
, <emphasis>
LockMask</emphasis>
, <emphasis>
Mod1Mask</emphasis>
, <emphasis>
Mod2Mask</emphasis>
, <emphasis>
Mod3Mask</emphasis>
, <emphasis>
Mod4Mask,</emphasis>
 and <emphasis>
Mod5Mask</emphasis>
.
</para>


<para>
Use <emphasis>
XkbLookupKeySym</emphasis>
 to find the symbol associated with a key for a particular state.
</para>


<informaltable frame='none'>
<tgroup cols='1'>
<colspec colsep='0'/>
<tbody>
  <row rowsep='0'>
    <entry role='functiondecl'>
Bool <emphasis>
XkbLookupKeySym</emphasis>
(<emphasis>
dpy</emphasis>
,<emphasis>
 key</emphasis>
,<emphasis>
 state</emphasis>
,<emphasis>
 mods_rtrn</emphasis>
,<emphasis>
 sym_rtrn</emphasis>
)
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
Display * <emphasis>
            dpy</emphasis>
;            /* connection to X server */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
KeyCode <emphasis>
            key</emphasis>
;            /* key for which symbols are to be found */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
unsigned int <emphasis>
            state</emphasis>
;            /* state for which symbol should be found */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
unsigned int * <emphasis>
            mods_rtrn</emphasis>
;            /* backfilled with unconsumed modifiers */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
KeySym *<emphasis>
            sym_rtrn</emphasis>
;            /* backfilled with symbol associated with key + state */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

<para>
<emphasis>
XkbLookupKeySym</emphasis>
 is the equivalent of the core <emphasis>
XLookupKeySym</emphasis>
 function. For the core keyboard, given a keycode <emphasis>
key</emphasis>
 and an Xkb state <emphasis>
state</emphasis>
, <emphasis>
XkbLookupKeySym</emphasis>
 returns the symbol associated with the key  in <emphasis>
sym_rtrn</emphasis>
 and the list of modifiers that should still be applied in <emphasis>
mods_rtrn</emphasis>
. The <emphasis>
state</emphasis>
 parameter is the state from a <emphasis>
KeyPress</emphasis>
 or <emphasis>
KeyRelease</emphasis>
 event. <emphasis>
XkbLookupKeySym</emphasis>
 returns <emphasis>
True</emphasis>
 if it succeeds.
</para>


<para>
Use <emphasis>
XkbLookupKeyBinding</emphasis>
 to find the string bound to a key by <emphasis>
XRebindKeySym</emphasis>
. <emphasis>
XkbLookupKeyBinding</emphasis>
 is the equivalent of the core <emphasis>
XLookupString</emphasis>
 function.
</para>


<informaltable frame='none'>
<tgroup cols='1'>
<colspec colsep='0'/>
<tbody>
  <row rowsep='0'>
    <entry role='functiondecl'>
int <emphasis>
XkbLookupKeyBinding</emphasis>
(<emphasis>
dpy</emphasis>
,<emphasis>
 sym</emphasis>
,<emphasis>
 state</emphasis>
,<emphasis>
 buf</emphasis>
,<emphasis>
 nbytes</emphasis>
,<emphasis>
 extra_rtrn</emphasis>
)
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
Display * <emphasis>
            dpy</emphasis>
;            /* connection to server */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
KeySym<emphasis>
            sym</emphasis>
;            /* symbol to be looked up */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
unsigned int            <emphasis>
state</emphasis>
;            /* state for which string is to be looked up */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
char * <emphasis>
            buf</emphasis>
;            /* buffer into which returned string is written */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
int <emphasis>
            nbytes</emphasis>
;            /* size of buffer in bytes */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
int * <emphasis>
            extra_rtrn</emphasis>
;            /* backfilled with number bytes overflow */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

<para>
<emphasis>
XRebindKeysym</emphasis>
 binds an ASCII string to a specified keysym, so that the string and keysym are
returned when the key is pressed and a specified list of modifiers are also
being held down. <emphasis>
XkbLookupKeyBinding</emphasis>
 returns in <emphasis>
buf</emphasis>
 the string associated with the keysym <emphasis>
sym</emphasis>
 and modifier state <emphasis>
state</emphasis>
. <emphasis>
buf</emphasis>
 is <emphasis>
NULL</emphasis>
 terminated unless there’s an overflow. If the string returned is larger than
<emphasis>
nbytes</emphasis>
, a count of bytes that does not fit into the buffer is returned in extra_rtrn.
<emphasis>
XkbTranslateKeySym</emphasis>
 returns the number of bytes that it placed into <emphasis>
buf</emphasis>
.
</para>


<para>
To find the string and symbol associated with a keysym for a given keyboard
state, use <emphasis>
XkbTranslateKeySym</emphasis>
.
</para>


<informaltable frame='none'>
<tgroup cols='1'>
<colspec colsep='0'/>
<tbody>
  <row rowsep='0'>
    <entry role='functiondecl'>
int <emphasis>
XkbTranslateKeySym</emphasis>
(<emphasis>
dpy</emphasis>
,<emphasis>
 sym_inout</emphasis>
,<emphasis>
 mods</emphasis>
,<emphasis>
 buf</emphasis>
,<emphasis>
 nbytes</emphasis>
, <emphasis>
extra_rtrn</emphasis>
)
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
Display * <emphasis>
            dpy</emphasis>
;            /* connection to X server */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
KeySym * <emphasis>
            sym_inout</emphasis>
;            /* symbol to be translated; result of translation */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
unsigned int <emphasis>
            mods</emphasis>
;            /* modifiers to apply to <emphasis>
sym_inout</emphasis>
 */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
char * <emphasis>
            buf</emphasis>
;            /* buffer into which returned string is written */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
int <emphasis>
            nbytes</emphasis>
;            /* size of buffer in bytes */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
int *<emphasis>
            extra_rtrn</emphasis>
;            /* number of bytes overflow*/
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

<para>
<emphasis>
XkbTranslateKeySym</emphasis>
 applies the transformations specified in <emphasis>
mods</emphasis>
 to the symbol specified by <emphasis>
sym_inout</emphasis>
. It returns in <emphasis>
buf</emphasis>
 the string, if any, associated with the keysym for the current locale. If the
transformations in <emphasis>
mods</emphasis>
 changes the keysym, <emphasis>
sym_inout</emphasis>
 is updated accordingly. If the string returned is larger than <emphasis>
nbytes</emphasis>
, a count of bytes that does not fit into the buffer is returned in extra_rtrn.
<emphasis>
XkbTranslateKeySym</emphasis>
 returns the number of bytes it placed into <emphasis>
buf</emphasis>
.
</para>


<para>
To update the keyboard description that is internal to the X library, use
<emphasis>
XkbRefreshKeyboardMapping</emphasis>
.
</para>


<informaltable frame='none'>
<tgroup cols='1'>
<colspec colsep='0'/>
<tbody>
  <row rowsep='0'>
    <entry role='functiondecl'>
Status <emphasis>
XkbRefreshKeyboardMapping</emphasis>
(<emphasis>
event)</emphasis>
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
XkbMapNotifyEvent * <emphasis>
            event</emphasis>
;            /* event initiating remapping */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

<para>
<emphasis>
XkbRefreshKeyboardMapping</emphasis>
 is the Xkb equivalent of the core <emphasis>
XRefreshKeyboardMapping</emphasis>
 function. It requests that the X server send the current key mapping
information to this client. A client usually invokes <emphasis>
XkbRefreshKeyboardMapping</emphasis>
 after receiving an <emphasis>
XkbMapNotify</emphasis>
 event. <emphasis>
XkbRefreshKeyboardMapping</emphasis>
 returns <emphasis>
Success</emphasis>
 if it succeeds and <emphasis>
BadMatch</emphasis>
 if the event is not an Xkb event.
</para>


<para>
The <emphasis>
XkbMapNotify</emphasis>
 event can be generated when some client calls <emphasis>
XkbSetMap</emphasis>
, <emphasis>
XkbChangeMap</emphasis>
, <emphasis>
XkbGetKeyboardByName</emphasis>
, or any of the standard X library functions that change the keyboard mapping
or modifier mapping.
</para>


<para>
To translate a keycode to a key symbol and modifiers, use <emphasis>
XkbTranslateKeyCode</emphasis>
.
</para>


<informaltable frame='none'>
<tgroup cols='1'>
<colspec colsep='0'/>
<tbody>
  <row rowsep='0'>
    <entry role='functiondecl'>
Booll <emphasis>
XkbTranslateKeyCode</emphasis>
(<emphasis>
xkb, key, mods, mods_rtrn, keysym_rtrn)</emphasis>
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
XkbDescPtr            <emphasis>
xkb</emphasis>
;            /* keyboard description to use for translation */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
KeyCode            <emphasis>
key</emphasis>
;            /* keycode to translate */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
unsigned int            <emphasis>
mods</emphasis>
;            /* modifiers to apply when translating <emphasis>
key</emphasis>
 */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
unsigned int *            <emphasis>
mods_rtrn</emphasis>
;            /* backfilled with unconsumed modifiers */
    </entry>
  </row>
  <row rowsep='0'>
    <entry role='functionargdecl'>
KeySym *            <emphasis>
keysym_rtrn</emphasis>
;            /* keysym resulting from translation */
    </entry>
</row>
</tbody>
</tgroup>
</informaltable>

<para>
<emphasis>
mods_rtrn</emphasis>
 is backfilled with the modifiers consumed by the translation process.
<emphasis>
mods</emphasis>
 is a bitwise inclusive OR of the legal modifier masks: <emphasis>
ShiftMask</emphasis>
, <emphasis>
LockMask</emphasis>
, <emphasis>
ControlMask</emphasis>
, <emphasis>
Mod1Mask</emphasis>
, <emphasis>
Mod2Mask</emphasis>
, <emphasis>
Mod3Mask</emphasis>
, <emphasis>
Mod4Mask</emphasis>
, <emphasis>
Mod5Mask</emphasis>
.The <emphasis>
AlwaysConsumeShiftAndLock</emphasis>
 library control (see section 11.1.3), if enabled, causes <emphasis>
XkbTranslateKeyCode</emphasis>
 to consume shift and lock.<emphasis>
 XkbTranslateKeyCode</emphasis>
 returns <emphasis>
True</emphasis>
 if the translation resulted in a keysym, and <emphasis>
False</emphasis>
 if it resulted in <emphasis>
NoSymbol</emphasis>
.
</para>
</sect1>
</chapter>