1 <chapter id='Attaching_Xkb_Actions_to_X_Input_Extension_Devices'>
2 <title>Attaching Xkb Actions to X Input Extension Devices</title>
5 The X input extension allows an X server to support multiple keyboards, as well
6 as other input devices, in addition to the core X keyboard and pointer. The
7 input extension categorizes devices by grouping them into classes. Keyboards
8 and other input devices with keys are classified as KeyClass devices by the
9 input extension. Other types of devices supported by the input extension
10 include, but are not limited to: mice, tablets, touchscreens, barcode readers,
11 button boxes, trackballs, identifier devices, data gloves, and eye trackers.
12 Xkb provides additional control over all X input extension devices, whether
13 they are <emphasis>KeyClass</emphasis>
14 devices or not, as well as the core keyboard and pointer.
19 If an X server implements support for both the input extension and Xkb, the
20 server implementor determines whether interaction between Xkb and the input
21 extension is allowed. Implementors are free to restrict the effects of Xkb to
22 only the core X keyboard device or allow interaction between Xkb and the input
28 Several types of interaction between Xkb and the input extension are defined by
29 Xkb. Some or all may be allowed by the X server implementation.
34 Regardless of whether the server allows interaction between Xkb and the input
35 extension, the following access is provided:
41 Xkb functionality for the core X keyboard device and its mapping is accessed
42 via the functions described in the other chapters of this specification.
47 Xkb functionality for the core X pointer device is accessed via the
48 XkbGetDeviceInfo and XkbSetDeviceInfo functions described in this chapter.
54 If all types of interaction are allowed between Xkb and the input extension,
55 the following additional access is provided:
61 If allowed, Xkb functionality for additional <emphasis>
63 devices supported by the input extension is accessed via those same functions.
68 If allowed, Xkb functionality for non-<emphasis>
70 devices supported by the input extension is also accessed via the
71 XkbGetDeviceInfo and XkbSetDeviceInfo functions described in this chapter.
77 Each device has an X Input Extension device ID. Each device may have several
78 classes of feedback. For example, there are two types of feedbacks that can
79 generate bells: bell feedback and keyboard feedback (<emphasis>
80 BellFeedbackClass</emphasis>
82 KbdFeedbackClass</emphasis>
83 ). A device can have more than one feedback of each type; the feedback ID
84 identifies the particular feedback within its class.
89 A keyboard feedback has:
95 Auto-repeat status (global and per key)
111 An indicator feedback has:
123 If the input extension is present and the server allows interaction between the
124 input extension and Xkb, then the core keyboard, the core keyboard indicators,
125 and the core keyboard bells may each be addressed using an appropriate device
126 spec, class, and ID. The constant <emphasis>
127 XkbXIDfltID</emphasis>
128 may be used as the device ID to specify the core keyboard indicators for the
129 core indicator feedback. The particular device ID corresponding to the core
130 keyboard feedback and the core indicator feedback may be obtained by calling
132 XkbGetDeviceInfo</emphasis>
133 and specifying <emphasis>
134 XkbUseCoreKbd</emphasis>
136 device_spec</emphasis>
137 ; the values will be returned in <emphasis>
138 dflt_kbd_id</emphasis>
140 dflt_led_id</emphasis>
146 If the server does not allow Xkb access to input extension <emphasis>
148 devices, attempts to use Xkb requests with those devices fail with a
151 error. Attempts to access non-<emphasis>
153 input extension devices via XkbGetDeviceInfo and XkbSetDeviceInfo fail
154 silently if Xkb access to those devices is not supported by the X server.
157 <sect1 id='XkbDeviceInfoRec'>
158 <title>XkbDeviceInfoRec</title>
161 Information about X Input Extension devices is transferred between a client
162 program and the Xkb extension in an <emphasis>
163 XkbDeviceInfoRec</emphasis>
167 <para><programlisting>
169 char * name; /* name for device */
170 Atom type; /* name for class of devices */
171 unsigned short device_spec; /* device of interest */
172 Bool has_own_state; /* <emphasis> True</emphasis> =>this
173 device has its own state */
174 unsigned short supported; /* bits indicating supported capabilities */
175 unsigned short unsupported; /* bits indicating unsupported capabilities */
176 unsigned short num_btns; /* number of entries in <emphasis> btn_acts</emphasis> */
177 XkbAction * btn_acts; /* button actions */
178 unsigned short sz_leds; /* total number of entries in LEDs vector */
179 unsigned short num_leds; /* number of valid entries in LEDs vector */
180 unsigned short dflt_kbd_fb; /* input extension ID of default (core kbd) indicator */
181 unsigned short dflt_led_fb; /* input extension ID of default indicator feedback */
182 XkbDeviceLedInfoPtr leds; /* LED descriptions */
183 } <emphasis>XkbDeviceInfoRec</emphasis>, *XkbDeviceInfoPtr;
184 </programlisting></para>
186 <para><programlisting>
188 unsigned short led_class; /* class for this LED device*/
189 unsigned short led_id; /* ID for this LED device */
190 unsigned int phys_indicators; /* bits for which LEDs physically
192 unsigned int maps_present; /* bits for which LEDs have maps in
193 <emphasis>maps</emphasis> */
194 unsigned int names_present; /* bits for which LEDs are in
195 <emphasis> names</emphasis> */
196 unsigned int state; /* 1 bit => corresponding LED is on */
197 Atom names[XkbNumIndicators]; /* names for LEDs */
198 XkbIndicatorMapRec maps; /* indicator maps for each LED */
199 } <emphasis>XkbDeviceLedInfoRec</emphasis>, *XkbDeviceLedInfoPtr;
200 </programlisting></para>
205 field is a registered symbolic name for a class of devices (for example,
206 "TABLET"). If a device is a keyboard (that is, is a member of <emphasis>
208 ), it has its own state, and <emphasis>
209 has_own_state</emphasis>
213 has_own_state</emphasis>
216 , the state of the core keyboard is used. The <emphasis>
219 unsupported</emphasis>
220 fields are masks where each bit indicates a capability. The meaning of the
221 mask bits is listed in Table 21.1, together with the fields in the <emphasis>
222 XkbDeviceInfoRec</emphasis>
223 structure that are associated with the capability represented by each bit. The
224 same bits are used to indicate the specific information desired in many of the
225 functions described subsequently in this section.
228 <table frame='topbot'>
229 <title>XkbDeviceInfoRec Mask Bits</title>
230 <?dbfo keep-together="always" ?>
231 <tgroup cols='4' align='left' colsep='0' rowsep='0'>
232 <colspec colname='c1' colwidth='2.9*'/>
233 <colspec colname='c2' colwidth='2.0*'/>
234 <colspec colname='c3' colwidth='0.9*'/>
235 <colspec colname='c4' colwidth='2.0*'/>
239 <entry>XkbDeviceInfoRec Fields Effected</entry>
241 <entry>Capability If Set</entry>
246 <entry>XkbXI_KeyboardsMask</entry>
248 <entry>(1L << 0)</entry>
250 Clients can use all Xkb requests and events with
251 <emphasis>KeyClass</emphasis>
252 devices supported by the input device extension.
256 <entry>XkbXI_ButtonActionsMask</entry>
258 <para>num_btns</para>
259 <para>btn_acts</para>
261 <entry>(1L <<1)</entry>
263 Clients can assign key actions to buttons on non-<emphasis>
265 input extension devices.
269 <entry>XkbXI_IndicatorNamesMask</entry>
270 <entry>leds->names</entry>
271 <entry>(1L <<2)</entry>
273 Clients can assign names to indicators on non-<emphasis>
275 input extension devices.
279 <entry>XkbXI_IndicatorMapsMask</entry>
280 <entry>leds->maps</entry>
281 <entry>(1L <<3)</entry>
283 Clients can assign indicator maps to indicators on non-<emphasis>
285 input extension devices.
289 <entry>XkbXI_IndicatorStateMask</entry>
290 <entry>leds->state</entry>
291 <entry>(1L <<4)</entry>
293 Clients can request the status of indicators on non-<emphasis>
295 input extension devices.
299 <entry>XkbXI_IndicatorsMask</entry>
302 <para>num_leds</para>
303 <para>leds->*</para>
305 <entry>(0x1c)</entry>
307 <para>XkbXI_IndicatorNames­Mask |</para>
308 <para>XkbXI_IndicatorMaps­Mask |</para>
309 <para>XkbXI_IndicatorState­Mask</para>
313 <entry>XkbXI_UnsupportedFeaturesMask</entry>
314 <entry>unsupported</entry>
315 <entry>(1L <<15)</entry>
319 <entry>XkbXI_AllDeviceFeaturesMask</entry>
320 <entry>Those selected by Value column masks</entry>
321 <entry>(0x1e)</entry>
323 <para>XkbXI_Indicators­Mask | </para>
324 <para>XkbSI_ButtonActions­Mask</para>
328 <entry>XkbXI_AllFeaturesMask</entry>
329 <entry>Those selected by Value column masks</entry>
330 <entry>(0x1f)</entry>
332 <para>XkbSI_AllDevice­FeaturesMask |</para>
333 <para>XkbSI_Keyboards­Mask</para>
337 <entry>XkbXI_AllDetailsMask</entry>
338 <entry>Those selected by Value column masks</entry>
339 <entry>(0x801f)</entry>
341 <para>XkbXI_AllFeatures­Mask | </para>
342 <para>XkbXI_Unsupported­FeaturesMask</para>
355 has_own_state</emphasis>
359 unsupported</emphasis>
360 fields are always filled in when a valid reply is returned from the server
361 involving an <emphasis>
362 XkbDeviceInfoRec</emphasis>
363 . All of the other fields are modified only if the particular function asks for
368 <sect1 id='Querying_Xkb_Features_for_Non_KeyClass_Input_Extension_Devices'>
369 <title>Querying Xkb Features for Non-KeyClass Input Extension Devices</title>
372 To determine whether the X server allows Xkb access to particular capabilities
373 of input devices other than the core X keyboard, or to determine the status of
374 indicator maps, indicator names or button actions on a non-<emphasis>
376 extension device, use XkbGetDeviceInfo.
379 <informaltable frame='none'>
380 <?dbfo keep-together="always" ?>
381 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
382 <colspec colname='c1' colwidth='1.0*'/>
385 <entry role='functiondecl'>
386 XkbDeviceInfoPtr <emphasis>
387 XkbGetDeviceInfo</emphasis>
390 , which, device_spec, ind_class, ind_id)
394 <entry role='functionargdecl'>
397 ; /* connection to X server */
401 <entry role='functionargdecl'>
402 unsigned int which; /* mask indicating information to
407 <entry role='functionargdecl'>
408 unsigned int <emphasis>
409 device_spec</emphasis>
410 ; /* device ID, or <emphasis>
411 XkbUseCoreKbd</emphasis>
416 <entry role='functionargdecl'>
417 unsigned int <emphasis>
419 ; /* feedback class for indicator requests */
423 <entry role='functionargdecl'>
424 unsigned int <emphasis>
426 ; /* feedback ID for indicator requests */
435 XkbGetDeviceInfo</emphasis>
436 returns information about the input device specified by <emphasis>
437 device_spec</emphasis>
438 . Unlike the <emphasis>
439 device_spec</emphasis>
440 parameter of most Xkb functions, <emphasis>
441 device_spec</emphasis>
442 does not need to be a keyboard device. It must, however, indicate either the
443 core keyboard or a valid X Input Extension device.
452 is a mask specifying optional information to be returned. It is an inclusive OR
453 of one or more of the values from Table 21.1 and causes the returned <emphasis>
454 XkbDeviceInfoRec</emphasis>
455 to contain values for the corresponding fields specified in the table.
461 XkbDeviceInfoRec</emphasis>
462 returned by <emphasis>
463 XkbGetDeviceInfo</emphasis>
464 always has values for <emphasis>
466 (may be a null string, ""), <emphasis>
471 unsupported</emphasis>
473 has_own_state</emphasis>
475 dflt_kbd_fd</emphasis>
477 dflt_kbd_fb</emphasis>
478 . Other fields are filled in as specified by <emphasis>
485 Upon return, the <emphasis>
487 field will be set to the inclusive OR of zero or more bits from Table 21.1;
488 each bit set indicates an optional Xkb extension device feature supported by
489 the server implementation, and a client may modify the associated behavior.
495 XkbButtonActionsMask</emphasis>
496 bit is set in <emphasis>
499 XkbDeviceInfoRec</emphasis>
500 returned will have the button actions (<emphasis>
502 field) filled in for all buttons.
509 includes one of the bits in XkbXI_IndicatorsMask, the feedback class of the
510 indicators must be specified in ind_class, and the feedback ID of the
511 indicators must be specified in ind_id. If the request does not include any of
512 the bits in XkbXI_IndicatorsMask, the ind_class and ind_id parameters are
513 ignored. The class and ID can be obtained via the input device extension
514 XListInputDevices request.
519 If any of the <emphasis>
520 XkbXI_IndicatorsMask</emphasis>
521 bits are set in <emphasis>
524 XkbDeviceInfoRec</emphasis>
525 returned will have filled in the portions of the <emphasis>
527 structure corresponding to the indicator feedback identified by <emphasis>
533 vector of the <emphasis>
534 XkbDeviceInfoRec</emphasis>
535 is allocated if necessary and <emphasis>
539 filled in. The <emphasis>
544 phys_indicators</emphasis>
545 fields of the <emphasis>
547 entry corresponding to <emphasis>
551 are always filled in. If <emphasis>
554 XkbXI_IndicatorNamesMask</emphasis>
556 names_present</emphasis>
559 fields of the <emphasis>
561 structure corresponding to <emphasis>
565 are returned.<emphasis>
570 XkbXI_IndicatorStateMask</emphasis>
573 the corresponding <emphasis>
575 field is updated. If <emphasis>
578 XkbXI_IndicatorMapsMask</emphasis>
580 maps_present</emphasis>
588 Xkb provides convenience functions to request subsets of the information
589 available via <emphasis>
590 XkbGetDeviceInfo</emphasis>
591 . These convenience functions mirror some of the mask bits. The functions all
593 XkbDeviceInfoPtr</emphasis>
594 as an input argument and operate on the X Input Extension device specified by
596 device_spec</emphasis>
597 field of the structure. Only the parts of the structure indicated in the
598 function description are updated. The <emphasis>
599 XkbDeviceInfo</emphasis>
600 Rec structure used in the function call can be obtained by calling
601 XkbGetDeviceInfo or can be allocated by calling XkbAllocDeviceInfo (see section
607 These convenience functions are described as follows.
612 To query the button actions associated with an X Input Extension device, use
613 XkbGetDeviceButtonActions.
617 <informaltable frame='none'>
618 <?dbfo keep-together="always" ?>
619 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
620 <colspec colname='c1' colwidth='1.0*'/>
623 <entry role='functiondecl'>
625 XkbGetDeviceButtonActions</emphasis>
627 dpy, device_info, all_buttons, first_button, num_buttons</emphasis>
632 <entry role='functionargdecl'>
635 ; /* connection to X server */
639 <entry role='functionargdecl'>
640 XkbDeviceInfoPtr device_info; /* structure to update with
645 <entry role='functionargdecl'>
647 all_buttons</emphasis>
650 => get information for all buttons */
654 <entry role='functionargdecl'>
655 unsigned int first_button; /* number of first button for
656 which info is desired */
660 <entry role='functionargdecl'>
661 unsigned int num_buttons; /* number of buttons for which
671 XkbGetDeviceButtonActions</emphasis>
672 queries the server for the desired button information for the device indicated
674 device_spec</emphasis>
676 device_info</emphasis>
677 and waits for a reply. If successful,<emphasis>
678 XkbGetDeviceButtonActions</emphasis>
679 backfills the button actions (<emphasis>
682 device_info</emphasis>
683 ) for only the requested buttons, updates the <emphasis>
690 unsupported</emphasis>
691 fields, and returns <emphasis>
699 all_buttons</emphasis>
701 first_button</emphasis>
703 num_buttons</emphasis>
704 specify the device buttons for which actions should be returned. Setting
706 all_buttons</emphasis>
709 requests actions for all device buttons; if <emphasis>
710 all_buttons</emphasis>
714 first_button</emphasis>
716 num_buttons</emphasis>
717 specify a range of buttons for which actions are requested.
722 If a compatible version of Xkb is not available in the server or the Xkb
723 extension has not been properly initialized, XkbGetDeviceButtonActions returns
726 . If allocation errors occur, a <emphasis>
728 status is returned. If the specified device (<emphasis>
729 device_info</emphasis>
731 device_spec</emphasis>
732 ) is invalid, a BadKeyboard status is returned. If the device has no buttons, a
735 status is returned. If <emphasis>
736 first_button</emphasis>
738 num_buttons</emphasis>
739 specify illegal buttons, a Bad<emphasis>
746 To query the indicator names, maps, and state associated with an LED feedback
747 of an input extension device, use XkbGetDeviceLedInfo.
751 <informaltable frame='none'>
752 <?dbfo keep-together="always" ?>
753 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
754 <colspec colname='c1' colwidth='1.0*'/>
757 <entry role='functiondecl'>
759 XkbGetDeviceLedInfo</emphasis>
761 dpy, device_i</emphasis>
762 nfo, led_class, led_id, which)
766 <entry role='functionargdecl'>
769 ; /* connection to X server */
773 <entry role='functionargdecl'>
774 XkbDeviceInfoPtr device_info; /* structure to update with
779 <entry role='functionargdecl'>
780 unsigned int <emphasis>
782 ; /* LED feedback class assigned by input extension */
786 <entry role='functionargdecl'>
787 unsigned int led_id; /* LED feedback ID assigned by input
792 <entry role='functionargdecl'>
793 unsigned int which; /* mask indicating desired
803 XkbGetDeviceLedInfo</emphasis>
804 queries the server for the desired LED information for the feedback specified
809 for the X input extension device indicated by <emphasis>
810 device_spec</emphasis>
812 device_info</emphasis>
813 and waits for a reply. If successful, <emphasis>
814 XkbGetDeviceLedInfo</emphasis>
815 backfills the relevant fields of <emphasis>
816 device_info</emphasis>
817 as determined by <emphasis>
819 with the results and returns <emphasis>
821 . Valid values for <emphasis>
823 are the inclusive OR of any of <emphasis>
824 XkbXI_IndicatorNamesMask</emphasis>
826 XkbXI_IndicatorMapsMask</emphasis>
828 XkbXI_IndicatorStateMask</emphasis>
834 The fields of <emphasis>
835 device_info</emphasis>
836 that are filled in when this request succeeds are <emphasis>
837 name, type, supported</emphasis>
839 unsupported</emphasis>
840 , and portions of the <emphasis>
842 structure corresponding to <emphasis>
846 as indicated by the bits set in <emphasis>
849 device_info->leds</emphasis>
850 vector is allocated if necessary and <emphasis>
854 filled in. The <emphasis>
859 phys_indicators</emphasis>
860 fields of the <emphasis>
861 device_info</emphasis>
864 entry corresponding to <emphasis>
868 are always filled in.
876 XkbXI_IndicatorNamesMask</emphasis>
878 names_present</emphasis>
881 fields of the <emphasis>
882 device_info</emphasis>
885 structure corresponding to <emphasis>
889 are updated, if <emphasis>
892 XkbXI_IndicatorStateMask</emphasis>
895 the corresponding <emphasis>
897 field is updated, and if <emphasis>
900 XkbXI_IndicatorMapsMask</emphasis>
902 maps_present</emphasis>
910 If a compatible version of Xkb is not available in the server or the Xkb
911 extension has not been properly initialized, <emphasis>
912 XkbGetDeviceLedInfo</emphasis>
915 . If allocation errors occur, a BadAlloc status is returned. If the device has
916 no indicators, a BadMatch error is returned. If <emphasis>
920 have illegal values, a Bad<emphasis>
922 error is returned. If they have legal values but do not specify a feedback
923 that contains LEDs and is associated with the specified device, a Bad<emphasis>
930 <sect1 id='Allocating_Initializing_and_Freeing_the_XkbDeviceInfoRecStructure'>
931 <title>Allocating, Initializing, and Freeing the XkbDeviceInfoRec
935 To obtain an <emphasis>
936 XkbDeviceInfoRec</emphasis>
937 structure, use XkbGetDeviceInfo or XkbAllocDeviceInfo.
940 <informaltable frame='none'>
941 <?dbfo keep-together="always" ?>
942 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
943 <colspec colname='c1' colwidth='1.0*'/>
946 <entry role='functiondecl'>
947 XkbDeviceInfoPtr <emphasis>
948 XkbAllocDeviceInfo</emphasis>
949 (device_spec, n_buttons, sz_leds)
953 <entry role='functionargdecl'>
954 unsigned int device_spec; /* device ID with which
955 structure will be used */
959 <entry role='functionargdecl'>
960 unsigned int <emphasis>
962 ; /* number of button actions to allocate space for*/
966 <entry role='functionargdecl'>
967 unsigned int <emphasis>
969 ; /* number of LED feedbacks to allocate space for */
978 XkbAllocDeviceInfo</emphasis>
979 allocates space for an <emphasis>
980 XkbDeviceInfoRec</emphasis>
981 structure and initializes that structure’s <emphasis>
982 device_spec</emphasis>
983 field with the device ID specified by device_spec. If <emphasis>
985 is nonzero, <emphasis>
988 XkbActions</emphasis>
989 are linked into the <emphasis>
990 XkbDeviceInfoRec</emphasis>
991 structure and initialized to zero. If sz_leds is nonzero, <emphasis>
994 XkbDeviceLedInfoRec</emphasis>
995 structures are also allocated and linked into the <emphasis>
996 XkbDeviceInfoRec</emphasis>
997 structure. If you request <emphasis>
998 XkbDeviceLedInfoRec</emphasis>
999 structures be allocated using this request, you must initialize them
1005 To obtain an <emphasis>
1006 XkbDeviceLedInfoRec</emphasis>
1007 structure, use XkbAllocDeviceLedInfo.
1011 <informaltable frame='none'>
1012 <?dbfo keep-together="always" ?>
1013 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
1014 <colspec colname='c1' colwidth='1.0*'/>
1017 <entry role='functiondecl'>
1019 XkbAllocDeviceLedInfo</emphasis>
1024 <entry role='functionargdecl'>
1025 XkbDeviceInfoPtr <emphasis>
1026 device_info</emphasis>
1027 ; /* structure in which to allocate LED space */
1031 <entry role='functionargdecl'>
1033 num_needed</emphasis>
1034 ; /* number of indicators to allocate space for */
1043 XkbAllocDeviceLedInfo</emphasis>
1044 allocates space for an <emphasis>
1045 XkbDeviceLedInfoRec</emphasis>
1046 and places it in <emphasis>
1047 device_info</emphasis>
1048 . If num_needed is nonzero, <emphasis>
1049 num_needed</emphasis>
1051 XkbIndicatorMapRec</emphasis>
1052 structures are also allocated and linked into the <emphasis>
1053 XkbDeviceLedInfoRec</emphasis>
1054 structure. If you request <emphasis>
1055 XkbIndicatorMapRec</emphasis>
1056 structures be allocated using this request, you must initialize them
1057 explicitly. All other fields are initialized to zero.
1062 To initialize an <emphasis>
1063 XkbDeviceLedInfoRec</emphasis>
1064 structure, use XkbAddDeviceLedInfo.
1068 <informaltable frame='none'>
1069 <?dbfo keep-together="always" ?>
1070 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
1071 <colspec colname='c1' colwidth='1.0*'/>
1074 <entry role='functiondecl'>
1075 XkbDeviceLedInfoPtr <emphasis>
1076 XkbAddDeviceLedInfo</emphasis>
1077 (device_info, led_class, led_id)
1081 <entry role='functionargdecl'>
1082 XkbDeviceInfoPtr device_info; /* structure in which to
1087 <entry role='functionargdecl'>
1088 unsigned int <emphasis>
1089 led_class</emphasis>
1090 ; /* input extension class for LED device of interest */
1094 <entry role='functionargdecl'>
1095 unsigned int <emphasis>
1097 ; /* input extension ID for LED device of interest */
1106 XkbAddDeviceLedInfo</emphasis>
1107 first checks to see whether an entry matching <emphasis>
1108 led_class</emphasis>
1111 already exists in the <emphasis>
1112 device_info->leds</emphasis>
1113 array. If it finds a matching entry, it returns a pointer to that entry.
1114 Otherwise, it checks to be sure there is at least one empty entry in <emphasis>
1115 device_info</emphasis>
1118 and extends it if there is not enough room. It then increments <emphasis>
1119 device_info</emphasis>
1122 and fills in the next available entry in <emphasis>
1123 device_info</emphasis>
1127 led_class</emphasis>
1135 If successful, <emphasis>
1136 XkbAddDeviceLedInfo</emphasis>
1137 returns a pointer to the <emphasis>
1138 XkbDeviceLedInfoRec</emphasis>
1139 structure that was initialized. If unable to allocate sufficient storage, or
1141 device_info</emphasis>
1142 points to an invalid <emphasis>
1143 XkbDeviceInfoRec</emphasis>
1144 structure, or if <emphasis>
1145 led_class</emphasis>
1148 are inappropriate, <emphasis>
1149 XkbAddDeviceLedInfo</emphasis>
1157 To allocate additional space for button actions in an <emphasis>
1158 XkbDeviceInfoRec</emphasis>
1159 structure, use XkbResizeDeviceButtonActions.
1163 <informaltable frame='none'>
1164 <?dbfo keep-together="always" ?>
1165 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
1166 <colspec colname='c1' colwidth='1.0*'/>
1169 <entry role='functiondecl'>
1171 XkbResizeDeviceButtonActions</emphasis>
1172 (device_info, new_total)
1176 <entry role='functionargdecl'>
1177 XkbDeviceInfoPtr device_info; /* structure in which to
1178 allocate button actions */
1182 <entry role='functionargdecl'>
1183 unsigned int <emphasis>
1184 new_total</emphasis>
1185 ; /* new total number of button actions needed */
1194 XkbResizeDeviceButton</emphasis>
1195 reallocates space, if necessary, to make sure there is room for a total of
1197 new_total</emphasis>
1198 button actions in the <emphasis>
1199 device_info</emphasis>
1200 structure. Any new entries allocated are zeroed. If successful, <emphasis>
1201 XkbResizeDeviceButton</emphasis>
1202 returns Success. If new_total is zero, all button actions are deleted,
1204 device_info</emphasis>
1207 is set to zero, and <emphasis>
1208 device_info</emphasis>
1211 is set to <emphasis>
1213 . If device_info is invalid or new_total is greater than 255, BadValue is
1214 returned. If a memory allocation failure occurs, a <emphasis>
1221 To free an <emphasis>
1222 XkbDeviceInfoRec</emphasis>
1223 structure, use XkbFreeDeviceInfo.
1227 <informaltable frame='none'>
1228 <?dbfo keep-together="always" ?>
1229 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
1230 <colspec colname='c1' colwidth='1.0*'/>
1233 <entry role='functiondecl'>
1235 XkbFreeDeviceInfo</emphasis>
1236 (device_info, which, free_all)
1240 <entry role='functionargdecl'>
1241 XkbDeviceInfoPtr device_info; /* pointer to <emphasis>
1242 XkbDeviceInfoRec</emphasis>
1243 in which to free items */
1247 <entry role='functionargdecl'>
1248 unsigned int <emphasis>
1250 ; /* mask of components of <emphasis>
1251 device_info</emphasis>
1256 <entry role='functionargdecl'>
1261 => free everything, including device_info */
1269 If free_all is <emphasis>
1272 XkbFreeDeviceInfo</emphasis>
1273 frees all components of <emphasis>
1274 device_info</emphasis>
1276 XkbDeviceInfoRec</emphasis>
1277 structure pointed to by <emphasis>
1278 device_info</emphasis>
1279 itself. If free_all is <emphasis>
1281 , the value of which determines which subcomponents are freed. <emphasis>
1283 is an inclusive OR of one or more of the values from Table 21.1. If which
1284 contains XkbXI_ButtonActionsMask, all button actions associated with <emphasis>
1285 device_info</emphasis>
1286 are freed, <emphasis>
1287 device_info</emphasis>
1290 is set to <emphasis>
1293 device_info</emphasis>
1296 is set to zero. If which contains all bits in XkbXI_IndicatorsMask, all
1298 XkbDeviceLedInfoRec</emphasis>
1299 structures associated with <emphasis>
1300 device_info</emphasis>
1301 are freed, <emphasis>
1302 device_info</emphasis>
1305 is set to <emphasis>
1308 device_info</emphasis>
1312 device_info</emphasis>
1315 are set to zero. If which contains XkbXI_IndicatorMapsMask, all indicator maps
1316 associated with <emphasis>
1317 device_info</emphasis>
1318 are cleared, but the number of LEDs and the leds structures themselves are
1319 preserved. If which contains XkbXI_IndicatorNamesMask, all indicator names
1320 associated with device_info are cleared, but the number of LEDs and the leds
1321 structures themselves are preserved. If which contains
1322 XkbXI_IndicatorStateMask, the indicator state associated with the <emphasis>
1323 device_info</emphasis>
1324 leds are set to zeros but the number of LEDs and the leds structures
1325 themselves are preserved.
1330 <sect1 id='Setting_Xkb_Features_for_Non_KeyClass_Input_Extension_Devices'>
1331 <title>Setting Xkb Features for Non-KeyClass Input Extension Devices</title>
1334 The Xkb extension allows clients to assign any key action to either core
1335 pointer or input extension device buttons. This makes it possible to control
1336 the keyboard or generate keyboard key events from extension devices or from the
1342 Key actions assigned to core X pointer buttons or input extension device
1343 buttons cause key events to be generated as if they had originated from the
1349 Xkb implementations are required to support key actions for the buttons of the
1350 core pointer device, but support for actions on extension devices is optional.
1351 Implementations that do not support button actions for extension devices must
1352 not set the <emphasis>
1353 XkbXI_ButtonActionsMask</emphasis>
1354 bit in the <emphasis>
1355 supported</emphasis>
1356 field of an <emphasis>
1357 XkbDeviceInfoRec</emphasis>
1363 If a client attempts to modify valid characteristics of a device using an
1364 implementation that does not support modification of those characteristics, no
1365 protocol error is generated. Instead, the server reports a failure for the
1366 request; it also sends an <emphasis>
1367 XkbExtensionDeviceNotify</emphasis>
1368 event to the client that issued the request if the client has selected to
1369 receive these events.
1374 To change characteristics of an X Input Extension device in the server, first
1375 modify a local copy of the device structure and then use either <emphasis>
1376 XkbSetDeviceInfo,</emphasis>
1377 or, to save network traffic, use an <emphasis>
1378 XkbDeviceChangesRec</emphasis>
1379 structure (see section 21.6) and call <emphasis>
1380 XkbChangeDeviceInfo</emphasis>
1381 to download the changes to the server.
1386 To modify some or all of the characteristics of an X Input Extension device,
1387 use XkbSetDeviceInfo.
1390 <informaltable frame='none'>
1391 <?dbfo keep-together="always" ?>
1392 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
1393 <colspec colname='c1' colwidth='1.0*'/>
1396 <entry role='functiondecl'>
1398 XkbSetDeviceInfo</emphasis>
1401 , which, device_info)
1405 <entry role='functionargdecl'>
1406 Display * <emphasis>
1408 ; /* connection to X server */
1412 <entry role='functionargdecl'>
1413 unsigned int <emphasis>
1415 ; /* mask indicating characteristics to modify */
1419 <entry role='functionargdecl'>
1420 XkbDeviceInfoPtr device_info; /* structure defining the
1421 device and modifications */
1430 XkbSetDeviceInfo</emphasis>
1431 sends a request to the server to modify the characteristics of the device
1432 specified in the <emphasis>
1433 device_info</emphasis>
1434 structure. The particular characteristics modified are identified by the bits
1437 and take their values from the relevant fields in <emphasis>
1438 device_info</emphasis>
1439 (see Table 21.1). <emphasis>
1440 XkbSetDeviceInfo</emphasis>
1443 if the request was successfully sent to the server. If the X server
1444 implementation does not allow interaction between the X input extension and the
1445 Xkb Extension, the function does nothing and returns <emphasis>
1454 parameter specifies which aspects of the device should be changed and is a
1455 bitmask composed of an inclusive OR or one or more of the following bits:
1457 XkbXI_ButtonActionsMask</emphasis>
1459 XkbXI_IndicatorNamesMask</emphasis>
1461 XkbXI_IndicatorMapsMask</emphasis>
1462 . If the features requested to be manipulated in <emphasis>
1464 are valid for the device, but the server does not support assignment of one or
1465 more of them, that particular portion of the request is ignored.
1470 If the device specified in <emphasis>
1471 device_info</emphasis>
1473 device_spec</emphasis>
1474 does not contain buttons and a request affecting buttons is made, or the
1475 device does not contain indicators and a request affecting indicators is made,
1478 protocol error results.
1484 XkbXI_ButtonActionsMask</emphasis>
1485 bit is set in the supported mask returned by XkbGetDeviceInfo, the Xkb
1486 extension allows applications to assign key actions to buttons on input
1487 extension devices other than the core keyboard device. If the <emphasis>
1488 XkbXI_ButtonActionsMask</emphasis>
1489 is set in <emphasis>
1491 , the actions for all buttons specified in device_info are set to the <emphasis>
1492 XkbAction</emphasis>
1493 s specified in <emphasis>
1494 device_info</emphasis>
1497 . If the number of buttons requested to be updated is not valid for the device,
1499 XkbSetDeviceInfo</emphasis>
1504 protocol error results.
1510 XkbXI_IndicatorMaps</emphasis>
1512 XkbXI_IndicatorNamesMask</emphasis>
1513 bit is set in the supported mask returned by XkbGetDeviceInfo, the Xkb
1514 extension allows applications to assign maps and / or names to the indicators
1515 of nonkeyboard extension devices. If supported, maps and / or names can be
1516 assigned to all extension device indicators, whether they are part of a
1517 keyboard feedback or part of an indicator feedback.
1523 XkbXI_IndicatorMapsMask</emphasis>
1525 XkbXI_IndicatorNamesMask</emphasis>
1526 flag is set in <emphasis>
1528 , the indicator maps and / or names for all <emphasis>
1529 device_info</emphasis>
1532 indicator devices specified in <emphasis>
1533 device_info</emphasis>
1536 are set to the maps and / or names specified in <emphasis>
1537 device_info</emphasis>
1541 device_info</emphasis>
1545 led_class</emphasis>
1548 specify the input extension class and device ID for each indicator device to
1549 modify; if they have invalid values, a <emphasis>
1551 protocol error results and <emphasis>
1552 XkbSetDeviceInfo</emphasis>
1555 . If they have legal values but do not specify a keyboard or indicator class
1556 feedback for the device in question, a <emphasis>
1558 error results. If any of the values in <emphasis>
1559 device_info</emphasis>
1566 are not a valid Atom or <emphasis>
1570 protocol error results.
1575 Xkb provides convenience functions to modify subsets of the information
1576 accessible via <emphasis>
1577 XkbSetDeviceInfo</emphasis>
1578 . Only the parts of the structure indicated in the function description are
1579 modified. These convenience functions are described as follows.
1584 To change only the button actions for an input extension device, use
1585 XkbSetDeviceButtonActions.
1589 <informaltable frame='none'>
1590 <?dbfo keep-together="always" ?>
1591 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
1592 <colspec colname='c1' colwidth='1.0*'/>
1595 <entry role='functiondecl'>
1597 XkbSetDeviceButtonActions</emphasis>
1600 , device, first_button, num_buttons, actions)
1604 <entry role='functionargdecl'>
1605 Display * <emphasis>
1607 ; /* connection to X server */
1611 <entry role='functionargdecl'>
1612 XkbDeviceInfoPtr device_info; /* structure defining the
1613 device and modifications */
1617 <entry role='functionargdecl'>
1618 unsigned int first_button; /* number of first button to
1619 update, 0 relative */
1623 <entry role='functionargdecl'>
1624 unsigned int num_buttons; /* number of buttons to update
1634 XkbSetDeviceButtonActions</emphasis>
1635 assigns actions to the buttons of the device specified in
1636 device_info-><emphasis>
1637 device_spec</emphasis>
1638 . Actions are assigned to <emphasis>
1639 num_buttons</emphasis>
1640 buttons beginning with <emphasis>
1641 first_button</emphasis>
1642 and are taken from the actions specified in <emphasis>
1643 device_info</emphasis>
1651 If the server does not support assignment of Xkb actions to extension device
1653 XkbSetDeviceButtonActions</emphasis>
1654 has no effect and returns <emphasis>
1656 . If the device has no buttons or if <emphasis>
1657 first_button</emphasis>
1659 num_buttons</emphasis>
1660 specify buttons outside of the valid range as determined by <emphasis>
1661 device_info</emphasis>
1664 , the function has no effect and returns <emphasis>
1666 . Otherwise, <emphasis>
1667 XkbSetDeviceButtonActions</emphasis>
1668 sends a request to the server to change the actions for the specified buttons
1669 and returns <emphasis>
1676 If the actual request sent to the server involved illegal button numbers, a
1679 protocol error is generated. If an invalid device identifier is specified in
1680 device_info-><emphasis>
1681 device_spec</emphasis>
1682 , a BadKeyboard protocol error results. If the actual device specified in
1684 device_info</emphasis>
1686 device_spec</emphasis>
1687 does not contain buttons and a request affecting buttons is made, a <emphasis>
1689 protocol error is generated.
1694 <sect1 id='XkbExtensionDeviceNotify_Event'>
1695 <title>XkbExtensionDeviceNotify Event</title>
1698 The Xkb extension generates <emphasis>
1699 XkbExtensionDeviceNotify</emphasis>
1700 events when the status of an input extension device changes or when an attempt
1701 is made to use an Xkb feature that is not supported by a particular device.
1704 <note><para>Events indicating an attempt to use an unsupported feature are
1705 delivered only to the client requesting the event.</para></note>
1708 To track changes to the status of input extension devices or attempts to use
1709 unsupported features of a device, select to receive <emphasis>
1710 XkbExtensionDeviceNotify</emphasis>
1711 events by calling either <emphasis>
1712 XkbSelectEvents</emphasis>
1714 XkbSelectEventDetails</emphasis>
1720 To receive <emphasis>
1721 XkbExtensionDeviceNotify</emphasis>
1722 events under all possible conditions, call <emphasis>
1723 XkbSelectEvents</emphasis>
1725 XkbExtensionDeviceNotifyMask</emphasis>
1727 bits_to_change</emphasis>
1729 values_for_bits</emphasis>
1736 XkbExtensionDeviceNotify</emphasis>
1737 event has no event details. However, you can call <emphasis>
1738 XkbSelectEventDetails</emphasis>
1740 XkbExtensionDeviceNotify</emphasis>
1742 event_type</emphasis>
1743 and specifying <emphasis>
1744 XkbAllExtensionDeviceMask</emphasis>
1746 bits_to_change</emphasis>
1748 values_for_bits.</emphasis>
1749 This has the same effect as a call to <emphasis>
1750 XkbSelectEvents</emphasis>
1756 The structure for <emphasis>
1757 XkbExtensionDeviceNotify</emphasis>
1761 <para><programlisting>
1763 int type; /* Xkb extension base event code */
1764 unsigned long serial; /* X server serial number for event */
1765 Bool send_event; /* <emphasis>True</emphasis>
1766 => synthetically generated*/
1767 Display * display; /* server connection where event generated */
1768 Time time; /* server time when event generated */
1769 int xkb_type; /* <emphasis>XkbExtensionDeviceNotifyEvent</emphasis> */
1770 int device; /* Xkb device ID, will not be
1771 <emphasis>XkbUseCoreKbd</emphasis> */
1772 unsigned int reason; /* reason for the event */
1773 unsigned int supported; /* mask of supported features */
1774 unsigned int unsupported; /* unsupported features this client
1776 int first_btn; /* first button that changed */
1777 int num_btns; /* number of buttons that changed */
1778 unsigned int leds_defined; /* indicators with names or maps */
1779 unsigned int led_state; /* current state of the indicators */
1780 int led_class; /* feedback class for LED changes */
1781 int led_id; /* feedback ID for LED changes */
1782 } <emphasis>XkbExtensionDeviceNotifyEvent</emphasis>;
1783 </programlisting></para>
1787 XkbExtensionDeviceNotify</emphasis>
1788 event has fields enabling it to report changes in the state (on/off) of all of
1789 the buttons for a device, but only for one LED feedback associated with a
1790 device. You will get multiple events when more than one LED feedback changes
1791 state or configuration.
1796 <sect1 id='Tracking_Changes_to_Extension_Devices'>
1797 <title>Tracking Changes to Extension Devices</title>
1800 Changes to an Xkb extension device may be tracked by listening to <emphasis>
1801 XkbDeviceExtensionNotify</emphasis>
1802 events and accumulating the changes in an <emphasis>
1803 XkbDeviceChangesRec</emphasis>
1804 structure. The changes noted in the structure may then be used in subsequent
1805 operations to update either a server configuration or a local copy of an Xkb
1806 extension device configuration. The changes structure is defined as follows:
1809 <para><programlisting>
1810 typedef struct _XkbDeviceChanges {
1811 unsigned int changed; /* bits indicating what has changed */
1812 unsigned short first_btn; /* number of first button which changed,
1814 unsigned short num_btns; /* number of buttons that have changed */
1815 XkbDeviceLedChangesRec leds;
1816 } <emphasis>XkbDeviceChangesRec</emphasis>,*XkbDeviceChangesPtr;
1817 </programlisting></para>
1819 <para><programlisting>
1820 typedef struct _XkbDeviceLedChanges {
1821 unsigned short led_class; /* class of this indicator feedback bundle */
1822 unsigned short led_id; /* ID of this indicator feedback bundle */
1823 unsigned int names; /* bits indicating which names have changed */
1824 unsigned int maps; /* bits indicating which maps have changed */
1825 struct _XkbDeviceLedChanges *next; /* link to indicator change record
1827 } <emphasis>XkbDeviceLedChangesRec</emphasis>,*XkbDeviceLedChangesPtr;
1828 </programlisting></para>
1831 A local description of the configuration and state of a device may be kept in
1833 XkbDeviceInfoRec</emphasis>
1834 structure. The actual state or configuration of the device may change because
1835 of XkbSetDeviceInfo and XkbSetButtonActions requests made by clients or by user
1836 interaction with the device. The X server sends an XkbExtensionDeviceNotify
1837 event to all interested clients when the state of any buttons or indicators or
1838 the configuration of the buttons or indicators on the core keyboard or any
1839 input extension device changes. The event reports the state of indicators for a
1840 single indicator feedback, and the state of up to 128 buttons. If more than 128
1841 buttons or more than one indicator feedback are changed, the additional buttons
1842 and indicator feedbacks are reported in subsequent events. Xkb provides
1843 functions with which you can track changes to input extension devices by noting
1844 the changes that were made and then requesting the changed information from the
1850 To note device changes reported in an <emphasis>
1851 XkbExtensionDeviceNotify</emphasis>
1852 event, use XkbNoteDeviceChanges.
1855 <informaltable frame='none'>
1856 <?dbfo keep-together="always" ?>
1857 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
1858 <colspec colname='c1' colwidth='1.0*'/>
1861 <entry role='functiondecl'>
1863 XkbNoteDeviceChanges</emphasis>
1865 old, new, wanted</emphasis>
1870 <entry role='functionargdecl'>
1871 XkbDeviceChangesPtr <emphasis>
1873 ; /* structure tracking state changes */
1877 <entry role='functionargdecl'>
1878 XkbExtensionDeviceNotifyEvent * <emphasis>
1880 ; /* event indicating state changes */
1884 <entry role='functionargdecl'>
1885 unsigned int <emphasis>
1887 ; /* mask indicating changes to note */
1895 The wanted field specifies the changes that should be noted in <emphasis>
1897 , and is composed of the bitwise inclusive OR of one or more of the masks from
1898 Table 21.1<emphasis>
1902 field of the event in <emphasis>
1904 indicates the types of changes the event is reporting. <emphasis>
1905 XkbNoteDeviceChanges</emphasis>
1906 updates the <emphasis>
1907 XkbDeviceChangesRec</emphasis>
1908 specified by <emphasis>
1910 with the changes that are both specified in <emphasis>
1912 and contained in <emphasis>
1921 To update a local copy of the state and configuration of an X input extension
1922 device with the changes previously noted in an <emphasis>
1923 XkbDeviceChangesRec</emphasis>
1924 structure, use XkbGetDeviceInfoChanges.
1929 To query the changes that have occurred in the button actions or indicator
1930 names and indicator maps associated with an input extension device, use
1931 XkbGetDeviceInfoChanges.
1935 <informaltable frame='none'>
1936 <?dbfo keep-together="always" ?>
1937 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
1938 <colspec colname='c1' colwidth='1.0*'/>
1941 <entry role='functiondecl'>
1943 XkbGetDeviceInfoChanges</emphasis>
1947 device_info</emphasis>
1952 <entry role='functionargdecl'>
1953 Display * <emphasis>
1955 ; /* connection to X server */
1959 <entry role='functionargdecl'>
1960 XkbDeviceInfoPtr device_info; /* structure to update with
1965 <entry role='functionargdecl'>
1966 XkbDeviceChangesPtr <emphasis>
1968 ; /* contains notes of changes that have occurred */
1976 The changes->changed field indicates which attributes of the device
1977 specified in <emphasis>
1981 have changed. The parameters describing the changes are contained in the other
1982 fields of <emphasis>
1985 XkbGetDeviceInfoChanges</emphasis>
1986 uses that information to call XkbGetDeviceInfo to obtain the current status of
1987 those attributes that have changed. It then updates the local description of
1988 the device in <emphasis>
1989 device_info</emphasis>
1990 with the new information.
1995 To update the server’s description of a device with the changes noted in an
1996 XkbDeviceChangesRec, use XkbChangeDeviceInfo.
2000 <informaltable frame='none'>
2001 <?dbfo keep-together="always" ?>
2002 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
2003 <colspec colname='c1' colwidth='1.0*'/>
2006 <entry role='functiondecl'>
2008 XkbChangeDeviceInfo</emphasis>
2010 dpy, device_info, changes</emphasis>
2015 <entry role='functionargdecl'>
2016 Display * <emphasis>
2018 ; /* connection to X server */
2022 <entry role='functionargdecl'>
2023 XkbDeviceInfoPtr <emphasis>
2024 device_info</emphasis>
2025 ; /* local copy of device state and configuration */
2029 <entry role='functionargdecl'>
2030 XkbDeviceChangesPtr <emphasis>
2032 ; /* note specifying changes in <emphasis>
2033 device_info</emphasis>
2043 XkbChangeDeviceInfo</emphasis>
2044 updates the server’s description of the device specified in <emphasis>
2045 device_info</emphasis>
2047 device_spec</emphasis>
2048 with the changes specified in <emphasis>
2050 and contained in <emphasis>
2051 device_info</emphasis>
2052 . The update is made by an XkbSetDeviceInfo request.