darwinXinput.c revision 4642e01f
1/*
2 * X server support of the XINPUT extension for xquartz
3 *
4 * This is currently a copy of Xi/stubs.c, but eventually this
5 * should include more complete XINPUT support.
6 */
7
8/************************************************************
9
10Copyright 1989, 1998  The Open Group
11
12Permission to use, copy, modify, distribute, and sell this software and its
13documentation for any purpose is hereby granted without fee, provided that
14the above copyright notice appear in all copies and that both that
15copyright notice and this permission notice appear in supporting
16documentation.
17
18The above copyright notice and this permission notice shall be included in
19all copies or substantial portions of the Software.
20
21THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
24OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
25AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
28Except as contained in this notice, the name of The Open Group shall not be
29used in advertising or otherwise to promote the sale, use or other dealings
30in this Software without prior written authorization from The Open Group.
31
32Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
33
34			All Rights Reserved
35
36Permission to use, copy, modify, and distribute this software and its
37documentation for any purpose and without fee is hereby granted,
38provided that the above copyright notice appear in all copies and that
39both that copyright notice and this permission notice appear in
40supporting documentation, and that the name of Hewlett-Packard not be
41used in advertising or publicity pertaining to distribution of the
42software without specific, written prior permission.
43
44HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
45ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
46HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
47ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
48WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
49ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
50SOFTWARE.
51
52********************************************************/
53
54#define	 NEED_EVENTS
55#ifdef HAVE_DIX_CONFIG_H
56#include <dix-config.h>
57#endif
58
59#include <X11/X.h>
60#include <X11/Xproto.h>
61#include "inputstr.h"
62#include <X11/extensions/XI.h>
63#include <X11/extensions/XIproto.h>
64#include "XIstubs.h"
65#include "darwin.h"
66
67/***********************************************************************
68 *
69 * Caller:	ProcXCloseDevice
70 *
71 * Take care of implementation-dependent details of closing a device.
72 * Some implementations may actually close the device, others may just
73 * remove this clients interest in that device.
74 *
75 * The default implementation is to do nothing (assume all input devices
76 * are initialized during X server initialization and kept open).
77 *
78 */
79
80void
81CloseInputDevice(DeviceIntPtr d, ClientPtr client)
82{
83  DEBUG_LOG("CloseInputDevice(%p, %p)\n", d, client);
84}
85
86/***********************************************************************
87 *
88 * Caller:	ProcXListInputDevices
89 *
90 * This is the implementation-dependent routine to initialize an input
91 * device to the point that information about it can be listed.
92 * Some implementations open all input devices when the server is first
93 * initialized, and never close them.  Other implementations open only
94 * the X pointer and keyboard devices during server initialization,
95 * and only open other input devices when some client makes an
96 * XOpenDevice request.  If some other process has the device open, the
97 * server may not be able to get information about the device to list it.
98 *
99 * This procedure should be used by implementations that do not initialize
100 * all input devices at server startup.  It should do device-dependent
101 * initialization for any devices not previously initialized, and call
102 * AddInputDevice for each of those devices so that a DeviceIntRec will be
103 * created for them.
104 *
105 * The default implementation is to do nothing (assume all input devices
106 * are initialized during X server initialization and kept open).
107 * The commented-out sample code shows what you might do if you don't want
108 * the default.
109 *
110 */
111
112void
113AddOtherInputDevices(void)
114{
115    /**********************************************************************
116     for each uninitialized device, do something like:
117
118    DeviceIntPtr dev;
119    DeviceProc deviceProc;
120    pointer private;
121
122    dev = (DeviceIntPtr) AddInputDevice(deviceProc, TRUE);
123    dev->public.devicePrivate = private;
124    RegisterOtherDevice(dev);
125    dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
126    ************************************************************************/
127  DEBUG_LOG("AddOtherInputDevices\n");
128}
129
130/***********************************************************************
131 *
132 * Caller:	ProcXOpenDevice
133 *
134 * This is the implementation-dependent routine to open an input device.
135 * Some implementations open all input devices when the server is first
136 * initialized, and never close them.  Other implementations open only
137 * the X pointer and keyboard devices during server initialization,
138 * and only open other input devices when some client makes an
139 * XOpenDevice request.  This entry point is for the latter type of
140 * implementation.
141 *
142 * If the physical device is not already open, do it here.  In this case,
143 * you need to keep track of the fact that one or more clients has the
144 * device open, and physically close it when the last client that has
145 * it open does an XCloseDevice.
146 *
147 * The default implementation is to do nothing (assume all input devices
148 * are opened during X server initialization and kept open).
149 *
150 */
151
152void
153OpenInputDevice(DeviceIntPtr dev, ClientPtr client, int *status)
154{
155  DEBUG_LOG("OpenInputDevice(%p, %p, %p)\n", dev, client, status);
156}
157
158/****************************************************************************
159 *
160 * Caller:	ProcXSetDeviceMode
161 *
162 * Change the mode of an extension device.
163 * This function is used to change the mode of a device from reporting
164 * relative motion to reporting absolute positional information, and
165 * vice versa.
166 * The default implementation below is that no such devices are supported.
167 *
168 */
169
170int
171SetDeviceMode(ClientPtr client, DeviceIntPtr dev, int mode)
172{
173  DEBUG_LOG("SetDeviceMode(%p, %p, %d)\n", client, dev, mode);
174    return BadMatch;
175}
176
177/****************************************************************************
178 *
179 * Caller:	ProcXSetDeviceValuators
180 *
181 * Set the value of valuators on an extension input device.
182 * This function is used to set the initial value of valuators on
183 * those input devices that are capable of reporting either relative
184 * motion or an absolute position, and allow an initial position to be set.
185 * The default implementation below is that no such devices are supported.
186 *
187 */
188
189int
190SetDeviceValuators(ClientPtr client, DeviceIntPtr dev,
191		   int *valuators, int first_valuator, int num_valuators)
192{
193  DEBUG_LOG("SetDeviceValuators(%p, %p, %p, %d, %d)\n", client,
194	    dev, valuators, first_valuator, num_valuators);
195  return BadMatch;
196}
197
198/****************************************************************************
199 *
200 * Caller:	ProcXChangeDeviceControl
201 *
202 * Change the specified device controls on an extension input device.
203 *
204 */
205
206int
207ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev,
208		    xDeviceCtl * control)
209{
210
211  DEBUG_LOG("ChangeDeviceControl(%p, %p, %p)\n", client, dev, control);
212    switch (control->control) {
213    case DEVICE_RESOLUTION:
214	return (BadMatch);
215    case DEVICE_ABS_CALIB:
216    case DEVICE_ABS_AREA:
217        return (BadMatch);
218    case DEVICE_CORE:
219        return (BadMatch);
220    default:
221	return (BadMatch);
222    }
223}
224
225
226/****************************************************************************
227 *
228 * Caller: configAddDevice (and others)
229 *
230 * Add a new device with the specified options.
231 *
232 */
233int
234NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
235{
236  DEBUG_LOG("NewInputDeviceRequest(%p, %p)\n", options, pdev);
237  return BadValue;
238}
239
240/****************************************************************************
241 *
242 * Caller: configRemoveDevice (and others)
243 *
244 * Remove the specified device previously added.
245 *
246 */
247void
248DeleteInputDeviceRequest(DeviceIntPtr dev)
249{
250  DEBUG_LOG("DeleteInputDeviceRequest(%p)\n", dev);
251}
252