135c4bbdfSmrg<?xml version="1.0" encoding="UTF-8" ?>
235c4bbdfSmrg<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
335c4bbdfSmrg                   "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"[
435c4bbdfSmrg <!ENTITY % defs SYSTEM "/xserver/doc/xml/xserver.ent"> %defs;
535c4bbdfSmrg]>
635c4bbdfSmrg
735c4bbdfSmrg<!-- lifted from troff+ms+XMan by doclifter -->
835c4bbdfSmrg<book id="porting">
935c4bbdfSmrg
1035c4bbdfSmrg<bookinfo>
1135c4bbdfSmrg   <title>X11 Input Extension Porting Document</title>
1235c4bbdfSmrg   <authorgroup>
1335c4bbdfSmrg      <author>
1435c4bbdfSmrg         <firstname>George</firstname><surname>Sachs</surname>
1535c4bbdfSmrg         <affiliation><orgname>Hewlett-Packard</orgname></affiliation>
1635c4bbdfSmrg      </author>
1735c4bbdfSmrg   </authorgroup>
1835c4bbdfSmrg   <releaseinfo>X Server Version &xserver.version;</releaseinfo>
1935c4bbdfSmrg   <copyright><year>1989</year><year>1990</year><year>1991</year>
2035c4bbdfSmrg     <holder>Hewlett-Packard Company</holder>
2135c4bbdfSmrg   </copyright>
2235c4bbdfSmrg
2335c4bbdfSmrg<legalnotice>
2435c4bbdfSmrg
2535c4bbdfSmrg
2635c4bbdfSmrg<para>
2735c4bbdfSmrgPermission to use, copy, modify, and distribute this documentation for any purpose and without fee is
2835c4bbdfSmrghereby granted, provided that the above copyright notice and this permission notice appear in all copies.
2935c4bbdfSmrgHewlett-Packard makes no representations about the suitability for any purpose of the information in this
3035c4bbdfSmrgdocument. It is provided "as is" without express or implied warranty. This document is only a draft stan-
3135c4bbdfSmrgdard of the X Consortium and is therefore subject to change.
3235c4bbdfSmrg</para>
3335c4bbdfSmrg</legalnotice>
3435c4bbdfSmrg
3535c4bbdfSmrg<legalnotice>
3635c4bbdfSmrg<para role="multiLicensing">Copyright © 1989, 1990, 1991 X Consortium</para>
3735c4bbdfSmrg<para>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the &ldquo;Software&rdquo;), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</para>
3835c4bbdfSmrg<para>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</para>
3935c4bbdfSmrg
4035c4bbdfSmrg<para>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</para>
4135c4bbdfSmrg
4235c4bbdfSmrg<para>Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium.</para>
4335c4bbdfSmrg
4435c4bbdfSmrg<para>X Window System is a trademark of The Open Group.</para>
4535c4bbdfSmrg</legalnotice>
4635c4bbdfSmrg
4735c4bbdfSmrg</bookinfo>
4835c4bbdfSmrg
4935c4bbdfSmrg<chapter id="x11_input_extension_porting_document">
5035c4bbdfSmrg<title>X11 Input Extension Porting Document</title>
5135c4bbdfSmrg
5235c4bbdfSmrg<para>
5335c4bbdfSmrgThis document is intended to aid the process of integrating the 
5435c4bbdfSmrgX11 Input Extension into an X server.
5535c4bbdfSmrg</para>
5635c4bbdfSmrg<para>
5735c4bbdfSmrg<!-- .LP -->
5835c4bbdfSmrgMost of the functionality provided by the input extension is 
5935c4bbdfSmrgdevice- and implementation-independent, and should require no changes.  
6035c4bbdfSmrgThe functionality is implemented by
6135c4bbdfSmrgroutines that typically reside in the server source tree directory 
6235c4bbdfSmrgextensions/server/xinput.
6335c4bbdfSmrgThis extension includes functions to enable and disable input extension devices,
6435c4bbdfSmrgselect input, grab and focus those devices, query and change key
6535c4bbdfSmrgand button mappings, and others.  The only input extension requirements 
6635c4bbdfSmrgfor the device-dependent part of X are that the input devices be 
6735c4bbdfSmrgcorrectly initialized and input events from those devices be correctly
6835c4bbdfSmrggenerated.  Device-dependent X is responsible for reading input data from 
6935c4bbdfSmrgthe input device hardware and if necessary, reformatting it into X events.
7035c4bbdfSmrg</para>
7135c4bbdfSmrg<para>
7235c4bbdfSmrg<!-- .LP -->
7335c4bbdfSmrgThe process of initializing input extension devices is similar to that used 
7435c4bbdfSmrgfor the core devices, and is described in the following sections.  When
7535c4bbdfSmrgmultiple input devices are attached to X server, the choice of which devices
7635c4bbdfSmrgto initially use as the core X pointer and keyboard is left 
7735c4bbdfSmrgimplementation-dependent.  It is also up to each implementation to decide
7835c4bbdfSmrgwhether all input devices will be opened by the server during its 
7935c4bbdfSmrginitialization and kept open for the life of the server.  The alternative is
8035c4bbdfSmrgto open only the X keyboard and X pointer during server initialization, and
8135c4bbdfSmrgopen other input devices only when requested by a client to do so.  Either
8235c4bbdfSmrgtype of implementation is supported by the input extension.
8335c4bbdfSmrg</para>
8435c4bbdfSmrg<para>
8535c4bbdfSmrg<!-- .LP -->
8635c4bbdfSmrgInput extension events generated by the X server use the same 32-byte xEvent
8735c4bbdfSmrgwire event as do core input events.  However, additional information must be
8835c4bbdfSmrgsent for input extension devices, requiring that multiple xEvents be generated
8935c4bbdfSmrgeach time data is received from an input extension device.  These xEvents are
9035c4bbdfSmrgcombined into a single client XEvent by the input extension library.  A later
9135c4bbdfSmrgsection of this document describes the format and generation of input extension
9235c4bbdfSmrgevents.
9335c4bbdfSmrg</para>
9435c4bbdfSmrg<sect1 id="Initializing_Extension_Devices">
9535c4bbdfSmrg<title>Initializing Extension Devices</title>
9635c4bbdfSmrg<para>
9735c4bbdfSmrg<!-- .LP -->
9835c4bbdfSmrgExtension input devices are initialized in the same manner as the core 
9935c4bbdfSmrgX input devices.  Device-Independent X provides functions that can be 
10035c4bbdfSmrgcalled from DDX to initialize these devices.  Which functions are called
10135c4bbdfSmrgand when will vary by implementation, and will depend on whether the 
10235c4bbdfSmrgimplementation opens all the input devices available to X when X is initialized,
10335c4bbdfSmrgor waits until a client requests that a device be opened.
10435c4bbdfSmrgIn the simplest case, DDX will open all input devices as part of its
10535c4bbdfSmrginitialization, when the InitInput routine is called.
10635c4bbdfSmrg</para>
10735c4bbdfSmrg<sect2 id="Summary_of_Calling_Sequence">
10835c4bbdfSmrg<title>Summary of Calling Sequence</title>
10935c4bbdfSmrg<para>
11035c4bbdfSmrg<!-- .LP -->
11135c4bbdfSmrg<literallayout class="monospaced">
11235c4bbdfSmrgDevice-Independent X       |  Device-Dependent X
11335c4bbdfSmrg--------------------       |  -------------------             
11435c4bbdfSmrg                           |                                        
11535c4bbdfSmrgInitInput --------------&gt;  |  - do device-specific initialization
11635c4bbdfSmrg                           |                                        
11735c4bbdfSmrg                           |  - call AddInputDevice  (deviceProc,AutoStart)
11835c4bbdfSmrgAddInputDevice             |   
11935c4bbdfSmrg  - creates DeviceIntRec   |
12035c4bbdfSmrg  - records deviceProc     |
12135c4bbdfSmrg  - adds new device to     | 
12235c4bbdfSmrg    list of off_devices.   |
12335c4bbdfSmrgsets dev-&gt;startup=AutoStart|           
12435c4bbdfSmrg                           |  - call one of:                       
12535c4bbdfSmrg                           |    - RegisterPointerDevice (X pointer)
12635c4bbdfSmrg                           |      - processInputProc = ProcessPointerEvents
12735c4bbdfSmrg                           |    - RegisterKeyboardDevice (X keyboard)
12835c4bbdfSmrg                           |      - processInputProc = ProcessKeyboardEvents
12935c4bbdfSmrg                           |    - RegisterOtherDevice  (extension device)
13035c4bbdfSmrg                           |      - processInputProc = ProcessOtherEvents
13135c4bbdfSmrg                           |                                        
13235c4bbdfSmrg                           |                                        
13335c4bbdfSmrgInitAndStartDevices -----&gt; |  - calls deviceProc with parameters
13435c4bbdfSmrg                           |    (DEVICE_INIT, AutoStart)
13535c4bbdfSmrgsets dev-&gt;inited = return  |
13635c4bbdfSmrg  value from deviceProc    |    
13735c4bbdfSmrg                           |                                        
13835c4bbdfSmrg                           |  - in deviceProc, do one of:                       
13935c4bbdfSmrg                           |    - call InitPointerDeviceStruct (X pointer)
14035c4bbdfSmrg                           |    - call InitKeyboardDeviceStruct (X keybd)
14135c4bbdfSmrg                           |    - init extension device by calling some of:
14235c4bbdfSmrg                           |      - InitKeyClassDeviceStruct
14335c4bbdfSmrg                           |      - InitButtonClassDeviceStruct
14435c4bbdfSmrg                           |      - InitValuatorClassDeviceStruct
14535c4bbdfSmrg                           |      - InitValuatorAxisStruct
14635c4bbdfSmrg                           |      - InitFocusClassDeviceStruct
14735c4bbdfSmrg                           |      - InitProximityClassDeviceStruct
14835c4bbdfSmrg                           |      - InitKbdFeedbackClassDeviceStruct
14935c4bbdfSmrg                           |      - InitPtrFeedbackClassDeviceStruct
15035c4bbdfSmrg                           |      - InitLedFeedbackClassDeviceStruct
15135c4bbdfSmrg                           |      - InitStringFeedbackClassDeviceStruct
15235c4bbdfSmrg                           |      - InitIntegerFeedbackClassDeviceStruct
15335c4bbdfSmrg                           |      - InitBellFeedbackClassDeviceStruct
15435c4bbdfSmrg                           |    - init device name and type by:
15535c4bbdfSmrg                           |      - calling MakeAtom with one of the 
15635c4bbdfSmrg                           |        predefined names
15735c4bbdfSmrg                           |      - calling AssignTypeAndName
15835c4bbdfSmrg                           |                                        
15935c4bbdfSmrg                           |                                        
16035c4bbdfSmrgfor each device added      |                                        
16135c4bbdfSmrg    by AddInputDevice,     |                                        
16235c4bbdfSmrg    InitAndStartDevices    |                                        
16335c4bbdfSmrg    calls EnableDevice if  |  - EnableDevice calls deviceProc with 
16435c4bbdfSmrg    dev-&gt;startup &amp;         |    (DEVICE_ON, AutoStart)
16535c4bbdfSmrg    dev-&gt;inited            |  
16635c4bbdfSmrg                           |                                        
16735c4bbdfSmrgIf deviceProc returns      |  - core devices are now enabled, extension
16835c4bbdfSmrg    Success, EnableDevice  |    devices are now available to be accessed
16935c4bbdfSmrg    move the device from   |    through the input extension protocol
17035c4bbdfSmrg    inputInfo.off_devices  |    requests.                           
17135c4bbdfSmrg    to inputInfo.devices   |                                        
17235c4bbdfSmrg</literallayout>
17335c4bbdfSmrg</para>
17435c4bbdfSmrg</sect2>
17535c4bbdfSmrg<sect2 id="Initialization_Called_From_InitInput">
17635c4bbdfSmrg<title>Initialization Called From InitInput</title>
17735c4bbdfSmrg<para>
17835c4bbdfSmrg<!-- .LP -->
17935c4bbdfSmrgInitInput is the first DDX input entry point called during X server startup.
18035c4bbdfSmrgThis routine is responsible for
18135c4bbdfSmrgdevice- and implementation- specific initialization, and for calling
18235c4bbdfSmrgAddInputDevice to create and initialize the DeviceIntRec structure for each
18335c4bbdfSmrginput device.  AddInputDevice is passed the address of a procedure to be called
18435c4bbdfSmrgby the DIX routine InitAndStartDevices when input devices are enabled.
18535c4bbdfSmrgThis procedure is expected to perform X initialization for the input device.
18635c4bbdfSmrg</para>
18735c4bbdfSmrg<para>
18835c4bbdfSmrg<!-- .LP -->
18935c4bbdfSmrgIf the device is to be used as the X pointer, DDX should then call
19035c4bbdfSmrgRegisterPointerDevice, passing the DeviceIntRec pointer,
19135c4bbdfSmrgto initialize the device as the X pointer.
19235c4bbdfSmrg</para>
19335c4bbdfSmrg<para>
19435c4bbdfSmrg<!-- .LP -->
19535c4bbdfSmrgIf the device is to be used as the X keyboard, DDX should instead call
19635c4bbdfSmrgRegisterKeyboardDevice to initialize the device as the X keyboard.
19735c4bbdfSmrg</para>
19835c4bbdfSmrg<para>
19935c4bbdfSmrg<!-- .LP -->
20035c4bbdfSmrgIf the device is to be used as an extension device, DDX should instead
20135c4bbdfSmrgcall RegisterOtherDevice, passing the DeviceIntPtr returned by
20235c4bbdfSmrgAddInputDevice.
20335c4bbdfSmrg</para>
20435c4bbdfSmrg<para>
20535c4bbdfSmrg<!-- .LP -->
20635c4bbdfSmrgA sample InitInput implementation is shown below.
20735c4bbdfSmrg</para>
20835c4bbdfSmrg<para>
20935c4bbdfSmrg<!-- .LP -->
21035c4bbdfSmrg<literallayout class="monospaced">
21135c4bbdfSmrgInitInput(argc,argv)
21235c4bbdfSmrg    {
2131b5d61b8Smrg    int i, numdevs;
21435c4bbdfSmrg    DeviceIntPtr dev;
21535c4bbdfSmrg    LocalDevice localdevs[LOCAL_MAX_DEVS];
21635c4bbdfSmrg    DeviceProc kbdproc, ptrproc, extproc;
21735c4bbdfSmrg
21835c4bbdfSmrg    /**************************************************************
21935c4bbdfSmrg     * Open the appropriate input devices, determine which are 
22035c4bbdfSmrg     * available, and choose an X pointer and X keyboard device
22135c4bbdfSmrg     * in some implementation-dependent manner.
22235c4bbdfSmrg     ***************************************************************/
22335c4bbdfSmrg
22435c4bbdfSmrg    open_input_devices (&amp;numdevs, localdevs);
22535c4bbdfSmrg
22635c4bbdfSmrg    /**************************************************************
22735c4bbdfSmrg     * Register the input devices with DIX.
22835c4bbdfSmrg     ***************************************************************/
22935c4bbdfSmrg
23035c4bbdfSmrg    for (i=0; i&lt;numdevs; i++)
23135c4bbdfSmrg        {
23235c4bbdfSmrg        if (localdevs[i].use == IsXKeyboard)
23335c4bbdfSmrg            {
23435c4bbdfSmrg            dev = AddInputDevice (kbdproc, TRUE);
23535c4bbdfSmrg            RegisterKeyboardDevice (dev);
23635c4bbdfSmrg            }
23735c4bbdfSmrg        else if (localdevs[i].use == IsXPointer)
23835c4bbdfSmrg            {
23935c4bbdfSmrg            dev = AddInputDevice (ptrproc, TRUE);
24035c4bbdfSmrg            RegisterPointerDevice (dev);
24135c4bbdfSmrg            }
24235c4bbdfSmrg        else 
24335c4bbdfSmrg            {
24435c4bbdfSmrg            dev = AddInputDevice (extproc, FALSE);
24535c4bbdfSmrg            RegisterOtherDevice (dev);
24635c4bbdfSmrg            }
24735c4bbdfSmrg        if (dev == NULL)
24835c4bbdfSmrg            FatalError ("Too many input devices.");
24935c4bbdfSmrg        dev-&gt;devicePrivate = (pointer) &amp;localdevs[i];
25035c4bbdfSmrg        }
25135c4bbdfSmrg</literallayout>
25235c4bbdfSmrg</para>
25335c4bbdfSmrg</sect2>
25435c4bbdfSmrg<sect2 id="Initialization_Called_From_InitAndStartDevices">
25535c4bbdfSmrg<title>Initialization Called From InitAndStartDevices</title>
25635c4bbdfSmrg<para>
25735c4bbdfSmrg<!-- .LP -->
25835c4bbdfSmrgAfter InitInput has returned,
25935c4bbdfSmrgInitAndStartDevices is the DIX routine that is called to enable input devices. 
26035c4bbdfSmrgIt calls the device control routine that was passed to AddInputDevice,
26135c4bbdfSmrgwith a mode value of DEVICE_INIT.  The action taken by the device control
26235c4bbdfSmrgroutine depends on how the device is to be used.  If the device is to be
26335c4bbdfSmrgthe X pointer, the device control routine should call
26435c4bbdfSmrgInitPointerDeviceStruct to initialize it.  If the device is to be the
26535c4bbdfSmrgX keyboard, the device control routine should call
26635c4bbdfSmrgInitKeyboardDeviceStruct.  Since input extension devices may support various
26735c4bbdfSmrgcombinations of keys, buttons, valuators, and feedbacks,
26835c4bbdfSmrgeach class of input that it supports must be initialized.
26935c4bbdfSmrgEntry points are defined by DIX to initialize each of the supported classes of
27035c4bbdfSmrginput, and are described in the following sections.
27135c4bbdfSmrg</para>
27235c4bbdfSmrg<para>
27335c4bbdfSmrg<!-- .LP -->
27435c4bbdfSmrgA sample device control routine called from InitAndStartDevices is 
27535c4bbdfSmrgshown below.
27635c4bbdfSmrg</para>
27735c4bbdfSmrg<para>
27835c4bbdfSmrg<!-- .LP -->
27935c4bbdfSmrg<literallayout class="monospaced">
28035c4bbdfSmrgBool extproc (dev, mode)
28135c4bbdfSmrg    DeviceIntPtr dev;
28235c4bbdfSmrg    int mode;
28335c4bbdfSmrg    {
28435c4bbdfSmrg    LocalDevice *localdev = (LocalDevice *) dev-&gt;devicePrivate;
28535c4bbdfSmrg
28635c4bbdfSmrg    switch (mode)
28735c4bbdfSmrg        {
28835c4bbdfSmrg        case DEVICE_INIT:
28935c4bbdfSmrg            if (strcmp(localdev-&gt;name, XI_TABLET) == 0)
29035c4bbdfSmrg                {
29135c4bbdfSmrg                /****************************************************
29235c4bbdfSmrg                 * This device reports proximity, has buttons,
29335c4bbdfSmrg                 * reports two axes of motion, and can be focused.
29435c4bbdfSmrg                 * It also supports the same feedbacks as the X pointer
29535c4bbdfSmrg                 * (acceleration and threshold can be set).
29635c4bbdfSmrg                 ****************************************************/
29735c4bbdfSmrg
29835c4bbdfSmrg                InitButtonClassDeviceStruct (dev, button_count, button_map);
29935c4bbdfSmrg                InitValuatorClassDeviceStruct (dev, localdev-&gt;n_axes,);
30035c4bbdfSmrg                    motionproc, MOTION_BUF_SIZE, Absolute);
30135c4bbdfSmrg                for (i=0; i&lt;localdev-&gt;n_axes; i++)
30235c4bbdfSmrg                    InitValuatorAxisStruct (dev, i, min_val, max_val, 
30335c4bbdfSmrg                        resolution);
30435c4bbdfSmrg                InitFocusClassDeviceStruct (dev);
30535c4bbdfSmrg                InitProximityClassDeviceStruct (dev);
30635c4bbdfSmrg                InitPtrFeedbackClassDeviceStruct (dev, p_controlproc);
30735c4bbdfSmrg                }
30835c4bbdfSmrg            else if (strcmp(localdev-&gt;name, XI_BUTTONBOX) == 0)
30935c4bbdfSmrg                {
31035c4bbdfSmrg                /****************************************************
31135c4bbdfSmrg                 * This device has keys and LEDs, and can be focused.
31235c4bbdfSmrg                 ****************************************************/
31335c4bbdfSmrg
31435c4bbdfSmrg                InitKeyClassDeviceStruct (dev, syms, modmap);
31535c4bbdfSmrg                InitFocusClassDeviceStruct (dev);
31635c4bbdfSmrg                InitLedFeedbackClassDeviceStruct (dev, ledcontrol);
31735c4bbdfSmrg                }
31835c4bbdfSmrg            else if (strcmp(localdev-&gt;name, XI_KNOBBOX) == 0)
31935c4bbdfSmrg                {
32035c4bbdfSmrg                /****************************************************
32135c4bbdfSmrg                 * This device reports motion.
32235c4bbdfSmrg                 * It can be focused.
32335c4bbdfSmrg                 ****************************************************/
32435c4bbdfSmrg
32535c4bbdfSmrg                InitValuatorClassDeviceStruct (dev, localdev-&gt;n_axes,);
32635c4bbdfSmrg                    motionproc, MOTION_BUF_SIZE, Absolute);
32735c4bbdfSmrg                for (i=0; i&lt;localdev-&gt;n_axes; i++)
32835c4bbdfSmrg                    InitValuatorAxisStruct (dev, i, min_val, max_val, 
32935c4bbdfSmrg                        resolution);
33035c4bbdfSmrg                InitFocusClassDeviceStruct (dev);
33135c4bbdfSmrg                }
33235c4bbdfSmrg            localdev-&gt;atom = 
33335c4bbdfSmrg                MakeAtom(localdev-&gt;name, strlen(localdev-&gt;name), FALSE);
33435c4bbdfSmrg            AssignTypeAndName (dev, localdev-&gt;atom, localdev-&gt;name);
33535c4bbdfSmrg            break;
33635c4bbdfSmrg        case DEVICE_ON:
33735c4bbdfSmrg            AddEnabledDevice (localdev-&gt;file_ds);
33835c4bbdfSmrg            dev-&gt;on = TRUE;
33935c4bbdfSmrg            break;
34035c4bbdfSmrg        case DEVICE_OFF:
34135c4bbdfSmrg            dev-&gt;on = FALSE;
34235c4bbdfSmrg            RemoveEnabledDevice (localdev-&gt;file_ds);
34335c4bbdfSmrg            break;
34435c4bbdfSmrg        case DEVICE_CLOSE:
34535c4bbdfSmrg            break;
34635c4bbdfSmrg        }
34735c4bbdfSmrg    }
34835c4bbdfSmrg</literallayout>
34935c4bbdfSmrg</para>
35035c4bbdfSmrg<para>
35135c4bbdfSmrg<!-- .LP -->
35235c4bbdfSmrgThe device control routine is called with a mode value of DEVICE_ON
35335c4bbdfSmrgby the DIX routine EnableDevice, which is called from InitAndStartDevices.  
35435c4bbdfSmrgWhen called with this mode, it should call AddEnabledDevice to cause the 
35535c4bbdfSmrgserver to begin checking for available input from this device.
35635c4bbdfSmrg</para>
35735c4bbdfSmrg<para>
35835c4bbdfSmrg<!-- .LP -->
35935c4bbdfSmrgFrom InitAndStartDevices, EnableDevice is called for all devices that have
36035c4bbdfSmrgthe "inited" and "startup" fields in the DeviceIntRec set to TRUE.  The
36135c4bbdfSmrg"inited" field is set by InitAndStartDevices to the value returned by
36235c4bbdfSmrgthe deviceproc when called with a mode value of DEVICE_INIT.  The "startup"
36335c4bbdfSmrgfield is set by AddInputDevice to value of the second parameter (autoStart).
36435c4bbdfSmrg</para>
36535c4bbdfSmrg<para>
36635c4bbdfSmrg<!-- .LP -->
36735c4bbdfSmrgWhen the server is first initialized, it should only be checking for input
36835c4bbdfSmrgfrom the core X keyboard and pointer.  One way to accomplish this is to
36935c4bbdfSmrgcall AddInputDevice for the core X keyboard and pointer with an
37035c4bbdfSmrgautoStart value equal to TRUE, while calling AddInputDevice for 
37135c4bbdfSmrginput extension devices with an autoStart value equal to FALSE.  If this is 
37235c4bbdfSmrgdone, EnableDevice will skip all input extension devices during server
37335c4bbdfSmrginitialization.  In this case,
37435c4bbdfSmrgthe OpenInputDevice routine should set the "startup" field to TRUE
37535c4bbdfSmrgwhen called for input extension devices.  This will cause ProcXOpenInputDevice
37635c4bbdfSmrgto call EnableDevice for those devices when a client first does an
37735c4bbdfSmrgXOpenDevice request.
37835c4bbdfSmrg</para>
37935c4bbdfSmrg</sect2>
38035c4bbdfSmrg<sect2 id="DIX_Input_Class_Initialization_Routines">
38135c4bbdfSmrg<title>DIX Input Class Initialization Routines</title>
38235c4bbdfSmrg<para>
38335c4bbdfSmrg<!-- .LP -->
38435c4bbdfSmrgDIX routines are defined to initialize each of the defined input classes.
38535c4bbdfSmrgThe defined classes are:
38635c4bbdfSmrg<!-- .RS -->
38735c4bbdfSmrg<!-- .in +5n -->
38835c4bbdfSmrg</para>
38935c4bbdfSmrg<itemizedlist>
39035c4bbdfSmrg  <listitem>
39135c4bbdfSmrg    <para>
39235c4bbdfSmrgKeyClass - the device has keys.
39335c4bbdfSmrg    </para>
39435c4bbdfSmrg  </listitem>
39535c4bbdfSmrg  <listitem>
39635c4bbdfSmrg    <para>
39735c4bbdfSmrgButtonClass - the device has buttons.
39835c4bbdfSmrg    </para>
39935c4bbdfSmrg  </listitem>
40035c4bbdfSmrg  <listitem>
40135c4bbdfSmrg    <para>
40235c4bbdfSmrgValuatorClass - the device reports motion data or positional data.
40335c4bbdfSmrg    </para>
40435c4bbdfSmrg  </listitem>
40535c4bbdfSmrg  <listitem>
40635c4bbdfSmrg    <para>
40735c4bbdfSmrgProximitylass - the device reports proximity information.
40835c4bbdfSmrg    </para>
40935c4bbdfSmrg  </listitem>
41035c4bbdfSmrg  <listitem>
41135c4bbdfSmrg    <para>
41235c4bbdfSmrgFocusClass - the device can be focused.
41335c4bbdfSmrg    </para>
41435c4bbdfSmrg  </listitem>
41535c4bbdfSmrg  <listitem>
41635c4bbdfSmrg    <para>
41735c4bbdfSmrgFeedbackClass - the device supports some kind of feedback.
41835c4bbdfSmrg<!-- .in -5n -->
41935c4bbdfSmrg<!-- .RE -->
42035c4bbdfSmrg    </para>
42135c4bbdfSmrg  </listitem>
42235c4bbdfSmrg</itemizedlist>
42335c4bbdfSmrg<para>
42435c4bbdfSmrg<!-- .LP -->
42535c4bbdfSmrgDIX routines are provided to initialize the X pointer and keyboard, as in
42635c4bbdfSmrgprevious releases of X.  During X initialization, InitPointerDeviceStruct 
42735c4bbdfSmrgis called to initialize the X pointer, and InitKeyboardDeviceStruct is
42835c4bbdfSmrgcalled to initialize the X keyboard.  There is no
42935c4bbdfSmrgcorresponding routine for extension input devices, since they do not all
43035c4bbdfSmrgsupport the same classes of input.  Instead, DDX is responsible for the 
43135c4bbdfSmrginitialization of the input classes supported by extension devices.  
43235c4bbdfSmrgA description of the routines provided by DIX to perform that initialization
43335c4bbdfSmrgfollows.
43435c4bbdfSmrg</para>
43535c4bbdfSmrg<sect3 id="InitKeyClassDeviceStruct">
43635c4bbdfSmrg<title>InitKeyClassDeviceStruct</title>
43735c4bbdfSmrg<para>
43835c4bbdfSmrg<!-- .LP -->
43935c4bbdfSmrgThis function is provided to allocate and initialize a KeyClassRec, and 
44035c4bbdfSmrgshould be called for extension devices that have keys.  It is passed a pointer
44135c4bbdfSmrgto the device, and pointers to arrays of keysyms and modifiers reported by
44235c4bbdfSmrgthe device.  It returns FALSE if the KeyClassRec could not be allocated,
44335c4bbdfSmrgor if the maps for the keysyms and modifiers could not be allocated.
44435c4bbdfSmrgIts parameters are:
44535c4bbdfSmrg</para>
44635c4bbdfSmrg<para>
44735c4bbdfSmrg<!-- .LP -->
44835c4bbdfSmrg<literallayout class="monospaced">
44935c4bbdfSmrgBool
45035c4bbdfSmrgInitKeyClassDeviceStruct(dev, pKeySyms, pModifiers)
45135c4bbdfSmrg    DeviceIntPtr dev;
45235c4bbdfSmrg    KeySymsPtr pKeySyms;
45335c4bbdfSmrg    CARD8 pModifiers[];
45435c4bbdfSmrg</literallayout>
45535c4bbdfSmrg</para>
45635c4bbdfSmrg<para>
45735c4bbdfSmrg<!-- .LP -->
45835c4bbdfSmrgThe DIX entry point InitKeyboardDeviceStruct calls this routine for the
45935c4bbdfSmrgcore X keyboard.  It must be called explicitly for extension devices
46035c4bbdfSmrgthat have keys.
46135c4bbdfSmrg</para>
46235c4bbdfSmrg</sect3>
46335c4bbdfSmrg<sect3 id="InitButtonClassDeviceStruct">
46435c4bbdfSmrg<title>InitButtonClassDeviceStruct</title>
46535c4bbdfSmrg<para>
46635c4bbdfSmrg<!-- .LP -->
46735c4bbdfSmrgThis function is provided to allocate and initialize a ButtonClassRec, and 
46835c4bbdfSmrgshould be called for extension devices that have buttons.  It is passed a 
46935c4bbdfSmrgpointer to the device, the number of buttons supported, and a map of the 
47035c4bbdfSmrgreported button codes.  It returns FALSE if the ButtonClassRec could not be 
47135c4bbdfSmrgallocated.  Its parameters are:
47235c4bbdfSmrg</para>
47335c4bbdfSmrg<para>
47435c4bbdfSmrg<!-- .LP -->
47535c4bbdfSmrg<literallayout class="monospaced">
47635c4bbdfSmrgBool
47735c4bbdfSmrgInitButtonClassDeviceStruct(dev, numButtons, map)
47835c4bbdfSmrg    register DeviceIntPtr dev;
47935c4bbdfSmrg    int numButtons;
48035c4bbdfSmrg    CARD8 *map;
48135c4bbdfSmrg</literallayout>
48235c4bbdfSmrg</para>
48335c4bbdfSmrg<para>
48435c4bbdfSmrg<!-- .LP -->
48535c4bbdfSmrgThe DIX entry point InitPointerDeviceStruct calls this routine for the
48635c4bbdfSmrgcore X pointer.  It must be called explicitly for extension devices that
48735c4bbdfSmrghave buttons.
48835c4bbdfSmrg</para>
48935c4bbdfSmrg</sect3>
49035c4bbdfSmrg<sect3 id="InitValuatorClassDeviceStruct">
49135c4bbdfSmrg<title>InitValuatorClassDeviceStruct</title>
49235c4bbdfSmrg<para>
49335c4bbdfSmrg<!-- .LP -->
49435c4bbdfSmrgThis function is provided to allocate and initialize a ValuatorClassRec, and 
49535c4bbdfSmrgshould be called for extension devices that have valuators.  It is passed the
49635c4bbdfSmrgnumber of axes of motion reported by the device, the address of the motion
49735c4bbdfSmrghistory procedure for the device, the size of the motion history buffer,
49835c4bbdfSmrgand the mode (Absolute or Relative) of the device.  It returns FALSE if 
49935c4bbdfSmrgthe ValuatorClassRec could not be allocated.  Its parameters are:
50035c4bbdfSmrg</para>
50135c4bbdfSmrg<para>
50235c4bbdfSmrg<!-- .LP -->
50335c4bbdfSmrg<literallayout class="monospaced">
50435c4bbdfSmrgBool
50535c4bbdfSmrgInitValuatorClassDeviceStruct(dev, numAxes, motionProc, numMotionEvents, mode)
50635c4bbdfSmrg    DeviceIntPtr dev;
50735c4bbdfSmrg    int (*motionProc)();
50835c4bbdfSmrg    int numAxes;
50935c4bbdfSmrg    int numMotionEvents;
51035c4bbdfSmrg    int mode;
51135c4bbdfSmrg</literallayout>
51235c4bbdfSmrg</para>
51335c4bbdfSmrg<para>
51435c4bbdfSmrg<!-- .LP -->
51535c4bbdfSmrgThe DIX entry point InitPointerDeviceStruct calls this routine for the
51635c4bbdfSmrgcore X pointer.  It must be called explicitly for extension devices that
51735c4bbdfSmrgreport motion.
51835c4bbdfSmrg</para>
51935c4bbdfSmrg</sect3>
52035c4bbdfSmrg<sect3 id="InitValuatorAxisStruct">
52135c4bbdfSmrg<title>InitValuatorAxisStruct</title>
52235c4bbdfSmrg<para>
52335c4bbdfSmrg<!-- .LP -->
52435c4bbdfSmrgThis function is provided to initialize an XAxisInfoRec, and 
52535c4bbdfSmrgshould be called for core and extension devices that have valuators.  
52635c4bbdfSmrgThe space for the XAxisInfoRec is allocated by 
52735c4bbdfSmrgthe InitValuatorClassDeviceStruct function, but is not initialized.
52835c4bbdfSmrg</para>
52935c4bbdfSmrg<para>
53035c4bbdfSmrg<!-- .LP -->
53135c4bbdfSmrgInitValuatorAxisStruct should be called once for each axis of motion 
53235c4bbdfSmrgreported by the device.  Each
53335c4bbdfSmrginvocation should be passed the axis number (starting with 0), the
53435c4bbdfSmrgminimum value for that axis, the maximum value for that axis, and the
53535c4bbdfSmrgresolution of the device in counts per meter.  If the device reports
53635c4bbdfSmrgrelative motion, 0 should be reported as the minimum and maximum values.
53735c4bbdfSmrgInitValuatorAxisStruct has the following parameters:
53835c4bbdfSmrg<literallayout class="monospaced">
53935c4bbdfSmrgInitValuatorAxisStruct(dev, axnum, minval, maxval, resolution)
54035c4bbdfSmrg    DeviceIntPtr dev;
54135c4bbdfSmrg    int axnum;
54235c4bbdfSmrg    int minval;
54335c4bbdfSmrg    int maxval;
54435c4bbdfSmrg    int resolution;
54535c4bbdfSmrg</literallayout>
54635c4bbdfSmrg</para>
54735c4bbdfSmrg<para>
54835c4bbdfSmrg<!-- .LP -->
54935c4bbdfSmrgThis routine is not called by InitPointerDeviceStruct for the
55035c4bbdfSmrgcore X pointer.  It must be called explicitly for core and extension devices 
55135c4bbdfSmrgthat report motion.
55235c4bbdfSmrg</para>
55335c4bbdfSmrg</sect3>
55435c4bbdfSmrg<sect3 id="InitFocusClassDeviceStruct">
55535c4bbdfSmrg<title>InitFocusClassDeviceStruct</title>
55635c4bbdfSmrg<para>
55735c4bbdfSmrg<!-- .LP -->
55835c4bbdfSmrgThis function is provided to allocate and initialize a FocusClassRec, and 
55935c4bbdfSmrgshould be called for extension devices that can be focused.  It is passed a
56035c4bbdfSmrgpointer to the device, and returns FALSE if the allocation fails.
56135c4bbdfSmrgIt has the following parameter:
56235c4bbdfSmrg<literallayout class="monospaced">
56335c4bbdfSmrgBool
56435c4bbdfSmrgInitFocusClassDeviceStruct(dev)
56535c4bbdfSmrg    DeviceIntPtr dev;
56635c4bbdfSmrg</literallayout>
56735c4bbdfSmrg</para>
56835c4bbdfSmrg<para>
56935c4bbdfSmrg<!-- .LP -->
57035c4bbdfSmrgThe DIX entry point InitKeyboardDeviceStruct calls this routine for the
57135c4bbdfSmrgcore X keyboard.  It must be called explicitly for extension devices
57235c4bbdfSmrgthat can be focused.  Whether or not a particular device can be focused
57335c4bbdfSmrgis left implementation-dependent.
57435c4bbdfSmrg</para>
57535c4bbdfSmrg</sect3>
57635c4bbdfSmrg<sect3 id="InitProximityClassDeviceStruct">
57735c4bbdfSmrg<title>InitProximityClassDeviceStruct</title>
57835c4bbdfSmrg<para>
57935c4bbdfSmrg<!-- .LP -->
58035c4bbdfSmrgThis function is provided to allocate and initialize a ProximityClassRec, and 
58135c4bbdfSmrgshould be called for extension absolute pointing devices that report proximity.
58235c4bbdfSmrgIt is passed a pointer to the device, and returns FALSE if the allocation fails.
58335c4bbdfSmrgIt has the following parameter:
58435c4bbdfSmrg<literallayout class="monospaced">
58535c4bbdfSmrgBool
58635c4bbdfSmrgInitProximityClassDeviceStruct(dev)
58735c4bbdfSmrg    DeviceIntPtr dev;
58835c4bbdfSmrg</literallayout>
58935c4bbdfSmrg</para>
59035c4bbdfSmrg</sect3>
59135c4bbdfSmrg<sect3 id="Initializing_Feedbacks">
59235c4bbdfSmrg<title>Initializing Feedbacks</title>
59335c4bbdfSmrg<para>
59435c4bbdfSmrg<!-- .LP -->
59535c4bbdfSmrg</para>
59635c4bbdfSmrg<sect4 id="InitKbdFeedbackClassDeviceStruct">
59735c4bbdfSmrg<title>InitKbdFeedbackClassDeviceStruct</title>
59835c4bbdfSmrg<para>
59935c4bbdfSmrg<!-- .LP -->
60035c4bbdfSmrgThis function is provided to allocate and initialize a KbdFeedbackClassRec, and 
60135c4bbdfSmrgmay be called for extension devices that support some or all of the 
60235c4bbdfSmrgfeedbacks that the core keyboard supports.  It is passed a
60335c4bbdfSmrgpointer to the device, a pointer to the procedure that sounds the bell,
60435c4bbdfSmrgand a pointer to the device control procedure.
60535c4bbdfSmrgIt returns FALSE if the allocation fails, and has the following parameters:
60635c4bbdfSmrg<literallayout class="monospaced">
60735c4bbdfSmrgBool
60835c4bbdfSmrgInitKbdFeedbackClassDeviceStruct(dev, bellProc, controlProc)
60935c4bbdfSmrg    DeviceIntPtr dev;
61035c4bbdfSmrg    void (*bellProc)();
61135c4bbdfSmrg    void (*controlProc)();
61235c4bbdfSmrg</literallayout>
61335c4bbdfSmrgThe DIX entry point InitKeyboardDeviceStruct calls this routine for the
61435c4bbdfSmrgcore X keyboard.  It must be called explicitly for extension devices
61535c4bbdfSmrgthat have the same feedbacks as a keyboard.  Some feedbacks, such as LEDs and
61635c4bbdfSmrgbell, can be supported either with a KbdFeedbackClass or with BellFeedbackClass
61735c4bbdfSmrgand LedFeedbackClass feedbacks.
61835c4bbdfSmrg</para>
61935c4bbdfSmrg</sect4>
62035c4bbdfSmrg<sect4 id="InitPtrFeedbackClassDeviceStruct">
62135c4bbdfSmrg<title>InitPtrFeedbackClassDeviceStruct</title>
62235c4bbdfSmrg<para>
62335c4bbdfSmrg<!-- .LP -->
62435c4bbdfSmrgThis function is provided to allocate and initialize a PtrFeedbackClassRec, and 
62535c4bbdfSmrgshould be called for extension devices that allow the setting of acceleration
62635c4bbdfSmrgand threshold.  It is passed a pointer to the device,
62735c4bbdfSmrgand a pointer to the device control procedure.
62835c4bbdfSmrgIt returns FALSE if the allocation fails, and has the following parameters:
62935c4bbdfSmrg<literallayout class="monospaced">
63035c4bbdfSmrgBool
63135c4bbdfSmrgInitPtrFeedbackClassDeviceStruct(dev, controlProc)
63235c4bbdfSmrg    DeviceIntPtr dev;
63335c4bbdfSmrg    void (*controlProc)();
63435c4bbdfSmrg</literallayout>
63535c4bbdfSmrg</para>
63635c4bbdfSmrg<para>
63735c4bbdfSmrg<!-- .LP -->
63835c4bbdfSmrgThe DIX entry point InitPointerDeviceStruct calls this routine for the
63935c4bbdfSmrgcore X pointer.  It must be called explicitly for extension devices
64035c4bbdfSmrgthat support the setting of acceleration and threshold.
64135c4bbdfSmrg</para>
64235c4bbdfSmrg</sect4>
64335c4bbdfSmrg<sect4 id="InitLedFeedbackClassDeviceStruct">
64435c4bbdfSmrg<title>InitLedFeedbackClassDeviceStruct</title>
64535c4bbdfSmrg<para>
64635c4bbdfSmrg<!-- .LP -->
64735c4bbdfSmrgThis function is provided to allocate and initialize a LedFeedbackClassRec, and 
64835c4bbdfSmrgshould be called for extension devices that have LEDs.
64935c4bbdfSmrgIt is passed a pointer to the device,
65035c4bbdfSmrgand a pointer to the device control procedure.
65135c4bbdfSmrgIt returns FALSE if the allocation fails, and has the following parameters:
65235c4bbdfSmrg<literallayout class="monospaced">
65335c4bbdfSmrgBool
65435c4bbdfSmrgInitLedFeedbackClassDeviceStruct(dev, controlProc)
65535c4bbdfSmrg    DeviceIntPtr dev;
65635c4bbdfSmrg    void (*controlProc)();
65735c4bbdfSmrg</literallayout>
65835c4bbdfSmrg</para>
65935c4bbdfSmrg<para>
66035c4bbdfSmrg<!-- .LP -->
66135c4bbdfSmrgUp to 32 LEDs per feedback can be supported, and a device may have 
66235c4bbdfSmrgmultiple feedbacks of the same type.
66335c4bbdfSmrg</para>
66435c4bbdfSmrg</sect4>
66535c4bbdfSmrg<sect4 id="InitBellFeedbackClassDeviceStruct">
66635c4bbdfSmrg<title>InitBellFeedbackClassDeviceStruct</title>
66735c4bbdfSmrg<para>
66835c4bbdfSmrg<!-- .LP -->
66935c4bbdfSmrgThis function is provided to allocate and initialize a BellFeedbackClassRec, 
67035c4bbdfSmrgand should be called for extension devices that have a bell.
67135c4bbdfSmrgIt is passed a pointer to the device,
67235c4bbdfSmrgand a pointer to the device control procedure.
67335c4bbdfSmrgIt returns FALSE if the allocation fails, and has the following parameters:
67435c4bbdfSmrg<literallayout class="monospaced">
67535c4bbdfSmrgBool
67635c4bbdfSmrgInitBellFeedbackClassDeviceStruct(dev, bellProc, controlProc)
67735c4bbdfSmrg    DeviceIntPtr dev;
67835c4bbdfSmrg    void (*bellProc)();
67935c4bbdfSmrg    void (*controlProc)();
68035c4bbdfSmrg</literallayout>
68135c4bbdfSmrg</para>
68235c4bbdfSmrg</sect4>
68335c4bbdfSmrg<sect4 id="InitStringFeedbackClassDeviceStruct">
68435c4bbdfSmrg<title>InitStringFeedbackClassDeviceStruct</title>
68535c4bbdfSmrg<para>
68635c4bbdfSmrg<!-- .LP -->
68735c4bbdfSmrgThis function is provided to allocate and initialize a StringFeedbackClassRec, 
68835c4bbdfSmrgand should be called for extension devices that have a display upon which a 
68935c4bbdfSmrgstring can be displayed.
69035c4bbdfSmrgIt is passed a pointer to the device,
69135c4bbdfSmrgand a pointer to the device control procedure.
69235c4bbdfSmrgIt returns FALSE if the allocation fails, and has the following parameters:
69335c4bbdfSmrg<literallayout class="monospaced">
69435c4bbdfSmrgBool
69535c4bbdfSmrgInitStringFeedbackClassDeviceStruct(dev, controlProc, max_symbols, 
69635c4bbdfSmrg	num_symbols_supported, symbols)
69735c4bbdfSmrg    DeviceIntPtr dev;
69835c4bbdfSmrg    void (*controlProc)();
69935c4bbdfSmrg    int max_symbols;
70035c4bbdfSmrg    int num_symbols_supported;
70135c4bbdfSmrg    KeySym *symbols;
70235c4bbdfSmrg</literallayout>
70335c4bbdfSmrg</para>
70435c4bbdfSmrg</sect4>
70535c4bbdfSmrg<sect4 id="InitIntegerFeedbackClassDeviceStruct">
70635c4bbdfSmrg<title>InitIntegerFeedbackClassDeviceStruct</title>
70735c4bbdfSmrg<para>
70835c4bbdfSmrg<!-- .LP -->
70935c4bbdfSmrgThis function is provided to allocate and initialize an 
71035c4bbdfSmrgIntegerFeedbackClassRec, 
71135c4bbdfSmrgand should be called for extension devices that have a display upon which an
71235c4bbdfSmrginteger can be displayed.
71335c4bbdfSmrgIt is passed a pointer to the device,
71435c4bbdfSmrgand a pointer to the device control procedure.
71535c4bbdfSmrgIt returns FALSE if the allocation fails, and has the following parameters:
71635c4bbdfSmrg<literallayout class="monospaced">
71735c4bbdfSmrgBool
71835c4bbdfSmrgInitIntegerFeedbackClassDeviceStruct(dev, controlProc)
71935c4bbdfSmrg    DeviceIntPtr dev;
72035c4bbdfSmrg    void (*controlProc)();
72135c4bbdfSmrg</literallayout>
72235c4bbdfSmrg</para>
72335c4bbdfSmrg</sect4>
72435c4bbdfSmrg</sect3>
72535c4bbdfSmrg</sect2>
72635c4bbdfSmrg<sect2 id="Initializing_The_Device_Name_And_Type">
72735c4bbdfSmrg<title>Initializing The Device Name And Type</title>
72835c4bbdfSmrg<para>
72935c4bbdfSmrg<!-- .LP -->
73035c4bbdfSmrgThe device name and type can be initialized by calling AssignTypeAndName
73135c4bbdfSmrgwith the following parameters:
73235c4bbdfSmrg<literallayout class="monospaced">
73335c4bbdfSmrgvoid
73435c4bbdfSmrgAssignTypeAndName(dev, type, name)
73535c4bbdfSmrg    DeviceIntPtr dev;
73635c4bbdfSmrg    Atom type;
73735c4bbdfSmrg    char *name;
73835c4bbdfSmrg</literallayout>
73935c4bbdfSmrg</para>
74035c4bbdfSmrg<para>
74135c4bbdfSmrg<!-- .LP -->
74235c4bbdfSmrgThis will allocate space for the device name and copy the name that was passed.
74335c4bbdfSmrgThe device type can be obtained by calling MakeAtom with one of the names
74435c4bbdfSmrgdefined for input devices.  MakeAtom has the following parameters:
74535c4bbdfSmrg<literallayout class="monospaced">
74635c4bbdfSmrgAtom
74735c4bbdfSmrgMakeAtom(name, len, makeit)
74835c4bbdfSmrg    char *name;
74935c4bbdfSmrg    int len;
75035c4bbdfSmrg    Bool makeit;
75135c4bbdfSmrg</literallayout>
75235c4bbdfSmrg</para>
75335c4bbdfSmrg<para>
75435c4bbdfSmrg<!-- .LP -->
75535c4bbdfSmrgSince the atom was already made when the input extension was initialized, the
75635c4bbdfSmrgvalue of makeit should be FALSE;
75735c4bbdfSmrg</para>
75835c4bbdfSmrg</sect2>
75935c4bbdfSmrg</sect1>
76035c4bbdfSmrg<sect1 id="Closing_Extension_Devices">
76135c4bbdfSmrg<title>Closing Extension Devices</title>
76235c4bbdfSmrg<para>
76335c4bbdfSmrg<!-- .LP -->
76435c4bbdfSmrgThe DisableDevice entry point is provided by DIX to disable input devices.
76535c4bbdfSmrgIt calls the device control routine for the specified
76635c4bbdfSmrgdevice with a mode value of DEVICE_OFF.  The device control routine should
76735c4bbdfSmrgcall RemoveEnabledDevice to stop the server from checking for input from
76835c4bbdfSmrgthat device.
76935c4bbdfSmrg</para>
77035c4bbdfSmrg<para>
77135c4bbdfSmrg<!-- .LP -->
77235c4bbdfSmrgDisableDevice is not called by any input extension routines.  It can be 
77335c4bbdfSmrgcalled from the CloseInputDevice routine, which is called by
77435c4bbdfSmrgProcXCloseDevice when a client makes an XCloseDevice request.  If
77535c4bbdfSmrgDisableDevice is called, it should only be called when the last client
77635c4bbdfSmrgusing the extension device has terminated or called XCloseDevice.
77735c4bbdfSmrg</para>
77835c4bbdfSmrg</sect1>
77935c4bbdfSmrg<sect1 id="Implementation_Dependent_Routines">
78035c4bbdfSmrg<title>Implementation-Dependent Routines</title>
78135c4bbdfSmrg<para>
78235c4bbdfSmrg<!-- .LP -->
78335c4bbdfSmrgSeveral input extension protocol requests have 
78435c4bbdfSmrgimplementation-dependent  entry points.  Default routines
78535c4bbdfSmrgare defined for these entry points and contained in the source
78635c4bbdfSmrgfile extensions/server/xinput/xstubs.c.  Some implementations may
78735c4bbdfSmrgbe able to use the default routines without change.
78835c4bbdfSmrgThe following sections describe each of these routines.
78935c4bbdfSmrg</para>
79035c4bbdfSmrg<sect2 id="AddOtherInputDevices">
79135c4bbdfSmrg<title>AddOtherInputDevices</title>
79235c4bbdfSmrg<para>
79335c4bbdfSmrg<!-- .LP -->
79435c4bbdfSmrgAddOtherInputDevice is called from ProcXListInputDevices as a result of 
79535c4bbdfSmrgan XListInputDevices protocol request.  It may be needed by
79635c4bbdfSmrgimplementations that do not open extension input devices until requested
79735c4bbdfSmrgto do so by some client.  These implementations may not initialize
79835c4bbdfSmrgall devices when the X server starts up, because some of those devices
79935c4bbdfSmrgmay be in use.  Since the XListInputDevices
80035c4bbdfSmrgfunction only lists those devices that have been initialized,
80135c4bbdfSmrgAddOtherInputDevices is called to give DDX a chance to 
80235c4bbdfSmrginitialize any previously unavailable input devices.
80335c4bbdfSmrg</para>
80435c4bbdfSmrg<para>
80535c4bbdfSmrg<!-- .LP -->
80635c4bbdfSmrgA sample AddOtherInputDevices routine might look like the following:
80735c4bbdfSmrg<literallayout class="monospaced">
80835c4bbdfSmrgvoid
80935c4bbdfSmrgAddOtherInputDevices ()
81035c4bbdfSmrg    {
81135c4bbdfSmrg    DeviceIntPtr dev;
81235c4bbdfSmrg    int i;
81335c4bbdfSmrg
81435c4bbdfSmrg    for (i=0; i&lt;MAX_DEVICES; i++) 
81535c4bbdfSmrg        {
81635c4bbdfSmrg        if (!local_dev[i].initialized &amp;&amp; available(local_dev[i]))
81735c4bbdfSmrg            {
81835c4bbdfSmrg            dev = (DeviceIntPtr) AddInputDevice (local_dev[i].deviceProc, TRUE);
81935c4bbdfSmrg            dev-&gt;public.devicePrivate = local_dev[i];
82035c4bbdfSmrg            RegisterOtherDevice (dev);
82135c4bbdfSmrg            dev-&gt;inited = ((*dev-&gt;deviceProc)(dev, DEVICE_INIT) == Success);
82235c4bbdfSmrg            }
82335c4bbdfSmrg        }
82435c4bbdfSmrg    }
82535c4bbdfSmrg</literallayout>
82635c4bbdfSmrg</para>
82735c4bbdfSmrg<para>
82835c4bbdfSmrg<!-- .LP -->
82935c4bbdfSmrgThe default AddOtherInputDevices routine in xstubs.c does nothing.
83035c4bbdfSmrgIf all input extension devices are initialized when the server 
83135c4bbdfSmrgstarts up, it can be left as a null routine.
83235c4bbdfSmrg</para>
83335c4bbdfSmrg</sect2>
83435c4bbdfSmrg<sect2 id="OpenInputDevice">
83535c4bbdfSmrg<title>OpenInputDevice</title>
83635c4bbdfSmrg<para>
83735c4bbdfSmrg<!-- .LP -->
83835c4bbdfSmrgSome X server implementations open all input devices when the server
83935c4bbdfSmrgis initialized and never close them.  Other implementations may open only
84035c4bbdfSmrgthe X pointer and keyboard devices during server initialization,
84135c4bbdfSmrgand open other input devices only when some client makes an
84235c4bbdfSmrgXOpenDevice request.  This entry point is for the latter type of 
84335c4bbdfSmrgimplementation.
84435c4bbdfSmrg</para>
84535c4bbdfSmrg<para>
84635c4bbdfSmrg<!-- .LP -->
84735c4bbdfSmrgIf the physical device is not already open, it can be done in this routine.  
84835c4bbdfSmrgIn this case, the server must keep track of the fact that one or more clients 
84935c4bbdfSmrghave the device open, and physically close it when the last client that has
85035c4bbdfSmrgit open makes an XCloseDevice request.
85135c4bbdfSmrg</para>
85235c4bbdfSmrg<para>
85335c4bbdfSmrg<!-- .LP -->
85435c4bbdfSmrgThe default implementation is to do nothing (assume all input devices
85535c4bbdfSmrgare opened during X server initialization and kept open).
85635c4bbdfSmrg</para>
85735c4bbdfSmrg</sect2>
85835c4bbdfSmrg<sect2 id="CloseInputDevice">
85935c4bbdfSmrg<title>CloseInputDevice</title>
86035c4bbdfSmrg<para>
86135c4bbdfSmrg<!-- .LP -->
86235c4bbdfSmrgSome implementations may close an input device when the last client
86335c4bbdfSmrgusing that device requests that it be closed, or terminates.
86435c4bbdfSmrgCloseInputDevice is called from ProcXCloseDevice when a client
86535c4bbdfSmrgmakes an XCloseDevice protocol request.
86635c4bbdfSmrg</para>
86735c4bbdfSmrg<para>
86835c4bbdfSmrg<!-- .LP -->
86935c4bbdfSmrgThe default implementation is to do nothing (assume all input devices
87035c4bbdfSmrgare opened during X server initialization and kept open).
87135c4bbdfSmrg</para>
87235c4bbdfSmrg</sect2>
87335c4bbdfSmrg<sect2 id="SetDeviceMode">
87435c4bbdfSmrg<title>SetDeviceMode</title>
87535c4bbdfSmrg<para>
87635c4bbdfSmrg<!-- .LP -->
87735c4bbdfSmrgSome implementations support input devices that can report 
87835c4bbdfSmrgeither absolute positional data or relative motion.  The XSetDeviceMode
87935c4bbdfSmrgprotocol request is provided to allow DDX to change the current mode of 
88035c4bbdfSmrgsuch a device.
88135c4bbdfSmrg</para>
88235c4bbdfSmrg<para>
88335c4bbdfSmrg<!-- .LP -->
88435c4bbdfSmrgThe default implementation is to always return a BadMatch error.  If the
88535c4bbdfSmrgimplementation does not support any input devices that are capable of 
88635c4bbdfSmrgreporting both relative motion and absolute position information, the
88735c4bbdfSmrgdefault implementation may be left unchanged.
88835c4bbdfSmrg</para>
88935c4bbdfSmrg</sect2>
89035c4bbdfSmrg<sect2 id="SetDeviceValuators">
89135c4bbdfSmrg<title>SetDeviceValuators</title>
89235c4bbdfSmrg<para>
89335c4bbdfSmrg<!-- .LP -->
89435c4bbdfSmrgSome implementations support input devices that allow their valuators to be 
89535c4bbdfSmrgset to an initial value.  The XSetDeviceValuators 
89635c4bbdfSmrgprotocol request is provided to allow DDX to set the valuators of
89735c4bbdfSmrgsuch a device.
89835c4bbdfSmrg</para>
89935c4bbdfSmrg<para>
90035c4bbdfSmrg<!-- .LP -->
90135c4bbdfSmrgThe default implementation is to always return a BadMatch error.  If the
90235c4bbdfSmrgimplementation does not support any input devices that allow their
90335c4bbdfSmrgvaluators to be set, the default implementation may be left unchanged.
90435c4bbdfSmrg</para>
90535c4bbdfSmrg</sect2>
90635c4bbdfSmrg<sect2 id="ChangePointerDevice">
90735c4bbdfSmrg<title>ChangePointerDevice</title>
90835c4bbdfSmrg<para>
90935c4bbdfSmrg<!-- .LP -->
91035c4bbdfSmrgThe XChangePointerDevice protocol request is provided to change which device is
91135c4bbdfSmrgused as the X pointer.  Some implementations may maintain information
91235c4bbdfSmrgspecific to the X pointer in the private data structure pointed to by
91335c4bbdfSmrgthe DeviceIntRec.  ChangePointerDevice is called to allow such 
91435c4bbdfSmrgimplementations to move that information to the new pointer device.
91535c4bbdfSmrgThe current location of the X cursor is an example of the type of 
91635c4bbdfSmrginformation that might be affected.
91735c4bbdfSmrg</para>
91835c4bbdfSmrg<para>
91935c4bbdfSmrg<!-- .LP -->
92035c4bbdfSmrgThe DeviceIntRec structure that describes the X pointer device does not 
92135c4bbdfSmrgcontain a FocusRec.  If the device that has been made into the new X pointer 
92235c4bbdfSmrgwas previously a device that could be focused, ProcXChangePointerDevice will 
92335c4bbdfSmrgfree the FocusRec associated with that device.
92435c4bbdfSmrg</para>
92535c4bbdfSmrg<para>
92635c4bbdfSmrg<!-- .LP -->
92735c4bbdfSmrgIf the server implementation desires to allow clients to focus the old pointer 
92835c4bbdfSmrgdevice (which is now accessible through the input extension), it should call
92935c4bbdfSmrgInitFocusClassDeviceStruct for the old pointer device.
93035c4bbdfSmrg</para>
93135c4bbdfSmrg<para>
93235c4bbdfSmrg<!-- .LP -->
93335c4bbdfSmrgThe XChangePointerDevice protocol request also allows the client
93435c4bbdfSmrgto choose which axes of the new pointer device are used to move 
93535c4bbdfSmrgthe X cursor in the X- and Y- directions.  If the axes are different
93635c4bbdfSmrgthan the default ones, the server implementation should record that fact.
93735c4bbdfSmrg</para>
93835c4bbdfSmrg<para>
93935c4bbdfSmrg<!-- .LP -->
94035c4bbdfSmrgIf the server implementation supports input devices with valuators that 
94135c4bbdfSmrgare not allowed to be used as the X pointer, they should be screened out
94235c4bbdfSmrgby this routine and a  BadDevice error returned.
94335c4bbdfSmrg</para>
94435c4bbdfSmrg<para>
94535c4bbdfSmrg<!-- .LP -->
94635c4bbdfSmrgThe default implementation is to do nothing. 
94735c4bbdfSmrg</para>
94835c4bbdfSmrg</sect2>
94935c4bbdfSmrg<sect2 id="ChangeKeyboardDevice">
95035c4bbdfSmrg<title>ChangeKeyboardDevice</title>
95135c4bbdfSmrg<para>
95235c4bbdfSmrg<!-- .LP -->
95335c4bbdfSmrgThe XChangeKeyboardDevice protocol request is provided to change which device is
95435c4bbdfSmrgused as the X keyboard.  Some implementations may maintain information
95535c4bbdfSmrgspecific to the X keyboard in the private data structure pointed to by
95635c4bbdfSmrgthe DeviceIntRec.  ChangeKeyboardDevice is called to allow such 
95735c4bbdfSmrgimplementations to move that information to the new keyboard device.
95835c4bbdfSmrg</para>
95935c4bbdfSmrg<para>
96035c4bbdfSmrg<!-- .LP -->
96135c4bbdfSmrgThe X keyboard device can be focused, and the DeviceIntRec that describes
96235c4bbdfSmrgthat device has a FocusRec.  If the device that has been made into the new X 
96335c4bbdfSmrgkeyboard did not previously have a FocusRec, 
96435c4bbdfSmrgProcXChangeKeyboardDevice will allocate one for it.
96535c4bbdfSmrg</para>
96635c4bbdfSmrg<para>
96735c4bbdfSmrg<!-- .LP -->
96835c4bbdfSmrgIf the implementation does not want clients to be able to focus the old X 
96935c4bbdfSmrgkeyboard (which has now become available as an input extension device)
97035c4bbdfSmrgit should call DeleteFocusClassDeviceStruct to free the FocusRec.
97135c4bbdfSmrg</para>
97235c4bbdfSmrg<para>
97335c4bbdfSmrg<!-- .LP -->
97435c4bbdfSmrgIf the implementation supports input devices with keys that are not allowed
97535c4bbdfSmrgto be used as the X keyboard, they should be checked for here, and a
97635c4bbdfSmrgBadDevice error returned.
97735c4bbdfSmrg</para>
97835c4bbdfSmrg<para>
97935c4bbdfSmrg<!-- .LP -->
98035c4bbdfSmrgThe default implementation is to do nothing. 
98135c4bbdfSmrg</para>
98235c4bbdfSmrg</sect2>
98335c4bbdfSmrg</sect1>
98435c4bbdfSmrg<sect1 id="Input_Extension_Events">
98535c4bbdfSmrg<title>Input Extension Events</title>
98635c4bbdfSmrg<para>
98735c4bbdfSmrg<!-- .LP -->
98835c4bbdfSmrgEvents accessed through the input extension are analogous to the core input
98935c4bbdfSmrgevents, but have different event types.  They are of types 
99035c4bbdfSmrg<function>DeviceKeyPress</function>, <function>DeviceKeyRelease</function>, <function>DeviceButtonPress</function>,
99135c4bbdfSmrg<function>DeviceButtonRelease</function>, <function>DeviceDeviceMotionNotify</function>,
99235c4bbdfSmrg<function>DeviceProximityIn</function>, <function>DeviceProximityOut</function>, and <function>DeviceValuator</function>.
99335c4bbdfSmrgThese event types are not constants.  Instead, they are external integers 
99435c4bbdfSmrgdefined by the input extension.  Their actual values will depend on which
99535c4bbdfSmrgextensions are supported by a server, and the order in which they are
99635c4bbdfSmrginitialized.
99735c4bbdfSmrg</para>
99835c4bbdfSmrg<para>
99935c4bbdfSmrg<!-- .LP -->
100035c4bbdfSmrgThe data structures that describe these
100135c4bbdfSmrgevents are defined in the file <function>extensions/include/XIproto.h</function>.  Other
100235c4bbdfSmrginput extension constants needed by DDX are defined in the file
100335c4bbdfSmrg<function>extensions/include/XI.h</function>.
100435c4bbdfSmrg</para>
100535c4bbdfSmrg<para>
100635c4bbdfSmrg<!-- .LP -->
100735c4bbdfSmrgSome events defined by the input extension contain more information than can
100835c4bbdfSmrgbe contained in the 32-byte xEvent data structure.  To send this information
100935c4bbdfSmrgto clients, DDX must generate two or more 32-byte wire events.  The following
101035c4bbdfSmrgsections describe the contents of these events. 
101135c4bbdfSmrg</para>
101235c4bbdfSmrg<sect2 id="Device_Key_Events">
101335c4bbdfSmrg<title>Device Key Events</title>
101435c4bbdfSmrg<para>
101535c4bbdfSmrg<!-- .LP -->
101635c4bbdfSmrg<function>DeviceKeyPresss</function> events contain all the information that is contained in
101735c4bbdfSmrga core <function>KeyPress</function> event, and also the following additional information:
101835c4bbdfSmrg</para>
101935c4bbdfSmrg<para>
102035c4bbdfSmrg<!-- .LP -->
102135c4bbdfSmrg<!-- .RS -->
102235c4bbdfSmrg<!-- .in +5n -->
102335c4bbdfSmrg</para>
102435c4bbdfSmrg<itemizedlist>
102535c4bbdfSmrg  <listitem>
102635c4bbdfSmrg    <para>
102735c4bbdfSmrgdeviceid - the identifier of the device that generated the event.
102835c4bbdfSmrg    </para>
102935c4bbdfSmrg  </listitem>
103035c4bbdfSmrg  <listitem>
103135c4bbdfSmrg    <para>
103235c4bbdfSmrgdevice_state - the state of any modifiers on the device that generated the event.
103335c4bbdfSmrg    </para>
103435c4bbdfSmrg  </listitem>
103535c4bbdfSmrg  <listitem>
103635c4bbdfSmrg    <para>
103735c4bbdfSmrgnum_valuators - the number of valuators reported in this event.
103835c4bbdfSmrg    </para>
103935c4bbdfSmrg  </listitem>
104035c4bbdfSmrg  <listitem>
104135c4bbdfSmrg    <para>
104235c4bbdfSmrgfirst_valuator - the first valuator reported in this event.
104335c4bbdfSmrg    </para>
104435c4bbdfSmrg  </listitem>
104535c4bbdfSmrg  <listitem>
104635c4bbdfSmrg    <para>
104735c4bbdfSmrgvaluator0 through valuator5 - the values of the valuators.
104835c4bbdfSmrg<!-- .in -5n -->
104935c4bbdfSmrg<!-- .RE -->
105035c4bbdfSmrg    </para>
105135c4bbdfSmrg  </listitem>
105235c4bbdfSmrg</itemizedlist>
105335c4bbdfSmrg<para>
105435c4bbdfSmrg<!-- .LP -->
105535c4bbdfSmrgIn order to pass this information to the input extension library, two 32-byte
105635c4bbdfSmrgwire events must be generated by DDX.  The first has an event type of 
105735c4bbdfSmrg<function>DeviceKeyPress</function>, and the second has an event type of <function>DeviceValuator</function>.
105835c4bbdfSmrg</para>
105935c4bbdfSmrg<para>
106035c4bbdfSmrg<!-- .LP -->
106135c4bbdfSmrgThe following code fragment shows how the two wire events could be initialized:
106235c4bbdfSmrg</para>
106335c4bbdfSmrg<para>
106435c4bbdfSmrg<!-- .LP -->
106535c4bbdfSmrg<literallayout class="monospaced">
106635c4bbdfSmrg    extern int DeviceKeyPress;
106735c4bbdfSmrg    DeviceIntPtr dev;
106835c4bbdfSmrg    xEvent xE[2];
106935c4bbdfSmrg    CARD8 id, num_valuators;
107035c4bbdfSmrg    INT16 x, y, pointerx, pointery;
107135c4bbdfSmrg    Time timestamp;
107235c4bbdfSmrg    deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *) xE;
107335c4bbdfSmrg    deviceValuator *xv;
107435c4bbdfSmrg
107535c4bbdfSmrg    xev-&gt;type = DeviceKeyPress;         /* defined by input extension */
107635c4bbdfSmrg    xev-&gt;detail = keycode;              /* key pressed on this device */
107735c4bbdfSmrg    xev-&gt;time = timestamp;              /* same as for core events    */
107835c4bbdfSmrg    xev-&gt;rootX = pointerx;              /* x location of core pointer */
107935c4bbdfSmrg    xev-&gt;rootY = pointery;              /* y location of core pointer */
108035c4bbdfSmrg
108135c4bbdfSmrg    /******************************************************************/
108235c4bbdfSmrg    /*                                                                */
108335c4bbdfSmrg    /* The following field does not exist for core input events.      */
108435c4bbdfSmrg    /* It contains the device id for the device that generated the    */
108535c4bbdfSmrg    /* event, and also indicates whether more than one 32-byte wire   */
108635c4bbdfSmrg    /* event is being sent.                                           */
108735c4bbdfSmrg    /*                                                                */
108835c4bbdfSmrg    /******************************************************************/
108935c4bbdfSmrg
109035c4bbdfSmrg    xev-&gt;deviceid = dev-&gt;id | MORE_EVENTS;     /* sending more than 1 */
109135c4bbdfSmrg
109235c4bbdfSmrg    /******************************************************************/
109335c4bbdfSmrg    /* Fields in the second 32-byte wire event:                       */
109435c4bbdfSmrg    /******************************************************************/
109535c4bbdfSmrg
109635c4bbdfSmrg    xv = (deviceValuator *) ++xev;
109735c4bbdfSmrg    xv-&gt;type = DeviceValuator;          /* event type of second event */
109835c4bbdfSmrg    xv-&gt;deviceid = dev-&gt;id;             /* id of this device          */
109935c4bbdfSmrg    xv-&gt;num_valuators = 0;              /* no valuators being sent    */
110035c4bbdfSmrg    xv-&gt;device_state  = 0;              /* will be filled in by DIX   */
110135c4bbdfSmrg</literallayout>
110235c4bbdfSmrg</para>
110335c4bbdfSmrg</sect2>
110435c4bbdfSmrg<sect2 id="Device_Button_Events">
110535c4bbdfSmrg<title>Device Button Events</title>
110635c4bbdfSmrg<para>
110735c4bbdfSmrg<!-- .LP -->
110835c4bbdfSmrg<function>DeviceButton</function> events contain all the information that is contained in
110935c4bbdfSmrga core button event, and also the same additional information that a 
111035c4bbdfSmrg<function>DeviceKey</function> event contains.
111135c4bbdfSmrg</para>
111235c4bbdfSmrg</sect2>
111335c4bbdfSmrg<sect2 id="Device_Motion_Events">
111435c4bbdfSmrg<title>Device Motion Events</title>
111535c4bbdfSmrg<para>
111635c4bbdfSmrg<!-- .LP -->
111735c4bbdfSmrg<function>DeviceMotion</function> events contain all the information that is contained in
111835c4bbdfSmrga core motion event, and also additional valuator information.  At least
111935c4bbdfSmrgtwo wire events are required to contain this information.
112035c4bbdfSmrgThe following code fragment shows how the two wire events could be initialized:
112135c4bbdfSmrg</para>
112235c4bbdfSmrg<para>
112335c4bbdfSmrg<!-- .LP -->
112435c4bbdfSmrg<literallayout class="monospaced">
112535c4bbdfSmrg    extern int DeviceMotionNotify;
112635c4bbdfSmrg    DeviceIntPtr dev;
112735c4bbdfSmrg    xEvent xE[2];
112835c4bbdfSmrg    CARD8 id, num_valuators;
112935c4bbdfSmrg    INT16 x, y, pointerx, pointery;
113035c4bbdfSmrg    Time timestamp;
113135c4bbdfSmrg    deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *) xE;
113235c4bbdfSmrg    deviceValuator *xv;
113335c4bbdfSmrg
113435c4bbdfSmrg    xev-&gt;type = DeviceMotionNotify;     /* defined by input extension */
113535c4bbdfSmrg    xev-&gt;detail = keycode;              /* key pressed on this device */
113635c4bbdfSmrg    xev-&gt;time = timestamp;              /* same as for core events    */
113735c4bbdfSmrg    xev-&gt;rootX = pointerx;              /* x location of core pointer */
113835c4bbdfSmrg    xev-&gt;rootY = pointery;              /* y location of core pointer */
113935c4bbdfSmrg
114035c4bbdfSmrg    /******************************************************************/
114135c4bbdfSmrg    /*                                                                */
114235c4bbdfSmrg    /* The following field does not exist for core input events.      */
114335c4bbdfSmrg    /* It contains the device id for the device that generated the    */
114435c4bbdfSmrg    /* event, and also indicates whether more than one 32-byte wire   */
114535c4bbdfSmrg    /* event is being sent.                                           */
114635c4bbdfSmrg    /*                                                                */
114735c4bbdfSmrg    /******************************************************************/
114835c4bbdfSmrg
114935c4bbdfSmrg    xev-&gt;deviceid = dev-&gt;id | MORE_EVENTS;     /* sending more than 1 */
115035c4bbdfSmrg
115135c4bbdfSmrg    /******************************************************************/
115235c4bbdfSmrg    /* Fields in the second 32-byte wire event:                       */
115335c4bbdfSmrg    /******************************************************************/
115435c4bbdfSmrg
115535c4bbdfSmrg    xv = (deviceValuator *) ++xev;
115635c4bbdfSmrg    xv-&gt;type = DeviceValuator;          /* event type of second event */
115735c4bbdfSmrg    xv-&gt;deviceid = dev-&gt;id;             /* id of this device          */
115835c4bbdfSmrg    xv-&gt;num_valuators = 2;              /* 2 valuators being sent     */
115935c4bbdfSmrg    xv-&gt;first_valuator = 0;             /* first valuator being sent  */
116035c4bbdfSmrg    xv-&gt;device_state  = 0;              /* will be filled in by DIX   */
116135c4bbdfSmrg    xv-&gt;valuator0 = x;                  /* first axis of this device  */
116235c4bbdfSmrg    xv-&gt;valuator1 = y;                  /* second axis of this device */
116335c4bbdfSmrg</literallayout>
116435c4bbdfSmrg</para>
116535c4bbdfSmrg<para>
116635c4bbdfSmrg<!-- .LP -->
116735c4bbdfSmrgUp to six axes can be reported in the deviceValuator event.  If the device
116835c4bbdfSmrgis reporting more than 6 axes, additional pairs of DeviceMotionNotify and
116935c4bbdfSmrgDeviceValuator events should be sent,  with the first_valuator field
117035c4bbdfSmrgset correctly.
117135c4bbdfSmrg</para>
117235c4bbdfSmrg</sect2>
117335c4bbdfSmrg<sect2 id="Device_Proximity_Events">
117435c4bbdfSmrg<title>Device Proximity Events</title>
117535c4bbdfSmrg<para>
117635c4bbdfSmrg<!-- .LP -->
117735c4bbdfSmrgSome input devices that report absolute positional information, such as 
117835c4bbdfSmrggraphics tablets and touchscreens, may report proximity events.  
117935c4bbdfSmrg<function>ProximityIn</function>
118035c4bbdfSmrgevents are generated when a pointing device like a stylus, or in the case
118135c4bbdfSmrgof a touchscreen, the user's finger, comes into close proximity with the
118235c4bbdfSmrgsurface of the input device.  <function>ProximityOut</function> events are generated when
118335c4bbdfSmrgthe stylus or finger leaves the proximity of the input devices surface.
118435c4bbdfSmrg</para>
118535c4bbdfSmrg<para>
118635c4bbdfSmrg<!-- .LP -->
118735c4bbdfSmrg<function>Proximity</function> events contain almost the same information as button events.
118835c4bbdfSmrgThe event type is <function>ProximityIn</function> or <function>ProximityOut</function>, and there is no
118935c4bbdfSmrgdetail information.
119035c4bbdfSmrg<!-- .bp -->
119135c4bbdfSmrg<!-- .\" .TC -->
119235c4bbdfSmrg
119335c4bbdfSmrg</para>
119435c4bbdfSmrg</sect2>
119535c4bbdfSmrg</sect1>
119635c4bbdfSmrg</chapter>
119735c4bbdfSmrg</book>
1198