1*4882a593Smuzhiyun<?xml version="1.0" encoding="UTF-8" ?> 2*4882a593Smuzhiyun<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" 3*4882a593Smuzhiyun "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"[ 4*4882a593Smuzhiyun <!ENTITY % defs SYSTEM "/xserver/doc/xml/xserver.ent"> %defs; 5*4882a593Smuzhiyun]> 6*4882a593Smuzhiyun 7*4882a593Smuzhiyun<!-- lifted from troff+ms+XMan by doclifter --> 8*4882a593Smuzhiyun<book id="porting"> 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun<bookinfo> 11*4882a593Smuzhiyun <title>X11 Input Extension Porting Document</title> 12*4882a593Smuzhiyun <authorgroup> 13*4882a593Smuzhiyun <author> 14*4882a593Smuzhiyun <firstname>George</firstname><surname>Sachs</surname> 15*4882a593Smuzhiyun <affiliation><orgname>Hewlett-Packard</orgname></affiliation> 16*4882a593Smuzhiyun </author> 17*4882a593Smuzhiyun </authorgroup> 18*4882a593Smuzhiyun <releaseinfo>X Server Version &xserver.version;</releaseinfo> 19*4882a593Smuzhiyun <copyright><year>1989</year><year>1990</year><year>1991</year> 20*4882a593Smuzhiyun <holder>Hewlett-Packard Company</holder> 21*4882a593Smuzhiyun </copyright> 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun<legalnotice> 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun<para> 27*4882a593SmuzhiyunPermission to use, copy, modify, and distribute this documentation for any purpose and without fee is 28*4882a593Smuzhiyunhereby granted, provided that the above copyright notice and this permission notice appear in all copies. 29*4882a593SmuzhiyunHewlett-Packard makes no representations about the suitability for any purpose of the information in this 30*4882a593Smuzhiyundocument. It is provided "as is" without express or implied warranty. This document is only a draft stan- 31*4882a593Smuzhiyundard of the X Consortium and is therefore subject to change. 32*4882a593Smuzhiyun</para> 33*4882a593Smuzhiyun</legalnotice> 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun<legalnotice> 36*4882a593Smuzhiyun<para role="multiLicensing">Copyright © 1989, 1990, 1991 X Consortium</para> 37*4882a593Smuzhiyun<para>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), 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> 38*4882a593Smuzhiyun<para>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</para> 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun<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> 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun<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> 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun<para>X Window System is a trademark of The Open Group.</para> 45*4882a593Smuzhiyun</legalnotice> 46*4882a593Smuzhiyun 47*4882a593Smuzhiyun</bookinfo> 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun<chapter id="x11_input_extension_porting_document"> 50*4882a593Smuzhiyun<title>X11 Input Extension Porting Document</title> 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun<para> 53*4882a593SmuzhiyunThis document is intended to aid the process of integrating the 54*4882a593SmuzhiyunX11 Input Extension into an X server. 55*4882a593Smuzhiyun</para> 56*4882a593Smuzhiyun<para> 57*4882a593Smuzhiyun<!-- .LP --> 58*4882a593SmuzhiyunMost of the functionality provided by the input extension is 59*4882a593Smuzhiyundevice- and implementation-independent, and should require no changes. 60*4882a593SmuzhiyunThe functionality is implemented by 61*4882a593Smuzhiyunroutines that typically reside in the server source tree directory 62*4882a593Smuzhiyunextensions/server/xinput. 63*4882a593SmuzhiyunThis extension includes functions to enable and disable input extension devices, 64*4882a593Smuzhiyunselect input, grab and focus those devices, query and change key 65*4882a593Smuzhiyunand button mappings, and others. The only input extension requirements 66*4882a593Smuzhiyunfor the device-dependent part of X are that the input devices be 67*4882a593Smuzhiyuncorrectly initialized and input events from those devices be correctly 68*4882a593Smuzhiyungenerated. Device-dependent X is responsible for reading input data from 69*4882a593Smuzhiyunthe input device hardware and if necessary, reformatting it into X events. 70*4882a593Smuzhiyun</para> 71*4882a593Smuzhiyun<para> 72*4882a593Smuzhiyun<!-- .LP --> 73*4882a593SmuzhiyunThe process of initializing input extension devices is similar to that used 74*4882a593Smuzhiyunfor the core devices, and is described in the following sections. When 75*4882a593Smuzhiyunmultiple input devices are attached to X server, the choice of which devices 76*4882a593Smuzhiyunto initially use as the core X pointer and keyboard is left 77*4882a593Smuzhiyunimplementation-dependent. It is also up to each implementation to decide 78*4882a593Smuzhiyunwhether all input devices will be opened by the server during its 79*4882a593Smuzhiyuninitialization and kept open for the life of the server. The alternative is 80*4882a593Smuzhiyunto open only the X keyboard and X pointer during server initialization, and 81*4882a593Smuzhiyunopen other input devices only when requested by a client to do so. Either 82*4882a593Smuzhiyuntype of implementation is supported by the input extension. 83*4882a593Smuzhiyun</para> 84*4882a593Smuzhiyun<para> 85*4882a593Smuzhiyun<!-- .LP --> 86*4882a593SmuzhiyunInput extension events generated by the X server use the same 32-byte xEvent 87*4882a593Smuzhiyunwire event as do core input events. However, additional information must be 88*4882a593Smuzhiyunsent for input extension devices, requiring that multiple xEvents be generated 89*4882a593Smuzhiyuneach time data is received from an input extension device. These xEvents are 90*4882a593Smuzhiyuncombined into a single client XEvent by the input extension library. A later 91*4882a593Smuzhiyunsection of this document describes the format and generation of input extension 92*4882a593Smuzhiyunevents. 93*4882a593Smuzhiyun</para> 94*4882a593Smuzhiyun<sect1 id="Initializing_Extension_Devices"> 95*4882a593Smuzhiyun<title>Initializing Extension Devices</title> 96*4882a593Smuzhiyun<para> 97*4882a593Smuzhiyun<!-- .LP --> 98*4882a593SmuzhiyunExtension input devices are initialized in the same manner as the core 99*4882a593SmuzhiyunX input devices. Device-Independent X provides functions that can be 100*4882a593Smuzhiyuncalled from DDX to initialize these devices. Which functions are called 101*4882a593Smuzhiyunand when will vary by implementation, and will depend on whether the 102*4882a593Smuzhiyunimplementation opens all the input devices available to X when X is initialized, 103*4882a593Smuzhiyunor waits until a client requests that a device be opened. 104*4882a593SmuzhiyunIn the simplest case, DDX will open all input devices as part of its 105*4882a593Smuzhiyuninitialization, when the InitInput routine is called. 106*4882a593Smuzhiyun</para> 107*4882a593Smuzhiyun<sect2 id="Summary_of_Calling_Sequence"> 108*4882a593Smuzhiyun<title>Summary of Calling Sequence</title> 109*4882a593Smuzhiyun<para> 110*4882a593Smuzhiyun<!-- .LP --> 111*4882a593Smuzhiyun<literallayout class="monospaced"> 112*4882a593SmuzhiyunDevice-Independent X | Device-Dependent X 113*4882a593Smuzhiyun-------------------- | ------------------- 114*4882a593Smuzhiyun | 115*4882a593SmuzhiyunInitInput --------------> | - do device-specific initialization 116*4882a593Smuzhiyun | 117*4882a593Smuzhiyun | - call AddInputDevice (deviceProc,AutoStart) 118*4882a593SmuzhiyunAddInputDevice | 119*4882a593Smuzhiyun - creates DeviceIntRec | 120*4882a593Smuzhiyun - records deviceProc | 121*4882a593Smuzhiyun - adds new device to | 122*4882a593Smuzhiyun list of off_devices. | 123*4882a593Smuzhiyunsets dev->startup=AutoStart| 124*4882a593Smuzhiyun | - call one of: 125*4882a593Smuzhiyun | - RegisterPointerDevice (X pointer) 126*4882a593Smuzhiyun | - processInputProc = ProcessPointerEvents 127*4882a593Smuzhiyun | - RegisterKeyboardDevice (X keyboard) 128*4882a593Smuzhiyun | - processInputProc = ProcessKeyboardEvents 129*4882a593Smuzhiyun | - RegisterOtherDevice (extension device) 130*4882a593Smuzhiyun | - processInputProc = ProcessOtherEvents 131*4882a593Smuzhiyun | 132*4882a593Smuzhiyun | 133*4882a593SmuzhiyunInitAndStartDevices -----> | - calls deviceProc with parameters 134*4882a593Smuzhiyun | (DEVICE_INIT, AutoStart) 135*4882a593Smuzhiyunsets dev->inited = return | 136*4882a593Smuzhiyun value from deviceProc | 137*4882a593Smuzhiyun | 138*4882a593Smuzhiyun | - in deviceProc, do one of: 139*4882a593Smuzhiyun | - call InitPointerDeviceStruct (X pointer) 140*4882a593Smuzhiyun | - call InitKeyboardDeviceStruct (X keybd) 141*4882a593Smuzhiyun | - init extension device by calling some of: 142*4882a593Smuzhiyun | - InitKeyClassDeviceStruct 143*4882a593Smuzhiyun | - InitButtonClassDeviceStruct 144*4882a593Smuzhiyun | - InitValuatorClassDeviceStruct 145*4882a593Smuzhiyun | - InitValuatorAxisStruct 146*4882a593Smuzhiyun | - InitFocusClassDeviceStruct 147*4882a593Smuzhiyun | - InitProximityClassDeviceStruct 148*4882a593Smuzhiyun | - InitKbdFeedbackClassDeviceStruct 149*4882a593Smuzhiyun | - InitPtrFeedbackClassDeviceStruct 150*4882a593Smuzhiyun | - InitLedFeedbackClassDeviceStruct 151*4882a593Smuzhiyun | - InitStringFeedbackClassDeviceStruct 152*4882a593Smuzhiyun | - InitIntegerFeedbackClassDeviceStruct 153*4882a593Smuzhiyun | - InitBellFeedbackClassDeviceStruct 154*4882a593Smuzhiyun | - init device name and type by: 155*4882a593Smuzhiyun | - calling MakeAtom with one of the 156*4882a593Smuzhiyun | predefined names 157*4882a593Smuzhiyun | - calling AssignTypeAndName 158*4882a593Smuzhiyun | 159*4882a593Smuzhiyun | 160*4882a593Smuzhiyunfor each device added | 161*4882a593Smuzhiyun by AddInputDevice, | 162*4882a593Smuzhiyun InitAndStartDevices | 163*4882a593Smuzhiyun calls EnableDevice if | - EnableDevice calls deviceProc with 164*4882a593Smuzhiyun dev->startup & | (DEVICE_ON, AutoStart) 165*4882a593Smuzhiyun dev->inited | 166*4882a593Smuzhiyun | 167*4882a593SmuzhiyunIf deviceProc returns | - core devices are now enabled, extension 168*4882a593Smuzhiyun Success, EnableDevice | devices are now available to be accessed 169*4882a593Smuzhiyun move the device from | through the input extension protocol 170*4882a593Smuzhiyun inputInfo.off_devices | requests. 171*4882a593Smuzhiyun to inputInfo.devices | 172*4882a593Smuzhiyun</literallayout> 173*4882a593Smuzhiyun</para> 174*4882a593Smuzhiyun</sect2> 175*4882a593Smuzhiyun<sect2 id="Initialization_Called_From_InitInput"> 176*4882a593Smuzhiyun<title>Initialization Called From InitInput</title> 177*4882a593Smuzhiyun<para> 178*4882a593Smuzhiyun<!-- .LP --> 179*4882a593SmuzhiyunInitInput is the first DDX input entry point called during X server startup. 180*4882a593SmuzhiyunThis routine is responsible for 181*4882a593Smuzhiyundevice- and implementation- specific initialization, and for calling 182*4882a593SmuzhiyunAddInputDevice to create and initialize the DeviceIntRec structure for each 183*4882a593Smuzhiyuninput device. AddInputDevice is passed the address of a procedure to be called 184*4882a593Smuzhiyunby the DIX routine InitAndStartDevices when input devices are enabled. 185*4882a593SmuzhiyunThis procedure is expected to perform X initialization for the input device. 186*4882a593Smuzhiyun</para> 187*4882a593Smuzhiyun<para> 188*4882a593Smuzhiyun<!-- .LP --> 189*4882a593SmuzhiyunIf the device is to be used as the X pointer, DDX should then call 190*4882a593SmuzhiyunRegisterPointerDevice, passing the DeviceIntRec pointer, 191*4882a593Smuzhiyunto initialize the device as the X pointer. 192*4882a593Smuzhiyun</para> 193*4882a593Smuzhiyun<para> 194*4882a593Smuzhiyun<!-- .LP --> 195*4882a593SmuzhiyunIf the device is to be used as the X keyboard, DDX should instead call 196*4882a593SmuzhiyunRegisterKeyboardDevice to initialize the device as the X keyboard. 197*4882a593Smuzhiyun</para> 198*4882a593Smuzhiyun<para> 199*4882a593Smuzhiyun<!-- .LP --> 200*4882a593SmuzhiyunIf the device is to be used as an extension device, DDX should instead 201*4882a593Smuzhiyuncall RegisterOtherDevice, passing the DeviceIntPtr returned by 202*4882a593SmuzhiyunAddInputDevice. 203*4882a593Smuzhiyun</para> 204*4882a593Smuzhiyun<para> 205*4882a593Smuzhiyun<!-- .LP --> 206*4882a593SmuzhiyunA sample InitInput implementation is shown below. 207*4882a593Smuzhiyun</para> 208*4882a593Smuzhiyun<para> 209*4882a593Smuzhiyun<!-- .LP --> 210*4882a593Smuzhiyun<literallayout class="monospaced"> 211*4882a593SmuzhiyunInitInput(argc,argv) 212*4882a593Smuzhiyun { 213*4882a593Smuzhiyun int i, numdevs; 214*4882a593Smuzhiyun DeviceIntPtr dev; 215*4882a593Smuzhiyun LocalDevice localdevs[LOCAL_MAX_DEVS]; 216*4882a593Smuzhiyun DeviceProc kbdproc, ptrproc, extproc; 217*4882a593Smuzhiyun 218*4882a593Smuzhiyun /************************************************************** 219*4882a593Smuzhiyun * Open the appropriate input devices, determine which are 220*4882a593Smuzhiyun * available, and choose an X pointer and X keyboard device 221*4882a593Smuzhiyun * in some implementation-dependent manner. 222*4882a593Smuzhiyun ***************************************************************/ 223*4882a593Smuzhiyun 224*4882a593Smuzhiyun open_input_devices (&numdevs, localdevs); 225*4882a593Smuzhiyun 226*4882a593Smuzhiyun /************************************************************** 227*4882a593Smuzhiyun * Register the input devices with DIX. 228*4882a593Smuzhiyun ***************************************************************/ 229*4882a593Smuzhiyun 230*4882a593Smuzhiyun for (i=0; i<numdevs; i++) 231*4882a593Smuzhiyun { 232*4882a593Smuzhiyun if (localdevs[i].use == IsXKeyboard) 233*4882a593Smuzhiyun { 234*4882a593Smuzhiyun dev = AddInputDevice (kbdproc, TRUE); 235*4882a593Smuzhiyun RegisterKeyboardDevice (dev); 236*4882a593Smuzhiyun } 237*4882a593Smuzhiyun else if (localdevs[i].use == IsXPointer) 238*4882a593Smuzhiyun { 239*4882a593Smuzhiyun dev = AddInputDevice (ptrproc, TRUE); 240*4882a593Smuzhiyun RegisterPointerDevice (dev); 241*4882a593Smuzhiyun } 242*4882a593Smuzhiyun else 243*4882a593Smuzhiyun { 244*4882a593Smuzhiyun dev = AddInputDevice (extproc, FALSE); 245*4882a593Smuzhiyun RegisterOtherDevice (dev); 246*4882a593Smuzhiyun } 247*4882a593Smuzhiyun if (dev == NULL) 248*4882a593Smuzhiyun FatalError ("Too many input devices."); 249*4882a593Smuzhiyun dev->devicePrivate = (pointer) &localdevs[i]; 250*4882a593Smuzhiyun } 251*4882a593Smuzhiyun</literallayout> 252*4882a593Smuzhiyun</para> 253*4882a593Smuzhiyun</sect2> 254*4882a593Smuzhiyun<sect2 id="Initialization_Called_From_InitAndStartDevices"> 255*4882a593Smuzhiyun<title>Initialization Called From InitAndStartDevices</title> 256*4882a593Smuzhiyun<para> 257*4882a593Smuzhiyun<!-- .LP --> 258*4882a593SmuzhiyunAfter InitInput has returned, 259*4882a593SmuzhiyunInitAndStartDevices is the DIX routine that is called to enable input devices. 260*4882a593SmuzhiyunIt calls the device control routine that was passed to AddInputDevice, 261*4882a593Smuzhiyunwith a mode value of DEVICE_INIT. The action taken by the device control 262*4882a593Smuzhiyunroutine depends on how the device is to be used. If the device is to be 263*4882a593Smuzhiyunthe X pointer, the device control routine should call 264*4882a593SmuzhiyunInitPointerDeviceStruct to initialize it. If the device is to be the 265*4882a593SmuzhiyunX keyboard, the device control routine should call 266*4882a593SmuzhiyunInitKeyboardDeviceStruct. Since input extension devices may support various 267*4882a593Smuzhiyuncombinations of keys, buttons, valuators, and feedbacks, 268*4882a593Smuzhiyuneach class of input that it supports must be initialized. 269*4882a593SmuzhiyunEntry points are defined by DIX to initialize each of the supported classes of 270*4882a593Smuzhiyuninput, and are described in the following sections. 271*4882a593Smuzhiyun</para> 272*4882a593Smuzhiyun<para> 273*4882a593Smuzhiyun<!-- .LP --> 274*4882a593SmuzhiyunA sample device control routine called from InitAndStartDevices is 275*4882a593Smuzhiyunshown below. 276*4882a593Smuzhiyun</para> 277*4882a593Smuzhiyun<para> 278*4882a593Smuzhiyun<!-- .LP --> 279*4882a593Smuzhiyun<literallayout class="monospaced"> 280*4882a593SmuzhiyunBool extproc (dev, mode) 281*4882a593Smuzhiyun DeviceIntPtr dev; 282*4882a593Smuzhiyun int mode; 283*4882a593Smuzhiyun { 284*4882a593Smuzhiyun LocalDevice *localdev = (LocalDevice *) dev->devicePrivate; 285*4882a593Smuzhiyun 286*4882a593Smuzhiyun switch (mode) 287*4882a593Smuzhiyun { 288*4882a593Smuzhiyun case DEVICE_INIT: 289*4882a593Smuzhiyun if (strcmp(localdev->name, XI_TABLET) == 0) 290*4882a593Smuzhiyun { 291*4882a593Smuzhiyun /**************************************************** 292*4882a593Smuzhiyun * This device reports proximity, has buttons, 293*4882a593Smuzhiyun * reports two axes of motion, and can be focused. 294*4882a593Smuzhiyun * It also supports the same feedbacks as the X pointer 295*4882a593Smuzhiyun * (acceleration and threshold can be set). 296*4882a593Smuzhiyun ****************************************************/ 297*4882a593Smuzhiyun 298*4882a593Smuzhiyun InitButtonClassDeviceStruct (dev, button_count, button_map); 299*4882a593Smuzhiyun InitValuatorClassDeviceStruct (dev, localdev->n_axes,); 300*4882a593Smuzhiyun motionproc, MOTION_BUF_SIZE, Absolute); 301*4882a593Smuzhiyun for (i=0; i<localdev->n_axes; i++) 302*4882a593Smuzhiyun InitValuatorAxisStruct (dev, i, min_val, max_val, 303*4882a593Smuzhiyun resolution); 304*4882a593Smuzhiyun InitFocusClassDeviceStruct (dev); 305*4882a593Smuzhiyun InitProximityClassDeviceStruct (dev); 306*4882a593Smuzhiyun InitPtrFeedbackClassDeviceStruct (dev, p_controlproc); 307*4882a593Smuzhiyun } 308*4882a593Smuzhiyun else if (strcmp(localdev->name, XI_BUTTONBOX) == 0) 309*4882a593Smuzhiyun { 310*4882a593Smuzhiyun /**************************************************** 311*4882a593Smuzhiyun * This device has keys and LEDs, and can be focused. 312*4882a593Smuzhiyun ****************************************************/ 313*4882a593Smuzhiyun 314*4882a593Smuzhiyun InitKeyClassDeviceStruct (dev, syms, modmap); 315*4882a593Smuzhiyun InitFocusClassDeviceStruct (dev); 316*4882a593Smuzhiyun InitLedFeedbackClassDeviceStruct (dev, ledcontrol); 317*4882a593Smuzhiyun } 318*4882a593Smuzhiyun else if (strcmp(localdev->name, XI_KNOBBOX) == 0) 319*4882a593Smuzhiyun { 320*4882a593Smuzhiyun /**************************************************** 321*4882a593Smuzhiyun * This device reports motion. 322*4882a593Smuzhiyun * It can be focused. 323*4882a593Smuzhiyun ****************************************************/ 324*4882a593Smuzhiyun 325*4882a593Smuzhiyun InitValuatorClassDeviceStruct (dev, localdev->n_axes,); 326*4882a593Smuzhiyun motionproc, MOTION_BUF_SIZE, Absolute); 327*4882a593Smuzhiyun for (i=0; i<localdev->n_axes; i++) 328*4882a593Smuzhiyun InitValuatorAxisStruct (dev, i, min_val, max_val, 329*4882a593Smuzhiyun resolution); 330*4882a593Smuzhiyun InitFocusClassDeviceStruct (dev); 331*4882a593Smuzhiyun } 332*4882a593Smuzhiyun localdev->atom = 333*4882a593Smuzhiyun MakeAtom(localdev->name, strlen(localdev->name), FALSE); 334*4882a593Smuzhiyun AssignTypeAndName (dev, localdev->atom, localdev->name); 335*4882a593Smuzhiyun break; 336*4882a593Smuzhiyun case DEVICE_ON: 337*4882a593Smuzhiyun AddEnabledDevice (localdev->file_ds); 338*4882a593Smuzhiyun dev->on = TRUE; 339*4882a593Smuzhiyun break; 340*4882a593Smuzhiyun case DEVICE_OFF: 341*4882a593Smuzhiyun dev->on = FALSE; 342*4882a593Smuzhiyun RemoveEnabledDevice (localdev->file_ds); 343*4882a593Smuzhiyun break; 344*4882a593Smuzhiyun case DEVICE_CLOSE: 345*4882a593Smuzhiyun break; 346*4882a593Smuzhiyun } 347*4882a593Smuzhiyun } 348*4882a593Smuzhiyun</literallayout> 349*4882a593Smuzhiyun</para> 350*4882a593Smuzhiyun<para> 351*4882a593Smuzhiyun<!-- .LP --> 352*4882a593SmuzhiyunThe device control routine is called with a mode value of DEVICE_ON 353*4882a593Smuzhiyunby the DIX routine EnableDevice, which is called from InitAndStartDevices. 354*4882a593SmuzhiyunWhen called with this mode, it should call AddEnabledDevice to cause the 355*4882a593Smuzhiyunserver to begin checking for available input from this device. 356*4882a593Smuzhiyun</para> 357*4882a593Smuzhiyun<para> 358*4882a593Smuzhiyun<!-- .LP --> 359*4882a593SmuzhiyunFrom InitAndStartDevices, EnableDevice is called for all devices that have 360*4882a593Smuzhiyunthe "inited" and "startup" fields in the DeviceIntRec set to TRUE. The 361*4882a593Smuzhiyun"inited" field is set by InitAndStartDevices to the value returned by 362*4882a593Smuzhiyunthe deviceproc when called with a mode value of DEVICE_INIT. The "startup" 363*4882a593Smuzhiyunfield is set by AddInputDevice to value of the second parameter (autoStart). 364*4882a593Smuzhiyun</para> 365*4882a593Smuzhiyun<para> 366*4882a593Smuzhiyun<!-- .LP --> 367*4882a593SmuzhiyunWhen the server is first initialized, it should only be checking for input 368*4882a593Smuzhiyunfrom the core X keyboard and pointer. One way to accomplish this is to 369*4882a593Smuzhiyuncall AddInputDevice for the core X keyboard and pointer with an 370*4882a593SmuzhiyunautoStart value equal to TRUE, while calling AddInputDevice for 371*4882a593Smuzhiyuninput extension devices with an autoStart value equal to FALSE. If this is 372*4882a593Smuzhiyundone, EnableDevice will skip all input extension devices during server 373*4882a593Smuzhiyuninitialization. In this case, 374*4882a593Smuzhiyunthe OpenInputDevice routine should set the "startup" field to TRUE 375*4882a593Smuzhiyunwhen called for input extension devices. This will cause ProcXOpenInputDevice 376*4882a593Smuzhiyunto call EnableDevice for those devices when a client first does an 377*4882a593SmuzhiyunXOpenDevice request. 378*4882a593Smuzhiyun</para> 379*4882a593Smuzhiyun</sect2> 380*4882a593Smuzhiyun<sect2 id="DIX_Input_Class_Initialization_Routines"> 381*4882a593Smuzhiyun<title>DIX Input Class Initialization Routines</title> 382*4882a593Smuzhiyun<para> 383*4882a593Smuzhiyun<!-- .LP --> 384*4882a593SmuzhiyunDIX routines are defined to initialize each of the defined input classes. 385*4882a593SmuzhiyunThe defined classes are: 386*4882a593Smuzhiyun<!-- .RS --> 387*4882a593Smuzhiyun<!-- .in +5n --> 388*4882a593Smuzhiyun</para> 389*4882a593Smuzhiyun<itemizedlist> 390*4882a593Smuzhiyun <listitem> 391*4882a593Smuzhiyun <para> 392*4882a593SmuzhiyunKeyClass - the device has keys. 393*4882a593Smuzhiyun </para> 394*4882a593Smuzhiyun </listitem> 395*4882a593Smuzhiyun <listitem> 396*4882a593Smuzhiyun <para> 397*4882a593SmuzhiyunButtonClass - the device has buttons. 398*4882a593Smuzhiyun </para> 399*4882a593Smuzhiyun </listitem> 400*4882a593Smuzhiyun <listitem> 401*4882a593Smuzhiyun <para> 402*4882a593SmuzhiyunValuatorClass - the device reports motion data or positional data. 403*4882a593Smuzhiyun </para> 404*4882a593Smuzhiyun </listitem> 405*4882a593Smuzhiyun <listitem> 406*4882a593Smuzhiyun <para> 407*4882a593SmuzhiyunProximitylass - the device reports proximity information. 408*4882a593Smuzhiyun </para> 409*4882a593Smuzhiyun </listitem> 410*4882a593Smuzhiyun <listitem> 411*4882a593Smuzhiyun <para> 412*4882a593SmuzhiyunFocusClass - the device can be focused. 413*4882a593Smuzhiyun </para> 414*4882a593Smuzhiyun </listitem> 415*4882a593Smuzhiyun <listitem> 416*4882a593Smuzhiyun <para> 417*4882a593SmuzhiyunFeedbackClass - the device supports some kind of feedback. 418*4882a593Smuzhiyun<!-- .in -5n --> 419*4882a593Smuzhiyun<!-- .RE --> 420*4882a593Smuzhiyun </para> 421*4882a593Smuzhiyun </listitem> 422*4882a593Smuzhiyun</itemizedlist> 423*4882a593Smuzhiyun<para> 424*4882a593Smuzhiyun<!-- .LP --> 425*4882a593SmuzhiyunDIX routines are provided to initialize the X pointer and keyboard, as in 426*4882a593Smuzhiyunprevious releases of X. During X initialization, InitPointerDeviceStruct 427*4882a593Smuzhiyunis called to initialize the X pointer, and InitKeyboardDeviceStruct is 428*4882a593Smuzhiyuncalled to initialize the X keyboard. There is no 429*4882a593Smuzhiyuncorresponding routine for extension input devices, since they do not all 430*4882a593Smuzhiyunsupport the same classes of input. Instead, DDX is responsible for the 431*4882a593Smuzhiyuninitialization of the input classes supported by extension devices. 432*4882a593SmuzhiyunA description of the routines provided by DIX to perform that initialization 433*4882a593Smuzhiyunfollows. 434*4882a593Smuzhiyun</para> 435*4882a593Smuzhiyun<sect3 id="InitKeyClassDeviceStruct"> 436*4882a593Smuzhiyun<title>InitKeyClassDeviceStruct</title> 437*4882a593Smuzhiyun<para> 438*4882a593Smuzhiyun<!-- .LP --> 439*4882a593SmuzhiyunThis function is provided to allocate and initialize a KeyClassRec, and 440*4882a593Smuzhiyunshould be called for extension devices that have keys. It is passed a pointer 441*4882a593Smuzhiyunto the device, and pointers to arrays of keysyms and modifiers reported by 442*4882a593Smuzhiyunthe device. It returns FALSE if the KeyClassRec could not be allocated, 443*4882a593Smuzhiyunor if the maps for the keysyms and modifiers could not be allocated. 444*4882a593SmuzhiyunIts parameters are: 445*4882a593Smuzhiyun</para> 446*4882a593Smuzhiyun<para> 447*4882a593Smuzhiyun<!-- .LP --> 448*4882a593Smuzhiyun<literallayout class="monospaced"> 449*4882a593SmuzhiyunBool 450*4882a593SmuzhiyunInitKeyClassDeviceStruct(dev, pKeySyms, pModifiers) 451*4882a593Smuzhiyun DeviceIntPtr dev; 452*4882a593Smuzhiyun KeySymsPtr pKeySyms; 453*4882a593Smuzhiyun CARD8 pModifiers[]; 454*4882a593Smuzhiyun</literallayout> 455*4882a593Smuzhiyun</para> 456*4882a593Smuzhiyun<para> 457*4882a593Smuzhiyun<!-- .LP --> 458*4882a593SmuzhiyunThe DIX entry point InitKeyboardDeviceStruct calls this routine for the 459*4882a593Smuzhiyuncore X keyboard. It must be called explicitly for extension devices 460*4882a593Smuzhiyunthat have keys. 461*4882a593Smuzhiyun</para> 462*4882a593Smuzhiyun</sect3> 463*4882a593Smuzhiyun<sect3 id="InitButtonClassDeviceStruct"> 464*4882a593Smuzhiyun<title>InitButtonClassDeviceStruct</title> 465*4882a593Smuzhiyun<para> 466*4882a593Smuzhiyun<!-- .LP --> 467*4882a593SmuzhiyunThis function is provided to allocate and initialize a ButtonClassRec, and 468*4882a593Smuzhiyunshould be called for extension devices that have buttons. It is passed a 469*4882a593Smuzhiyunpointer to the device, the number of buttons supported, and a map of the 470*4882a593Smuzhiyunreported button codes. It returns FALSE if the ButtonClassRec could not be 471*4882a593Smuzhiyunallocated. Its parameters are: 472*4882a593Smuzhiyun</para> 473*4882a593Smuzhiyun<para> 474*4882a593Smuzhiyun<!-- .LP --> 475*4882a593Smuzhiyun<literallayout class="monospaced"> 476*4882a593SmuzhiyunBool 477*4882a593SmuzhiyunInitButtonClassDeviceStruct(dev, numButtons, map) 478*4882a593Smuzhiyun register DeviceIntPtr dev; 479*4882a593Smuzhiyun int numButtons; 480*4882a593Smuzhiyun CARD8 *map; 481*4882a593Smuzhiyun</literallayout> 482*4882a593Smuzhiyun</para> 483*4882a593Smuzhiyun<para> 484*4882a593Smuzhiyun<!-- .LP --> 485*4882a593SmuzhiyunThe DIX entry point InitPointerDeviceStruct calls this routine for the 486*4882a593Smuzhiyuncore X pointer. It must be called explicitly for extension devices that 487*4882a593Smuzhiyunhave buttons. 488*4882a593Smuzhiyun</para> 489*4882a593Smuzhiyun</sect3> 490*4882a593Smuzhiyun<sect3 id="InitValuatorClassDeviceStruct"> 491*4882a593Smuzhiyun<title>InitValuatorClassDeviceStruct</title> 492*4882a593Smuzhiyun<para> 493*4882a593Smuzhiyun<!-- .LP --> 494*4882a593SmuzhiyunThis function is provided to allocate and initialize a ValuatorClassRec, and 495*4882a593Smuzhiyunshould be called for extension devices that have valuators. It is passed the 496*4882a593Smuzhiyunnumber of axes of motion reported by the device, the address of the motion 497*4882a593Smuzhiyunhistory procedure for the device, the size of the motion history buffer, 498*4882a593Smuzhiyunand the mode (Absolute or Relative) of the device. It returns FALSE if 499*4882a593Smuzhiyunthe ValuatorClassRec could not be allocated. Its parameters are: 500*4882a593Smuzhiyun</para> 501*4882a593Smuzhiyun<para> 502*4882a593Smuzhiyun<!-- .LP --> 503*4882a593Smuzhiyun<literallayout class="monospaced"> 504*4882a593SmuzhiyunBool 505*4882a593SmuzhiyunInitValuatorClassDeviceStruct(dev, numAxes, motionProc, numMotionEvents, mode) 506*4882a593Smuzhiyun DeviceIntPtr dev; 507*4882a593Smuzhiyun int (*motionProc)(); 508*4882a593Smuzhiyun int numAxes; 509*4882a593Smuzhiyun int numMotionEvents; 510*4882a593Smuzhiyun int mode; 511*4882a593Smuzhiyun</literallayout> 512*4882a593Smuzhiyun</para> 513*4882a593Smuzhiyun<para> 514*4882a593Smuzhiyun<!-- .LP --> 515*4882a593SmuzhiyunThe DIX entry point InitPointerDeviceStruct calls this routine for the 516*4882a593Smuzhiyuncore X pointer. It must be called explicitly for extension devices that 517*4882a593Smuzhiyunreport motion. 518*4882a593Smuzhiyun</para> 519*4882a593Smuzhiyun</sect3> 520*4882a593Smuzhiyun<sect3 id="InitValuatorAxisStruct"> 521*4882a593Smuzhiyun<title>InitValuatorAxisStruct</title> 522*4882a593Smuzhiyun<para> 523*4882a593Smuzhiyun<!-- .LP --> 524*4882a593SmuzhiyunThis function is provided to initialize an XAxisInfoRec, and 525*4882a593Smuzhiyunshould be called for core and extension devices that have valuators. 526*4882a593SmuzhiyunThe space for the XAxisInfoRec is allocated by 527*4882a593Smuzhiyunthe InitValuatorClassDeviceStruct function, but is not initialized. 528*4882a593Smuzhiyun</para> 529*4882a593Smuzhiyun<para> 530*4882a593Smuzhiyun<!-- .LP --> 531*4882a593SmuzhiyunInitValuatorAxisStruct should be called once for each axis of motion 532*4882a593Smuzhiyunreported by the device. Each 533*4882a593Smuzhiyuninvocation should be passed the axis number (starting with 0), the 534*4882a593Smuzhiyunminimum value for that axis, the maximum value for that axis, and the 535*4882a593Smuzhiyunresolution of the device in counts per meter. If the device reports 536*4882a593Smuzhiyunrelative motion, 0 should be reported as the minimum and maximum values. 537*4882a593SmuzhiyunInitValuatorAxisStruct has the following parameters: 538*4882a593Smuzhiyun<literallayout class="monospaced"> 539*4882a593SmuzhiyunInitValuatorAxisStruct(dev, axnum, minval, maxval, resolution) 540*4882a593Smuzhiyun DeviceIntPtr dev; 541*4882a593Smuzhiyun int axnum; 542*4882a593Smuzhiyun int minval; 543*4882a593Smuzhiyun int maxval; 544*4882a593Smuzhiyun int resolution; 545*4882a593Smuzhiyun</literallayout> 546*4882a593Smuzhiyun</para> 547*4882a593Smuzhiyun<para> 548*4882a593Smuzhiyun<!-- .LP --> 549*4882a593SmuzhiyunThis routine is not called by InitPointerDeviceStruct for the 550*4882a593Smuzhiyuncore X pointer. It must be called explicitly for core and extension devices 551*4882a593Smuzhiyunthat report motion. 552*4882a593Smuzhiyun</para> 553*4882a593Smuzhiyun</sect3> 554*4882a593Smuzhiyun<sect3 id="InitFocusClassDeviceStruct"> 555*4882a593Smuzhiyun<title>InitFocusClassDeviceStruct</title> 556*4882a593Smuzhiyun<para> 557*4882a593Smuzhiyun<!-- .LP --> 558*4882a593SmuzhiyunThis function is provided to allocate and initialize a FocusClassRec, and 559*4882a593Smuzhiyunshould be called for extension devices that can be focused. It is passed a 560*4882a593Smuzhiyunpointer to the device, and returns FALSE if the allocation fails. 561*4882a593SmuzhiyunIt has the following parameter: 562*4882a593Smuzhiyun<literallayout class="monospaced"> 563*4882a593SmuzhiyunBool 564*4882a593SmuzhiyunInitFocusClassDeviceStruct(dev) 565*4882a593Smuzhiyun DeviceIntPtr dev; 566*4882a593Smuzhiyun</literallayout> 567*4882a593Smuzhiyun</para> 568*4882a593Smuzhiyun<para> 569*4882a593Smuzhiyun<!-- .LP --> 570*4882a593SmuzhiyunThe DIX entry point InitKeyboardDeviceStruct calls this routine for the 571*4882a593Smuzhiyuncore X keyboard. It must be called explicitly for extension devices 572*4882a593Smuzhiyunthat can be focused. Whether or not a particular device can be focused 573*4882a593Smuzhiyunis left implementation-dependent. 574*4882a593Smuzhiyun</para> 575*4882a593Smuzhiyun</sect3> 576*4882a593Smuzhiyun<sect3 id="InitProximityClassDeviceStruct"> 577*4882a593Smuzhiyun<title>InitProximityClassDeviceStruct</title> 578*4882a593Smuzhiyun<para> 579*4882a593Smuzhiyun<!-- .LP --> 580*4882a593SmuzhiyunThis function is provided to allocate and initialize a ProximityClassRec, and 581*4882a593Smuzhiyunshould be called for extension absolute pointing devices that report proximity. 582*4882a593SmuzhiyunIt is passed a pointer to the device, and returns FALSE if the allocation fails. 583*4882a593SmuzhiyunIt has the following parameter: 584*4882a593Smuzhiyun<literallayout class="monospaced"> 585*4882a593SmuzhiyunBool 586*4882a593SmuzhiyunInitProximityClassDeviceStruct(dev) 587*4882a593Smuzhiyun DeviceIntPtr dev; 588*4882a593Smuzhiyun</literallayout> 589*4882a593Smuzhiyun</para> 590*4882a593Smuzhiyun</sect3> 591*4882a593Smuzhiyun<sect3 id="Initializing_Feedbacks"> 592*4882a593Smuzhiyun<title>Initializing Feedbacks</title> 593*4882a593Smuzhiyun<para> 594*4882a593Smuzhiyun<!-- .LP --> 595*4882a593Smuzhiyun</para> 596*4882a593Smuzhiyun<sect4 id="InitKbdFeedbackClassDeviceStruct"> 597*4882a593Smuzhiyun<title>InitKbdFeedbackClassDeviceStruct</title> 598*4882a593Smuzhiyun<para> 599*4882a593Smuzhiyun<!-- .LP --> 600*4882a593SmuzhiyunThis function is provided to allocate and initialize a KbdFeedbackClassRec, and 601*4882a593Smuzhiyunmay be called for extension devices that support some or all of the 602*4882a593Smuzhiyunfeedbacks that the core keyboard supports. It is passed a 603*4882a593Smuzhiyunpointer to the device, a pointer to the procedure that sounds the bell, 604*4882a593Smuzhiyunand a pointer to the device control procedure. 605*4882a593SmuzhiyunIt returns FALSE if the allocation fails, and has the following parameters: 606*4882a593Smuzhiyun<literallayout class="monospaced"> 607*4882a593SmuzhiyunBool 608*4882a593SmuzhiyunInitKbdFeedbackClassDeviceStruct(dev, bellProc, controlProc) 609*4882a593Smuzhiyun DeviceIntPtr dev; 610*4882a593Smuzhiyun void (*bellProc)(); 611*4882a593Smuzhiyun void (*controlProc)(); 612*4882a593Smuzhiyun</literallayout> 613*4882a593SmuzhiyunThe DIX entry point InitKeyboardDeviceStruct calls this routine for the 614*4882a593Smuzhiyuncore X keyboard. It must be called explicitly for extension devices 615*4882a593Smuzhiyunthat have the same feedbacks as a keyboard. Some feedbacks, such as LEDs and 616*4882a593Smuzhiyunbell, can be supported either with a KbdFeedbackClass or with BellFeedbackClass 617*4882a593Smuzhiyunand LedFeedbackClass feedbacks. 618*4882a593Smuzhiyun</para> 619*4882a593Smuzhiyun</sect4> 620*4882a593Smuzhiyun<sect4 id="InitPtrFeedbackClassDeviceStruct"> 621*4882a593Smuzhiyun<title>InitPtrFeedbackClassDeviceStruct</title> 622*4882a593Smuzhiyun<para> 623*4882a593Smuzhiyun<!-- .LP --> 624*4882a593SmuzhiyunThis function is provided to allocate and initialize a PtrFeedbackClassRec, and 625*4882a593Smuzhiyunshould be called for extension devices that allow the setting of acceleration 626*4882a593Smuzhiyunand threshold. It is passed a pointer to the device, 627*4882a593Smuzhiyunand a pointer to the device control procedure. 628*4882a593SmuzhiyunIt returns FALSE if the allocation fails, and has the following parameters: 629*4882a593Smuzhiyun<literallayout class="monospaced"> 630*4882a593SmuzhiyunBool 631*4882a593SmuzhiyunInitPtrFeedbackClassDeviceStruct(dev, controlProc) 632*4882a593Smuzhiyun DeviceIntPtr dev; 633*4882a593Smuzhiyun void (*controlProc)(); 634*4882a593Smuzhiyun</literallayout> 635*4882a593Smuzhiyun</para> 636*4882a593Smuzhiyun<para> 637*4882a593Smuzhiyun<!-- .LP --> 638*4882a593SmuzhiyunThe DIX entry point InitPointerDeviceStruct calls this routine for the 639*4882a593Smuzhiyuncore X pointer. It must be called explicitly for extension devices 640*4882a593Smuzhiyunthat support the setting of acceleration and threshold. 641*4882a593Smuzhiyun</para> 642*4882a593Smuzhiyun</sect4> 643*4882a593Smuzhiyun<sect4 id="InitLedFeedbackClassDeviceStruct"> 644*4882a593Smuzhiyun<title>InitLedFeedbackClassDeviceStruct</title> 645*4882a593Smuzhiyun<para> 646*4882a593Smuzhiyun<!-- .LP --> 647*4882a593SmuzhiyunThis function is provided to allocate and initialize a LedFeedbackClassRec, and 648*4882a593Smuzhiyunshould be called for extension devices that have LEDs. 649*4882a593SmuzhiyunIt is passed a pointer to the device, 650*4882a593Smuzhiyunand a pointer to the device control procedure. 651*4882a593SmuzhiyunIt returns FALSE if the allocation fails, and has the following parameters: 652*4882a593Smuzhiyun<literallayout class="monospaced"> 653*4882a593SmuzhiyunBool 654*4882a593SmuzhiyunInitLedFeedbackClassDeviceStruct(dev, controlProc) 655*4882a593Smuzhiyun DeviceIntPtr dev; 656*4882a593Smuzhiyun void (*controlProc)(); 657*4882a593Smuzhiyun</literallayout> 658*4882a593Smuzhiyun</para> 659*4882a593Smuzhiyun<para> 660*4882a593Smuzhiyun<!-- .LP --> 661*4882a593SmuzhiyunUp to 32 LEDs per feedback can be supported, and a device may have 662*4882a593Smuzhiyunmultiple feedbacks of the same type. 663*4882a593Smuzhiyun</para> 664*4882a593Smuzhiyun</sect4> 665*4882a593Smuzhiyun<sect4 id="InitBellFeedbackClassDeviceStruct"> 666*4882a593Smuzhiyun<title>InitBellFeedbackClassDeviceStruct</title> 667*4882a593Smuzhiyun<para> 668*4882a593Smuzhiyun<!-- .LP --> 669*4882a593SmuzhiyunThis function is provided to allocate and initialize a BellFeedbackClassRec, 670*4882a593Smuzhiyunand should be called for extension devices that have a bell. 671*4882a593SmuzhiyunIt is passed a pointer to the device, 672*4882a593Smuzhiyunand a pointer to the device control procedure. 673*4882a593SmuzhiyunIt returns FALSE if the allocation fails, and has the following parameters: 674*4882a593Smuzhiyun<literallayout class="monospaced"> 675*4882a593SmuzhiyunBool 676*4882a593SmuzhiyunInitBellFeedbackClassDeviceStruct(dev, bellProc, controlProc) 677*4882a593Smuzhiyun DeviceIntPtr dev; 678*4882a593Smuzhiyun void (*bellProc)(); 679*4882a593Smuzhiyun void (*controlProc)(); 680*4882a593Smuzhiyun</literallayout> 681*4882a593Smuzhiyun</para> 682*4882a593Smuzhiyun</sect4> 683*4882a593Smuzhiyun<sect4 id="InitStringFeedbackClassDeviceStruct"> 684*4882a593Smuzhiyun<title>InitStringFeedbackClassDeviceStruct</title> 685*4882a593Smuzhiyun<para> 686*4882a593Smuzhiyun<!-- .LP --> 687*4882a593SmuzhiyunThis function is provided to allocate and initialize a StringFeedbackClassRec, 688*4882a593Smuzhiyunand should be called for extension devices that have a display upon which a 689*4882a593Smuzhiyunstring can be displayed. 690*4882a593SmuzhiyunIt is passed a pointer to the device, 691*4882a593Smuzhiyunand a pointer to the device control procedure. 692*4882a593SmuzhiyunIt returns FALSE if the allocation fails, and has the following parameters: 693*4882a593Smuzhiyun<literallayout class="monospaced"> 694*4882a593SmuzhiyunBool 695*4882a593SmuzhiyunInitStringFeedbackClassDeviceStruct(dev, controlProc, max_symbols, 696*4882a593Smuzhiyun num_symbols_supported, symbols) 697*4882a593Smuzhiyun DeviceIntPtr dev; 698*4882a593Smuzhiyun void (*controlProc)(); 699*4882a593Smuzhiyun int max_symbols; 700*4882a593Smuzhiyun int num_symbols_supported; 701*4882a593Smuzhiyun KeySym *symbols; 702*4882a593Smuzhiyun</literallayout> 703*4882a593Smuzhiyun</para> 704*4882a593Smuzhiyun</sect4> 705*4882a593Smuzhiyun<sect4 id="InitIntegerFeedbackClassDeviceStruct"> 706*4882a593Smuzhiyun<title>InitIntegerFeedbackClassDeviceStruct</title> 707*4882a593Smuzhiyun<para> 708*4882a593Smuzhiyun<!-- .LP --> 709*4882a593SmuzhiyunThis function is provided to allocate and initialize an 710*4882a593SmuzhiyunIntegerFeedbackClassRec, 711*4882a593Smuzhiyunand should be called for extension devices that have a display upon which an 712*4882a593Smuzhiyuninteger can be displayed. 713*4882a593SmuzhiyunIt is passed a pointer to the device, 714*4882a593Smuzhiyunand a pointer to the device control procedure. 715*4882a593SmuzhiyunIt returns FALSE if the allocation fails, and has the following parameters: 716*4882a593Smuzhiyun<literallayout class="monospaced"> 717*4882a593SmuzhiyunBool 718*4882a593SmuzhiyunInitIntegerFeedbackClassDeviceStruct(dev, controlProc) 719*4882a593Smuzhiyun DeviceIntPtr dev; 720*4882a593Smuzhiyun void (*controlProc)(); 721*4882a593Smuzhiyun</literallayout> 722*4882a593Smuzhiyun</para> 723*4882a593Smuzhiyun</sect4> 724*4882a593Smuzhiyun</sect3> 725*4882a593Smuzhiyun</sect2> 726*4882a593Smuzhiyun<sect2 id="Initializing_The_Device_Name_And_Type"> 727*4882a593Smuzhiyun<title>Initializing The Device Name And Type</title> 728*4882a593Smuzhiyun<para> 729*4882a593Smuzhiyun<!-- .LP --> 730*4882a593SmuzhiyunThe device name and type can be initialized by calling AssignTypeAndName 731*4882a593Smuzhiyunwith the following parameters: 732*4882a593Smuzhiyun<literallayout class="monospaced"> 733*4882a593Smuzhiyunvoid 734*4882a593SmuzhiyunAssignTypeAndName(dev, type, name) 735*4882a593Smuzhiyun DeviceIntPtr dev; 736*4882a593Smuzhiyun Atom type; 737*4882a593Smuzhiyun char *name; 738*4882a593Smuzhiyun</literallayout> 739*4882a593Smuzhiyun</para> 740*4882a593Smuzhiyun<para> 741*4882a593Smuzhiyun<!-- .LP --> 742*4882a593SmuzhiyunThis will allocate space for the device name and copy the name that was passed. 743*4882a593SmuzhiyunThe device type can be obtained by calling MakeAtom with one of the names 744*4882a593Smuzhiyundefined for input devices. MakeAtom has the following parameters: 745*4882a593Smuzhiyun<literallayout class="monospaced"> 746*4882a593SmuzhiyunAtom 747*4882a593SmuzhiyunMakeAtom(name, len, makeit) 748*4882a593Smuzhiyun char *name; 749*4882a593Smuzhiyun int len; 750*4882a593Smuzhiyun Bool makeit; 751*4882a593Smuzhiyun</literallayout> 752*4882a593Smuzhiyun</para> 753*4882a593Smuzhiyun<para> 754*4882a593Smuzhiyun<!-- .LP --> 755*4882a593SmuzhiyunSince the atom was already made when the input extension was initialized, the 756*4882a593Smuzhiyunvalue of makeit should be FALSE; 757*4882a593Smuzhiyun</para> 758*4882a593Smuzhiyun</sect2> 759*4882a593Smuzhiyun</sect1> 760*4882a593Smuzhiyun<sect1 id="Closing_Extension_Devices"> 761*4882a593Smuzhiyun<title>Closing Extension Devices</title> 762*4882a593Smuzhiyun<para> 763*4882a593Smuzhiyun<!-- .LP --> 764*4882a593SmuzhiyunThe DisableDevice entry point is provided by DIX to disable input devices. 765*4882a593SmuzhiyunIt calls the device control routine for the specified 766*4882a593Smuzhiyundevice with a mode value of DEVICE_OFF. The device control routine should 767*4882a593Smuzhiyuncall RemoveEnabledDevice to stop the server from checking for input from 768*4882a593Smuzhiyunthat device. 769*4882a593Smuzhiyun</para> 770*4882a593Smuzhiyun<para> 771*4882a593Smuzhiyun<!-- .LP --> 772*4882a593SmuzhiyunDisableDevice is not called by any input extension routines. It can be 773*4882a593Smuzhiyuncalled from the CloseInputDevice routine, which is called by 774*4882a593SmuzhiyunProcXCloseDevice when a client makes an XCloseDevice request. If 775*4882a593SmuzhiyunDisableDevice is called, it should only be called when the last client 776*4882a593Smuzhiyunusing the extension device has terminated or called XCloseDevice. 777*4882a593Smuzhiyun</para> 778*4882a593Smuzhiyun</sect1> 779*4882a593Smuzhiyun<sect1 id="Implementation_Dependent_Routines"> 780*4882a593Smuzhiyun<title>Implementation-Dependent Routines</title> 781*4882a593Smuzhiyun<para> 782*4882a593Smuzhiyun<!-- .LP --> 783*4882a593SmuzhiyunSeveral input extension protocol requests have 784*4882a593Smuzhiyunimplementation-dependent entry points. Default routines 785*4882a593Smuzhiyunare defined for these entry points and contained in the source 786*4882a593Smuzhiyunfile extensions/server/xinput/xstubs.c. Some implementations may 787*4882a593Smuzhiyunbe able to use the default routines without change. 788*4882a593SmuzhiyunThe following sections describe each of these routines. 789*4882a593Smuzhiyun</para> 790*4882a593Smuzhiyun<sect2 id="AddOtherInputDevices"> 791*4882a593Smuzhiyun<title>AddOtherInputDevices</title> 792*4882a593Smuzhiyun<para> 793*4882a593Smuzhiyun<!-- .LP --> 794*4882a593SmuzhiyunAddOtherInputDevice is called from ProcXListInputDevices as a result of 795*4882a593Smuzhiyunan XListInputDevices protocol request. It may be needed by 796*4882a593Smuzhiyunimplementations that do not open extension input devices until requested 797*4882a593Smuzhiyunto do so by some client. These implementations may not initialize 798*4882a593Smuzhiyunall devices when the X server starts up, because some of those devices 799*4882a593Smuzhiyunmay be in use. Since the XListInputDevices 800*4882a593Smuzhiyunfunction only lists those devices that have been initialized, 801*4882a593SmuzhiyunAddOtherInputDevices is called to give DDX a chance to 802*4882a593Smuzhiyuninitialize any previously unavailable input devices. 803*4882a593Smuzhiyun</para> 804*4882a593Smuzhiyun<para> 805*4882a593Smuzhiyun<!-- .LP --> 806*4882a593SmuzhiyunA sample AddOtherInputDevices routine might look like the following: 807*4882a593Smuzhiyun<literallayout class="monospaced"> 808*4882a593Smuzhiyunvoid 809*4882a593SmuzhiyunAddOtherInputDevices () 810*4882a593Smuzhiyun { 811*4882a593Smuzhiyun DeviceIntPtr dev; 812*4882a593Smuzhiyun int i; 813*4882a593Smuzhiyun 814*4882a593Smuzhiyun for (i=0; i<MAX_DEVICES; i++) 815*4882a593Smuzhiyun { 816*4882a593Smuzhiyun if (!local_dev[i].initialized && available(local_dev[i])) 817*4882a593Smuzhiyun { 818*4882a593Smuzhiyun dev = (DeviceIntPtr) AddInputDevice (local_dev[i].deviceProc, TRUE); 819*4882a593Smuzhiyun dev->public.devicePrivate = local_dev[i]; 820*4882a593Smuzhiyun RegisterOtherDevice (dev); 821*4882a593Smuzhiyun dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success); 822*4882a593Smuzhiyun } 823*4882a593Smuzhiyun } 824*4882a593Smuzhiyun } 825*4882a593Smuzhiyun</literallayout> 826*4882a593Smuzhiyun</para> 827*4882a593Smuzhiyun<para> 828*4882a593Smuzhiyun<!-- .LP --> 829*4882a593SmuzhiyunThe default AddOtherInputDevices routine in xstubs.c does nothing. 830*4882a593SmuzhiyunIf all input extension devices are initialized when the server 831*4882a593Smuzhiyunstarts up, it can be left as a null routine. 832*4882a593Smuzhiyun</para> 833*4882a593Smuzhiyun</sect2> 834*4882a593Smuzhiyun<sect2 id="OpenInputDevice"> 835*4882a593Smuzhiyun<title>OpenInputDevice</title> 836*4882a593Smuzhiyun<para> 837*4882a593Smuzhiyun<!-- .LP --> 838*4882a593SmuzhiyunSome X server implementations open all input devices when the server 839*4882a593Smuzhiyunis initialized and never close them. Other implementations may open only 840*4882a593Smuzhiyunthe X pointer and keyboard devices during server initialization, 841*4882a593Smuzhiyunand open other input devices only when some client makes an 842*4882a593SmuzhiyunXOpenDevice request. This entry point is for the latter type of 843*4882a593Smuzhiyunimplementation. 844*4882a593Smuzhiyun</para> 845*4882a593Smuzhiyun<para> 846*4882a593Smuzhiyun<!-- .LP --> 847*4882a593SmuzhiyunIf the physical device is not already open, it can be done in this routine. 848*4882a593SmuzhiyunIn this case, the server must keep track of the fact that one or more clients 849*4882a593Smuzhiyunhave the device open, and physically close it when the last client that has 850*4882a593Smuzhiyunit open makes an XCloseDevice request. 851*4882a593Smuzhiyun</para> 852*4882a593Smuzhiyun<para> 853*4882a593Smuzhiyun<!-- .LP --> 854*4882a593SmuzhiyunThe default implementation is to do nothing (assume all input devices 855*4882a593Smuzhiyunare opened during X server initialization and kept open). 856*4882a593Smuzhiyun</para> 857*4882a593Smuzhiyun</sect2> 858*4882a593Smuzhiyun<sect2 id="CloseInputDevice"> 859*4882a593Smuzhiyun<title>CloseInputDevice</title> 860*4882a593Smuzhiyun<para> 861*4882a593Smuzhiyun<!-- .LP --> 862*4882a593SmuzhiyunSome implementations may close an input device when the last client 863*4882a593Smuzhiyunusing that device requests that it be closed, or terminates. 864*4882a593SmuzhiyunCloseInputDevice is called from ProcXCloseDevice when a client 865*4882a593Smuzhiyunmakes an XCloseDevice protocol request. 866*4882a593Smuzhiyun</para> 867*4882a593Smuzhiyun<para> 868*4882a593Smuzhiyun<!-- .LP --> 869*4882a593SmuzhiyunThe default implementation is to do nothing (assume all input devices 870*4882a593Smuzhiyunare opened during X server initialization and kept open). 871*4882a593Smuzhiyun</para> 872*4882a593Smuzhiyun</sect2> 873*4882a593Smuzhiyun<sect2 id="SetDeviceMode"> 874*4882a593Smuzhiyun<title>SetDeviceMode</title> 875*4882a593Smuzhiyun<para> 876*4882a593Smuzhiyun<!-- .LP --> 877*4882a593SmuzhiyunSome implementations support input devices that can report 878*4882a593Smuzhiyuneither absolute positional data or relative motion. The XSetDeviceMode 879*4882a593Smuzhiyunprotocol request is provided to allow DDX to change the current mode of 880*4882a593Smuzhiyunsuch a device. 881*4882a593Smuzhiyun</para> 882*4882a593Smuzhiyun<para> 883*4882a593Smuzhiyun<!-- .LP --> 884*4882a593SmuzhiyunThe default implementation is to always return a BadMatch error. If the 885*4882a593Smuzhiyunimplementation does not support any input devices that are capable of 886*4882a593Smuzhiyunreporting both relative motion and absolute position information, the 887*4882a593Smuzhiyundefault implementation may be left unchanged. 888*4882a593Smuzhiyun</para> 889*4882a593Smuzhiyun</sect2> 890*4882a593Smuzhiyun<sect2 id="SetDeviceValuators"> 891*4882a593Smuzhiyun<title>SetDeviceValuators</title> 892*4882a593Smuzhiyun<para> 893*4882a593Smuzhiyun<!-- .LP --> 894*4882a593SmuzhiyunSome implementations support input devices that allow their valuators to be 895*4882a593Smuzhiyunset to an initial value. The XSetDeviceValuators 896*4882a593Smuzhiyunprotocol request is provided to allow DDX to set the valuators of 897*4882a593Smuzhiyunsuch a device. 898*4882a593Smuzhiyun</para> 899*4882a593Smuzhiyun<para> 900*4882a593Smuzhiyun<!-- .LP --> 901*4882a593SmuzhiyunThe default implementation is to always return a BadMatch error. If the 902*4882a593Smuzhiyunimplementation does not support any input devices that allow their 903*4882a593Smuzhiyunvaluators to be set, the default implementation may be left unchanged. 904*4882a593Smuzhiyun</para> 905*4882a593Smuzhiyun</sect2> 906*4882a593Smuzhiyun<sect2 id="ChangePointerDevice"> 907*4882a593Smuzhiyun<title>ChangePointerDevice</title> 908*4882a593Smuzhiyun<para> 909*4882a593Smuzhiyun<!-- .LP --> 910*4882a593SmuzhiyunThe XChangePointerDevice protocol request is provided to change which device is 911*4882a593Smuzhiyunused as the X pointer. Some implementations may maintain information 912*4882a593Smuzhiyunspecific to the X pointer in the private data structure pointed to by 913*4882a593Smuzhiyunthe DeviceIntRec. ChangePointerDevice is called to allow such 914*4882a593Smuzhiyunimplementations to move that information to the new pointer device. 915*4882a593SmuzhiyunThe current location of the X cursor is an example of the type of 916*4882a593Smuzhiyuninformation that might be affected. 917*4882a593Smuzhiyun</para> 918*4882a593Smuzhiyun<para> 919*4882a593Smuzhiyun<!-- .LP --> 920*4882a593SmuzhiyunThe DeviceIntRec structure that describes the X pointer device does not 921*4882a593Smuzhiyuncontain a FocusRec. If the device that has been made into the new X pointer 922*4882a593Smuzhiyunwas previously a device that could be focused, ProcXChangePointerDevice will 923*4882a593Smuzhiyunfree the FocusRec associated with that device. 924*4882a593Smuzhiyun</para> 925*4882a593Smuzhiyun<para> 926*4882a593Smuzhiyun<!-- .LP --> 927*4882a593SmuzhiyunIf the server implementation desires to allow clients to focus the old pointer 928*4882a593Smuzhiyundevice (which is now accessible through the input extension), it should call 929*4882a593SmuzhiyunInitFocusClassDeviceStruct for the old pointer device. 930*4882a593Smuzhiyun</para> 931*4882a593Smuzhiyun<para> 932*4882a593Smuzhiyun<!-- .LP --> 933*4882a593SmuzhiyunThe XChangePointerDevice protocol request also allows the client 934*4882a593Smuzhiyunto choose which axes of the new pointer device are used to move 935*4882a593Smuzhiyunthe X cursor in the X- and Y- directions. If the axes are different 936*4882a593Smuzhiyunthan the default ones, the server implementation should record that fact. 937*4882a593Smuzhiyun</para> 938*4882a593Smuzhiyun<para> 939*4882a593Smuzhiyun<!-- .LP --> 940*4882a593SmuzhiyunIf the server implementation supports input devices with valuators that 941*4882a593Smuzhiyunare not allowed to be used as the X pointer, they should be screened out 942*4882a593Smuzhiyunby this routine and a BadDevice error returned. 943*4882a593Smuzhiyun</para> 944*4882a593Smuzhiyun<para> 945*4882a593Smuzhiyun<!-- .LP --> 946*4882a593SmuzhiyunThe default implementation is to do nothing. 947*4882a593Smuzhiyun</para> 948*4882a593Smuzhiyun</sect2> 949*4882a593Smuzhiyun<sect2 id="ChangeKeyboardDevice"> 950*4882a593Smuzhiyun<title>ChangeKeyboardDevice</title> 951*4882a593Smuzhiyun<para> 952*4882a593Smuzhiyun<!-- .LP --> 953*4882a593SmuzhiyunThe XChangeKeyboardDevice protocol request is provided to change which device is 954*4882a593Smuzhiyunused as the X keyboard. Some implementations may maintain information 955*4882a593Smuzhiyunspecific to the X keyboard in the private data structure pointed to by 956*4882a593Smuzhiyunthe DeviceIntRec. ChangeKeyboardDevice is called to allow such 957*4882a593Smuzhiyunimplementations to move that information to the new keyboard device. 958*4882a593Smuzhiyun</para> 959*4882a593Smuzhiyun<para> 960*4882a593Smuzhiyun<!-- .LP --> 961*4882a593SmuzhiyunThe X keyboard device can be focused, and the DeviceIntRec that describes 962*4882a593Smuzhiyunthat device has a FocusRec. If the device that has been made into the new X 963*4882a593Smuzhiyunkeyboard did not previously have a FocusRec, 964*4882a593SmuzhiyunProcXChangeKeyboardDevice will allocate one for it. 965*4882a593Smuzhiyun</para> 966*4882a593Smuzhiyun<para> 967*4882a593Smuzhiyun<!-- .LP --> 968*4882a593SmuzhiyunIf the implementation does not want clients to be able to focus the old X 969*4882a593Smuzhiyunkeyboard (which has now become available as an input extension device) 970*4882a593Smuzhiyunit should call DeleteFocusClassDeviceStruct to free the FocusRec. 971*4882a593Smuzhiyun</para> 972*4882a593Smuzhiyun<para> 973*4882a593Smuzhiyun<!-- .LP --> 974*4882a593SmuzhiyunIf the implementation supports input devices with keys that are not allowed 975*4882a593Smuzhiyunto be used as the X keyboard, they should be checked for here, and a 976*4882a593SmuzhiyunBadDevice error returned. 977*4882a593Smuzhiyun</para> 978*4882a593Smuzhiyun<para> 979*4882a593Smuzhiyun<!-- .LP --> 980*4882a593SmuzhiyunThe default implementation is to do nothing. 981*4882a593Smuzhiyun</para> 982*4882a593Smuzhiyun</sect2> 983*4882a593Smuzhiyun</sect1> 984*4882a593Smuzhiyun<sect1 id="Input_Extension_Events"> 985*4882a593Smuzhiyun<title>Input Extension Events</title> 986*4882a593Smuzhiyun<para> 987*4882a593Smuzhiyun<!-- .LP --> 988*4882a593SmuzhiyunEvents accessed through the input extension are analogous to the core input 989*4882a593Smuzhiyunevents, but have different event types. They are of types 990*4882a593Smuzhiyun<function>DeviceKeyPress</function>, <function>DeviceKeyRelease</function>, <function>DeviceButtonPress</function>, 991*4882a593Smuzhiyun<function>DeviceButtonRelease</function>, <function>DeviceDeviceMotionNotify</function>, 992*4882a593Smuzhiyun<function>DeviceProximityIn</function>, <function>DeviceProximityOut</function>, and <function>DeviceValuator</function>. 993*4882a593SmuzhiyunThese event types are not constants. Instead, they are external integers 994*4882a593Smuzhiyundefined by the input extension. Their actual values will depend on which 995*4882a593Smuzhiyunextensions are supported by a server, and the order in which they are 996*4882a593Smuzhiyuninitialized. 997*4882a593Smuzhiyun</para> 998*4882a593Smuzhiyun<para> 999*4882a593Smuzhiyun<!-- .LP --> 1000*4882a593SmuzhiyunThe data structures that describe these 1001*4882a593Smuzhiyunevents are defined in the file <function>extensions/include/XIproto.h</function>. Other 1002*4882a593Smuzhiyuninput extension constants needed by DDX are defined in the file 1003*4882a593Smuzhiyun<function>extensions/include/XI.h</function>. 1004*4882a593Smuzhiyun</para> 1005*4882a593Smuzhiyun<para> 1006*4882a593Smuzhiyun<!-- .LP --> 1007*4882a593SmuzhiyunSome events defined by the input extension contain more information than can 1008*4882a593Smuzhiyunbe contained in the 32-byte xEvent data structure. To send this information 1009*4882a593Smuzhiyunto clients, DDX must generate two or more 32-byte wire events. The following 1010*4882a593Smuzhiyunsections describe the contents of these events. 1011*4882a593Smuzhiyun</para> 1012*4882a593Smuzhiyun<sect2 id="Device_Key_Events"> 1013*4882a593Smuzhiyun<title>Device Key Events</title> 1014*4882a593Smuzhiyun<para> 1015*4882a593Smuzhiyun<!-- .LP --> 1016*4882a593Smuzhiyun<function>DeviceKeyPresss</function> events contain all the information that is contained in 1017*4882a593Smuzhiyuna core <function>KeyPress</function> event, and also the following additional information: 1018*4882a593Smuzhiyun</para> 1019*4882a593Smuzhiyun<para> 1020*4882a593Smuzhiyun<!-- .LP --> 1021*4882a593Smuzhiyun<!-- .RS --> 1022*4882a593Smuzhiyun<!-- .in +5n --> 1023*4882a593Smuzhiyun</para> 1024*4882a593Smuzhiyun<itemizedlist> 1025*4882a593Smuzhiyun <listitem> 1026*4882a593Smuzhiyun <para> 1027*4882a593Smuzhiyundeviceid - the identifier of the device that generated the event. 1028*4882a593Smuzhiyun </para> 1029*4882a593Smuzhiyun </listitem> 1030*4882a593Smuzhiyun <listitem> 1031*4882a593Smuzhiyun <para> 1032*4882a593Smuzhiyundevice_state - the state of any modifiers on the device that generated the event. 1033*4882a593Smuzhiyun </para> 1034*4882a593Smuzhiyun </listitem> 1035*4882a593Smuzhiyun <listitem> 1036*4882a593Smuzhiyun <para> 1037*4882a593Smuzhiyunnum_valuators - the number of valuators reported in this event. 1038*4882a593Smuzhiyun </para> 1039*4882a593Smuzhiyun </listitem> 1040*4882a593Smuzhiyun <listitem> 1041*4882a593Smuzhiyun <para> 1042*4882a593Smuzhiyunfirst_valuator - the first valuator reported in this event. 1043*4882a593Smuzhiyun </para> 1044*4882a593Smuzhiyun </listitem> 1045*4882a593Smuzhiyun <listitem> 1046*4882a593Smuzhiyun <para> 1047*4882a593Smuzhiyunvaluator0 through valuator5 - the values of the valuators. 1048*4882a593Smuzhiyun<!-- .in -5n --> 1049*4882a593Smuzhiyun<!-- .RE --> 1050*4882a593Smuzhiyun </para> 1051*4882a593Smuzhiyun </listitem> 1052*4882a593Smuzhiyun</itemizedlist> 1053*4882a593Smuzhiyun<para> 1054*4882a593Smuzhiyun<!-- .LP --> 1055*4882a593SmuzhiyunIn order to pass this information to the input extension library, two 32-byte 1056*4882a593Smuzhiyunwire events must be generated by DDX. The first has an event type of 1057*4882a593Smuzhiyun<function>DeviceKeyPress</function>, and the second has an event type of <function>DeviceValuator</function>. 1058*4882a593Smuzhiyun</para> 1059*4882a593Smuzhiyun<para> 1060*4882a593Smuzhiyun<!-- .LP --> 1061*4882a593SmuzhiyunThe following code fragment shows how the two wire events could be initialized: 1062*4882a593Smuzhiyun</para> 1063*4882a593Smuzhiyun<para> 1064*4882a593Smuzhiyun<!-- .LP --> 1065*4882a593Smuzhiyun<literallayout class="monospaced"> 1066*4882a593Smuzhiyun extern int DeviceKeyPress; 1067*4882a593Smuzhiyun DeviceIntPtr dev; 1068*4882a593Smuzhiyun xEvent xE[2]; 1069*4882a593Smuzhiyun CARD8 id, num_valuators; 1070*4882a593Smuzhiyun INT16 x, y, pointerx, pointery; 1071*4882a593Smuzhiyun Time timestamp; 1072*4882a593Smuzhiyun deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *) xE; 1073*4882a593Smuzhiyun deviceValuator *xv; 1074*4882a593Smuzhiyun 1075*4882a593Smuzhiyun xev->type = DeviceKeyPress; /* defined by input extension */ 1076*4882a593Smuzhiyun xev->detail = keycode; /* key pressed on this device */ 1077*4882a593Smuzhiyun xev->time = timestamp; /* same as for core events */ 1078*4882a593Smuzhiyun xev->rootX = pointerx; /* x location of core pointer */ 1079*4882a593Smuzhiyun xev->rootY = pointery; /* y location of core pointer */ 1080*4882a593Smuzhiyun 1081*4882a593Smuzhiyun /******************************************************************/ 1082*4882a593Smuzhiyun /* */ 1083*4882a593Smuzhiyun /* The following field does not exist for core input events. */ 1084*4882a593Smuzhiyun /* It contains the device id for the device that generated the */ 1085*4882a593Smuzhiyun /* event, and also indicates whether more than one 32-byte wire */ 1086*4882a593Smuzhiyun /* event is being sent. */ 1087*4882a593Smuzhiyun /* */ 1088*4882a593Smuzhiyun /******************************************************************/ 1089*4882a593Smuzhiyun 1090*4882a593Smuzhiyun xev->deviceid = dev->id | MORE_EVENTS; /* sending more than 1 */ 1091*4882a593Smuzhiyun 1092*4882a593Smuzhiyun /******************************************************************/ 1093*4882a593Smuzhiyun /* Fields in the second 32-byte wire event: */ 1094*4882a593Smuzhiyun /******************************************************************/ 1095*4882a593Smuzhiyun 1096*4882a593Smuzhiyun xv = (deviceValuator *) ++xev; 1097*4882a593Smuzhiyun xv->type = DeviceValuator; /* event type of second event */ 1098*4882a593Smuzhiyun xv->deviceid = dev->id; /* id of this device */ 1099*4882a593Smuzhiyun xv->num_valuators = 0; /* no valuators being sent */ 1100*4882a593Smuzhiyun xv->device_state = 0; /* will be filled in by DIX */ 1101*4882a593Smuzhiyun</literallayout> 1102*4882a593Smuzhiyun</para> 1103*4882a593Smuzhiyun</sect2> 1104*4882a593Smuzhiyun<sect2 id="Device_Button_Events"> 1105*4882a593Smuzhiyun<title>Device Button Events</title> 1106*4882a593Smuzhiyun<para> 1107*4882a593Smuzhiyun<!-- .LP --> 1108*4882a593Smuzhiyun<function>DeviceButton</function> events contain all the information that is contained in 1109*4882a593Smuzhiyuna core button event, and also the same additional information that a 1110*4882a593Smuzhiyun<function>DeviceKey</function> event contains. 1111*4882a593Smuzhiyun</para> 1112*4882a593Smuzhiyun</sect2> 1113*4882a593Smuzhiyun<sect2 id="Device_Motion_Events"> 1114*4882a593Smuzhiyun<title>Device Motion Events</title> 1115*4882a593Smuzhiyun<para> 1116*4882a593Smuzhiyun<!-- .LP --> 1117*4882a593Smuzhiyun<function>DeviceMotion</function> events contain all the information that is contained in 1118*4882a593Smuzhiyuna core motion event, and also additional valuator information. At least 1119*4882a593Smuzhiyuntwo wire events are required to contain this information. 1120*4882a593SmuzhiyunThe following code fragment shows how the two wire events could be initialized: 1121*4882a593Smuzhiyun</para> 1122*4882a593Smuzhiyun<para> 1123*4882a593Smuzhiyun<!-- .LP --> 1124*4882a593Smuzhiyun<literallayout class="monospaced"> 1125*4882a593Smuzhiyun extern int DeviceMotionNotify; 1126*4882a593Smuzhiyun DeviceIntPtr dev; 1127*4882a593Smuzhiyun xEvent xE[2]; 1128*4882a593Smuzhiyun CARD8 id, num_valuators; 1129*4882a593Smuzhiyun INT16 x, y, pointerx, pointery; 1130*4882a593Smuzhiyun Time timestamp; 1131*4882a593Smuzhiyun deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *) xE; 1132*4882a593Smuzhiyun deviceValuator *xv; 1133*4882a593Smuzhiyun 1134*4882a593Smuzhiyun xev->type = DeviceMotionNotify; /* defined by input extension */ 1135*4882a593Smuzhiyun xev->detail = keycode; /* key pressed on this device */ 1136*4882a593Smuzhiyun xev->time = timestamp; /* same as for core events */ 1137*4882a593Smuzhiyun xev->rootX = pointerx; /* x location of core pointer */ 1138*4882a593Smuzhiyun xev->rootY = pointery; /* y location of core pointer */ 1139*4882a593Smuzhiyun 1140*4882a593Smuzhiyun /******************************************************************/ 1141*4882a593Smuzhiyun /* */ 1142*4882a593Smuzhiyun /* The following field does not exist for core input events. */ 1143*4882a593Smuzhiyun /* It contains the device id for the device that generated the */ 1144*4882a593Smuzhiyun /* event, and also indicates whether more than one 32-byte wire */ 1145*4882a593Smuzhiyun /* event is being sent. */ 1146*4882a593Smuzhiyun /* */ 1147*4882a593Smuzhiyun /******************************************************************/ 1148*4882a593Smuzhiyun 1149*4882a593Smuzhiyun xev->deviceid = dev->id | MORE_EVENTS; /* sending more than 1 */ 1150*4882a593Smuzhiyun 1151*4882a593Smuzhiyun /******************************************************************/ 1152*4882a593Smuzhiyun /* Fields in the second 32-byte wire event: */ 1153*4882a593Smuzhiyun /******************************************************************/ 1154*4882a593Smuzhiyun 1155*4882a593Smuzhiyun xv = (deviceValuator *) ++xev; 1156*4882a593Smuzhiyun xv->type = DeviceValuator; /* event type of second event */ 1157*4882a593Smuzhiyun xv->deviceid = dev->id; /* id of this device */ 1158*4882a593Smuzhiyun xv->num_valuators = 2; /* 2 valuators being sent */ 1159*4882a593Smuzhiyun xv->first_valuator = 0; /* first valuator being sent */ 1160*4882a593Smuzhiyun xv->device_state = 0; /* will be filled in by DIX */ 1161*4882a593Smuzhiyun xv->valuator0 = x; /* first axis of this device */ 1162*4882a593Smuzhiyun xv->valuator1 = y; /* second axis of this device */ 1163*4882a593Smuzhiyun</literallayout> 1164*4882a593Smuzhiyun</para> 1165*4882a593Smuzhiyun<para> 1166*4882a593Smuzhiyun<!-- .LP --> 1167*4882a593SmuzhiyunUp to six axes can be reported in the deviceValuator event. If the device 1168*4882a593Smuzhiyunis reporting more than 6 axes, additional pairs of DeviceMotionNotify and 1169*4882a593SmuzhiyunDeviceValuator events should be sent, with the first_valuator field 1170*4882a593Smuzhiyunset correctly. 1171*4882a593Smuzhiyun</para> 1172*4882a593Smuzhiyun</sect2> 1173*4882a593Smuzhiyun<sect2 id="Device_Proximity_Events"> 1174*4882a593Smuzhiyun<title>Device Proximity Events</title> 1175*4882a593Smuzhiyun<para> 1176*4882a593Smuzhiyun<!-- .LP --> 1177*4882a593SmuzhiyunSome input devices that report absolute positional information, such as 1178*4882a593Smuzhiyungraphics tablets and touchscreens, may report proximity events. 1179*4882a593Smuzhiyun<function>ProximityIn</function> 1180*4882a593Smuzhiyunevents are generated when a pointing device like a stylus, or in the case 1181*4882a593Smuzhiyunof a touchscreen, the user's finger, comes into close proximity with the 1182*4882a593Smuzhiyunsurface of the input device. <function>ProximityOut</function> events are generated when 1183*4882a593Smuzhiyunthe stylus or finger leaves the proximity of the input devices surface. 1184*4882a593Smuzhiyun</para> 1185*4882a593Smuzhiyun<para> 1186*4882a593Smuzhiyun<!-- .LP --> 1187*4882a593Smuzhiyun<function>Proximity</function> events contain almost the same information as button events. 1188*4882a593SmuzhiyunThe event type is <function>ProximityIn</function> or <function>ProximityOut</function>, and there is no 1189*4882a593Smuzhiyundetail information. 1190*4882a593Smuzhiyun<!-- .bp --> 1191*4882a593Smuzhiyun<!-- .\" .TC --> 1192*4882a593Smuzhiyun 1193*4882a593Smuzhiyun</para> 1194*4882a593Smuzhiyun</sect2> 1195*4882a593Smuzhiyun</sect1> 1196*4882a593Smuzhiyun</chapter> 1197*4882a593Smuzhiyun</book> 1198