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 * XChangeFeedbackControl - Change the control attributes of feedbacks on
50 * an extension device.
58 #include <X11/extensions/XI.h>
59 #include <X11/extensions/XIproto.h>
60 #include <X11/Xlibint.h>
61 #include <X11/extensions/XInput.h>
62 #include <X11/extensions/extutil.h>
66 XChangeFeedbackControl(
67 register Display *dpy,
73 xChangeFeedbackControlReq *req;
74 XExtDisplayInfo *info = XInput_find_display(dpy);
77 if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1)
78 return (NoSuchExtension);
80 GetReq(ChangeFeedbackControl, req);
81 req->reqType = info->codes->major_opcode;
82 req->ReqType = X_ChangeFeedbackControl;
83 req->deviceid = dev->device_id;
85 req->feedbackid = f->class;
87 if (f->class == KbdFeedbackClass) {
88 XKbdFeedbackControl *K;
91 K = (XKbdFeedbackControl *) f;
92 k.class = KbdFeedbackClass;
93 k.length = sizeof(xKbdFeedbackCtl);
96 k.percent = K->percent;
98 k.duration = K->duration;
99 k.led_mask = K->led_mask;
100 k.led_values = K->led_value;
102 k.auto_repeat_mode = K->auto_repeat_mode;
103 length = ((unsigned)(k.length + 3) >> 2);
104 req->length += length;
106 Data(dpy, (char *)&k, length);
107 } else if (f->class == PtrFeedbackClass) {
108 XPtrFeedbackControl *P;
111 P = (XPtrFeedbackControl *) f;
112 p.class = PtrFeedbackClass;
113 p.length = sizeof(xPtrFeedbackCtl);
116 p.denom = P->accelDenom;
117 p.thresh = P->threshold;
118 length = ((unsigned)(p.length + 3) >> 2);
119 req->length += length;
121 Data(dpy, (char *)&p, length);
122 } else if (f->class == IntegerFeedbackClass) {
123 XIntegerFeedbackControl *I;
124 xIntegerFeedbackCtl i;
126 I = (XIntegerFeedbackControl *) f;
127 i.class = IntegerFeedbackClass;
128 i.length = sizeof(xIntegerFeedbackCtl);
130 i.int_to_display = I->int_to_display;
131 length = ((unsigned)(i.length + 3) >> 2);
132 req->length += length;
134 Data(dpy, (char *)&i, length);
135 } else if (f->class == StringFeedbackClass) {
136 XStringFeedbackControl *S;
137 xStringFeedbackCtl s;
139 S = (XStringFeedbackControl *) f;
140 s.class = StringFeedbackClass;
141 s.length = sizeof(xStringFeedbackCtl) +
142 (S->num_keysyms * sizeof(KeySym));
144 s.num_keysyms = S->num_keysyms;
145 req->length += ((unsigned)(s.length + 3) >> 2);
146 length = sizeof(xStringFeedbackCtl);
147 Data(dpy, (char *)&s, length);
148 length = (s.num_keysyms * sizeof(KeySym));
149 Data(dpy, (char *)S->syms_to_display, length);
150 } else if (f->class == BellFeedbackClass) {
151 XBellFeedbackControl *B;
154 B = (XBellFeedbackControl *) f;
155 b.class = BellFeedbackClass;
156 b.length = sizeof(xBellFeedbackCtl);
158 b.percent = B->percent;
160 b.duration = B->duration;
161 length = ((unsigned)(b.length + 3) >> 2);
162 req->length += length;
164 Data(dpy, (char *)&b, length);
165 } else if (f->class == LedFeedbackClass) {
166 XLedFeedbackControl *L;
169 L = (XLedFeedbackControl *) f;
170 l.class = LedFeedbackClass;
171 l.length = sizeof(xLedFeedbackCtl);
173 l.led_mask = L->led_mask;
174 l.led_values = L->led_values;
175 length = ((unsigned)(l.length + 3) >> 2);
176 req->length += length;
178 Data(dpy, (char *)&l, length);
183 u.length = f->length - sizeof(int);
185 length = ((unsigned)(u.length + 3) >> 2);
186 req->length += length;
188 Data(dpy, (char *)&u, length);