diff --git a/doc/Xinput.xml b/doc/Xinput.xml index 0e7fbda722..1f7f3034b7 100644 --- a/doc/Xinput.xml +++ b/doc/Xinput.xml @@ -50,32 +50,32 @@ dard of the X Consortium and is therefore subject to change. X11 Input Extension Porting Document -This document is intended to aid the process of integrating the +This document is intended to aid the process of integrating the X11 Input Extension into an X server. -Most of the functionality provided by the input extension is -device- and implementation-independent, and should require no changes. +Most of the functionality provided by the input extension is +device- and implementation-independent, and should require no changes. The functionality is implemented by -routines that typically reside in the server source tree directory +routines that typically reside in the server source tree directory extensions/server/xinput. This extension includes functions to enable and disable input extension devices, select input, grab and focus those devices, query and change key -and button mappings, and others. The only input extension requirements -for the device-dependent part of X are that the input devices be +and button mappings, and others. The only input extension requirements +for the device-dependent part of X are that the input devices be correctly initialized and input events from those devices be correctly -generated. Device-dependent X is responsible for reading input data from +generated. Device-dependent X is responsible for reading input data from the input device hardware and if necessary, reformatting it into X events. -The process of initializing input extension devices is similar to that used +The process of initializing input extension devices is similar to that used for the core devices, and is described in the following sections. When multiple input devices are attached to X server, the choice of which devices -to initially use as the core X pointer and keyboard is left +to initially use as the core X pointer and keyboard is left implementation-dependent. It is also up to each implementation to decide -whether all input devices will be opened by the server during its +whether all input devices will be opened by the server during its initialization and kept open for the life of the server. The alternative is to open only the X keyboard and X pointer during server initialization, and open other input devices only when requested by a client to do so. Either @@ -95,10 +95,10 @@ events. Initializing Extension Devices -Extension input devices are initialized in the same manner as the core -X input devices. Device-Independent X provides functions that can be +Extension input devices are initialized in the same manner as the core +X input devices. Device-Independent X provides functions that can be called from DDX to initialize these devices. Which functions are called -and when will vary by implementation, and will depend on whether the +and when will vary by implementation, and will depend on whether the implementation opens all the input devices available to X when X is initialized, or waits until a client requests that a device be opened. In the simplest case, DDX will open all input devices as part of its @@ -109,66 +109,66 @@ initialization, when the InitInput routine is called. -Device-Independent X | Device-Dependent X --------------------- | ------------------- - | -InitInput --------------> | - do device-specific initialization - | - | - call AddInputDevice (deviceProc,AutoStart) -AddInputDevice | - - creates DeviceIntRec | - - records deviceProc | - - adds new device to | - list of off_devices. | -sets dev->startup=AutoStart| - | - call one of: - | - RegisterPointerDevice (X pointer) - | - processInputProc = ProcessPointerEvents - | - RegisterKeyboardDevice (X keyboard) - | - processInputProc = ProcessKeyboardEvents - | - RegisterOtherDevice (extension device) - | - processInputProc = ProcessOtherEvents - | - | -InitAndStartDevices -----> | - calls deviceProc with parameters - | (DEVICE_INIT, AutoStart) -sets dev->inited = return | - value from deviceProc | - | - | - in deviceProc, do one of: - | - call InitPointerDeviceStruct (X pointer) - | - call InitKeyboardDeviceStruct (X keybd) - | - init extension device by calling some of: - | - InitKeyClassDeviceStruct - | - InitButtonClassDeviceStruct - | - InitValuatorClassDeviceStruct - | - InitValuatorAxisStruct - | - InitFocusClassDeviceStruct - | - InitProximityClassDeviceStruct - | - InitKbdFeedbackClassDeviceStruct - | - InitPtrFeedbackClassDeviceStruct - | - InitLedFeedbackClassDeviceStruct - | - InitStringFeedbackClassDeviceStruct - | - InitIntegerFeedbackClassDeviceStruct - | - InitBellFeedbackClassDeviceStruct - | - init device name and type by: - | - calling MakeAtom with one of the - | predefined names - | - calling AssignTypeAndName - | - | -for each device added | - by AddInputDevice, | - InitAndStartDevices | - calls EnableDevice if | - EnableDevice calls deviceProc with - dev->startup & | (DEVICE_ON, AutoStart) - dev->inited | - | -If deviceProc returns | - core devices are now enabled, extension - Success, EnableDevice | devices are now available to be accessed - move the device from | through the input extension protocol - inputInfo.off_devices | requests. - to inputInfo.devices | +Device-Independent X | Device-Dependent X +-------------------- | ------------------- + | +InitInput --------------> | - do device-specific initialization + | + | - call AddInputDevice (deviceProc,AutoStart) +AddInputDevice | + - creates DeviceIntRec | + - records deviceProc | + - adds new device to | + list of off_devices. | +sets dev->startup=AutoStart | + | - call one of: + | - RegisterPointerDevice (X pointer) + | - processInputProc = ProcessPointerEvents + | - RegisterKeyboardDevice (X keyboard) + | - processInputProc = ProcessKeyboardEvents + | - RegisterOtherDevice (extension device) + | - processInputProc = ProcessOtherEvents + | + | +InitAndStartDevices -----> | - calls deviceProc with parameters + | (DEVICE_INIT, AutoStart) +sets dev->inited = return | + value from deviceProc | + | + | - in deviceProc, do one of: + | - call InitPointerDeviceStruct (X pointer) + | - call InitKeyboardDeviceStruct (X keybd) + | - init extension device by calling some of: + | - InitKeyClassDeviceStruct + | - InitButtonClassDeviceStruct + | - InitValuatorClassDeviceStruct + | - InitValuatorAxisStruct + | - InitFocusClassDeviceStruct + | - InitProximityClassDeviceStruct + | - InitKbdFeedbackClassDeviceStruct + | - InitPtrFeedbackClassDeviceStruct + | - InitLedFeedbackClassDeviceStruct + | - InitStringFeedbackClassDeviceStruct + | - InitIntegerFeedbackClassDeviceStruct + | - InitBellFeedbackClassDeviceStruct + | - init device name and type by: + | - calling MakeAtom with one of the + | predefined names + | - calling AssignTypeAndName + | + | +for each device added | + by AddInputDevice, | + InitAndStartDevices | + calls EnableDevice if | - EnableDevice calls deviceProc with + dev->startup & | (DEVICE_ON, AutoStart) + dev->inited | + | +If deviceProc returns | - core devices are now enabled, extension + Success, EnableDevice | devices are now available to be accessed + move the device from | through the input extension protocol + inputInfo.off_devices | requests. + to inputInfo.devices | @@ -216,7 +216,7 @@ InitInput(argc,argv) DeviceProc kbdproc, ptrproc, extproc; /************************************************************** - * Open the appropriate input devices, determine which are + * Open the appropriate input devices, determine which are * available, and choose an X pointer and X keyboard device * in some implementation-dependent manner. ***************************************************************/ @@ -239,7 +239,7 @@ InitInput(argc,argv) dev = AddInputDevice (ptrproc, TRUE); RegisterPointerDevice (dev); } - else + else { dev = AddInputDevice (extproc, FALSE); RegisterOtherDevice (dev); @@ -256,7 +256,7 @@ InitInput(argc,argv) After InitInput has returned, -InitAndStartDevices is the DIX routine that is called to enable input devices. +InitAndStartDevices is the DIX routine that is called to enable input devices. It calls the device control routine that was passed to AddInputDevice, with a mode value of DEVICE_INIT. The action taken by the device control routine depends on how the device is to be used. If the device is to be @@ -271,7 +271,7 @@ input, and are described in the following sections. -A sample device control routine called from InitAndStartDevices is +A sample device control routine called from InitAndStartDevices is shown below. @@ -299,7 +299,7 @@ Bool extproc (dev, mode) InitValuatorClassDeviceStruct (dev, localdev->n_axes,); motionproc, MOTION_BUF_SIZE, Absolute); for (i=0; i<localdev->n_axes; i++) - InitValuatorAxisStruct (dev, i, min_val, max_val, + InitValuatorAxisStruct (dev, i, min_val, max_val, resolution); InitFocusClassDeviceStruct (dev); InitProximityClassDeviceStruct (dev); @@ -325,11 +325,11 @@ Bool extproc (dev, mode) InitValuatorClassDeviceStruct (dev, localdev->n_axes,); motionproc, MOTION_BUF_SIZE, Absolute); for (i=0; i<localdev->n_axes; i++) - InitValuatorAxisStruct (dev, i, min_val, max_val, + InitValuatorAxisStruct (dev, i, min_val, max_val, resolution); InitFocusClassDeviceStruct (dev); } - localdev->atom = + localdev->atom = MakeAtom(localdev->name, strlen(localdev->name), FALSE); AssignTypeAndName (dev, localdev->atom, localdev->name); break; @@ -350,8 +350,8 @@ Bool extproc (dev, mode) The device control routine is called with a mode value of DEVICE_ON -by the DIX routine EnableDevice, which is called from InitAndStartDevices. -When called with this mode, it should call AddEnabledDevice to cause the +by the DIX routine EnableDevice, which is called from InitAndStartDevices. +When called with this mode, it should call AddEnabledDevice to cause the server to begin checking for available input from this device. @@ -367,8 +367,8 @@ field is set by AddInputDevice to value of the second parameter (autoStart). When the server is first initialized, it should only be checking for input from the core X keyboard and pointer. One way to accomplish this is to call AddInputDevice for the core X keyboard and pointer with an -autoStart value equal to TRUE, while calling AddInputDevice for -input extension devices with an autoStart value equal to FALSE. If this is +autoStart value equal to TRUE, while calling AddInputDevice for +input extension devices with an autoStart value equal to FALSE. If this is done, EnableDevice will skip all input extension devices during server initialization. In this case, the OpenInputDevice routine should set the "startup" field to TRUE @@ -423,12 +423,12 @@ FeedbackClass - the device supports some kind of feedback. DIX routines are provided to initialize the X pointer and keyboard, as in -previous releases of X. During X initialization, InitPointerDeviceStruct +previous releases of X. During X initialization, InitPointerDeviceStruct is called to initialize the X pointer, and InitKeyboardDeviceStruct is called to initialize the X keyboard. There is no corresponding routine for extension input devices, since they do not all -support the same classes of input. Instead, DDX is responsible for the -initialization of the input classes supported by extension devices. +support the same classes of input. Instead, DDX is responsible for the +initialization of the input classes supported by extension devices. A description of the routines provided by DIX to perform that initialization follows. @@ -436,7 +436,7 @@ follows. InitKeyClassDeviceStruct -This function is provided to allocate and initialize a KeyClassRec, and +This function is provided to allocate and initialize a KeyClassRec, and should be called for extension devices that have keys. It is passed a pointer to the device, and pointers to arrays of keysyms and modifiers reported by the device. It returns FALSE if the KeyClassRec could not be allocated, @@ -464,10 +464,10 @@ that have keys. InitButtonClassDeviceStruct -This function is provided to allocate and initialize a ButtonClassRec, and -should be called for extension devices that have buttons. It is passed a -pointer to the device, the number of buttons supported, and a map of the -reported button codes. It returns FALSE if the ButtonClassRec could not be +This function is provided to allocate and initialize a ButtonClassRec, and +should be called for extension devices that have buttons. It is passed a +pointer to the device, the number of buttons supported, and a map of the +reported button codes. It returns FALSE if the ButtonClassRec could not be allocated. Its parameters are: @@ -491,11 +491,11 @@ have buttons. InitValuatorClassDeviceStruct -This function is provided to allocate and initialize a ValuatorClassRec, and +This function is provided to allocate and initialize a ValuatorClassRec, and should be called for extension devices that have valuators. It is passed the number of axes of motion reported by the device, the address of the motion history procedure for the device, the size of the motion history buffer, -and the mode (Absolute or Relative) of the device. It returns FALSE if +and the mode (Absolute or Relative) of the device. It returns FALSE if the ValuatorClassRec could not be allocated. Its parameters are: @@ -521,14 +521,14 @@ report motion. InitValuatorAxisStruct -This function is provided to initialize an XAxisInfoRec, and -should be called for core and extension devices that have valuators. -The space for the XAxisInfoRec is allocated by +This function is provided to initialize an XAxisInfoRec, and +should be called for core and extension devices that have valuators. +The space for the XAxisInfoRec is allocated by the InitValuatorClassDeviceStruct function, but is not initialized. -InitValuatorAxisStruct should be called once for each axis of motion +InitValuatorAxisStruct should be called once for each axis of motion reported by the device. Each invocation should be passed the axis number (starting with 0), the minimum value for that axis, the maximum value for that axis, and the @@ -547,7 +547,7 @@ InitValuatorAxisStruct(dev, axnum, minval, maxval, resolution) This routine is not called by InitPointerDeviceStruct for the -core X pointer. It must be called explicitly for core and extension devices +core X pointer. It must be called explicitly for core and extension devices that report motion. @@ -555,7 +555,7 @@ that report motion. InitFocusClassDeviceStruct -This function is provided to allocate and initialize a FocusClassRec, and +This function is provided to allocate and initialize a FocusClassRec, and should be called for extension devices that can be focused. It is passed a pointer to the device, and returns FALSE if the allocation fails. It has the following parameter: @@ -577,7 +577,7 @@ is left implementation-dependent. InitProximityClassDeviceStruct -This function is provided to allocate and initialize a ProximityClassRec, and +This function is provided to allocate and initialize a ProximityClassRec, and should be called for extension absolute pointing devices that report proximity. It is passed a pointer to the device, and returns FALSE if the allocation fails. It has the following parameter: @@ -597,8 +597,8 @@ InitProximityClassDeviceStruct(dev) InitKbdFeedbackClassDeviceStruct -This function is provided to allocate and initialize a KbdFeedbackClassRec, and -may be called for extension devices that support some or all of the +This function is provided to allocate and initialize a KbdFeedbackClassRec, and +may be called for extension devices that support some or all of the feedbacks that the core keyboard supports. It is passed a pointer to the device, a pointer to the procedure that sounds the bell, and a pointer to the device control procedure. @@ -621,7 +621,7 @@ and LedFeedbackClass feedbacks. InitPtrFeedbackClassDeviceStruct -This function is provided to allocate and initialize a PtrFeedbackClassRec, and +This function is provided to allocate and initialize a PtrFeedbackClassRec, and should be called for extension devices that allow the setting of acceleration and threshold. It is passed a pointer to the device, and a pointer to the device control procedure. @@ -644,7 +644,7 @@ that support the setting of acceleration and threshold. InitLedFeedbackClassDeviceStruct -This function is provided to allocate and initialize a LedFeedbackClassRec, and +This function is provided to allocate and initialize a LedFeedbackClassRec, and should be called for extension devices that have LEDs. It is passed a pointer to the device, and a pointer to the device control procedure. @@ -658,7 +658,7 @@ InitLedFeedbackClassDeviceStruct(dev, controlProc) -Up to 32 LEDs per feedback can be supported, and a device may have +Up to 32 LEDs per feedback can be supported, and a device may have multiple feedbacks of the same type. @@ -666,7 +666,7 @@ multiple feedbacks of the same type. InitBellFeedbackClassDeviceStruct -This function is provided to allocate and initialize a BellFeedbackClassRec, +This function is provided to allocate and initialize a BellFeedbackClassRec, and should be called for extension devices that have a bell. It is passed a pointer to the device, and a pointer to the device control procedure. @@ -684,15 +684,15 @@ InitBellFeedbackClassDeviceStruct(dev, bellProc, controlProc) InitStringFeedbackClassDeviceStruct -This function is provided to allocate and initialize a StringFeedbackClassRec, -and should be called for extension devices that have a display upon which a +This function is provided to allocate and initialize a StringFeedbackClassRec, +and should be called for extension devices that have a display upon which a string can be displayed. It is passed a pointer to the device, and a pointer to the device control procedure. It returns FALSE if the allocation fails, and has the following parameters: Bool -InitStringFeedbackClassDeviceStruct(dev, controlProc, max_symbols, +InitStringFeedbackClassDeviceStruct(dev, controlProc, max_symbols, num_symbols_supported, symbols) DeviceIntPtr dev; void (*controlProc)(); @@ -706,8 +706,8 @@ InitStringFeedbackClassDeviceStruct(dev, controlProc, max_symbols, InitIntegerFeedbackClassDeviceStruct -This function is provided to allocate and initialize an -IntegerFeedbackClassRec, +This function is provided to allocate and initialize an +IntegerFeedbackClassRec, and should be called for extension devices that have a display upon which an integer can be displayed. It is passed a pointer to the device, @@ -769,7 +769,7 @@ that device. -DisableDevice is not called by any input extension routines. It can be +DisableDevice is not called by any input extension routines. It can be called from the CloseInputDevice routine, which is called by ProcXCloseDevice when a client makes an XCloseDevice request. If DisableDevice is called, it should only be called when the last client @@ -780,7 +780,7 @@ using the extension device has terminated or called XCloseDevice. Implementation-Dependent Routines -Several input extension protocol requests have +Several input extension protocol requests have implementation-dependent entry points. Default routines are defined for these entry points and contained in the source file extensions/server/xinput/xstubs.c. Some implementations may @@ -791,14 +791,14 @@ The following sections describe each of these routines. AddOtherInputDevices -AddOtherInputDevice is called from ProcXListInputDevices as a result of +AddOtherInputDevice is called from ProcXListInputDevices as a result of an XListInputDevices protocol request. It may be needed by implementations that do not open extension input devices until requested to do so by some client. These implementations may not initialize all devices when the X server starts up, because some of those devices may be in use. Since the XListInputDevices function only lists those devices that have been initialized, -AddOtherInputDevices is called to give DDX a chance to +AddOtherInputDevices is called to give DDX a chance to initialize any previously unavailable input devices. @@ -811,7 +811,7 @@ AddOtherInputDevices () DeviceIntPtr dev; int i; - for (i=0; i<MAX_DEVICES; i++) + for (i=0; i<MAX_DEVICES; i++) { if (!local_dev[i].initialized && available(local_dev[i])) { @@ -827,7 +827,7 @@ AddOtherInputDevices () The default AddOtherInputDevices routine in xstubs.c does nothing. -If all input extension devices are initialized when the server +If all input extension devices are initialized when the server starts up, it can be left as a null routine. @@ -839,13 +839,13 @@ Some X server implementations open all input devices when the server is initialized and never close them. Other implementations may open only the X pointer and keyboard devices during server initialization, and open other input devices only when some client makes an -XOpenDevice request. This entry point is for the latter type of +XOpenDevice request. This entry point is for the latter type of implementation. -If the physical device is not already open, it can be done in this routine. -In this case, the server must keep track of the fact that one or more clients +If the physical device is not already open, it can be done in this routine. +In this case, the server must keep track of the fact that one or more clients have the device open, and physically close it when the last client that has it open makes an XCloseDevice request. @@ -874,15 +874,15 @@ are opened during X server initialization and kept open). SetDeviceMode -Some implementations support input devices that can report +Some implementations support input devices that can report either absolute positional data or relative motion. The XSetDeviceMode -protocol request is provided to allow DDX to change the current mode of +protocol request is provided to allow DDX to change the current mode of such a device. The default implementation is to always return a BadMatch error. If the -implementation does not support any input devices that are capable of +implementation does not support any input devices that are capable of reporting both relative motion and absolute position information, the default implementation may be left unchanged. @@ -891,8 +891,8 @@ default implementation may be left unchanged. SetDeviceValuators -Some implementations support input devices that allow their valuators to be -set to an initial value. The XSetDeviceValuators +Some implementations support input devices that allow their valuators to be +set to an initial value. The XSetDeviceValuators protocol request is provided to allow DDX to set the valuators of such a device. @@ -910,40 +910,40 @@ valuators to be set, the default implementation may be left unchanged. The XChangePointerDevice protocol request is provided to change which device is used as the X pointer. Some implementations may maintain information specific to the X pointer in the private data structure pointed to by -the DeviceIntRec. ChangePointerDevice is called to allow such +the DeviceIntRec. ChangePointerDevice is called to allow such implementations to move that information to the new pointer device. -The current location of the X cursor is an example of the type of +The current location of the X cursor is an example of the type of information that might be affected. -The DeviceIntRec structure that describes the X pointer device does not -contain a FocusRec. If the device that has been made into the new X pointer -was previously a device that could be focused, ProcXChangePointerDevice will +The DeviceIntRec structure that describes the X pointer device does not +contain a FocusRec. If the device that has been made into the new X pointer +was previously a device that could be focused, ProcXChangePointerDevice will free the FocusRec associated with that device. -If the server implementation desires to allow clients to focus the old pointer +If the server implementation desires to allow clients to focus the old pointer device (which is now accessible through the input extension), it should call InitFocusClassDeviceStruct for the old pointer device. The XChangePointerDevice protocol request also allows the client -to choose which axes of the new pointer device are used to move +to choose which axes of the new pointer device are used to move the X cursor in the X- and Y- directions. If the axes are different than the default ones, the server implementation should record that fact. -If the server implementation supports input devices with valuators that +If the server implementation supports input devices with valuators that are not allowed to be used as the X pointer, they should be screened out by this routine and a BadDevice error returned. -The default implementation is to do nothing. +The default implementation is to do nothing. @@ -953,19 +953,19 @@ The default implementation is to do nothing. The XChangeKeyboardDevice protocol request is provided to change which device is used as the X keyboard. Some implementations may maintain information specific to the X keyboard in the private data structure pointed to by -the DeviceIntRec. ChangeKeyboardDevice is called to allow such +the DeviceIntRec. ChangeKeyboardDevice is called to allow such implementations to move that information to the new keyboard device. The X keyboard device can be focused, and the DeviceIntRec that describes -that device has a FocusRec. If the device that has been made into the new X -keyboard did not previously have a FocusRec, +that device has a FocusRec. If the device that has been made into the new X +keyboard did not previously have a FocusRec, ProcXChangeKeyboardDevice will allocate one for it. -If the implementation does not want clients to be able to focus the old X +If the implementation does not want clients to be able to focus the old X keyboard (which has now become available as an input extension device) it should call DeleteFocusClassDeviceStruct to free the FocusRec. @@ -977,7 +977,7 @@ BadDevice error returned. -The default implementation is to do nothing. +The default implementation is to do nothing. @@ -986,11 +986,11 @@ The default implementation is to do nothing. Events accessed through the input extension are analogous to the core input -events, but have different event types. They are of types +events, but have different event types. They are of types DeviceKeyPress, DeviceKeyRelease, DeviceButtonPress, DeviceButtonRelease, DeviceDeviceMotionNotify, DeviceProximityIn, DeviceProximityOut, and DeviceValuator. -These event types are not constants. Instead, they are external integers +These event types are not constants. Instead, they are external integers defined by the input extension. Their actual values will depend on which extensions are supported by a server, and the order in which they are initialized. @@ -1007,7 +1007,7 @@ input extension constants needed by DDX are defined in the file Some events defined by the input extension contain more information than can be contained in the 32-byte xEvent data structure. To send this information to clients, DDX must generate two or more 32-byte wire events. The following -sections describe the contents of these events. +sections describe the contents of these events. Device Key Events @@ -1053,7 +1053,7 @@ valuator0 through valuator5 - the values of the valuators. In order to pass this information to the input extension library, two 32-byte -wire events must be generated by DDX. The first has an event type of +wire events must be generated by DDX. The first has an event type of DeviceKeyPress, and the second has an event type of DeviceValuator. @@ -1106,7 +1106,7 @@ The following code fragment shows how the two wire events could be initialized: DeviceButton events contain all the information that is contained in -a core button event, and also the same additional information that a +a core button event, and also the same additional information that a DeviceKey event contains. @@ -1174,8 +1174,8 @@ set correctly. Device Proximity Events -Some input devices that report absolute positional information, such as -graphics tablets and touchscreens, may report proximity events. +Some input devices that report absolute positional information, such as +graphics tablets and touchscreens, may report proximity events. ProximityIn events are generated when a pointing device like a stylus, or in the case of a touchscreen, the user's finger, comes into close proximity with the