3 * X server support of the XINPUT extension for Darwin
5 * This is currently a copy of mi/stubs.c, but eventually this
6 * should include more complete XINPUT support.
9 /************************************************************
11 Copyright 1989, 1998 The Open Group
13 Permission to use, copy, modify, distribute, and sell this software and its
14 documentation for any purpose is hereby granted without fee, provided that
15 the above copyright notice appear in all copies and that both that
16 copyright notice and this permission notice appear in supporting
19 The above copyright notice and this permission notice shall be included in
20 all copies or substantial portions of the Software.
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 Except as contained in this notice, the name of The Open Group shall not be
30 used in advertising or otherwise to promote the sale, use or other dealings
31 in this Software without prior written authorization from The Open Group.
33 Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
37 Permission to use, copy, modify, and distribute this software and its
38 documentation for any purpose and without fee is hereby granted,
39 provided that the above copyright notice appear in all copies and that
40 both that copyright notice and this permission notice appear in
41 supporting documentation, and that the name of Hewlett-Packard not be
42 used in advertising or publicity pertaining to distribution of the
43 software without specific, written prior permission.
45 HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
46 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
47 HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
48 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
49 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
50 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
53 ********************************************************/
57 #include <X11/Xproto.h>
59 #include <X11/extensions/XI.h>
60 #include <X11/extensions/XIproto.h>
63 /***********************************************************************
65 * Caller: ProcXChangeKeyboardDevice
67 * This procedure does the implementation-dependent portion of the work
68 * needed to change the keyboard device.
70 * The X keyboard device has a FocusRec. If the device that has been
71 * made into the new X keyboard did not have a FocusRec,
72 * ProcXChangeKeyboardDevice will allocate one for it.
74 * If you do not want clients to be able to focus the old X keyboard
75 * device, call DeleteFocusClassDeviceStruct to free the FocusRec.
77 * If you support input devices with keys that you do not want to be
78 * used as the X keyboard, you need to check for them here and return
81 * The default implementation is to do nothing (assume you do want
82 * clients to be able to focus the old X keyboard). The commented-out
83 * sample code shows what you might do if you don't want the default.
88 ChangeKeyboardDevice (old_dev
, new_dev
)
92 /***********************************************************************
93 DeleteFocusClassDeviceStruct(old_dev); * defined in xchgptr.c *
94 **********************************************************************/
99 /***********************************************************************
101 * Caller: ProcXChangePointerDevice
103 * This procedure does the implementation-dependent portion of the work
104 * needed to change the pointer device.
106 * The X pointer device does not have a FocusRec. If the device that
107 * has been made into the new X pointer had a FocusRec,
108 * ProcXChangePointerDevice will free it.
110 * If you want clients to be able to focus the old pointer device that
111 * has now become accessible through the input extension, you need to
112 * add a FocusRec to it here.
114 * The XChangePointerDevice protocol request also allows the client
115 * to choose which axes of the new pointer device are used to move
116 * the X cursor in the X- and Y- directions. If the axes are different
117 * than the default ones, you need to keep track of that here.
119 * If you support input devices with valuators that you do not want to be
120 * used as the X pointer, you need to check for them here and return a
123 * The default implementation is to do nothing (assume you don't want
124 * clients to be able to focus the old X pointer). The commented-out
125 * sample code shows what you might do if you don't want the default.
130 ChangePointerDevice (
131 DeviceIntPtr old_dev
,
132 DeviceIntPtr new_dev
,
136 /***********************************************************************
137 InitFocusClassDeviceStruct(old_dev); * allow focusing old ptr*
139 x_axis = x; * keep track of new x-axis*
140 y_axis = y; * keep track of new y-axis*
141 if (x_axis != 0 || y_axis != 1)
142 axes_changed = TRUE; * remember axes have changed*
144 axes_changed = FALSE;
145 *************************************************************************/
149 /***********************************************************************
151 * Caller: ProcXCloseDevice
153 * Take care of implementation-dependent details of closing a device.
154 * Some implementations may actually close the device, others may just
155 * remove this clients interest in that device.
157 * The default implementation is to do nothing (assume all input devices
158 * are initialized during X server initialization and kept open).
163 CloseInputDevice (d
, client
)
169 /***********************************************************************
171 * Caller: ProcXListInputDevices
173 * This is the implementation-dependent routine to initialize an input
174 * device to the point that information about it can be listed.
175 * Some implementations open all input devices when the server is first
176 * initialized, and never close them. Other implementations open only
177 * the X pointer and keyboard devices during server initialization,
178 * and only open other input devices when some client makes an
179 * XOpenDevice request. If some other process has the device open, the
180 * server may not be able to get information about the device to list it.
182 * This procedure should be used by implementations that do not initialize
183 * all input devices at server startup. It should do device-dependent
184 * initialization for any devices not previously initialized, and call
185 * AddInputDevice for each of those devices so that a DeviceIntRec will be
188 * The default implementation is to do nothing (assume all input devices
189 * are initialized during X server initialization and kept open).
190 * The commented-out sample code shows what you might do if you don't want
196 AddOtherInputDevices ()
198 /**********************************************************************
199 for each uninitialized device, do something like:
202 DeviceProc deviceProc;
205 dev = (DeviceIntPtr) AddInputDevice(deviceProc, TRUE);
206 dev->public.devicePrivate = private;
207 RegisterOtherDevice(dev);
208 dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
209 ************************************************************************/
213 /***********************************************************************
215 * Caller: ProcXOpenDevice
217 * This is the implementation-dependent routine to open an input device.
218 * Some implementations open all input devices when the server is first
219 * initialized, and never close them. Other implementations open only
220 * the X pointer and keyboard devices during server initialization,
221 * and only open other input devices when some client makes an
222 * XOpenDevice request. This entry point is for the latter type of
225 * If the physical device is not already open, do it here. In this case,
226 * you need to keep track of the fact that one or more clients has the
227 * device open, and physically close it when the last client that has
228 * it open does an XCloseDevice.
230 * The default implementation is to do nothing (assume all input devices
231 * are opened during X server initialization and kept open).
236 OpenInputDevice (dev
, client
, status
)
243 /****************************************************************************
245 * Caller: ProcXSetDeviceMode
247 * Change the mode of an extension device.
248 * This function is used to change the mode of a device from reporting
249 * relative motion to reporting absolute positional information, and
251 * The default implementation below is that no such devices are supported.
256 SetDeviceMode (client
, dev
, mode
)
257 register ClientPtr client
;
264 /****************************************************************************
266 * Caller: ProcXSetDeviceValuators
268 * Set the value of valuators on an extension input device.
269 * This function is used to set the initial value of valuators on
270 * those input devices that are capable of reporting either relative
271 * motion or an absolute position, and allow an initial position to be set.
272 * The default implementation below is that no such devices are supported.
277 SetDeviceValuators (client
, dev
, valuators
, first_valuator
, num_valuators
)
278 register ClientPtr client
;
287 /****************************************************************************
289 * Caller: ProcXChangeDeviceControl
291 * Change the specified device controls on an extension input device.
296 ChangeDeviceControl (client
, dev
, control
)
297 register ClientPtr client
;
301 switch (control
->control
)
303 case DEVICE_RESOLUTION
: