1<?xml version="1.0" encoding="UTF-8" ?> 2<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" 3 "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"> 4<chapter id='Attaching_Xkb_Actions_to_X_Input_Extension_Devices'> 5<title>Attaching Xkb Actions to X Input Extension Devices</title> 6 7<para> 8The X input extension allows an X server to support multiple keyboards, as well 9as other input devices, in addition to the core X keyboard and pointer. The 10input extension categorizes devices by grouping them into classes. Keyboards 11and other input devices with keys are classified as KeyClass devices by the 12input extension. Other types of devices supported by the input extension 13include, but are not limited to: mice, tablets, touchscreens, barcode readers, 14button boxes, trackballs, identifier devices, data gloves, and eye trackers. 15Xkb provides additional control over all X input extension devices, whether 16they are <symbol>KeyClass</symbol> 17devices or not, as well as the core keyboard and pointer. 18</para> 19 20 21<para> 22If an X server implements support for both the input extension and Xkb, the 23server implementor determines whether interaction between Xkb and the input 24extension is allowed. Implementors are free to restrict the effects of Xkb to 25only the core X keyboard device or allow interaction between Xkb and the input 26extension. 27</para> 28 29 30<para> 31Several types of interaction between Xkb and the input extension are defined by 32Xkb. Some or all may be allowed by the X server implementation. 33</para> 34 35 36<para> 37Regardless of whether the server allows interaction between Xkb and the input 38extension, the following access is provided: 39</para> 40 41<itemizedlist> 42<listitem> 43 <para> 44Xkb functionality for the core X keyboard device and its mapping is accessed 45via the functions described in the other chapters of this specification. 46 </para> 47</listitem> 48<listitem> 49 <para> 50Xkb functionality for the core X pointer device is accessed via the 51XkbGetDeviceInfo and XkbSetDeviceInfo functions described in this chapter. 52 </para> 53</listitem> 54</itemizedlist> 55 56<para> 57If all types of interaction are allowed between Xkb and the input extension, 58the following additional access is provided: 59</para> 60 61<itemizedlist> 62<listitem> 63 <para> 64If allowed, Xkb functionality for additional 65<symbol>KeyClass</symbol> 66devices supported by the input extension is accessed via those same functions. 67 </para> 68</listitem> 69<listitem> 70 <para> 71If allowed, Xkb functionality for non- 72<symbol>KeyClass</symbol> 73devices supported by the input extension is also accessed via the 74XkbGetDeviceInfo and XkbSetDeviceInfo functions described in this chapter. 75 </para> 76</listitem> 77</itemizedlist> 78 79<para> 80Each device has an X Input Extension device ID. Each device may have several 81classes of feedback. For example, there are two types of feedbacks that can 82generate bells: bell feedback and keyboard feedback 83(<symbol>BellFeedbackClass</symbol> 84and 85<symbol>KbdFeedbackClass</symbol>). 86A device can have more than one feedback of each type; the feedback ID 87identifies the particular feedback within its class. 88</para> 89 90 91<para> 92A keyboard feedback has: 93</para> 94 95<itemizedlist> 96<listitem> 97 <para> 98Auto-repeat status (global and per key) 99 </para> 100</listitem> 101<listitem> 102 <para> 10332 LEDs 104 </para> 105</listitem> 106<listitem> 107 <para> 108A bell 109 </para> 110</listitem> 111</itemizedlist> 112 113<para> 114An indicator feedback has: 115</para> 116 117<itemizedlist> 118<listitem> 119 <para> 120Up to 32 LEDs 121 </para> 122</listitem> 123</itemizedlist> 124 125<para> 126If the input extension is present and the server allows interaction between the 127input extension and Xkb, then the core keyboard, the core keyboard indicators, 128and the core keyboard bells may each be addressed using an appropriate device 129spec, class, and ID. The constant 130<symbol>XkbDfltXIId</symbol> 131may be used as the device ID to specify the core keyboard indicators for the 132core indicator feedback. The particular device ID corresponding to the core 133keyboard feedback and the core indicator feedback may be obtained by calling 134<function>XkbGetDeviceInfo</function> 135and specifying 136<symbol>XkbUseCoreKbd</symbol> 137as the 138<parameter>device_spec</parameter>; 139the values will be returned in 140<structfield>dflt_kbd_fb</structfield> 141and 142<structfield>dflt_led_fb</structfield>. 143</para> 144 145 146<para> 147If the server does not allow Xkb access to input extension 148<symbol>KeyClass</symbol> 149devices, attempts to use Xkb requests with those devices fail with a 150<errorname>BadKeyboard</errorname> 151error. Attempts to access non- 152<symbol>KeyClass</symbol> 153input extension devices via XkbGetDeviceInfo and XkbSetDeviceInfo fail 154silently if Xkb access to those devices is not supported by the X server. 155</para> 156 157<sect1 id='XkbDeviceInfoRec'> 158<title>XkbDeviceInfoRec</title> 159<indexterm significance="preferred" zone="XkbDeviceInfoRec"> 160<primary><structname>XkbDeviceInfoRec</structname></primary></indexterm> 161<indexterm significance="preferred" zone="XkbDeviceInfoRec"> 162<primary><structname>XkbDeviceLedInfoRec</structname></primary></indexterm> 163 164<para> 165Information about X Input Extension devices is transferred between a client 166program and the Xkb extension in an 167<structname>XkbDeviceInfoRec</structname> 168structure: 169 170<programlisting> 171typedef struct { 172 char * name; /* name for device */ 173 Atom type; /* name for class of devices */ 174 unsigned short device_spec; /* device of interest */ 175 Bool has_own_state; /* <symbol>True</symbol> ⇒ this device has 176 its own state */ 177 unsigned short supported; /* bits indicating supported capabilities */ 178 unsigned short unsupported; /* bits indicating unsupported capabilities */ 179 unsigned short num_btns; /* number of entries in <structfield>btn_acts</structfield> */ 180 XkbAction * btn_acts; /* button actions */ 181 unsigned short sz_leds; /* total number of entries in LEDs vector */ 182 unsigned short num_leds; /* number of valid entries in LEDs vector */ 183 unsigned short dflt_kbd_fb; /* input extension ID of default 184 (core kbd) indicator */ 185 unsigned short dflt_led_fb; /* input extension ID of default 186 indicator feedback */ 187 XkbDeviceLedInfoPtr leds; /* LED descriptions */ 188} <structname>XkbDeviceInfoRec</structname>, *XkbDeviceInfoPtr; 189 190typedef struct { 191 unsigned short led_class; /* class for this LED device */ 192 unsigned short led_id; /* ID for this LED device */ 193 unsigned int phys_indicators; /* bits for which LEDs physically present */ 194 unsigned int maps_present; /* bits for which LEDs have maps in <structfield>maps</structfield> */ 195 unsigned int names_present; /* bits for which LEDs are in <structfield>names</structfield> */ 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} <structname>XkbDeviceLedInfoRec</structname>, *XkbDeviceLedInfoPtr; 200</programlisting></para> 201 202<para> 203The 204<structfield>type</structfield> 205field 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 207<symbol>KeyClass</symbol>), 208it has its own state, and 209<structfield>has_own_state</structfield> 210is 211<symbol>True</symbol>. 212If 213<structfield>has_own_state</structfield> 214is 215<symbol>False</symbol>, 216the state of the core keyboard is used. The 217<structfield>supported</structfield> 218and 219<structfield>unsupported</structfield> 220fields are masks where each bit indicates a capability. The meaning of the 221mask bits is listed in <link linkend="table21.1">Table 21.1</link>, 222together with the fields in the 223<structname>XkbDeviceInfoRec</structname> 224structure that are associated with the capability represented by each bit. The 225same bits are used to indicate the specific information desired in many of the 226functions described subsequently in this section. 227</para> 228 229<table id='table21.1' frame='topbot'> 230<title>XkbDeviceInfoRec Mask Bits</title> 231<?dbfo keep-together="always" ?> 232<tgroup cols='4' align='left' colsep='0' rowsep='0'> 233<colspec colname='c1' colwidth='2.9*'/> 234<colspec colname='c2' colwidth='2.0*'/> 235<colspec colname='c3' colwidth='0.9*'/> 236<colspec colname='c4' colwidth='2.0*'/> 237<thead> 238 <row rowsep='1'> 239 <entry>Name</entry> 240 <entry>XkbDeviceInfoRec Fields Effected</entry> 241 <entry>Value</entry> 242 <entry>Capability If Set</entry> 243 </row> 244</thead> 245<tbody> 246 <row> 247 <entry><symbol>XkbXI_KeyboardsMask</symbol></entry> 248 <entry></entry> 249 <entry>(1L << 0)</entry> 250 <entry> 251Clients can use all Xkb requests and events with 252<symbol>KeyClass</symbol> 253devices supported by the input device extension. 254 </entry> 255 </row> 256 <row> 257 <entry><symbol>XkbXI_ButtonActionsMask</symbol></entry> 258 <entry> 259<para>num_btns</para> 260<para>btn_acts</para> 261 </entry> 262 <entry>(1L <<1)</entry> 263 <entry> 264Clients can assign key actions to buttons on non- 265<symbol>KeyClass</symbol> 266input extension devices. 267 </entry> 268 </row> 269 <row> 270 <entry><symbol>XkbXI_IndicatorNamesMask</symbol></entry> 271 <entry>leds->names</entry> 272 <entry>(1L <<2)</entry> 273 <entry> 274Clients can assign names to indicators on non- 275<symbol>KeyClass</symbol> 276input extension devices. 277 </entry> 278 </row> 279 <row> 280 <entry><symbol>XkbXI_IndicatorMapsMask</symbol></entry> 281 <entry>leds->maps</entry> 282 <entry>(1L <<3)</entry> 283 <entry> 284Clients can assign indicator maps to indicators on non- 285<symbol>KeyClass</symbol> 286input extension devices. 287 </entry> 288 </row> 289 <row> 290 <entry><symbol>XkbXI_IndicatorStateMask</symbol></entry> 291 <entry>leds->state</entry> 292 <entry>(1L <<4)</entry> 293 <entry> 294Clients can request the status of indicators on non- 295<symbol>KeyClass</symbol> 296input extension devices. 297 </entry> 298 </row> 299 <row> 300 <entry><symbol>XkbXI_IndicatorsMask</symbol></entry> 301 <entry> 302<para>sz_leds</para> 303<para>num_leds</para> 304<para>leds->*</para> 305 </entry> 306 <entry>(0x1c)</entry> 307 <entry> 308<para><symbol>XkbXI_IndicatorNames­Mask</symbol> |</para> 309<para><symbol>XkbXI_IndicatorMaps­Mask</symbol> |</para> 310<para><symbol>XkbXI_IndicatorState­Mask</symbol></para> 311 </entry> 312 </row> 313 <row> 314 <entry><symbol>XkbXI_UnsupportedFeaturesMask</symbol></entry> 315 <entry>unsupported</entry> 316 <entry>(1L <<15)</entry> 317 <entry></entry> 318 </row> 319 <row> 320 <entry><symbol>XkbXI_AllDeviceFeaturesMask</symbol></entry> 321 <entry>Those selected by Value column masks</entry> 322 <entry>(0x1e)</entry> 323 <entry> 324<para><symbol>XkbXI_Indicators­Mask</symbol> | </para> 325<para><symbol>XkbXI_ButtonActions­Mask</symbol> </para> 326 </entry> 327 </row> 328 <row> 329 <entry><symbol>XkbXI_AllFeaturesMask</symbol></entry> 330 <entry>Those selected by Value column masks</entry> 331 <entry>(0x1f)</entry> 332 <entry> 333<para><symbol>XkbXI_AllDevice­FeaturesMask</symbol> | </para> 334<para><symbol>XkbXI_Keyboards­Mask</symbol> </para> 335 </entry> 336 </row> 337 <row> 338 <entry><symbol>XkbXI_AllDetailsMask</symbol></entry> 339 <entry>Those selected by Value column masks</entry> 340 <entry>(0x801f)</entry> 341 <entry> 342<para><symbol>XkbXI_AllFeatures­Mask</symbol> | </para> 343<para><symbol>XkbXI_Unsupported­FeaturesMask</symbol></para> 344 </entry> 345 </row> 346</tbody> 347</tgroup> 348</table> 349 350<para> 351The 352<structfield>name</structfield>, 353<structfield>type</structfield>, 354<structfield>has_own_state</structfield>, 355<structfield>supported</structfield>, 356and 357<structfield>unsupported</structfield> 358fields are always filled in when a valid reply is returned from the server 359involving an 360<structname>XkbDeviceInfoRec</structname>. 361All of the other fields are modified only if the particular function asks for 362them. 363</para> 364 365</sect1> 366<sect1 id='Querying_Xkb_Features_for_Non_KeyClass_Input_Extension_Devices'> 367<title>Querying Xkb Features for Non-KeyClass Input Extension Devices</title> 368 369<para> 370To determine whether the X server allows Xkb access to particular capabilities 371of input devices other than the core X keyboard, or to determine the status of 372indicator maps, indicator names or button actions on a non- 373<symbol>KeyClass</symbol> 374extension device, use XkbGetDeviceInfo. 375</para> 376 377<indexterm significance="preferred" zone="XkbGetDeviceInfo"><primary><function>XkbGetDeviceInfo</function></primary></indexterm> 378<funcsynopsis id="XkbGetDeviceInfo"> 379 <funcprototype> 380 <funcdef>XkbDeviceInfoPtr <function>XkbGetDeviceInfo</function></funcdef> 381<!-- ( 382<parameter>dpy</parameter>, 383which, device_spec, ind_class, ind_id) --> 384 385 <paramdef>Display *<parameter>dpy</parameter></paramdef> 386 <paramdef>unsigned int <parameter>which</parameter></paramdef> 387 <paramdef>unsigned int <parameter>device_spec</parameter></paramdef> 388 <paramdef>unsigned int <parameter>ind_class</parameter></paramdef> 389 <paramdef>unsigned int <parameter>ind_id</parameter></paramdef> 390 </funcprototype> 391</funcsynopsis> 392<variablelist> 393 <varlistentry> 394 <term> 395 <parameter>dpy</parameter> 396 </term> 397 <listitem> 398 <para> 399 connection to X server 400 </para> 401 </listitem> 402 </varlistentry> 403 <varlistentry> 404 <term> 405 <parameter>which</parameter> 406 </term> 407 <listitem> 408 <para> 409 mask indicating information to return 410 </para> 411 </listitem> 412 </varlistentry> 413 <varlistentry> 414 <term> 415 <parameter>device_spec</parameter> 416 </term> 417 <listitem> 418 <para> 419 device ID, or <symbol>XkbUseCoreKbd</symbol> 420 </para> 421 </listitem> 422 </varlistentry> 423 <varlistentry> 424 <term> 425 <parameter>ind_class</parameter> 426 </term> 427 <listitem> 428 <para> 429 feedback class for indicator requests 430 </para> 431 </listitem> 432 </varlistentry> 433 <varlistentry> 434 <term> 435 <parameter>ind_id</parameter> 436 </term> 437 <listitem> 438 <para> 439 feedback ID for indicator requests 440 </para> 441 </listitem> 442 </varlistentry> 443</variablelist> 444 445<para> 446<function>XkbGetDeviceInfo</function> 447returns information about the input device specified by 448<parameter>device_spec</parameter>. 449Unlike the 450<parameter>device_spec</parameter> 451parameter of most Xkb functions, 452<parameter>device_spec</parameter> 453does not need to be a keyboard device. It must, however, indicate either the 454core keyboard or a valid X Input Extension device. 455</para> 456 457 458<para> 459The 460<parameter>which</parameter> 461parameter 462is a mask specifying optional information to be returned. It is an inclusive OR 463of one or more of the values from <link linkend="table21.1">Table 21.1</link> 464and causes the returned 465<structname>XkbDeviceInfoRec</structname> 466to contain values for the corresponding fields specified in the table. 467</para> 468 469 470<para> 471The 472<structname>XkbDeviceInfoRec</structname> 473returned by 474<function>XkbGetDeviceInfo</function> 475always has values for 476<structfield>name</structfield> 477(may be a null string, ""), 478<structfield>type</structfield>, 479<structfield>supported</structfield>, 480<structfield>unsupported</structfield>, 481<structfield>has_own_state</structfield>, 482<structfield>dflt_kbd_fb</structfield>, 483and 484<structfield>dflt_led_fb</structfield>. 485Other fields are filled in as specified by 486<parameter>which</parameter>. 487</para> 488 489 490<para> 491Upon return, the 492<structfield>supported</structfield> 493field will be set to the inclusive OR of zero or more bits from 494<link linkend="table21.1">Table 21.1</link>; 495each bit set indicates an optional Xkb extension device feature supported by 496the server implementation, and a client may modify the associated behavior. 497</para> 498 499 500<para> 501If the 502<symbol>XkbXI_ButtonActionsMask</symbol> 503bit is set in 504<parameter>which</parameter>, 505the 506<structname>XkbDeviceInfoRec</structname> 507returned will have the button actions 508(<structfield>btn_acts</structfield> 509field) filled in for all buttons. 510</para> 511 512 513<para> 514If 515<parameter>which</parameter> 516includes one of the bits in <symbol>XkbXI_IndicatorsMask</symbol>, 517the feedback class of the 518indicators must be specified in ind_class, and the feedback ID of the 519indicators must be specified in ind_id. If the request does not include any of 520the bits in <symbol>XkbXI_IndicatorsMask</symbol>, 521the ind_class and ind_id parameters are 522ignored. The class and ID can be obtained via the input device extension 523XListInputDevices request. 524</para> 525 526 527<para> 528If any of the 529<symbol>XkbXI_IndicatorsMask</symbol> 530bits are set in 531<parameter>which</parameter>, 532the 533<structname>XkbDeviceInfoRec</structname> 534returned will have filled in the portions of the 535<structfield>leds</structfield> 536structure corresponding to the indicator feedback identified by 537<parameter>ind_class</parameter> 538and 539<parameter>ind_id</parameter>. 540The 541<structfield>leds</structfield> 542vector of the 543<structname>XkbDeviceInfoRec</structname> 544is allocated if necessary and 545<structfield>sz_leds</structfield> 546and 547<structfield>num_leds</structfield> 548filled in. The 549<structfield>led_class</structfield>, 550<structfield>led_id</structfield> 551and 552<structfield>phys_indicators</structfield> 553fields of the 554<structfield>leds</structfield> 555entry corresponding to 556<parameter>ind_class</parameter> 557and 558<parameter>ind_id</parameter> 559are always filled in. If 560<parameter>which</parameter> 561contains 562<symbol>XkbXI_IndicatorNamesMask</symbol>, 563the 564<structfield>names_present</structfield> 565and 566<structfield>names</structfield> 567fields of the 568<structfield>leds</structfield> 569structure corresponding to 570<parameter>ind_class</parameter> 571and 572<parameter>ind_id</parameter> 573are returned. 574If 575<parameter>which</parameter> 576contains 577<symbol>XkbXI_IndicatorStateMask</symbol>, 578the corresponding 579<structfield>state</structfield> 580field is updated. If 581<parameter>which</parameter> 582contains 583<symbol>XkbXI_IndicatorMapsMask</symbol>, 584the 585<structfield>maps_present</structfield> 586and 587<structfield>maps</structfield> 588fields are updated. 589</para> 590 591 592<para> 593Xkb provides convenience functions to request subsets of the information 594available via 595<function>XkbGetDeviceInfo</function>. 596These convenience functions mirror some of the mask bits. The functions all 597take an 598<type>XkbDeviceInfoPtr</type> 599as an input argument and operate on the X Input Extension device specified by 600the 601<parameter>device_spec</parameter> 602field of the structure. Only the parts of the structure indicated in the 603function description are updated. The 604<structname>XkbDeviceInfoRec</structname> 605structure used in the function call can be obtained by calling 606XkbGetDeviceInfo or can be allocated by calling XkbAllocDeviceInfo 607(see <link linkend="Allocating_Initializing_and_Freeing_the_XkbDeviceInfoRecStructure">section 21.3</link>). 608</para> 609 610 611<para> 612These convenience functions are described as follows. 613</para> 614 615 616<para> 617To query the button actions associated with an X Input Extension device, use 618XkbGetDeviceButtonActions. 619</para> 620 621 622<indexterm significance="preferred" zone="XkbGetDeviceButtonActions"><primary><function>XkbGetDeviceButtonActions</function></primary></indexterm> 623<funcsynopsis id="XkbGetDeviceButtonActions"> 624 <funcprototype> 625 <funcdef>Status <function>XkbGetDeviceButtonActions</function></funcdef> 626<!-- ( 627<parameter>dpy, device_info, all_buttons, first_button, num_buttons</parameter> 628) --> 629 630 <paramdef>Display *<parameter>dpy</parameter></paramdef> 631 <paramdef>XkbDeviceInfoPtr <parameter>device_info</parameter></paramdef> 632 <paramdef>Bool <parameter>all_buttons</parameter></paramdef> 633 <paramdef>unsigned int <parameter>first_button</parameter></paramdef> 634 <paramdef>unsigned int <parameter>num_buttons</parameter></paramdef> 635 </funcprototype> 636</funcsynopsis> 637<variablelist> 638 <varlistentry> 639 <term> 640 <parameter>dpy</parameter> 641 </term> 642 <listitem> 643 <para> 644 connection to X server 645 </para> 646 </listitem> 647 </varlistentry> 648 <varlistentry> 649 <term> 650 <parameter>device_info</parameter> 651 </term> 652 <listitem> 653 <para> 654 structure to update with results 655 </para> 656 </listitem> 657 </varlistentry> 658 <varlistentry> 659 <term> 660 <parameter>all_buttons</parameter> 661 </term> 662 <listitem> 663 <para> 664 <symbol>True</symbol> ⇒ get information for all buttons 665 </para> 666 </listitem> 667 </varlistentry> 668 <varlistentry> 669 <term> 670 <parameter>first_button</parameter> 671 </term> 672 <listitem> 673 <para> 674 number of first button for which info is desired 675 </para> 676 </listitem> 677 </varlistentry> 678 <varlistentry> 679 <term> 680 <parameter>num_buttons</parameter> 681 </term> 682 <listitem> 683 <para> 684 number of buttons for which info is desired 685 </para> 686 </listitem> 687 </varlistentry> 688</variablelist> 689 690<para> 691<function>XkbGetDeviceButtonActions</function> 692queries the server for the desired button information for the device indicated 693by the 694<structfield>device_spec</structfield> 695field of 696<parameter>device_info</parameter> 697and waits for a reply. If successful, 698<function>XkbGetDeviceButtonActions</function> 699backfills the button actions 700(<structfield>btn_acts</structfield> 701field of 702<parameter>device_info</parameter>) 703for only the requested buttons, updates the 704<structfield>name</structfield>, 705<structfield>type</structfield>, 706<structfield>supported</structfield>, 707and 708<structfield>unsupported</structfield> 709fields, and returns 710<symbol>Success</symbol>. 711</para> 712 713 714<para> 715<parameter>all_buttons</parameter>, 716<parameter>first_button</parameter> 717and 718<parameter>num_buttons</parameter> 719specify the device buttons for which actions should be returned. Setting 720<parameter>all_buttons</parameter> 721to 722<symbol>True</symbol> 723requests actions for all device buttons; if 724<parameter>all_buttons</parameter> 725is 726<symbol>False</symbol>, 727<parameter>first_button</parameter> 728and 729<parameter>num_buttons</parameter> 730specify a range of buttons for which actions are requested. 731</para> 732 733 734<para> 735If a compatible version of Xkb is not available in the server or the Xkb 736extension has not been properly initialized, XkbGetDeviceButtonActions returns 737<errorname>BadAccess</errorname>. 738If allocation errors occur, a 739<errorname>BadAlloc</errorname> 740status is returned. If the specified device 741(<parameter>device_info</parameter>-><structfield>device_spec</structfield>) 742is invalid, a 743<errorname>BadKeyboard</errorname> 744status is returned. If the device has no buttons, a 745<errorname>BadMatch</errorname> 746status is returned. If 747<parameter>first_button</parameter> 748and 749<parameter>num_buttons</parameter> 750specify illegal buttons, a 751<errorname>BadValue</errorname> 752status is returned. 753</para> 754 755 756<para> 757To query the indicator names, maps, and state associated with an LED feedback 758of an input extension device, use XkbGetDeviceLedInfo. 759</para> 760 761 762<indexterm significance="preferred" zone="XkbGetDeviceLedInfo"><primary><function>XkbGetDeviceLedInfo</function></primary></indexterm> 763<funcsynopsis id="XkbGetDeviceLedInfo"> 764 <funcprototype> 765 <funcdef>Status <function>XkbGetDeviceLedInfo</function></funcdef> 766<!-- ( 767<parameter>dpy, device_i</parameter> 768nfo, led_class, led_id, which) --> 769 770 <paramdef>Display *<parameter>dpy</parameter></paramdef> 771 <paramdef>XkbDeviceInfoPtr <parameter>device_info</parameter></paramdef> 772 <paramdef>unsigned int <parameter>led_class</parameter></paramdef> 773 <paramdef>unsigned int <parameter>led_id</parameter></paramdef> 774 <paramdef>unsigned int <parameter>which</parameter></paramdef> 775 </funcprototype> 776</funcsynopsis> 777<variablelist> 778 <varlistentry> 779 <term> 780 <parameter>dpy</parameter> 781 </term> 782 <listitem> 783 <para> 784 connection to X server 785 </para> 786 </listitem> 787 </varlistentry> 788 <varlistentry> 789 <term> 790 <parameter>device_info</parameter> 791 </term> 792 <listitem> 793 <para> 794 structure to update with results 795 </para> 796 </listitem> 797 </varlistentry> 798 <varlistentry> 799 <term> 800 <parameter>led_class</parameter> 801 </term> 802 <listitem> 803 <para> 804 LED feedback class assigned by input extension 805 </para> 806 </listitem> 807 </varlistentry> 808 <varlistentry> 809 <term> 810 <parameter>led_id</parameter> 811 </term> 812 <listitem> 813 <para> 814 LED feedback ID assigned by input extension 815 </para> 816 </listitem> 817 </varlistentry> 818 <varlistentry> 819 <term> 820 <parameter>which</parameter> 821 </term> 822 <listitem> 823 <para> 824 mask indicating desired information 825 </para> 826 </listitem> 827 </varlistentry> 828</variablelist> 829 830<para> 831<function>XkbGetDeviceLedInfo</function> 832queries the server for the desired LED information for the feedback specified 833by 834<parameter>led_class</parameter> 835and 836<parameter>led_id</parameter> 837for the X input extension device indicated by 838<structfield>device_spec</structfield>-><parameter>device_info</parameter> 839and waits for a reply. If successful, 840<function>XkbGetDeviceLedInfo</function> 841backfills the relevant fields of 842<parameter>device_info</parameter> 843as determined by 844<parameter>which</parameter> 845with the results and returns 846<symbol>Success</symbol>. 847Valid values for 848<parameter>which</parameter> 849are the inclusive OR of any of 850<symbol>XkbXI_IndicatorNamesMask</symbol>, 851<symbol>XkbXI_IndicatorMapsMask</symbol>, 852and 853<symbol>XkbXI_IndicatorStateMask</symbol>. 854</para> 855 856 857<para> 858The fields of 859<parameter>device_info</parameter> 860that are filled in when this request succeeds are 861<structfield>name</structfield>, 862<structfield>type</structfield>, 863<structfield>supported</structfield>, 864and 865<structfield>unsupported</structfield>, 866and portions of the 867<structfield>leds</structfield> 868structure corresponding to 869<parameter>led_class</parameter> 870and 871<parameter>led_id</parameter> 872as indicated by the bits set in 873<parameter>which</parameter>. 874The 875<structfield>device_info->leds</structfield> 876vector is allocated if necessary and 877<structfield>sz_leds</structfield> 878and 879<structfield>num_leds</structfield> 880filled in. The 881<parameter>led_class</parameter>, 882<parameter>led_id</parameter> 883and 884<structfield>phys_indicators</structfield> 885fields of the 886<parameter>device_info</parameter>-><structfield>leds</structfield> 887entry corresponding to 888<parameter>led_class</parameter> 889and 890<parameter>led_id</parameter> 891are always filled in. 892</para> 893 894 895<para> 896If 897<parameter>which</parameter> 898contains 899<symbol>XkbXI_IndicatorNamesMask</symbol>, 900the 901<structfield>names_present</structfield> 902and 903<structfield>names</structfield> 904fields of the 905<parameter>device_info</parameter>-><structfield>leds</structfield> 906structure corresponding to 907<parameter>led_class</parameter> 908and 909<parameter>led_id</parameter> 910are updated, if 911<parameter>which</parameter> 912contains 913<symbol>XkbXI_IndicatorStateMask</symbol>, 914the corresponding 915<structfield>state</structfield> 916field is updated, and if 917<parameter>which</parameter> 918contains 919<symbol>XkbXI_IndicatorMapsMask</symbol>, 920the 921<structfield>maps_present</structfield> 922and 923<structfield>maps</structfield> 924fields are updated. 925</para> 926 927 928<para> 929If a compatible version of Xkb is not available in the server or the Xkb 930extension has not been properly initialized, 931<function>XkbGetDeviceLedInfo</function> 932returns 933<errorname>BadAccess</errorname>. 934If allocation errors occur, a 935<errorname>BadAlloc</errorname> 936status is returned. If the device has no indicators, a 937<errorname>BadMatch</errorname> 938error is returned. If 939<structfield>ledClass</structfield> 940or 941<structfield>ledID</structfield> 942have illegal values, a 943<errorname>BadValue</errorname> 944error is returned. If they have legal values but do not specify a feedback 945that contains LEDs and is associated with the specified device, a 946<errorname>BadMatch</errorname> 947error is returned. 948</para> 949 950 951</sect1> 952<sect1 id='Allocating_Initializing_and_Freeing_the_XkbDeviceInfoRecStructure'> 953<title>Allocating, Initializing, and Freeing the XkbDeviceInfoRec 954Structure</title> 955 956<para> 957To obtain an 958<structname>XkbDeviceInfoRec</structname> 959structure, use XkbGetDeviceInfo or XkbAllocDeviceInfo. 960</para> 961 962<indexterm significance="preferred" zone="XkbAllocDeviceInfo"><primary><function>XkbAllocDeviceInfo</function></primary></indexterm> 963<funcsynopsis id="XkbAllocDeviceInfo"> 964 <funcprototype> 965 <funcdef>XkbDeviceInfoPtr <function>XkbAllocDeviceInfo</function></funcdef> 966<!-- (device_spec, n_buttons, sz_leds) --> 967 968 <paramdef>unsigned int <parameter>device_spec</parameter></paramdef> 969 <paramdef>unsigned int <parameter>n_buttons</parameter></paramdef> 970 <paramdef>unsigned int <parameter>sz_leds</parameter></paramdef> 971 </funcprototype> 972</funcsynopsis> 973<variablelist> 974 <varlistentry> 975 <term> 976 <parameter>device_spec</parameter> 977 </term> 978 <listitem> 979 <para> 980 device ID with which structure will be used 981 </para> 982 </listitem> 983 </varlistentry> 984 <varlistentry> 985 <term> 986 <parameter>n_buttons</parameter> 987 </term> 988 <listitem> 989 <para> 990 number of button actions to allocate space for 991 </para> 992 </listitem> 993 </varlistentry> 994 <varlistentry> 995 <term> 996 <parameter>sz_leds</parameter> 997 </term> 998 <listitem> 999 <para> 1000 number of LED feedbacks to allocate space for 1001 </para> 1002 </listitem> 1003 </varlistentry> 1004</variablelist> 1005 1006<para> 1007<function>XkbAllocDeviceInfo</function> 1008allocates space for an 1009<structname>XkbDeviceInfoRec</structname> 1010structure and initializes that structure’s 1011<parameter>device_spec</parameter> 1012field with the device ID specified by device_spec. If 1013<parameter>n_buttons</parameter> 1014is nonzero, 1015<parameter>n_buttons</parameter> 1016<structname>XkbAction</structname>s 1017are linked into the 1018<structname>XkbDeviceInfoRec</structname> 1019structure and initialized to zero. If sz_leds is nonzero, 1020<parameter>sz_leds</parameter> 1021<structname>XkbDeviceLedInfoRec</structname> 1022structures are also allocated and linked into the 1023<structname>XkbDeviceInfoRec</structname> 1024structure. If you request 1025<structname>XkbDeviceLedInfoRec</structname> 1026structures be allocated using this request, you must initialize them 1027explicitly. 1028</para> 1029 1030 1031<para> 1032To initialize an 1033<structname>XkbDeviceLedInfoRec</structname> 1034structure, use XkbAddDeviceLedInfo. 1035</para> 1036 1037 1038<indexterm significance="preferred" zone="XkbAddDeviceLedInfo"><primary><function>XkbAddDeviceLedInfo</function></primary></indexterm> 1039<funcsynopsis id="XkbAddDeviceLedInfo"> 1040 <funcprototype> 1041 <funcdef>XkbDeviceLedInfoPtr <function>XkbAddDeviceLedInfo</function></funcdef> 1042<!-- (device_info, led_class, led_id) --> 1043 1044 <paramdef>XkbDeviceInfoPtr <parameter>device_info</parameter></paramdef> 1045 <paramdef>unsigned int <parameter>led_class</parameter></paramdef> 1046 <paramdef>unsigned int <parameter>led_id</parameter></paramdef> 1047 </funcprototype> 1048</funcsynopsis> 1049<variablelist> 1050 <varlistentry> 1051 <term> 1052 <parameter>device_info</parameter> 1053 </term> 1054 <listitem> 1055 <para> 1056 structure in which to add LED info 1057 </para> 1058 </listitem> 1059 </varlistentry> 1060 <varlistentry> 1061 <term> 1062 <parameter>led_class</parameter> 1063 </term> 1064 <listitem> 1065 <para> 1066 input extension class for LED device of interest 1067 </para> 1068 </listitem> 1069 </varlistentry> 1070 <varlistentry> 1071 <term> 1072 <parameter>led_id</parameter> 1073 </term> 1074 <listitem> 1075 <para> 1076 input extension ID for LED device of interest 1077 </para> 1078 </listitem> 1079 </varlistentry> 1080</variablelist> 1081 1082<para> 1083<function>XkbAddDeviceLedInfo</function> 1084first checks to see whether an entry matching 1085<parameter>led_class</parameter> 1086and 1087<parameter>led_id</parameter> 1088already exists in the 1089<structfield>device_info->leds</structfield> 1090array. If it finds a matching entry, it returns a pointer to that entry. 1091Otherwise, it checks to be sure there is at least one empty entry in 1092<parameter>device_info</parameter>-><structfield>leds</structfield> 1093and extends it if there is not enough room. It then increments 1094<parameter>device_info</parameter>-><structfield>num_leds</structfield> 1095and fills in the next available entry in 1096<parameter>device_info</parameter>-><structfield>leds</structfield> 1097with 1098<parameter>led_class</parameter> 1099and 1100<parameter>led_id</parameter>. 1101</para> 1102 1103 1104<para> 1105If successful, 1106<function>XkbAddDeviceLedInfo</function> 1107returns a pointer to the 1108<structname>XkbDeviceLedInfoRec</structname> 1109structure that was initialized. If unable to allocate sufficient storage, or 1110if 1111<parameter>device_info</parameter> 1112points to an invalid 1113<structname>XkbDeviceInfoRec</structname> 1114structure, or if 1115<parameter>led_class</parameter> 1116or 1117<parameter>led_id</parameter> 1118are inappropriate, 1119<function>XkbAddDeviceLedInfo</function> 1120returns 1121<symbol>NULL</symbol>. 1122</para> 1123 1124 1125<para> 1126To allocate additional space for button actions in an 1127<structname>XkbDeviceInfoRec</structname> 1128structure, use XkbResizeDeviceButtonActions. 1129</para> 1130 1131 1132<indexterm significance="preferred" zone="XkbResizeDeviceButtonActions"><primary><function>XkbResizeDeviceButtonActions</function></primary></indexterm> 1133<funcsynopsis id="XkbResizeDeviceButtonActions"> 1134 <funcprototype> 1135 <funcdef>Status <function>XkbResizeDeviceButtonActions</function></funcdef> 1136<!-- (device_info, new_total) --> 1137 1138 <paramdef>XkbDeviceInfoPtr <parameter>device_info</parameter></paramdef> 1139 <paramdef>unsigned int <parameter>new_total</parameter></paramdef> 1140 </funcprototype> 1141</funcsynopsis> 1142<variablelist> 1143 <varlistentry> 1144 <term> 1145 <parameter>device_info</parameter> 1146 </term> 1147 <listitem> 1148 <para> 1149 structure in which to allocate button actions 1150 </para> 1151 </listitem> 1152 </varlistentry> 1153 <varlistentry> 1154 <term> 1155 <parameter>new_total</parameter> 1156 </term> 1157 <listitem> 1158 <para> 1159 new total number of button actions needed 1160 </para> 1161 </listitem> 1162 </varlistentry> 1163</variablelist> 1164 1165<para> 1166<function>XkbResizeDeviceButtonActions</function> 1167reallocates space, if necessary, to make sure there is room for a total of 1168<parameter>new_total</parameter> 1169button actions in the 1170<parameter>device_info</parameter> 1171structure. Any new entries allocated are zeroed. If successful, 1172<function>XkbResizeDeviceButtonActions</function> 1173returns Success. If new_total is zero, all button actions are deleted, 1174<parameter>device_info</parameter>-><structfield>num_btns</structfield> 1175is set to zero, and 1176<parameter>device_info</parameter>-><structfield>btn_acts</structfield> 1177is set to 1178<symbol>NULL</symbol>. 1179If device_info is invalid or new_total is greater than 255, 1180<errorname>BadValue</errorname> 1181is returned. If a memory allocation failure occurs, a 1182<errorname>BadAlloc</errorname> 1183is returned. 1184</para> 1185 1186 1187<para> 1188To free an 1189<structname>XkbDeviceInfoRec</structname> 1190structure, use XkbFreeDeviceInfo. 1191</para> 1192 1193 1194<indexterm significance="preferred" zone="XkbFreeDeviceInfo"><primary><function>XkbFreeDeviceInfo</function></primary></indexterm> 1195<funcsynopsis id="XkbFreeDeviceInfo"> 1196 <funcprototype> 1197 <funcdef>void <function>XkbFreeDeviceInfo</function></funcdef> 1198<!-- (device_info, which, free_all) --> 1199 1200 <paramdef>XkbDeviceInfoPtr <parameter>device_info</parameter></paramdef> 1201 <paramdef>unsigned int <parameter>which</parameter></paramdef> 1202 <paramdef>Bool <parameter>free_all</parameter></paramdef> 1203 </funcprototype> 1204</funcsynopsis> 1205<variablelist> 1206 <varlistentry> 1207 <term> 1208 <parameter>device_info</parameter> 1209 </term> 1210 <listitem> 1211 <para> 1212 pointer to <structname>XkbDeviceInfoRec</structname> in which to free items 1213 </para> 1214 </listitem> 1215 </varlistentry> 1216 <varlistentry> 1217 <term> 1218 <parameter>which</parameter> 1219 </term> 1220 <listitem> 1221 <para> 1222 mask of components of <parameter>device_info</parameter> to free 1223 </para> 1224 </listitem> 1225 </varlistentry> 1226 <varlistentry> 1227 <term> 1228 <parameter>free_all</parameter> 1229 </term> 1230 <listitem> 1231 <para> 1232 <symbol>True</symbol> ⇒ free everything, including device_info 1233 </para> 1234 </listitem> 1235 </varlistentry> 1236</variablelist> 1237 1238<para> 1239If free_all is 1240<symbol>True</symbol>, 1241the 1242<function>XkbFreeDeviceInfo</function> 1243frees all components of 1244<parameter>device_info</parameter> 1245and the 1246<structname>XkbDeviceInfoRec</structname> 1247structure pointed to by 1248<parameter>device_info</parameter> 1249itself. If free_all is 1250<symbol>False</symbol>, 1251the value of which determines which subcomponents are freed. 1252<parameter>which</parameter> 1253is an inclusive OR of one or more of the values from 1254<link linkend="table21.1">Table 21.1</link>. If which 1255contains <symbol>XkbXI_ButtonActionsMask</symbol>, 1256all button actions associated with 1257<parameter>device_info</parameter> 1258are freed, 1259<parameter>device_info</parameter>-><structfield>btn_acts</structfield> 1260is set to 1261<symbol>NULL</symbol>, 1262and 1263<parameter>device_info</parameter>-><structfield>num_btns</structfield> 1264is set to zero. If which contains all bits in 1265<symbol>XkbXI_IndicatorsMask</symbol>, all 1266<structname>XkbDeviceLedInfoRec</structname> 1267structures associated with 1268<parameter>device_info</parameter> 1269are freed, 1270<parameter>device_info</parameter>-><structfield>leds</structfield> 1271is set to 1272<symbol>NULL</symbol>, 1273and 1274<parameter>device_info</parameter>-><structfield>sz_leds</structfield> 1275and 1276<parameter>device_info</parameter>-><structfield>num_leds</structfield> 1277are set to zero. If which contains <symbol>XkbXI_IndicatorMapsMask</symbol>, 1278all indicator maps associated with 1279<parameter>device_info</parameter> 1280are cleared, but the number of LEDs and the leds structures themselves are 1281preserved. If which contains <symbol>XkbXI_IndicatorNamesMask</symbol>, 1282all indicator names 1283associated with device_info are cleared, but the number of LEDs and the leds 1284structures themselves are preserved. If which contains 1285<symbol>XkbXI_IndicatorStateMask</symbol>, 1286the indicator state associated with the 1287<parameter>device_info</parameter> 1288leds are set to zeros but the number of LEDs and the leds structures 1289themselves are preserved. 1290</para> 1291 1292 1293</sect1> 1294<sect1 id='Setting_Xkb_Features_for_Non_KeyClass_Input_Extension_Devices'> 1295<title>Setting Xkb Features for Non-KeyClass Input Extension Devices</title> 1296 1297<para> 1298The Xkb extension allows clients to assign any key action to either core 1299pointer or input extension device buttons. This makes it possible to control 1300the keyboard or generate keyboard key events from extension devices or from the 1301core pointer. 1302</para> 1303 1304 1305<para> 1306Key actions assigned to core X pointer buttons or input extension device 1307buttons cause key events to be generated as if they had originated from the 1308core X keyboard. 1309</para> 1310 1311 1312<para> 1313Xkb implementations are required to support key actions for the buttons of the 1314core pointer device, but support for actions on extension devices is optional. 1315Implementations that do not support button actions for extension devices must 1316not set the 1317<symbol>XkbXI_ButtonActionsMask</symbol> 1318bit in the 1319<structfield>supported</structfield> 1320field of an 1321<structname>XkbDeviceInfoRec</structname> 1322structure. 1323</para> 1324 1325 1326<para> 1327If a client attempts to modify valid characteristics of a device using an 1328implementation that does not support modification of those characteristics, no 1329protocol error is generated. Instead, the server reports a failure for the 1330request; it also sends an 1331<symbol>XkbExtensionDeviceNotify</symbol> 1332event to the client that issued the request if the client has selected to 1333receive these events. 1334</para> 1335 1336 1337<para> 1338To change characteristics of an X Input Extension device in the server, first 1339modify a local copy of the device structure and then use either 1340<function>XkbSetDeviceInfo</function>, 1341or, to save network traffic, use an 1342<structname>XkbDeviceChangesRec</structname> 1343structure (see <link linkend="Tracking_Changes_to_Extension_Devices">section 21.6</link>) and call 1344<function>XkbChangeDeviceInfo</function> 1345to download the changes to the server. 1346</para> 1347 1348 1349<para> 1350To modify some or all of the characteristics of an X Input Extension device, 1351use XkbSetDeviceInfo. 1352</para> 1353 1354<indexterm significance="preferred" zone="XkbSetDeviceInfo"><primary><function>XkbSetDeviceInfo</function></primary></indexterm> 1355<funcsynopsis id="XkbSetDeviceInfo"> 1356 <funcprototype> 1357 <funcdef>Bool <function>XkbSetDeviceInfo</function></funcdef> 1358<!-- ( 1359<parameter>dpy</parameter>, 1360which, device_info) --> 1361 1362 <paramdef>Display *<parameter>dpy</parameter></paramdef> 1363 <paramdef>unsigned int <parameter>which</parameter></paramdef> 1364 <paramdef>XkbDeviceInfoPtr <parameter>device_info</parameter></paramdef> 1365 </funcprototype> 1366</funcsynopsis> 1367<variablelist> 1368 <varlistentry> 1369 <term> 1370 <parameter>dpy</parameter> 1371 </term> 1372 <listitem> 1373 <para> 1374 connection to X server 1375 </para> 1376 </listitem> 1377 </varlistentry> 1378 <varlistentry> 1379 <term> 1380 <parameter>which</parameter> 1381 </term> 1382 <listitem> 1383 <para> 1384 mask indicating characteristics to modify 1385 </para> 1386 </listitem> 1387 </varlistentry> 1388 <varlistentry> 1389 <term> 1390 <parameter>device_info</parameter> 1391 </term> 1392 <listitem> 1393 <para> 1394 structure defining the device and modifications 1395 </para> 1396 </listitem> 1397 </varlistentry> 1398</variablelist> 1399 1400<para> 1401<function>XkbSetDeviceInfo</function> 1402sends a request to the server to modify the characteristics of the device 1403specified in the 1404<parameter>device_info</parameter> 1405structure. The particular characteristics modified are identified by the bits 1406set in 1407<parameter>which</parameter> 1408and take their values from the relevant fields in 1409<parameter>device_info</parameter> 1410(see <link linkend="table21.1">Table 21.1</link>). 1411<function>XkbSetDeviceInfo</function> 1412returns 1413<symbol>True</symbol> 1414if the request was successfully sent to the server. If the X server 1415implementation does not allow interaction between the X input extension and the 1416Xkb Extension, the function does nothing and returns 1417<symbol>False</symbol>. 1418</para> 1419 1420 1421<para> 1422The 1423<parameter>which</parameter> 1424parameter specifies which aspects of the device should be changed and is a 1425bitmask composed of an inclusive OR or one or more of the following bits: 1426<symbol>XkbXI_ButtonActionsMask</symbol>, 1427<symbol>XkbXI_IndicatorNamesMask</symbol>, 1428<symbol>XkbXI_IndicatorMapsMask</symbol>. 1429If the features requested to be manipulated in 1430<parameter>which</parameter> 1431are valid for the device, but the server does not support assignment of one or 1432more of them, that particular portion of the request is ignored. 1433</para> 1434 1435 1436<para> 1437If the device specified in 1438<parameter>device_info</parameter>-><structfield>device_spec</structfield> 1439does not contain buttons and a request affecting buttons is made, or the 1440device does not contain indicators and a request affecting indicators is made, 1441a 1442<errorname>BadMatch</errorname> 1443protocol error results. 1444</para> 1445 1446 1447<para> 1448If the 1449<symbol>XkbXI_ButtonActionsMask</symbol> 1450bit is set in the supported mask returned by XkbGetDeviceInfo, the Xkb 1451extension allows applications to assign key actions to buttons on input 1452extension devices other than the core keyboard device. If the 1453<symbol>XkbXI_ButtonActionsMask</symbol> 1454is set in 1455<parameter>which</parameter>, 1456the actions for all buttons specified in device_info are set to the 1457<structname>XkbAction</structname>s 1458specified in 1459<parameter>device_info</parameter>-><structfield>btn_acts</structfield>. 1460If the number of buttons requested to be updated is not valid for the device, 1461<function>XkbSetDeviceInfo</function> 1462returns 1463<symbol>False</symbol> 1464and a 1465<errorname>BadValue</errorname> 1466protocol error results. 1467</para> 1468 1469 1470<para> 1471If the 1472<symbol>XkbXI_IndicatorMapsMask</symbol> 1473and / or 1474<symbol>XkbXI_IndicatorNamesMask</symbol> 1475bit is set in the supported mask returned by XkbGetDeviceInfo, the Xkb 1476extension allows applications to assign maps and / or names to the indicators 1477of nonkeyboard extension devices. If supported, maps and / or names can be 1478assigned to all extension device indicators, whether they are part of a 1479keyboard feedback or part of an indicator feedback. 1480</para> 1481 1482 1483<para> 1484If the 1485<symbol>XkbXI_IndicatorMapsMask</symbol> 1486and / or 1487<symbol>XkbXI_IndicatorNamesMask</symbol> 1488flag is set in 1489<parameter>which</parameter>, 1490the indicator maps and / or names for all 1491<parameter>device_info</parameter>-><structfield>num_leds</structfield> 1492indicator devices specified in 1493<parameter>device_info</parameter>-><structfield>leds</structfield> 1494are set to the maps and / or names specified in 1495<parameter>device_info</parameter>-><structfield>leds</structfield>. 1496<parameter>device_info</parameter>-><structfield>leds</structfield>-><structfield>led_class</structfield> 1497and 1498<structfield>led_id</structfield> 1499specify the input extension class and device ID for each indicator device to 1500modify; if they have invalid values, a 1501<errorname>BadValue</errorname> 1502protocol error results and 1503<function>XkbSetDeviceInfo</function> 1504returns 1505<symbol>False</symbol>. 1506If they have legal values but do not specify a keyboard or indicator class 1507feedback for the device in question, a 1508<errorname>BadMatch</errorname> 1509error results. If any of the values in 1510<parameter>device_info</parameter>-><structfield>leds->names</structfield> 1511are not a valid Atom or 1512<symbol>None</symbol>, 1513a 1514<errorname>BadAtom</errorname> 1515protocol error results. 1516</para> 1517 1518 1519<para> 1520Xkb provides convenience functions to modify subsets of the information 1521accessible via 1522<function>XkbSetDeviceInfo</function>. 1523Only the parts of the structure indicated in the function description are 1524modified. These convenience functions are described as follows. 1525</para> 1526 1527 1528<para> 1529To change only the button actions for an input extension device, use 1530XkbSetDeviceButtonActions. 1531</para> 1532 1533 1534<indexterm significance="preferred" zone="XkbSetDeviceButtonActions"><primary><function>XkbSetDeviceButtonActions</function></primary></indexterm> 1535<funcsynopsis id="XkbSetDeviceButtonActions"> 1536 <funcprototype> 1537 <funcdef>Bool <function>XkbSetDeviceButtonActions</function></funcdef> 1538<!-- ( 1539<parameter>dpy</parameter>, 1540device, first_button, num_buttons, actions) --> 1541 1542 <paramdef>Display *<parameter>dpy</parameter></paramdef> 1543 <paramdef>XkbDeviceInfoPtr <parameter>device_info</parameter></paramdef> 1544 <paramdef>unsigned int <parameter>first_button</parameter></paramdef> 1545 <paramdef>unsigned int <parameter>num_buttons</parameter></paramdef> 1546 </funcprototype> 1547</funcsynopsis> 1548<variablelist> 1549 <varlistentry> 1550 <term> 1551 <parameter>dpy</parameter> 1552 </term> 1553 <listitem> 1554 <para> 1555 connection to X server 1556 </para> 1557 </listitem> 1558 </varlistentry> 1559 <varlistentry> 1560 <term> 1561 <parameter>device_info</parameter> 1562 </term> 1563 <listitem> 1564 <para> 1565 structure defining the device and modifications 1566 </para> 1567 </listitem> 1568 </varlistentry> 1569 <varlistentry> 1570 <term> 1571 <parameter>first_button</parameter> 1572 </term> 1573 <listitem> 1574 <para> 1575 number of first button to update, 0 relative 1576 </para> 1577 </listitem> 1578 </varlistentry> 1579 <varlistentry> 1580 <term> 1581 <parameter>num_buttons</parameter> 1582 </term> 1583 <listitem> 1584 <para> 1585 number of buttons to update 1586 </para> 1587 </listitem> 1588 </varlistentry> 1589</variablelist> 1590 1591<para> 1592<function>XkbSetDeviceButtonActions</function> 1593assigns actions to the buttons of the device specified in 1594device_info-><structfield>device_spec</structfield>. 1595Actions are assigned to 1596<parameter>num_buttons</parameter> 1597buttons beginning with 1598<parameter>first_button</parameter> 1599and are taken from the actions specified in 1600<parameter>device_info</parameter>-><structfield>btn_acts</structfield>. 1601</para> 1602 1603 1604<para> 1605If the server does not support assignment of Xkb actions to extension device 1606buttons, 1607<function>XkbSetDeviceButtonActions</function> 1608has no effect and returns 1609<symbol>False</symbol>. 1610If the device has no buttons or if 1611<parameter>first_button</parameter> 1612or 1613<parameter>num_buttons</parameter> 1614specify buttons outside of the valid range as determined by 1615<parameter>device_info</parameter>-><structfield>num_btns</structfield>, 1616the function has no effect and returns 1617<symbol>False</symbol>. 1618Otherwise, 1619<function>XkbSetDeviceButtonActions</function> 1620sends a request to the server to change the actions for the specified buttons 1621and returns 1622<symbol>True</symbol>. 1623</para> 1624 1625 1626<para> 1627If the actual request sent to the server involved illegal button numbers, a 1628<errorname>BadValue</errorname> 1629protocol error is generated. If an invalid device identifier is specified in 1630device_info-><structfield>device_spec</structfield>, 1631a <errorname>BadKeyboard</errorname> 1632protocol error results. If the actual device specified in 1633<parameter>device_info</parameter>-><structfield>device_spec</structfield> 1634does not contain buttons and a request affecting buttons is made, a 1635<errorname>BadMatch</errorname> 1636protocol error is generated. 1637</para> 1638 1639 1640</sect1> 1641<sect1 id='XkbExtensionDeviceNotify_Event'> 1642<title>XkbExtensionDeviceNotify Event</title> 1643<indexterm significance="preferred" zone="XkbExtensionDeviceNotify_Event"> 1644<primary>events</primary><secondary><symbol>XkbExtensionDeviceNotify</symbol></secondary></indexterm> 1645<indexterm significance="preferred" zone="XkbExtensionDeviceNotify_Event"> 1646<primary><structname>XkbExtensionDeviceNotifyEvent</structname></primary></indexterm> 1647 1648<para> 1649The Xkb extension generates 1650<symbol>XkbExtensionDeviceNotify</symbol> 1651events when the status of an input extension device changes or when an attempt 1652is made to use an Xkb feature that is not supported by a particular device. 1653</para> 1654 1655<note><para>Events indicating an attempt to use an unsupported feature are 1656delivered only to the client requesting the event.</para></note> 1657 1658<para> 1659To track changes to the status of input extension devices or attempts to use 1660unsupported features of a device, select to receive 1661<symbol>XkbExtensionDeviceNotify</symbol> 1662events by calling either 1663<function>XkbSelectEvents</function> 1664or 1665<function>XkbSelectEventDetails</function> 1666(see <link linkend="Selecting_Xkb_Events">section 4.3</link>). 1667</para> 1668 1669 1670<para> 1671To receive 1672<symbol>XkbExtensionDeviceNotify</symbol> 1673events under all possible conditions, call 1674<function>XkbSelectEvents</function> 1675and pass 1676<symbol>XkbExtensionDeviceNotifyMask</symbol> 1677in both 1678<parameter>bits_to_change</parameter> 1679and 1680<parameter>values_for_bits</parameter>. 1681</para> 1682 1683 1684<para> 1685The 1686<symbol>XkbExtensionDeviceNotify</symbol> 1687event has no event details. However, you can call 1688<function>XkbSelectEventDetails</function> 1689using 1690<symbol>XkbExtensionDeviceNotify</symbol> 1691as the 1692<structfield>event_type</structfield> 1693and specifying 1694<symbol>XkbAllExtensionDeviceEventsMask</symbol> 1695in 1696<parameter>bits_to_change</parameter> 1697and 1698<parameter>values_for_bits</parameter>. 1699This has the same effect as a call to 1700<function>XkbSelectEvents</function>. 1701</para> 1702 1703 1704<para> 1705The structure for 1706<symbol>XkbExtensionDeviceNotify</symbol> 1707events is: 1708 1709<programlisting> 1710typedef struct { 1711 int type; /* Xkb extension base event code */ 1712 unsigned long serial; /* X server serial number for event */ 1713 Bool send_event; /* <symbol>True</symbol> ⇒ synthetically generated */ 1714 Display * display; /* server connection where event generated */ 1715 Time time; /* server time when event generated */ 1716 int xkb_type; /* <structname>XkbExtensionDeviceNotifyEvent</structname> */ 1717 int device; /* Xkb device ID, will not be <symbol>XkbUseCoreKbd</symbol> */ 1718 unsigned int reason; /* reason for the event */ 1719 unsigned int supported; /* mask of supported features */ 1720 unsigned int unsupported; /* unsupported features this client 1721 attempted to use */ 1722 int first_btn; /* first button that changed */ 1723 int num_btns; /* number of buttons that changed */ 1724 unsigned int leds_defined; /* indicators with names or maps */ 1725 unsigned int led_state; /* current state of the indicators */ 1726 int led_class; /* feedback class for LED changes */ 1727 int led_id; /* feedback ID for LED changes */ 1728} <structname>XkbExtensionDeviceNotifyEvent</structname>; 1729</programlisting></para> 1730 1731<para> 1732The 1733<symbol>XkbExtensionDeviceNotify</symbol> 1734event has fields enabling it to report changes in the state (on/off) of all of 1735the buttons for a device, but only for one LED feedback associated with a 1736device. You will get multiple events when more than one LED feedback changes 1737state or configuration. 1738</para> 1739 1740 1741</sect1> 1742<sect1 id='Tracking_Changes_to_Extension_Devices'> 1743<title>Tracking Changes to Extension Devices</title> 1744<indexterm significance="preferred" zone="Tracking_Changes_to_Extension_Devices"> 1745<primary><structname>XkbDeviceChangesRec</structname></primary></indexterm> 1746<indexterm significance="preferred" zone="Tracking_Changes_to_Extension_Devices"> 1747<primary><structname>XkbDeviceLedChangesRec</structname></primary></indexterm> 1748 1749<para> 1750Changes to an Xkb extension device may be tracked by listening to 1751<symbol>XkbExtensionDeviceNotify</symbol> 1752events and accumulating the changes in an 1753<structname>XkbDeviceChangesRec</structname> 1754structure. The changes noted in the structure may then be used in subsequent 1755operations to update either a server configuration or a local copy of an Xkb 1756extension device configuration. The changes structure is defined as follows: 1757 1758<programlisting> 1759typedef struct _XkbDeviceChanges { 1760 unsigned int changed; /* bits indicating what has changed */ 1761 unsigned short first_btn; /* number of first button which changed, 1762 if any */ 1763 unsigned short num_btns; /* number of buttons that have changed */ 1764 XkbDeviceLedChangesRec leds; 1765} <structname>XkbDeviceChangesRec</structname>, *XkbDeviceChangesPtr; 1766 1767typedef struct _XkbDeviceLedChanges { 1768 unsigned short led_class; /* class of this indicator feedback bundle */ 1769 unsigned short led_id; /* ID of this indicator feedback bundle */ 1770 unsigned int names; /* bits indicating which names have changed */ 1771 unsigned int maps; /* bits indicating which maps have changed */ 1772 struct _XkbDeviceLedChanges *next; /* link to indicator change record 1773 for next set */ 1774} <structname>XkbDeviceLedChangesRec</structname>, *XkbDeviceLedChangesPtr; 1775</programlisting></para> 1776 1777<para> 1778A local description of the configuration and state of a device may be kept in 1779an 1780<structname>XkbDeviceInfoRec</structname> 1781structure. The actual state or configuration of the device may change because 1782of XkbSetDeviceInfo and XkbSetButtonActions requests made by clients or by user 1783interaction with the device. The X server sends an XkbExtensionDeviceNotify 1784event to all interested clients when the state of any buttons or indicators or 1785the configuration of the buttons or indicators on the core keyboard or any 1786input extension device changes. The event reports the state of indicators for a 1787single indicator feedback, and the state of up to 128 buttons. If more than 128 1788buttons or more than one indicator feedback are changed, the additional buttons 1789and indicator feedbacks are reported in subsequent events. Xkb provides 1790functions with which you can track changes to input extension devices by noting 1791the changes that were made and then requesting the changed information from the 1792server. 1793</para> 1794 1795 1796<para> 1797To note device changes reported in an 1798<symbol>XkbExtensionDeviceNotify</symbol> 1799event, use XkbNoteDeviceChanges. 1800</para> 1801 1802<indexterm significance="preferred" zone="XkbNoteDeviceChanges"><primary><function>XkbNoteDeviceChanges</function></primary></indexterm> 1803<funcsynopsis id="XkbNoteDeviceChanges"> 1804 <funcprototype> 1805 <funcdef>void <function>XkbNoteDeviceChanges</function></funcdef> 1806<!-- ( 1807<parameter>old, new, wanted</parameter> 1808) --> 1809 1810 <paramdef>XkbDeviceChangesPtr <parameter>old</parameter></paramdef> 1811 <paramdef>XkbExtensionDeviceNotifyEvent *<parameter>new</parameter></paramdef> 1812 <paramdef>unsigned int <parameter>wanted</parameter></paramdef> 1813 </funcprototype> 1814</funcsynopsis> 1815<variablelist> 1816 <varlistentry> 1817 <term> 1818 <parameter>old</parameter> 1819 </term> 1820 <listitem> 1821 <para> 1822 structure tracking state changes 1823 </para> 1824 </listitem> 1825 </varlistentry> 1826 <varlistentry> 1827 <term> 1828 <parameter>new</parameter> 1829 </term> 1830 <listitem> 1831 <para> 1832 event indicating state changes 1833 </para> 1834 </listitem> 1835 </varlistentry> 1836 <varlistentry> 1837 <term> 1838 <parameter>wanted</parameter> 1839 </term> 1840 <listitem> 1841 <para> 1842 mask indicating changes to note 1843 </para> 1844 </listitem> 1845 </varlistentry> 1846</variablelist> 1847 1848<para> 1849The wanted field specifies the changes that should be noted in 1850<parameter>old</parameter>, 1851and is composed of the bitwise inclusive OR of one or more of the masks from 1852<link linkend="table21.1">Table 21.1</link>. 1853The 1854<structfield>reason</structfield> 1855field of the event in 1856<parameter>new</parameter> 1857indicates the types of changes the event is reporting. 1858<function>XkbNoteDeviceChanges</function> 1859updates the 1860<structname>XkbDeviceChangesRec</structname> 1861specified by 1862<parameter>old</parameter> 1863with the changes that are both specified in 1864<parameter>wanted</parameter> 1865and contained in 1866<parameter>new</parameter>-><structfield>reason</structfield>. 1867</para> 1868 1869 1870<para> 1871To update a local copy of the state and configuration of an X input extension 1872device with the changes previously noted in an 1873<structname>XkbDeviceChangesRec</structname> 1874structure, use XkbGetDeviceInfoChanges. 1875</para> 1876 1877 1878<para> 1879To query the changes that have occurred in the button actions or indicator 1880names and indicator maps associated with an input extension device, use 1881XkbGetDeviceInfoChanges. 1882</para> 1883 1884 1885<indexterm significance="preferred" zone="XkbGetDeviceInfoChanges"><primary><function>XkbGetDeviceInfoChanges</function></primary></indexterm> 1886<funcsynopsis id="XkbGetDeviceInfoChanges"> 1887 <funcprototype> 1888 <funcdef>Status <function>XkbGetDeviceInfoChanges</function></funcdef> 1889<!-- ( 1890<parameter>dpy</parameter>, 1891<parameter>device_info</parameter>, 1892changes) --> 1893 1894 <paramdef>Display *<parameter>dpy</parameter></paramdef> 1895 <paramdef>XkbDeviceInfoPtr <parameter>device_info</parameter></paramdef> 1896 <paramdef>XkbDeviceChangesPtr <parameter>changes</parameter></paramdef> 1897 </funcprototype> 1898</funcsynopsis> 1899<variablelist> 1900 <varlistentry> 1901 <term> 1902 <parameter>dpy</parameter> 1903 </term> 1904 <listitem> 1905 <para> 1906 connection to X server 1907 </para> 1908 </listitem> 1909 </varlistentry> 1910 <varlistentry> 1911 <term> 1912 <parameter>device_info</parameter> 1913 </term> 1914 <listitem> 1915 <para> 1916 structure to update with results 1917 </para> 1918 </listitem> 1919 </varlistentry> 1920 <varlistentry> 1921 <term> 1922 <parameter>changes</parameter> 1923 </term> 1924 <listitem> 1925 <para> 1926 contains notes of changes that have occurred 1927 </para> 1928 </listitem> 1929 </varlistentry> 1930</variablelist> 1931 1932<para> 1933The changes->changed field indicates which attributes of the device 1934specified in 1935<parameter>changes</parameter>-><structfield>device</structfield> 1936have changed. The parameters describing the changes are contained in the other 1937fields of 1938<parameter>changes</parameter>. 1939<function>XkbGetDeviceInfoChanges</function> 1940uses that information to call XkbGetDeviceInfo to obtain the current status of 1941those attributes that have changed. It then updates the local description of 1942the device in 1943<parameter>device_info</parameter> 1944with the new information. 1945</para> 1946 1947 1948<para> 1949To update the server’s description of a device with the changes noted in an 1950XkbDeviceChangesRec, use XkbChangeDeviceInfo. 1951</para> 1952 1953 1954<indexterm significance="preferred" zone="XkbChangeDeviceInfo"><primary><function>XkbChangeDeviceInfo</function></primary></indexterm> 1955<funcsynopsis id="XkbChangeDeviceInfo"> 1956 <funcprototype> 1957 <funcdef>Bool <function>XkbChangeDeviceInfo</function></funcdef> 1958<!-- ( 1959<parameter>dpy, device_info, changes</parameter> 1960) --> 1961 1962 <paramdef>Display *<parameter>dpy</parameter></paramdef> 1963 <paramdef>XkbDeviceInfoPtr <parameter>device_info</parameter></paramdef> 1964 <paramdef>XkbDeviceChangesPtr <parameter>changes</parameter></paramdef> 1965 </funcprototype> 1966</funcsynopsis> 1967<variablelist> 1968 <varlistentry> 1969 <term> 1970 <parameter>dpy</parameter> 1971 </term> 1972 <listitem> 1973 <para> 1974 connection to X server 1975 </para> 1976 </listitem> 1977 </varlistentry> 1978 <varlistentry> 1979 <term> 1980 <parameter>device_info</parameter> 1981 </term> 1982 <listitem> 1983 <para> 1984 local copy of device state and configuration 1985 </para> 1986 </listitem> 1987 </varlistentry> 1988 <varlistentry> 1989 <term> 1990 <parameter>changes</parameter> 1991 </term> 1992 <listitem> 1993 <para> 1994 note specifying changes in <parameter>device_info</parameter> 1995 </para> 1996 </listitem> 1997 </varlistentry> 1998</variablelist> 1999 2000<para> 2001<function>XkbChangeDeviceInfo</function> 2002updates the server’s description of the device specified in 2003<parameter>device_info</parameter>-><structfield>device_spec</structfield> 2004with the changes specified in 2005<parameter>changes</parameter> 2006and contained in 2007<parameter>device_info</parameter>. 2008The update is made by an XkbSetDeviceInfo request. 2009</para> 2010 2011</sect1> 2012</chapter> 2013