1/************************************************************ 2 3Copyright 1989, 1998 The Open Group 4 5Permission to use, copy, modify, distribute, and sell this software and its 6documentation for any purpose is hereby granted without fee, provided that 7the above copyright notice appear in all copies and that both that 8copyright notice and this permission notice appear in supporting 9documentation. 10 11The above copyright notice and this permission notice shall be included in 12all copies or substantial portions of the Software. 13 14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 21Except as contained in this notice, the name of The Open Group shall not be 22used in advertising or otherwise to promote the sale, use or other dealings 23in this Software without prior written authorization from The Open Group. 24 25Copyright 1989 by Hewlett-Packard Company, Palo Alto, California. 26 27 All Rights Reserved 28 29Permission to use, copy, modify, and distribute this software and its 30documentation for any purpose and without fee is hereby granted, 31provided that the above copyright notice appear in all copies and that 32both that copyright notice and this permission notice appear in 33supporting documentation, and that the name of Hewlett-Packard not be 34used in advertising or publicity pertaining to distribution of the 35software without specific, written prior permission. 36 37HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 38ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 39HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 40ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 41WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 42ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 43SOFTWARE. 44 45********************************************************/ 46 47/*********************************************************************** 48 * 49 * XChangeFeedbackControl - Change the control attributes of feedbacks on 50 * an extension device. 51 * 52 */ 53 54#ifdef HAVE_CONFIG_H 55#include <config.h> 56#endif 57 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> 63#include "XIint.h" 64 65int 66XChangeFeedbackControl( 67 register Display *dpy, 68 XDevice *dev, 69 unsigned long mask, 70 XFeedbackControl *f) 71{ 72 int length; 73 xChangeFeedbackControlReq *req; 74 XExtDisplayInfo *info = XInput_find_display(dpy); 75 76 LockDisplay(dpy); 77 if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) 78 return (NoSuchExtension); 79 80 GetReq(ChangeFeedbackControl, req); 81 req->reqType = info->codes->major_opcode; 82 req->ReqType = X_ChangeFeedbackControl; 83 req->deviceid = dev->device_id; 84 req->mask = mask; 85 req->feedbackid = f->class; 86 87 if (f->class == KbdFeedbackClass) { 88 XKbdFeedbackControl *K; 89 xKbdFeedbackCtl k = {0}; 90 91 K = (XKbdFeedbackControl *) f; 92 k.class = KbdFeedbackClass; 93 k.length = sizeof(xKbdFeedbackCtl); 94 k.id = K->id; 95 k.click = K->click; 96 k.percent = K->percent; 97 k.pitch = K->pitch; 98 k.duration = K->duration; 99 k.led_mask = K->led_mask; 100 k.led_values = K->led_value; 101 k.key = K->key; 102 k.auto_repeat_mode = K->auto_repeat_mode; 103 length = ((unsigned)(k.length + 3) >> 2); 104 req->length += length; 105 length <<= 2; 106 Data(dpy, (char *)&k, length); 107 } else if (f->class == PtrFeedbackClass) { 108 XPtrFeedbackControl *P; 109 xPtrFeedbackCtl p = {0}; 110 111 P = (XPtrFeedbackControl *) f; 112 p.class = PtrFeedbackClass; 113 p.length = sizeof(xPtrFeedbackCtl); 114 p.id = P->id; 115 p.num = P->accelNum; 116 p.denom = P->accelDenom; 117 p.thresh = P->threshold; 118 length = ((unsigned)(p.length + 3) >> 2); 119 req->length += length; 120 length <<= 2; 121 Data(dpy, (char *)&p, length); 122 } else if (f->class == IntegerFeedbackClass) { 123 XIntegerFeedbackControl *I; 124 xIntegerFeedbackCtl i = {0}; 125 126 I = (XIntegerFeedbackControl *) f; 127 i.class = IntegerFeedbackClass; 128 i.length = sizeof(xIntegerFeedbackCtl); 129 i.id = I->id; 130 i.int_to_display = I->int_to_display; 131 length = ((unsigned)(i.length + 3) >> 2); 132 req->length += length; 133 length <<= 2; 134 Data(dpy, (char *)&i, length); 135 } else if (f->class == StringFeedbackClass) { 136 XStringFeedbackControl *S; 137 xStringFeedbackCtl s = {0}; 138 139 S = (XStringFeedbackControl *) f; 140 s.class = StringFeedbackClass; 141 s.length = sizeof(xStringFeedbackCtl) + 142 (S->num_keysyms * sizeof(KeySym)); 143 s.id = S->id; 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; 152 xBellFeedbackCtl b = {0}; 153 154 B = (XBellFeedbackControl *) f; 155 b.class = BellFeedbackClass; 156 b.length = sizeof(xBellFeedbackCtl); 157 b.id = B->id; 158 b.percent = B->percent; 159 b.pitch = B->pitch; 160 b.duration = B->duration; 161 length = ((unsigned)(b.length + 3) >> 2); 162 req->length += length; 163 length <<= 2; 164 Data(dpy, (char *)&b, length); 165 } else if (f->class == LedFeedbackClass) { 166 XLedFeedbackControl *L; 167 xLedFeedbackCtl l = {0}; 168 169 L = (XLedFeedbackControl *) f; 170 l.class = LedFeedbackClass; 171 l.length = sizeof(xLedFeedbackCtl); 172 l.id = L->id; 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; 177 length <<= 2; 178 Data(dpy, (char *)&l, length); 179 } else { 180 xFeedbackCtl u = {0}; 181 182 u.class = f->class; 183 u.length = f->length - sizeof(int); 184 u.id = f->id; 185 length = ((unsigned)(u.length + 3) >> 2); 186 req->length += length; 187 length <<= 2; 188 Data(dpy, (char *)&u, length); 189 } 190 191 UnlockDisplay(dpy); 192 SyncHandle(); 193 return (Success); 194} 195