1 /************************************************************
3 Copyright 1989, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
25 Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
29 Permission to use, copy, modify, and distribute this software and its
30 documentation for any purpose and without fee is hereby granted,
31 provided that the above copyright notice appear in all copies and that
32 both that copyright notice and this permission notice appear in
33 supporting documentation, and that the name of Hewlett-Packard not be
34 used in advertising or publicity pertaining to distribution of the
35 software without specific, written prior permission.
37 HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
38 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
39 HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
40 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
41 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
42 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45 ********************************************************/
47 /********************************************************************
49 * Change feedback control attributes for an extension device.
53 #ifdef HAVE_DIX_CONFIG_H
54 #include <dix-config.h>
57 #include "inputstr.h" /* DeviceIntPtr */
58 #include <X11/extensions/XI.h>
59 #include <X11/extensions/XIproto.h> /* control constants */
61 #include "exglobals.h"
67 /***********************************************************************
69 * This procedure changes the control attributes for an extension device,
70 * for clients on machines with a different byte ordering than the server.
75 SProcXChangeFeedbackControl(ClientPtr client
)
77 REQUEST(xChangeFeedbackControlReq
);
78 swaps(&stuff
->length
);
79 REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq
);
81 return (ProcXChangeFeedbackControl(client
));
84 /******************************************************************************
86 * This procedure changes KbdFeedbackClass data.
91 ChangeKbdFeedback(ClientPtr client
, DeviceIntPtr dev
, long unsigned int mask
,
92 KbdFeedbackPtr k
, xKbdFeedbackCtl
* f
)
98 if (client
->swapped
) {
103 swapl(&f
->led_values
);
107 if (mask
& DvKeyClickPercent
) {
110 t
= defaultKeyboardControl
.click
;
111 else if (t
< 0 || t
> 100) {
112 client
->errorValue
= t
;
118 if (mask
& DvPercent
) {
121 t
= defaultKeyboardControl
.bell
;
122 else if (t
< 0 || t
> 100) {
123 client
->errorValue
= t
;
129 if (mask
& DvPitch
) {
132 t
= defaultKeyboardControl
.bell_pitch
;
134 client
->errorValue
= t
;
137 kctrl
.bell_pitch
= t
;
140 if (mask
& DvDuration
) {
143 t
= defaultKeyboardControl
.bell_duration
;
145 client
->errorValue
= t
;
148 kctrl
.bell_duration
= t
;
152 kctrl
.leds
&= ~(f
->led_mask
);
153 kctrl
.leds
|= (f
->led_mask
& f
->led_values
);
157 key
= (KeyCode
) f
->key
;
158 if (key
< 8 || key
> 255) {
159 client
->errorValue
= key
;
162 if (!(mask
& DvAutoRepeatMode
))
166 if (mask
& DvAutoRepeatMode
) {
167 int inx
= (key
>> 3);
168 int kmask
= (1 << (key
& 7));
170 t
= (CARD8
) f
->auto_repeat_mode
;
171 if (t
== AutoRepeatModeOff
) {
173 kctrl
.autoRepeat
= FALSE
;
175 kctrl
.autoRepeats
[inx
] &= ~kmask
;
177 else if (t
== AutoRepeatModeOn
) {
179 kctrl
.autoRepeat
= TRUE
;
181 kctrl
.autoRepeats
[inx
] |= kmask
;
183 else if (t
== AutoRepeatModeDefault
) {
185 kctrl
.autoRepeat
= defaultKeyboardControl
.autoRepeat
;
187 kctrl
.autoRepeats
[inx
] &= ~kmask
;
188 kctrl
.autoRepeats
[inx
] =
189 (kctrl
.autoRepeats
[inx
] & ~kmask
) |
190 (defaultKeyboardControl
.autoRepeats
[inx
] & kmask
);
193 client
->errorValue
= t
;
199 (*k
->CtrlProc
) (dev
, &k
->ctrl
);
203 /******************************************************************************
205 * This procedure changes PtrFeedbackClass data.
210 ChangePtrFeedback(ClientPtr client
, DeviceIntPtr dev
, long unsigned int mask
,
211 PtrFeedbackPtr p
, xPtrFeedbackCtl
* f
)
213 PtrCtrl pctrl
; /* might get BadValue part way through */
215 if (client
->swapped
) {
223 if (mask
& DvAccelNum
) {
228 pctrl
.num
= defaultPointerControl
.num
;
229 else if (accelNum
< 0) {
230 client
->errorValue
= accelNum
;
234 pctrl
.num
= accelNum
;
237 if (mask
& DvAccelDenom
) {
240 accelDenom
= f
->denom
;
241 if (accelDenom
== -1)
242 pctrl
.den
= defaultPointerControl
.den
;
243 else if (accelDenom
<= 0) {
244 client
->errorValue
= accelDenom
;
248 pctrl
.den
= accelDenom
;
251 if (mask
& DvThreshold
) {
254 threshold
= f
->thresh
;
256 pctrl
.threshold
= defaultPointerControl
.threshold
;
257 else if (threshold
< 0) {
258 client
->errorValue
= threshold
;
262 pctrl
.threshold
= threshold
;
266 (*p
->CtrlProc
) (dev
, &p
->ctrl
);
270 /******************************************************************************
272 * This procedure changes IntegerFeedbackClass data.
277 ChangeIntegerFeedback(ClientPtr client
, DeviceIntPtr dev
,
278 long unsigned int mask
, IntegerFeedbackPtr i
,
279 xIntegerFeedbackCtl
* f
)
281 if (client
->swapped
) {
283 swapl(&f
->int_to_display
);
286 i
->ctrl
.integer_displayed
= f
->int_to_display
;
287 (*i
->CtrlProc
) (dev
, &i
->ctrl
);
291 /******************************************************************************
293 * This procedure changes StringFeedbackClass data.
298 ChangeStringFeedback(ClientPtr client
, DeviceIntPtr dev
,
299 long unsigned int mask
, StringFeedbackPtr s
,
300 xStringFeedbackCtl
* f
)
303 KeySym
*syms
, *sup_syms
;
305 syms
= (KeySym
*) (f
+ 1);
306 if (client
->swapped
) {
307 swaps(&f
->length
); /* swapped num_keysyms in calling proc */
308 SwapLongs((CARD32
*) syms
, f
->num_keysyms
);
311 if (f
->num_keysyms
> s
->ctrl
.max_symbols
)
314 sup_syms
= s
->ctrl
.symbols_supported
;
315 for (i
= 0; i
< f
->num_keysyms
; i
++) {
316 for (j
= 0; j
< s
->ctrl
.num_symbols_supported
; j
++)
317 if (*(syms
+ i
) == *(sup_syms
+ j
))
319 if (j
== s
->ctrl
.num_symbols_supported
)
323 s
->ctrl
.num_symbols_displayed
= f
->num_keysyms
;
324 for (i
= 0; i
< f
->num_keysyms
; i
++)
325 *(s
->ctrl
.symbols_displayed
+ i
) = *(syms
+ i
);
326 (*s
->CtrlProc
) (dev
, &s
->ctrl
);
330 /******************************************************************************
332 * This procedure changes BellFeedbackClass data.
337 ChangeBellFeedback(ClientPtr client
, DeviceIntPtr dev
,
338 long unsigned int mask
, BellFeedbackPtr b
,
339 xBellFeedbackCtl
* f
)
342 BellCtrl bctrl
; /* might get BadValue part way through */
344 if (client
->swapped
) {
351 if (mask
& DvPercent
) {
354 t
= defaultKeyboardControl
.bell
;
355 else if (t
< 0 || t
> 100) {
356 client
->errorValue
= t
;
362 if (mask
& DvPitch
) {
365 t
= defaultKeyboardControl
.bell_pitch
;
367 client
->errorValue
= t
;
373 if (mask
& DvDuration
) {
376 t
= defaultKeyboardControl
.bell_duration
;
378 client
->errorValue
= t
;
384 (*b
->CtrlProc
) (dev
, &b
->ctrl
);
388 /******************************************************************************
390 * This procedure changes LedFeedbackClass data.
395 ChangeLedFeedback(ClientPtr client
, DeviceIntPtr dev
, long unsigned int mask
,
396 LedFeedbackPtr l
, xLedFeedbackCtl
* f
)
398 LedCtrl lctrl
; /* might get BadValue part way through */
400 if (client
->swapped
) {
402 swapl(&f
->led_values
);
406 f
->led_mask
&= l
->ctrl
.led_mask
; /* set only supported leds */
407 f
->led_values
&= l
->ctrl
.led_mask
; /* set only supported leds */
409 lctrl
.led_mask
= f
->led_mask
;
410 lctrl
.led_values
= f
->led_values
;
411 (*l
->CtrlProc
) (dev
, &lctrl
);
412 l
->ctrl
.led_values
&= ~(f
->led_mask
); /* zero changed leds */
413 l
->ctrl
.led_values
|= (f
->led_mask
& f
->led_values
); /* OR in set leds */
419 /***********************************************************************
421 * Change the control attributes.
426 ProcXChangeFeedbackControl(ClientPtr client
)
432 IntegerFeedbackPtr i
;
438 REQUEST(xChangeFeedbackControlReq
);
439 REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq
);
441 len
= stuff
->length
- bytes_to_int32(sizeof(xChangeFeedbackControlReq
));
442 rc
= dixLookupDevice(&dev
, stuff
->deviceid
, client
, DixManageAccess
);
446 switch (stuff
->feedbackid
) {
447 case KbdFeedbackClass
:
448 if (len
!= bytes_to_int32(sizeof(xKbdFeedbackCtl
)))
451 for (k
= dev
->kbdfeed
; k
; k
= k
->next
)
452 if (k
->ctrl
.id
== ((xKbdFeedbackCtl
*) &stuff
[1])->id
)
453 return ChangeKbdFeedback(client
, dev
, stuff
->mask
, k
,
454 (xKbdFeedbackCtl
*) &stuff
[1]);
456 case PtrFeedbackClass
:
457 if (len
!= bytes_to_int32(sizeof(xPtrFeedbackCtl
)))
460 for (p
= dev
->ptrfeed
; p
; p
= p
->next
)
461 if (p
->ctrl
.id
== ((xPtrFeedbackCtl
*) &stuff
[1])->id
)
462 return ChangePtrFeedback(client
, dev
, stuff
->mask
, p
,
463 (xPtrFeedbackCtl
*) &stuff
[1]);
465 case StringFeedbackClass
:
467 xStringFeedbackCtl
*f
= ((xStringFeedbackCtl
*) &stuff
[1]);
469 if (client
->swapped
) {
470 swaps(&f
->num_keysyms
);
473 (bytes_to_int32(sizeof(xStringFeedbackCtl
)) + f
->num_keysyms
))
476 for (s
= dev
->stringfeed
; s
; s
= s
->next
)
477 if (s
->ctrl
.id
== ((xStringFeedbackCtl
*) &stuff
[1])->id
)
478 return ChangeStringFeedback(client
, dev
, stuff
->mask
, s
,
479 (xStringFeedbackCtl
*) &stuff
[1]);
482 case IntegerFeedbackClass
:
483 if (len
!= bytes_to_int32(sizeof(xIntegerFeedbackCtl
)))
486 for (i
= dev
->intfeed
; i
; i
= i
->next
)
487 if (i
->ctrl
.id
== ((xIntegerFeedbackCtl
*) &stuff
[1])->id
)
488 return ChangeIntegerFeedback(client
, dev
, stuff
->mask
, i
,
489 (xIntegerFeedbackCtl
*) &
492 case LedFeedbackClass
:
493 if (len
!= bytes_to_int32(sizeof(xLedFeedbackCtl
)))
496 for (l
= dev
->leds
; l
; l
= l
->next
)
497 if (l
->ctrl
.id
== ((xLedFeedbackCtl
*) &stuff
[1])->id
)
498 return ChangeLedFeedback(client
, dev
, stuff
->mask
, l
,
499 (xLedFeedbackCtl
*) &stuff
[1]);
501 case BellFeedbackClass
:
502 if (len
!= bytes_to_int32(sizeof(xBellFeedbackCtl
)))
505 for (b
= dev
->bell
; b
; b
= b
->next
)
506 if (b
->ctrl
.id
== ((xBellFeedbackCtl
*) &stuff
[1])->id
)
507 return ChangeBellFeedback(client
, dev
, stuff
->mask
, b
,
508 (xBellFeedbackCtl
*) &stuff
[1]);