1
/* $Xorg: chgdctl.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
3
/************************************************************
5
Copyright 1989, 1998 The Open Group
7
Permission to use, copy, modify, distribute, and sell this software and its
8
documentation for any purpose is hereby granted without fee, provided that
9
the above copyright notice appear in all copies and that both that
10
copyright notice and this permission notice appear in supporting
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
Except as contained in this notice, the name of The Open Group shall not be
24
used in advertising or otherwise to promote the sale, use or other dealings
25
in this Software without prior written authorization from The Open Group.
27
Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
31
Permission to use, copy, modify, and distribute this software and its
32
documentation for any purpose and without fee is hereby granted,
33
provided that the above copyright notice appear in all copies and that
34
both that copyright notice and this permission notice appear in
35
supporting documentation, and that the name of Hewlett-Packard not be
36
used in advertising or publicity pertaining to distribution of the
37
software without specific, written prior permission.
39
HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41
HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
47
********************************************************/
48
/* $XFree86: xc/programs/Xserver/Xi/chgdctl.c,v 3.4 2001/12/14 19:58:54 dawes Exp $ */
50
/********************************************************************
52
* Change Device control attributes for an extension device.
56
#define NEED_EVENTS /* for inputstr.h */
58
#include "X.h" /* for inputstr.h */
59
#include "Xproto.h" /* Request macro */
60
#include "inputstr.h" /* DeviceIntPtr */
62
#include "XIproto.h" /* control constants */
65
#include "extnsionst.h"
66
#include "extinit.h" /* LookupDeviceIntRec */
67
#include "exglobals.h"
71
/***********************************************************************
73
* This procedure changes the control attributes for an extension device,
74
* for clients on machines with a different byte ordering than the server.
79
SProcXChangeDeviceControl(client)
80
register ClientPtr client;
84
REQUEST(xChangeDeviceControlReq);
85
swaps(&stuff->length, n);
86
REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
87
swaps(&stuff->control, n);
88
return(ProcXChangeDeviceControl(client));
91
/***********************************************************************
93
* Change the control attributes.
98
ProcXChangeDeviceControl(client)
104
xDeviceResolutionCtl *r;
105
xChangeDeviceControlReply rep;
109
REQUEST(xChangeDeviceControlReq);
110
REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
112
len = stuff->length - (sizeof(xChangeDeviceControlReq) >>2);
113
dev = LookupDeviceIntRec (stuff->deviceid);
116
SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0,
121
rep.repType = X_Reply;
122
rep.RepType = X_ChangeDeviceControl;
124
rep.sequenceNumber = client->sequence;
126
switch (stuff->control)
128
case DEVICE_RESOLUTION:
129
r = (xDeviceResolutionCtl *) &stuff[1];
130
if ((len < (sizeof(xDeviceResolutionCtl)>>2)) ||
131
(len != (sizeof(xDeviceResolutionCtl)>>2) +
134
SendErrorToClient (client, IReqCode, X_ChangeDeviceControl,
140
SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0,
144
if ((dev->grab) && !SameClient(dev->grab, client))
146
rep.status = AlreadyGrabbed;
147
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
151
resolution = (CARD32 *) (r + 1);
152
if (r->first_valuator + r->num_valuators > dev->valuator->numAxes)
154
SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0,
158
status = ChangeDeviceControl(client, dev, (xDeviceCtl*) r);
159
if (status == Success)
161
a = &dev->valuator->axes[r->first_valuator];
162
for (i=0; i<r->num_valuators; i++)
163
if (*(resolution+i) < (a+i)->min_resolution ||
164
*(resolution+i) > (a+i)->max_resolution)
166
SendErrorToClient (client, IReqCode,
167
X_ChangeDeviceControl, 0, BadValue);
170
for (i=0; i<r->num_valuators; i++)
171
(a++)->resolution = *resolution++;
173
else if (status == DeviceBusy)
175
rep.status = DeviceBusy;
176
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
182
SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0,
188
SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0,
192
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
196
/***********************************************************************
198
* This procedure writes the reply for the xChangeDeviceControl function,
199
* if the client and server have a different byte ordering.
204
SRepXChangeDeviceControl (client, size, rep)
207
xChangeDeviceControlReply *rep;
211
swaps(&rep->sequenceNumber, n);
212
swapl(&rep->length, n);
213
WriteToClient(client, size, (char *)rep);