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