1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3 "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"[
4 <!ENTITY % defs SYSTEM "/xserver/doc/xml/xserver.ent"> %defs;
7 <!-- lifted from troff+ms+XMan by doclifter -->
11 <title>X11 Input Extension Porting Document</title>
14 <firstname>George</firstname><surname>Sachs</surname>
15 <affiliation><orgname>Hewlett-Packard</orgname></affiliation>
18 <releaseinfo>X Server Version &xserver.version;</releaseinfo>
19 <copyright><year>1989</year><year>1990</year><year>1991</year>
20 <holder>Hewlett-Packard Company</holder>
27 Permission to use, copy, modify, and distribute this documentation for any purpose and without fee is
28 hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
29 Hewlett-Packard makes no representations about the suitability for any purpose of the information in this
30 document. It is provided "as is" without express or implied warranty. This document is only a draft stan-
31 dard of the X Consortium and is therefore subject to change.
36 <para role="multiLicensing">Copyright © 1989, 1990, 1991 X Consortium</para>
37 <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 <para>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</para>
40 <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>
42 <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>
44 <para>X Window System is a trademark of The Open Group.</para>
49 <chapter id="x11_input_extension_porting_document">
50 <title>X11 Input Extension Porting Document</title>
53 This document is intended to aid the process of integrating the
54 X11 Input Extension into an X server.
58 Most of the functionality provided by the input extension is
59 device- and implementation-independent, and should require no changes.
60 The functionality is implemented by
61 routines that typically reside in the server source tree directory
62 extensions/server/xinput.
63 This extension includes functions to enable and disable input extension devices,
64 select input, grab and focus those devices, query and change key
65 and button mappings, and others. The only input extension requirements
66 for the device-dependent part of X are that the input devices be
67 correctly initialized and input events from those devices be correctly
68 generated. Device-dependent X is responsible for reading input data from
69 the input device hardware and if necessary, reformatting it into X events.
73 The process of initializing input extension devices is similar to that used
74 for the core devices, and is described in the following sections. When
75 multiple input devices are attached to X server, the choice of which devices
76 to initially use as the core X pointer and keyboard is left
77 implementation-dependent. It is also up to each implementation to decide
78 whether all input devices will be opened by the server during its
79 initialization and kept open for the life of the server. The alternative is
80 to open only the X keyboard and X pointer during server initialization, and
81 open other input devices only when requested by a client to do so. Either
82 type of implementation is supported by the input extension.
86 Input extension events generated by the X server use the same 32-byte xEvent
87 wire event as do core input events. However, additional information must be
88 sent for input extension devices, requiring that multiple xEvents be generated
89 each time data is received from an input extension device. These xEvents are
90 combined into a single client XEvent by the input extension library. A later
91 section of this document describes the format and generation of input extension
94 <sect1 id="Initializing_Extension_Devices">
95 <title>Initializing Extension Devices</title>
98 Extension input devices are initialized in the same manner as the core
99 X input devices. Device-Independent X provides functions that can be
100 called from DDX to initialize these devices. Which functions are called
101 and when will vary by implementation, and will depend on whether the
102 implementation opens all the input devices available to X when X is initialized,
103 or waits until a client requests that a device be opened.
104 In the simplest case, DDX will open all input devices as part of its
105 initialization, when the InitInput routine is called.
107 <sect2 id="Summary_of_Calling_Sequence">
108 <title>Summary of Calling Sequence</title>
111 <literallayout class="monospaced">
112 Device-Independent X | Device-Dependent X
113 -------------------- | -------------------
115 InitInput --------------> | - do device-specific initialization
117 | - call AddInputDevice (deviceProc,AutoStart)
119 - creates DeviceIntRec |
120 - records deviceProc |
121 - adds new device to |
122 list of off_devices. |
123 sets dev->startup=AutoStart|
125 | - RegisterPointerDevice (X pointer)
126 | - processInputProc = ProcessPointerEvents
127 | - RegisterKeyboardDevice (X keyboard)
128 | - processInputProc = ProcessKeyboardEvents
129 | - RegisterOtherDevice (extension device)
130 | - processInputProc = ProcessOtherEvents
133 InitAndStartDevices -----> | - calls deviceProc with parameters
134 | (DEVICE_INIT, AutoStart)
135 sets dev->inited = return |
136 value from deviceProc |
138 | - in deviceProc, do one of:
139 | - call InitPointerDeviceStruct (X pointer)
140 | - call InitKeyboardDeviceStruct (X keybd)
141 | - init extension device by calling some of:
142 | - InitKeyClassDeviceStruct
143 | - InitButtonClassDeviceStruct
144 | - InitValuatorClassDeviceStruct
145 | - InitValuatorAxisStruct
146 | - InitFocusClassDeviceStruct
147 | - InitProximityClassDeviceStruct
148 | - InitKbdFeedbackClassDeviceStruct
149 | - InitPtrFeedbackClassDeviceStruct
150 | - InitLedFeedbackClassDeviceStruct
151 | - InitStringFeedbackClassDeviceStruct
152 | - InitIntegerFeedbackClassDeviceStruct
153 | - InitBellFeedbackClassDeviceStruct
154 | - init device name and type by:
155 | - calling MakeAtom with one of the
157 | - calling AssignTypeAndName
160 for each device added |
162 InitAndStartDevices |
163 calls EnableDevice if | - EnableDevice calls deviceProc with
164 dev->startup & | (DEVICE_ON, AutoStart)
167 If deviceProc returns | - core devices are now enabled, extension
168 Success, EnableDevice | devices are now available to be accessed
169 move the device from | through the input extension protocol
170 inputInfo.off_devices | requests.
171 to inputInfo.devices |
175 <sect2 id="Initialization_Called_From_InitInput">
176 <title>Initialization Called From InitInput</title>
179 InitInput is the first DDX input entry point called during X server startup.
180 This routine is responsible for
181 device- and implementation- specific initialization, and for calling
182 AddInputDevice to create and initialize the DeviceIntRec structure for each
183 input device. AddInputDevice is passed the address of a procedure to be called
184 by the DIX routine InitAndStartDevices when input devices are enabled.
185 This procedure is expected to perform X initialization for the input device.
189 If the device is to be used as the X pointer, DDX should then call
190 RegisterPointerDevice, passing the DeviceIntRec pointer,
191 to initialize the device as the X pointer.
195 If the device is to be used as the X keyboard, DDX should instead call
196 RegisterKeyboardDevice to initialize the device as the X keyboard.
200 If the device is to be used as an extension device, DDX should instead
201 call RegisterOtherDevice, passing the DeviceIntPtr returned by
206 A sample InitInput implementation is shown below.
210 <literallayout class="monospaced">
215 LocalDevice localdevs[LOCAL_MAX_DEVS];
216 DeviceProc kbdproc, ptrproc, extproc;
218 /**************************************************************
219 * Open the appropriate input devices, determine which are
220 * available, and choose an X pointer and X keyboard device
221 * in some implementation-dependent manner.
222 ***************************************************************/
224 open_input_devices (&numdevs, localdevs);
226 /**************************************************************
227 * Register the input devices with DIX.
228 ***************************************************************/
230 for (i=0; i<numdevs; i++)
232 if (localdevs[i].use == IsXKeyboard)
234 dev = AddInputDevice (kbdproc, TRUE);
235 RegisterKeyboardDevice (dev);
237 else if (localdevs[i].use == IsXPointer)
239 dev = AddInputDevice (ptrproc, TRUE);
240 RegisterPointerDevice (dev);
244 dev = AddInputDevice (extproc, FALSE);
245 RegisterOtherDevice (dev);
248 FatalError ("Too many input devices.");
249 dev->devicePrivate = (pointer) &localdevs[i];
254 <sect2 id="Initialization_Called_From_InitAndStartDevices">
255 <title>Initialization Called From InitAndStartDevices</title>
258 After InitInput has returned,
259 InitAndStartDevices is the DIX routine that is called to enable input devices.
260 It calls the device control routine that was passed to AddInputDevice,
261 with a mode value of DEVICE_INIT. The action taken by the device control
262 routine depends on how the device is to be used. If the device is to be
263 the X pointer, the device control routine should call
264 InitPointerDeviceStruct to initialize it. If the device is to be the
265 X keyboard, the device control routine should call
266 InitKeyboardDeviceStruct. Since input extension devices may support various
267 combinations of keys, buttons, valuators, and feedbacks,
268 each class of input that it supports must be initialized.
269 Entry points are defined by DIX to initialize each of the supported classes of
270 input, and are described in the following sections.
274 A sample device control routine called from InitAndStartDevices is
279 <literallayout class="monospaced">
280 Bool extproc (dev, mode)
284 LocalDevice *localdev = (LocalDevice *) dev->devicePrivate;
289 if (strcmp(localdev->name, XI_TABLET) == 0)
291 /****************************************************
292 * This device reports proximity, has buttons,
293 * reports two axes of motion, and can be focused.
294 * It also supports the same feedbacks as the X pointer
295 * (acceleration and threshold can be set).
296 ****************************************************/
298 InitButtonClassDeviceStruct (dev, button_count, button_map);
299 InitValuatorClassDeviceStruct (dev, localdev->n_axes,);
300 motionproc, MOTION_BUF_SIZE, Absolute);
301 for (i=0; i<localdev->n_axes; i++)
302 InitValuatorAxisStruct (dev, i, min_val, max_val,
304 InitFocusClassDeviceStruct (dev);
305 InitProximityClassDeviceStruct (dev);
306 InitPtrFeedbackClassDeviceStruct (dev, p_controlproc);
308 else if (strcmp(localdev->name, XI_BUTTONBOX) == 0)
310 /****************************************************
311 * This device has keys and LEDs, and can be focused.
312 ****************************************************/
314 InitKeyClassDeviceStruct (dev, syms, modmap);
315 InitFocusClassDeviceStruct (dev);
316 InitLedFeedbackClassDeviceStruct (dev, ledcontrol);
318 else if (strcmp(localdev->name, XI_KNOBBOX) == 0)
320 /****************************************************
321 * This device reports motion.
323 ****************************************************/
325 InitValuatorClassDeviceStruct (dev, localdev->n_axes,);
326 motionproc, MOTION_BUF_SIZE, Absolute);
327 for (i=0; i<localdev->n_axes; i++)
328 InitValuatorAxisStruct (dev, i, min_val, max_val,
330 InitFocusClassDeviceStruct (dev);
333 MakeAtom(localdev->name, strlen(localdev->name), FALSE);
334 AssignTypeAndName (dev, localdev->atom, localdev->name);
337 AddEnabledDevice (localdev->file_ds);
342 RemoveEnabledDevice (localdev->file_ds);
352 The device control routine is called with a mode value of DEVICE_ON
353 by the DIX routine EnableDevice, which is called from InitAndStartDevices.
354 When called with this mode, it should call AddEnabledDevice to cause the
355 server to begin checking for available input from this device.
359 From InitAndStartDevices, EnableDevice is called for all devices that have
360 the "inited" and "startup" fields in the DeviceIntRec set to TRUE. The
361 "inited" field is set by InitAndStartDevices to the value returned by
362 the deviceproc when called with a mode value of DEVICE_INIT. The "startup"
363 field is set by AddInputDevice to value of the second parameter (autoStart).
367 When the server is first initialized, it should only be checking for input
368 from the core X keyboard and pointer. One way to accomplish this is to
369 call AddInputDevice for the core X keyboard and pointer with an
370 autoStart value equal to TRUE, while calling AddInputDevice for
371 input extension devices with an autoStart value equal to FALSE. If this is
372 done, EnableDevice will skip all input extension devices during server
373 initialization. In this case,
374 the OpenInputDevice routine should set the "startup" field to TRUE
375 when called for input extension devices. This will cause ProcXOpenInputDevice
376 to call EnableDevice for those devices when a client first does an
380 <sect2 id="DIX_Input_Class_Initialization_Routines">
381 <title>DIX Input Class Initialization Routines</title>
384 DIX routines are defined to initialize each of the defined input classes.
385 The defined classes are:
392 KeyClass - the device has keys.
397 ButtonClass - the device has buttons.
402 ValuatorClass - the device reports motion data or positional data.
407 Proximitylass - the device reports proximity information.
412 FocusClass - the device can be focused.
417 FeedbackClass - the device supports some kind of feedback.
425 DIX routines are provided to initialize the X pointer and keyboard, as in
426 previous releases of X. During X initialization, InitPointerDeviceStruct
427 is called to initialize the X pointer, and InitKeyboardDeviceStruct is
428 called to initialize the X keyboard. There is no
429 corresponding routine for extension input devices, since they do not all
430 support the same classes of input. Instead, DDX is responsible for the
431 initialization of the input classes supported by extension devices.
432 A description of the routines provided by DIX to perform that initialization
435 <sect3 id="InitKeyClassDeviceStruct">
436 <title>InitKeyClassDeviceStruct</title>
439 This function is provided to allocate and initialize a KeyClassRec, and
440 should be called for extension devices that have keys. It is passed a pointer
441 to the device, and pointers to arrays of keysyms and modifiers reported by
442 the device. It returns FALSE if the KeyClassRec could not be allocated,
443 or if the maps for the keysyms and modifiers could not be allocated.
448 <literallayout class="monospaced">
450 InitKeyClassDeviceStruct(dev, pKeySyms, pModifiers)
458 The DIX entry point InitKeyboardDeviceStruct calls this routine for the
459 core X keyboard. It must be called explicitly for extension devices
463 <sect3 id="InitButtonClassDeviceStruct">
464 <title>InitButtonClassDeviceStruct</title>
467 This function is provided to allocate and initialize a ButtonClassRec, and
468 should be called for extension devices that have buttons. It is passed a
469 pointer to the device, the number of buttons supported, and a map of the
470 reported button codes. It returns FALSE if the ButtonClassRec could not be
471 allocated. Its parameters are:
475 <literallayout class="monospaced">
477 InitButtonClassDeviceStruct(dev, numButtons, map)
478 register DeviceIntPtr dev;
485 The DIX entry point InitPointerDeviceStruct calls this routine for the
486 core X pointer. It must be called explicitly for extension devices that
490 <sect3 id="InitValuatorClassDeviceStruct">
491 <title>InitValuatorClassDeviceStruct</title>
494 This function is provided to allocate and initialize a ValuatorClassRec, and
495 should be called for extension devices that have valuators. It is passed the
496 number of axes of motion reported by the device, the address of the motion
497 history procedure for the device, the size of the motion history buffer,
498 and the mode (Absolute or Relative) of the device. It returns FALSE if
499 the ValuatorClassRec could not be allocated. Its parameters are:
503 <literallayout class="monospaced">
505 InitValuatorClassDeviceStruct(dev, numAxes, motionProc, numMotionEvents, mode)
515 The DIX entry point InitPointerDeviceStruct calls this routine for the
516 core X pointer. It must be called explicitly for extension devices that
520 <sect3 id="InitValuatorAxisStruct">
521 <title>InitValuatorAxisStruct</title>
524 This function is provided to initialize an XAxisInfoRec, and
525 should be called for core and extension devices that have valuators.
526 The space for the XAxisInfoRec is allocated by
527 the InitValuatorClassDeviceStruct function, but is not initialized.
531 InitValuatorAxisStruct should be called once for each axis of motion
532 reported by the device. Each
533 invocation should be passed the axis number (starting with 0), the
534 minimum value for that axis, the maximum value for that axis, and the
535 resolution of the device in counts per meter. If the device reports
536 relative motion, 0 should be reported as the minimum and maximum values.
537 InitValuatorAxisStruct has the following parameters:
538 <literallayout class="monospaced">
539 InitValuatorAxisStruct(dev, axnum, minval, maxval, resolution)
549 This routine is not called by InitPointerDeviceStruct for the
550 core X pointer. It must be called explicitly for core and extension devices
554 <sect3 id="InitFocusClassDeviceStruct">
555 <title>InitFocusClassDeviceStruct</title>
558 This function is provided to allocate and initialize a FocusClassRec, and
559 should be called for extension devices that can be focused. It is passed a
560 pointer to the device, and returns FALSE if the allocation fails.
561 It has the following parameter:
562 <literallayout class="monospaced">
564 InitFocusClassDeviceStruct(dev)
570 The DIX entry point InitKeyboardDeviceStruct calls this routine for the
571 core X keyboard. It must be called explicitly for extension devices
572 that can be focused. Whether or not a particular device can be focused
573 is left implementation-dependent.
576 <sect3 id="InitProximityClassDeviceStruct">
577 <title>InitProximityClassDeviceStruct</title>
580 This function is provided to allocate and initialize a ProximityClassRec, and
581 should be called for extension absolute pointing devices that report proximity.
582 It is passed a pointer to the device, and returns FALSE if the allocation fails.
583 It has the following parameter:
584 <literallayout class="monospaced">
586 InitProximityClassDeviceStruct(dev)
591 <sect3 id="Initializing_Feedbacks">
592 <title>Initializing Feedbacks</title>
596 <sect4 id="InitKbdFeedbackClassDeviceStruct">
597 <title>InitKbdFeedbackClassDeviceStruct</title>
600 This function is provided to allocate and initialize a KbdFeedbackClassRec, and
601 may be called for extension devices that support some or all of the
602 feedbacks that the core keyboard supports. It is passed a
603 pointer to the device, a pointer to the procedure that sounds the bell,
604 and a pointer to the device control procedure.
605 It returns FALSE if the allocation fails, and has the following parameters:
606 <literallayout class="monospaced">
608 InitKbdFeedbackClassDeviceStruct(dev, bellProc, controlProc)
611 void (*controlProc)();
613 The DIX entry point InitKeyboardDeviceStruct calls this routine for the
614 core X keyboard. It must be called explicitly for extension devices
615 that have the same feedbacks as a keyboard. Some feedbacks, such as LEDs and
616 bell, can be supported either with a KbdFeedbackClass or with BellFeedbackClass
617 and LedFeedbackClass feedbacks.
620 <sect4 id="InitPtrFeedbackClassDeviceStruct">
621 <title>InitPtrFeedbackClassDeviceStruct</title>
624 This function is provided to allocate and initialize a PtrFeedbackClassRec, and
625 should be called for extension devices that allow the setting of acceleration
626 and threshold. It is passed a pointer to the device,
627 and a pointer to the device control procedure.
628 It returns FALSE if the allocation fails, and has the following parameters:
629 <literallayout class="monospaced">
631 InitPtrFeedbackClassDeviceStruct(dev, controlProc)
633 void (*controlProc)();
638 The DIX entry point InitPointerDeviceStruct calls this routine for the
639 core X pointer. It must be called explicitly for extension devices
640 that support the setting of acceleration and threshold.
643 <sect4 id="InitLedFeedbackClassDeviceStruct">
644 <title>InitLedFeedbackClassDeviceStruct</title>
647 This function is provided to allocate and initialize a LedFeedbackClassRec, and
648 should be called for extension devices that have LEDs.
649 It is passed a pointer to the device,
650 and a pointer to the device control procedure.
651 It returns FALSE if the allocation fails, and has the following parameters:
652 <literallayout class="monospaced">
654 InitLedFeedbackClassDeviceStruct(dev, controlProc)
656 void (*controlProc)();
661 Up to 32 LEDs per feedback can be supported, and a device may have
662 multiple feedbacks of the same type.
665 <sect4 id="InitBellFeedbackClassDeviceStruct">
666 <title>InitBellFeedbackClassDeviceStruct</title>
669 This function is provided to allocate and initialize a BellFeedbackClassRec,
670 and should be called for extension devices that have a bell.
671 It is passed a pointer to the device,
672 and a pointer to the device control procedure.
673 It returns FALSE if the allocation fails, and has the following parameters:
674 <literallayout class="monospaced">
676 InitBellFeedbackClassDeviceStruct(dev, bellProc, controlProc)
679 void (*controlProc)();
683 <sect4 id="InitStringFeedbackClassDeviceStruct">
684 <title>InitStringFeedbackClassDeviceStruct</title>
687 This function is provided to allocate and initialize a StringFeedbackClassRec,
688 and should be called for extension devices that have a display upon which a
689 string can be displayed.
690 It is passed a pointer to the device,
691 and a pointer to the device control procedure.
692 It returns FALSE if the allocation fails, and has the following parameters:
693 <literallayout class="monospaced">
695 InitStringFeedbackClassDeviceStruct(dev, controlProc, max_symbols,
696 num_symbols_supported, symbols)
698 void (*controlProc)();
700 int num_symbols_supported;
705 <sect4 id="InitIntegerFeedbackClassDeviceStruct">
706 <title>InitIntegerFeedbackClassDeviceStruct</title>
709 This function is provided to allocate and initialize an
710 IntegerFeedbackClassRec,
711 and should be called for extension devices that have a display upon which an
712 integer can be displayed.
713 It is passed a pointer to the device,
714 and a pointer to the device control procedure.
715 It returns FALSE if the allocation fails, and has the following parameters:
716 <literallayout class="monospaced">
718 InitIntegerFeedbackClassDeviceStruct(dev, controlProc)
720 void (*controlProc)();
726 <sect2 id="Initializing_The_Device_Name_And_Type">
727 <title>Initializing The Device Name And Type</title>
730 The device name and type can be initialized by calling AssignTypeAndName
731 with the following parameters:
732 <literallayout class="monospaced">
734 AssignTypeAndName(dev, type, name)
742 This will allocate space for the device name and copy the name that was passed.
743 The device type can be obtained by calling MakeAtom with one of the names
744 defined for input devices. MakeAtom has the following parameters:
745 <literallayout class="monospaced">
747 MakeAtom(name, len, makeit)
755 Since the atom was already made when the input extension was initialized, the
756 value of makeit should be FALSE;
760 <sect1 id="Closing_Extension_Devices">
761 <title>Closing Extension Devices</title>
764 The DisableDevice entry point is provided by DIX to disable input devices.
765 It calls the device control routine for the specified
766 device with a mode value of DEVICE_OFF. The device control routine should
767 call RemoveEnabledDevice to stop the server from checking for input from
772 DisableDevice is not called by any input extension routines. It can be
773 called from the CloseInputDevice routine, which is called by
774 ProcXCloseDevice when a client makes an XCloseDevice request. If
775 DisableDevice is called, it should only be called when the last client
776 using the extension device has terminated or called XCloseDevice.
779 <sect1 id="Implementation_Dependent_Routines">
780 <title>Implementation-Dependent Routines</title>
783 Several input extension protocol requests have
784 implementation-dependent entry points. Default routines
785 are defined for these entry points and contained in the source
786 file extensions/server/xinput/xstubs.c. Some implementations may
787 be able to use the default routines without change.
788 The following sections describe each of these routines.
790 <sect2 id="AddOtherInputDevices">
791 <title>AddOtherInputDevices</title>
794 AddOtherInputDevice is called from ProcXListInputDevices as a result of
795 an XListInputDevices protocol request. It may be needed by
796 implementations that do not open extension input devices until requested
797 to do so by some client. These implementations may not initialize
798 all devices when the X server starts up, because some of those devices
799 may be in use. Since the XListInputDevices
800 function only lists those devices that have been initialized,
801 AddOtherInputDevices is called to give DDX a chance to
802 initialize any previously unavailable input devices.
806 A sample AddOtherInputDevices routine might look like the following:
807 <literallayout class="monospaced">
809 AddOtherInputDevices ()
814 for (i=0; i<MAX_DEVICES; i++)
816 if (!local_dev[i].initialized && available(local_dev[i]))
818 dev = (DeviceIntPtr) AddInputDevice (local_dev[i].deviceProc, TRUE);
819 dev->public.devicePrivate = local_dev[i];
820 RegisterOtherDevice (dev);
821 dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
829 The default AddOtherInputDevices routine in xstubs.c does nothing.
830 If all input extension devices are initialized when the server
831 starts up, it can be left as a null routine.
834 <sect2 id="OpenInputDevice">
835 <title>OpenInputDevice</title>
838 Some X server implementations open all input devices when the server
839 is initialized and never close them. Other implementations may open only
840 the X pointer and keyboard devices during server initialization,
841 and open other input devices only when some client makes an
842 XOpenDevice request. This entry point is for the latter type of
847 If the physical device is not already open, it can be done in this routine.
848 In this case, the server must keep track of the fact that one or more clients
849 have the device open, and physically close it when the last client that has
850 it open makes an XCloseDevice request.
854 The default implementation is to do nothing (assume all input devices
855 are opened during X server initialization and kept open).
858 <sect2 id="CloseInputDevice">
859 <title>CloseInputDevice</title>
862 Some implementations may close an input device when the last client
863 using that device requests that it be closed, or terminates.
864 CloseInputDevice is called from ProcXCloseDevice when a client
865 makes an XCloseDevice protocol request.
869 The default implementation is to do nothing (assume all input devices
870 are opened during X server initialization and kept open).
873 <sect2 id="SetDeviceMode">
874 <title>SetDeviceMode</title>
877 Some implementations support input devices that can report
878 either absolute positional data or relative motion. The XSetDeviceMode
879 protocol request is provided to allow DDX to change the current mode of
884 The default implementation is to always return a BadMatch error. If the
885 implementation does not support any input devices that are capable of
886 reporting both relative motion and absolute position information, the
887 default implementation may be left unchanged.
890 <sect2 id="SetDeviceValuators">
891 <title>SetDeviceValuators</title>
894 Some implementations support input devices that allow their valuators to be
895 set to an initial value. The XSetDeviceValuators
896 protocol request is provided to allow DDX to set the valuators of
901 The default implementation is to always return a BadMatch error. If the
902 implementation does not support any input devices that allow their
903 valuators to be set, the default implementation may be left unchanged.
906 <sect2 id="ChangePointerDevice">
907 <title>ChangePointerDevice</title>
910 The XChangePointerDevice protocol request is provided to change which device is
911 used as the X pointer. Some implementations may maintain information
912 specific to the X pointer in the private data structure pointed to by
913 the DeviceIntRec. ChangePointerDevice is called to allow such
914 implementations to move that information to the new pointer device.
915 The current location of the X cursor is an example of the type of
916 information that might be affected.
920 The DeviceIntRec structure that describes the X pointer device does not
921 contain a FocusRec. If the device that has been made into the new X pointer
922 was previously a device that could be focused, ProcXChangePointerDevice will
923 free the FocusRec associated with that device.
927 If the server implementation desires to allow clients to focus the old pointer
928 device (which is now accessible through the input extension), it should call
929 InitFocusClassDeviceStruct for the old pointer device.
933 The XChangePointerDevice protocol request also allows the client
934 to choose which axes of the new pointer device are used to move
935 the X cursor in the X- and Y- directions. If the axes are different
936 than the default ones, the server implementation should record that fact.
940 If the server implementation supports input devices with valuators that
941 are not allowed to be used as the X pointer, they should be screened out
942 by this routine and a BadDevice error returned.
946 The default implementation is to do nothing.
949 <sect2 id="ChangeKeyboardDevice">
950 <title>ChangeKeyboardDevice</title>
953 The XChangeKeyboardDevice protocol request is provided to change which device is
954 used as the X keyboard. Some implementations may maintain information
955 specific to the X keyboard in the private data structure pointed to by
956 the DeviceIntRec. ChangeKeyboardDevice is called to allow such
957 implementations to move that information to the new keyboard device.
961 The X keyboard device can be focused, and the DeviceIntRec that describes
962 that device has a FocusRec. If the device that has been made into the new X
963 keyboard did not previously have a FocusRec,
964 ProcXChangeKeyboardDevice will allocate one for it.
968 If the implementation does not want clients to be able to focus the old X
969 keyboard (which has now become available as an input extension device)
970 it should call DeleteFocusClassDeviceStruct to free the FocusRec.
974 If the implementation supports input devices with keys that are not allowed
975 to be used as the X keyboard, they should be checked for here, and a
976 BadDevice error returned.
980 The default implementation is to do nothing.
984 <sect1 id="Input_Extension_Events">
985 <title>Input Extension Events</title>
988 Events accessed through the input extension are analogous to the core input
989 events, but have different event types. They are of types
990 <function>DeviceKeyPress</function>, <function>DeviceKeyRelease</function>, <function>DeviceButtonPress</function>,
991 <function>DeviceButtonRelease</function>, <function>DeviceDeviceMotionNotify</function>,
992 <function>DeviceProximityIn</function>, <function>DeviceProximityOut</function>, and <function>DeviceValuator</function>.
993 These event types are not constants. Instead, they are external integers
994 defined by the input extension. Their actual values will depend on which
995 extensions are supported by a server, and the order in which they are
1000 The data structures that describe these
1001 events are defined in the file <function>extensions/include/XIproto.h</function>. Other
1002 input extension constants needed by DDX are defined in the file
1003 <function>extensions/include/XI.h</function>.
1007 Some events defined by the input extension contain more information than can
1008 be contained in the 32-byte xEvent data structure. To send this information
1009 to clients, DDX must generate two or more 32-byte wire events. The following
1010 sections describe the contents of these events.
1012 <sect2 id="Device_Key_Events">
1013 <title>Device Key Events</title>
1016 <function>DeviceKeyPresss</function> events contain all the information that is contained in
1017 a core <function>KeyPress</function> event, and also the following additional information:
1027 deviceid - the identifier of the device that generated the event.
1032 device_state - the state of any modifiers on the device that generated the event.
1037 num_valuators - the number of valuators reported in this event.
1042 first_valuator - the first valuator reported in this event.
1047 valuator0 through valuator5 - the values of the valuators.
1055 In order to pass this information to the input extension library, two 32-byte
1056 wire events must be generated by DDX. The first has an event type of
1057 <function>DeviceKeyPress</function>, and the second has an event type of <function>DeviceValuator</function>.
1061 The following code fragment shows how the two wire events could be initialized:
1065 <literallayout class="monospaced">
1066 extern int DeviceKeyPress;
1069 CARD8 id, num_valuators;
1070 INT16 x, y, pointerx, pointery;
1072 deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *) xE;
1075 xev->type = DeviceKeyPress; /* defined by input extension */
1076 xev->detail = keycode; /* key pressed on this device */
1077 xev->time = timestamp; /* same as for core events */
1078 xev->rootX = pointerx; /* x location of core pointer */
1079 xev->rootY = pointery; /* y location of core pointer */
1081 /******************************************************************/
1083 /* The following field does not exist for core input events. */
1084 /* It contains the device id for the device that generated the */
1085 /* event, and also indicates whether more than one 32-byte wire */
1086 /* event is being sent. */
1088 /******************************************************************/
1090 xev->deviceid = dev->id | MORE_EVENTS; /* sending more than 1 */
1092 /******************************************************************/
1093 /* Fields in the second 32-byte wire event: */
1094 /******************************************************************/
1096 xv = (deviceValuator *) ++xev;
1097 xv->type = DeviceValuator; /* event type of second event */
1098 xv->deviceid = dev->id; /* id of this device */
1099 xv->num_valuators = 0; /* no valuators being sent */
1100 xv->device_state = 0; /* will be filled in by DIX */
1104 <sect2 id="Device_Button_Events">
1105 <title>Device Button Events</title>
1108 <function>DeviceButton</function> events contain all the information that is contained in
1109 a core button event, and also the same additional information that a
1110 <function>DeviceKey</function> event contains.
1113 <sect2 id="Device_Motion_Events">
1114 <title>Device Motion Events</title>
1117 <function>DeviceMotion</function> events contain all the information that is contained in
1118 a core motion event, and also additional valuator information. At least
1119 two wire events are required to contain this information.
1120 The following code fragment shows how the two wire events could be initialized:
1124 <literallayout class="monospaced">
1125 extern int DeviceMotionNotify;
1128 CARD8 id, num_valuators;
1129 INT16 x, y, pointerx, pointery;
1131 deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *) xE;
1134 xev->type = DeviceMotionNotify; /* defined by input extension */
1135 xev->detail = keycode; /* key pressed on this device */
1136 xev->time = timestamp; /* same as for core events */
1137 xev->rootX = pointerx; /* x location of core pointer */
1138 xev->rootY = pointery; /* y location of core pointer */
1140 /******************************************************************/
1142 /* The following field does not exist for core input events. */
1143 /* It contains the device id for the device that generated the */
1144 /* event, and also indicates whether more than one 32-byte wire */
1145 /* event is being sent. */
1147 /******************************************************************/
1149 xev->deviceid = dev->id | MORE_EVENTS; /* sending more than 1 */
1151 /******************************************************************/
1152 /* Fields in the second 32-byte wire event: */
1153 /******************************************************************/
1155 xv = (deviceValuator *) ++xev;
1156 xv->type = DeviceValuator; /* event type of second event */
1157 xv->deviceid = dev->id; /* id of this device */
1158 xv->num_valuators = 2; /* 2 valuators being sent */
1159 xv->first_valuator = 0; /* first valuator being sent */
1160 xv->device_state = 0; /* will be filled in by DIX */
1161 xv->valuator0 = x; /* first axis of this device */
1162 xv->valuator1 = y; /* second axis of this device */
1167 Up to six axes can be reported in the deviceValuator event. If the device
1168 is reporting more than 6 axes, additional pairs of DeviceMotionNotify and
1169 DeviceValuator events should be sent, with the first_valuator field
1173 <sect2 id="Device_Proximity_Events">
1174 <title>Device Proximity Events</title>
1177 Some input devices that report absolute positional information, such as
1178 graphics tablets and touchscreens, may report proximity events.
1179 <function>ProximityIn</function>
1180 events are generated when a pointing device like a stylus, or in the case
1181 of a touchscreen, the user's finger, comes into close proximity with the
1182 surface of the input device. <function>ProximityOut</function> events are generated when
1183 the stylus or finger leaves the proximity of the input devices surface.
1187 <function>Proximity</function> events contain almost the same information as button events.
1188 The event type is <function>ProximityIn</function> or <function>ProximityOut</function>, and there is no