summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/XAllowDv.c86
-rw-r--r--src/XChgDCtl.c128
-rw-r--r--src/XChgFCtl.c205
-rw-r--r--src/XChgKMap.c92
-rw-r--r--src/XChgKbd.c86
-rw-r--r--src/XChgPnt.c90
-rw-r--r--src/XChgProp.c96
-rw-r--r--src/XCloseDev.c83
-rw-r--r--src/XDevBell.c87
-rw-r--r--src/XExtInt.c660
-rw-r--r--src/XExtToWire.c450
-rw-r--r--src/XFreeLst.c72
-rw-r--r--src/XGMotion.c140
-rw-r--r--src/XGetBMap.c105
-rw-r--r--src/XGetDCtl.c171
-rw-r--r--src/XGetFCtl.c271
-rw-r--r--src/XGetKMap.c118
-rw-r--r--src/XGetMMap.c102
-rw-r--r--src/XGetProp.c118
-rw-r--r--src/XGetVers.c108
-rw-r--r--src/XGrDvBut.c112
-rw-r--r--src/XGrDvKey.c115
-rw-r--r--src/XGrabDev.c107
-rw-r--r--src/XGtFocus.c90
-rw-r--r--src/XGtSelect.c144
-rw-r--r--src/XListDev.c257
-rw-r--r--src/XOpenDev.c111
-rw-r--r--src/XQueryDv.c196
-rw-r--r--src/XSelect.c92
-rw-r--r--src/XSetBMap.c91
-rw-r--r--src/XSetDVal.c98
-rw-r--r--src/XSetMMap.c89
-rw-r--r--src/XSetMode.c86
-rw-r--r--src/XSndExEv.c121
-rw-r--r--src/XStFocus.c85
-rw-r--r--src/XUngrDev.c84
-rw-r--r--src/XUngrDvB.c91
-rw-r--r--src/XUngrDvK.c91
38 files changed, 5328 insertions, 0 deletions
diff --git a/src/XAllowDv.c b/src/XAllowDv.c
new file mode 100644
index 0000000..200bb4b
--- /dev/null
+++ b/src/XAllowDv.c
@@ -0,0 +1,86 @@
+/* $Xorg: XAllowDv.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XAllowDeviceEvents - Thaw a frozen extension device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XAllowDeviceEvents (dpy, dev, event_mode, time)
+ register Display *dpy;
+ XDevice *dev;
+ int event_mode;
+ Time time;
+ {
+ xAllowDeviceEventsReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(AllowDeviceEvents,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_AllowDeviceEvents;
+ req->deviceid = dev->device_id;
+ req->mode = event_mode;
+ req->time = time;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
+
diff --git a/src/XChgDCtl.c b/src/XChgDCtl.c
new file mode 100644
index 0000000..038136a
--- /dev/null
+++ b/src/XChgDCtl.c
@@ -0,0 +1,128 @@
+/* $Xorg: XChgDCtl.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XChangeDeviceControl - Change the control attributes of an extension
+ * input device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XChangeDeviceControl (dpy, dev, control, d)
+ register Display *dpy;
+ XDevice *dev;
+ int control;
+ XDeviceControl *d;
+ {
+ int length;
+ xChangeDeviceControlReq *req;
+ xChangeDeviceControlReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Add_XChangeDeviceControl) == -1)
+ return (NoSuchExtension);
+
+ GetReq(ChangeDeviceControl,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_ChangeDeviceControl;
+ req->deviceid = dev->device_id;
+ req->control = control;
+
+ switch (control)
+ {
+ case DEVICE_RESOLUTION:
+ {
+ XDeviceResolutionControl *R;
+ xDeviceResolutionCtl r;
+
+ R = (XDeviceResolutionControl *) d;
+ r.control = DEVICE_RESOLUTION;
+ r.length = sizeof (xDeviceResolutionCtl) +
+ R->num_valuators * sizeof(int);
+ r.first_valuator = R->first_valuator;
+ r.num_valuators = R->num_valuators;
+ req->length += ((unsigned)(r.length + 3) >> 2);
+ length = sizeof (xDeviceResolutionCtl);
+ Data (dpy, (char *) &r, length);
+ length = r.num_valuators * sizeof(int);
+ Data (dpy, (char *) R->resolutions, length);
+ if (! _XReply (dpy, (xReply *) &rep, 0, xTrue))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (NoSuchExtension);
+ }
+ else
+ return (rep.status);
+ }
+ default:
+ {
+ xDeviceCtl u;
+
+ u.control = d->control;
+ u.length = d->length - sizeof (int);
+ length = ((unsigned)(u.length + 3) >> 2);
+ req->length += length;
+ length <<= 2;
+ Data (dpy, (char *) &u, length);
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
+
diff --git a/src/XChgFCtl.c b/src/XChgFCtl.c
new file mode 100644
index 0000000..75fe93c
--- /dev/null
+++ b/src/XChgFCtl.c
@@ -0,0 +1,205 @@
+/* $Xorg: XChgFCtl.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XChangeFeedbackControl - Change the control attributes of feedbacks on
+ * an extension device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XChangeFeedbackControl (dpy, dev, mask, f)
+ register Display *dpy;
+ XDevice *dev;
+ unsigned long mask;
+ XFeedbackControl *f;
+ {
+ int length;
+ xChangeFeedbackControlReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(ChangeFeedbackControl,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_ChangeFeedbackControl;
+ req->deviceid = dev->device_id;
+ req->mask = mask;
+ req->feedbackid = f->class;
+
+ if (f->class == KbdFeedbackClass)
+ {
+ XKbdFeedbackControl *K;
+ xKbdFeedbackCtl k;
+
+ K = (XKbdFeedbackControl *) f;
+ k.class = KbdFeedbackClass;
+ k.length = sizeof (xKbdFeedbackCtl);
+ k.id = K->id;
+ k.click = K->click;
+ k.percent = K->percent;
+ k.pitch = K->pitch;
+ k.duration = K->duration;
+ k.led_mask = K->led_mask;
+ k.led_values = K->led_value;
+ k.key = K->key;
+ k.auto_repeat_mode = K->auto_repeat_mode;
+ length = ((unsigned)(k.length + 3) >> 2);
+ req->length += length;
+ length <<= 2;
+ Data (dpy, (char *) &k, length);
+ }
+ else if (f->class == PtrFeedbackClass)
+ {
+ XPtrFeedbackControl *P;
+ xPtrFeedbackCtl p;
+
+ P = (XPtrFeedbackControl *) f;
+ p.class = PtrFeedbackClass;
+ p.length = sizeof (xPtrFeedbackCtl);
+ p.id = P->id;
+ p.num = P->accelNum;
+ p.denom = P->accelDenom;
+ p.thresh = P->threshold;
+ length = ((unsigned)(p.length + 3) >> 2);
+ req->length += length;
+ length <<= 2;
+ Data (dpy, (char *) &p, length);
+ }
+ else if (f->class == IntegerFeedbackClass)
+ {
+ XIntegerFeedbackControl *I;
+ xIntegerFeedbackCtl i;
+
+ I = (XIntegerFeedbackControl *) f;
+ i.class = IntegerFeedbackClass;
+ i.length = sizeof (xIntegerFeedbackCtl);
+ i.id = I->id;
+ i.int_to_display = I->int_to_display;
+ length = ((unsigned)(i.length + 3) >> 2);
+ req->length += length;
+ length <<= 2;
+ Data (dpy, (char *) &i, length);
+ }
+ else if (f->class == StringFeedbackClass)
+ {
+ XStringFeedbackControl *S;
+ xStringFeedbackCtl s;
+
+ S = (XStringFeedbackControl *) f;
+ s.class = StringFeedbackClass;
+ s.length = sizeof (xStringFeedbackCtl) +
+ (S->num_keysyms * sizeof (KeySym));
+ s.id = S->id;
+ s.num_keysyms = S->num_keysyms;
+ req->length += ((unsigned)(s.length + 3) >> 2);
+ length = sizeof (xStringFeedbackCtl);
+ Data (dpy, (char *) &s, length);
+ length = (s.num_keysyms * sizeof (KeySym));
+ Data (dpy, (char *) S->syms_to_display, length);
+ }
+ else if (f->class == BellFeedbackClass)
+ {
+ XBellFeedbackControl *B;
+ xBellFeedbackCtl b;
+
+ B = (XBellFeedbackControl *) f;
+ b.class = BellFeedbackClass;
+ b.length = sizeof (xBellFeedbackCtl);
+ b.id = B->id;
+ b.percent = B->percent;
+ b.pitch = B->pitch;
+ b.duration = B->duration;
+ length = ((unsigned)(b.length + 3) >> 2);
+ req->length += length;
+ length <<= 2;
+ Data (dpy, (char *) &b, length);
+ }
+ else if (f->class == LedFeedbackClass)
+ {
+ XLedFeedbackControl *L;
+ xLedFeedbackCtl l;
+
+ L = (XLedFeedbackControl *) f;
+ l.class = LedFeedbackClass;
+ l.length = sizeof (xLedFeedbackCtl);
+ l.id = L->id;
+ l.led_mask = L->led_mask;
+ l.led_values = L->led_values;
+ length = ((unsigned)(l.length + 3) >> 2);
+ req->length += length;
+ length <<= 2;
+ Data (dpy, (char *) &l, length);
+ }
+ else
+ {
+ xFeedbackCtl u;
+
+ u.class = f->class;
+ u.length = f->length - sizeof (int);
+ u.id = f->id;
+ length = ((unsigned)(u.length + 3) >> 2);
+ req->length += length;
+ length <<= 2;
+ Data (dpy, (char *) &u, length);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
+
diff --git a/src/XChgKMap.c b/src/XChgKMap.c
new file mode 100644
index 0000000..74c1481
--- /dev/null
+++ b/src/XChgKMap.c
@@ -0,0 +1,92 @@
+/* $Xorg: XChgKMap.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XChangeDeviceKeyMapping - change the keymap of an extension device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XChangeDeviceKeyMapping (dpy, dev, first, syms_per_code, keysyms, count)
+ register Display *dpy;
+ XDevice *dev;
+ int first;
+ int syms_per_code;
+ KeySym *keysyms;
+ int count;
+ {
+ register long nbytes;
+ xChangeDeviceKeyMappingReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(ChangeDeviceKeyMapping,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_ChangeDeviceKeyMapping;
+ req->deviceid = dev->device_id;
+ req->firstKeyCode = first;
+ req->keyCodes = count;
+ req->keySymsPerKeyCode = syms_per_code;
+ req->length += count * syms_per_code;
+ nbytes = syms_per_code * count * sizeof (CARD32);
+ Data (dpy, (char *)keysyms, nbytes);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
diff --git a/src/XChgKbd.c b/src/XChgKbd.c
new file mode 100644
index 0000000..089f124
--- /dev/null
+++ b/src/XChgKbd.c
@@ -0,0 +1,86 @@
+/* $Xorg: XChgKbd.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XChangeKeyboardDevice - Change the device used as the X keyboard.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XChangeKeyboardDevice (dpy, dev)
+ register Display *dpy;
+ XDevice *dev;
+ {
+ xChangeKeyboardDeviceReq *req;
+ xChangeKeyboardDeviceReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(ChangeKeyboardDevice,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_ChangeKeyboardDevice;
+ req->deviceid = dev->device_id;
+ rep.status = Success;
+
+ (void) _XReply (dpy, (xReply *) &rep, 0, xTrue);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.status);
+ }
+
diff --git a/src/XChgPnt.c b/src/XChgPnt.c
new file mode 100644
index 0000000..e1dbb1e
--- /dev/null
+++ b/src/XChgPnt.c
@@ -0,0 +1,90 @@
+/* $Xorg: XChgPnt.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XChangePointerDevice - Change the device used as the X Pointer.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XChangePointerDevice (dpy, dev, xaxis, yaxis)
+ register Display *dpy;
+ XDevice *dev;
+ int xaxis;
+ int yaxis;
+ {
+ xChangePointerDeviceReq *req;
+ xChangePointerDeviceReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(ChangePointerDevice,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_ChangePointerDevice;
+ req->deviceid = dev->device_id;
+ req->xaxis = xaxis;
+ req->yaxis = yaxis;
+ rep.status = Success;
+
+ (void) _XReply (dpy, (xReply *) &rep, 0, xTrue);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.status);
+ }
+
diff --git a/src/XChgProp.c b/src/XChgProp.c
new file mode 100644
index 0000000..2426759
--- /dev/null
+++ b/src/XChgProp.c
@@ -0,0 +1,96 @@
+/* $Xorg: XChgProp.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XChangeDeviceDontPropagateList - Get the dont_propagate_list for a
+ * window.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XChangeDeviceDontPropagateList (dpy, window, count, events, mode)
+ register Display *dpy;
+ Window window;
+ int count;
+ XEventClass *events;
+ int mode;
+ {
+ xChangeDeviceDontPropagateListReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(ChangeDeviceDontPropagateList,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_ChangeDeviceDontPropagateList;
+ req->window = window;
+ req->count = count;
+ req->mode = mode;
+ req->length += count;
+
+ /* note: Data is a macro that uses its arguments multiple
+ times, so "nvalues" is changed in a separate assignment
+ statement */
+
+ count <<= 2;
+ Data32 (dpy, (long *) events, count);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
+
diff --git a/src/XCloseDev.c b/src/XCloseDev.c
new file mode 100644
index 0000000..f4da25e
--- /dev/null
+++ b/src/XCloseDev.c
@@ -0,0 +1,83 @@
+/* $Xorg: XCloseDev.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XCloseDevice - Request the server to close an extension device.
+ *
+ */
+
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XI.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XCloseDevice(dpy, dev)
+ register Display *dpy;
+ register XDevice *dev;
+ {
+ xCloseDeviceReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(CloseDevice,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_CloseDevice;
+ req->deviceid = dev->device_id;
+
+ XFree ((char *)dev);
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return (Success);
+ }
+
diff --git a/src/XDevBell.c b/src/XDevBell.c
new file mode 100644
index 0000000..b352a06
--- /dev/null
+++ b/src/XDevBell.c
@@ -0,0 +1,87 @@
+/* $Xorg: XDevBell.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XDeviceBell - Ring a bell on an extension device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XDeviceBell (dpy, dev, feedbackclass, feedbackid, percent)
+ register Display *dpy;
+ XDevice *dev;
+ XID feedbackclass, feedbackid;
+ int percent;
+ {
+ xDeviceBellReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Add_XDeviceBell) == -1)
+ return (NoSuchExtension);
+
+ GetReq(DeviceBell,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_DeviceBell;
+ req->deviceid = dev->device_id;
+ req->feedbackclass = feedbackclass;
+ req->feedbackid = feedbackid;
+ req->percent = percent;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
+
diff --git a/src/XExtInt.c b/src/XExtInt.c
new file mode 100644
index 0000000..b8da8a0
--- /dev/null
+++ b/src/XExtInt.c
@@ -0,0 +1,660 @@
+/* $Xorg: XExtInt.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * Input Extension library internal functions.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <stdio.h>
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+#define ENQUEUE_EVENT True
+#define DONT_ENQUEUE False
+
+static XExtensionInfo *xinput_info;
+static /* const */ char *xinput_extension_name = INAME;
+static int XInputClose();
+static char *XInputError();
+static Bool XInputWireToEvent();
+Status _XiEventToWire();
+static /* const */ XEvent emptyevent;
+
+typedef struct _XInputData
+ {
+ XEvent data;
+ XExtensionVersion *vers;
+ } XInputData;
+
+#define XInputCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xinput_extension_name, val)
+
+static /* const */ XExtensionHooks xinput_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ XInputClose, /* close_display */
+ XInputWireToEvent, /* wire_to_event */
+ _XiEventToWire, /* event_to_wire */
+ NULL, /* error */
+ XInputError, /* error_string */
+};
+
+static char *XInputErrorList[] = {
+ "BadDevice, invalid or uninitialized input device", /* BadDevice */
+ "BadEvent, invalid event type", /* BadEvent */
+ "BadMode, invalid mode parameter", /* BadMode */
+ "DeviceBusy, device is busy", /* DeviceBusy */
+ "BadClass, invalid event class", /* BadClass */
+};
+
+XEXT_GENERATE_FIND_DISPLAY (XInput_find_display, xinput_info,
+ xinput_extension_name, &xinput_extension_hooks, IEVENTS, NULL)
+
+static XEXT_GENERATE_ERROR_STRING (XInputError, xinput_extension_name,
+ IERRORS, XInputErrorList)
+/*******************************************************************
+ *
+ * Input extension versions.
+ *
+ */
+
+static XExtensionVersion versions[] = {{XI_Absent,0,0},
+ {XI_Present, XI_Initial_Release_Major, XI_Initial_Release_Minor},
+ {XI_Present, XI_Add_XDeviceBell_Major, XI_Add_XDeviceBell_Minor},
+ {XI_Present, XI_Add_XSetDeviceValuators_Major,
+ XI_Add_XSetDeviceValuators_Minor},
+ {XI_Present, XI_Add_XChangeDeviceControl_Major,
+ XI_Add_XChangeDeviceControl_Minor}};
+
+/***********************************************************************
+ *
+ * Return errors reported by this extension.
+ *
+ */
+
+void _xibaddevice (dpy, error)
+ Display *dpy;
+ int *error;
+ {
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+ *error = info->codes->first_error + XI_BadDevice;
+ }
+
+void _xibadclass (dpy, error)
+ Display *dpy;
+ int *error;
+ {
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+ *error = info->codes->first_error + XI_BadClass;
+ }
+
+void _xibadevent (dpy, error)
+ Display *dpy;
+ int *error;
+ {
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+ *error = info->codes->first_error + XI_BadEvent;
+ }
+
+void _xibadmode (dpy, error)
+ Display *dpy;
+ int *error;
+ {
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+ *error = info->codes->first_error + XI_BadMode;
+ }
+
+void _xidevicebusy (dpy, error)
+ Display *dpy;
+ int *error;
+ {
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+ *error = info->codes->first_error + XI_DeviceBusy;
+ }
+
+/***********************************************************************
+ *
+ * Check to see if the input extension is installed in the server.
+ * Also check to see if the version is >= the requested version.
+ *
+ */
+
+_XiCheckExtInit(dpy, version_index)
+ register Display *dpy;
+ register int version_index;
+ {
+ XExtensionVersion *ext;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ XInputCheckExtension (dpy, info, -1);
+
+ if (info->data == NULL)
+ {
+ info->data = (XPointer) Xmalloc (sizeof (XInputData));
+ if (!info->data)
+ {
+ UnlockDisplay(dpy);
+ return (-1);
+ }
+ ((XInputData *) info->data)->vers =
+ XGetExtensionVersion (dpy, "XInputExtension");
+ }
+
+ if (versions[version_index].major_version > Dont_Check)
+ {
+ ext = ((XInputData *) info->data)->vers;
+ if ((ext->major_version < versions[version_index].major_version) ||
+ ((ext->major_version == versions[version_index].major_version) &&
+ (ext->minor_version < versions[version_index].minor_version)))
+ {
+ UnlockDisplay(dpy);
+ return (-1);
+ }
+ }
+ return (0);
+ }
+
+/***********************************************************************
+ *
+ * Close display routine.
+ *
+ */
+
+static int
+XInputClose (dpy, codes)
+ Display *dpy;
+ XExtCodes *codes;
+ {
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+
+ if(info->data != NULL) {
+ XFree((char *)((XInputData *) info->data)->vers);
+ XFree((char *)info->data);
+ }
+ return XextRemoveDisplay (xinput_info, dpy);
+ }
+
+
+static int
+Ones(mask)
+ Mask mask;
+{
+ register Mask y;
+
+ y = (mask >> 1) &033333333333;
+ y = mask - y - ((y >>1) & 033333333333);
+ return (((y + (y >> 3)) & 030707070707) % 077);
+}
+
+/***********************************************************************
+ *
+ * Handle Input extension events.
+ * Reformat a wire event into an XEvent structure of the right type.
+ *
+ */
+
+static Bool
+XInputWireToEvent (dpy, re, event)
+ Display *dpy;
+ XEvent *re;
+ xEvent *event;
+ {
+ unsigned int type, reltype;
+ unsigned int i,j;
+ XExtDisplayInfo *info = XInput_find_display (dpy);
+ XEvent *save = (XEvent *) info->data;
+
+ type = event->u.u.type & 0x7f;
+ reltype = (type - info->codes->first_event);
+
+
+
+ if (reltype != XI_DeviceValuator &&
+ reltype != XI_DeviceKeystateNotify &&
+ reltype != XI_DeviceButtonstateNotify)
+ {
+ *save = emptyevent;
+ save->type = type;
+ ((XAnyEvent *)save)->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ ((XAnyEvent *)save)->send_event = ((event->u.u.type & 0x80) != 0);
+ ((XAnyEvent *)save)->display = dpy;
+ }
+
+ switch (reltype)
+ {
+ case XI_DeviceMotionNotify:
+ {
+ register XDeviceMotionEvent *ev = (XDeviceMotionEvent*) save;
+ deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event;
+
+ ev->root = ev2->root;
+ ev->window = ev2->event;
+ ev->subwindow = ev2->child;
+ ev->time = ev2->time;
+ ev->x_root = ev2->root_x;
+ ev->y_root = ev2->root_y;
+ ev->x = ev2->event_x;
+ ev->y = ev2->event_y;
+ ev->state = ev2->state;
+ ev->same_screen = ev2->same_screen;
+ ev->is_hint = ev2->detail;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ return (DONT_ENQUEUE);
+ }
+ break;
+ case XI_DeviceKeyPress:
+ case XI_DeviceKeyRelease:
+ {
+ register XDeviceKeyEvent *ev = (XDeviceKeyEvent*) save;
+ deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event;
+
+ ev->root = ev2->root;
+ ev->window = ev2->event;
+ ev->subwindow = ev2->child;
+ ev->time = ev2->time;
+ ev->x_root = ev2->root_x;
+ ev->y_root = ev2->root_y;
+ ev->x = ev2->event_x;
+ ev->y = ev2->event_y;
+ ev->state = ev2->state;
+ ev->same_screen = ev2->same_screen;
+ ev->keycode = ev2->detail;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ if (ev2->deviceid & MORE_EVENTS)
+ return (DONT_ENQUEUE);
+ else
+ {
+ *re = *save;
+ return (ENQUEUE_EVENT);
+ }
+ }
+ break;
+ case XI_DeviceButtonPress:
+ case XI_DeviceButtonRelease:
+ {
+ register XDeviceButtonEvent *ev = (XDeviceButtonEvent*) save;
+ deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event;
+
+ ev->root = ev2->root;
+ ev->window = ev2->event;
+ ev->subwindow = ev2->child;
+ ev->time = ev2->time;
+ ev->x_root = ev2->root_x;
+ ev->y_root = ev2->root_y;
+ ev->x = ev2->event_x;
+ ev->y = ev2->event_y;
+ ev->state = ev2->state;
+ ev->same_screen = ev2->same_screen;
+ ev->button = ev2->detail;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ if (ev2->deviceid & MORE_EVENTS)
+ return (DONT_ENQUEUE);
+ else
+ {
+ *re = *save;
+ return (ENQUEUE_EVENT);
+ }
+ }
+ break;
+ case XI_ProximityIn:
+ case XI_ProximityOut:
+ {
+ register XProximityNotifyEvent *ev =
+ (XProximityNotifyEvent *) save;
+ deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event;
+
+ ev->root = ev2->root;
+ ev->window = ev2->event;
+ ev->subwindow = ev2->child;
+ ev->time = ev2->time;
+ ev->x_root = ev2->root_x;
+ ev->y_root = ev2->root_y;
+ ev->x = ev2->event_x;
+ ev->y = ev2->event_y;
+ ev->state = ev2->state;
+ ev->same_screen = ev2->same_screen;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ if (ev2->deviceid & MORE_EVENTS)
+ return (DONT_ENQUEUE);
+ else
+ {
+ *re = *save;
+ return (ENQUEUE_EVENT);
+ }
+ }
+ break;
+ case XI_DeviceValuator:
+ {
+ deviceValuator *xev = (deviceValuator *) event;
+ int save_type = save->type - info->codes->first_event;
+
+ if (save_type == XI_DeviceKeyPress ||
+ save_type == XI_DeviceKeyRelease)
+ {
+ XDeviceKeyEvent *kev = (XDeviceKeyEvent*) save;
+ kev->device_state = xev->device_state;
+ kev->axes_count = xev->num_valuators;
+ kev->first_axis = xev->first_valuator;
+ i = xev->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: kev->axis_data[5] = xev->valuator5;
+ case 5: kev->axis_data[4] = xev->valuator4;
+ case 4: kev->axis_data[3] = xev->valuator3;
+ case 3: kev->axis_data[2] = xev->valuator2;
+ case 2: kev->axis_data[1] = xev->valuator1;
+ case 1: kev->axis_data[0] = xev->valuator0;
+ }
+ }
+ else if (save_type == XI_DeviceButtonPress ||
+ save_type == XI_DeviceButtonRelease)
+ {
+ XDeviceButtonEvent *bev = (XDeviceButtonEvent*) save;
+ bev->device_state = xev->device_state;
+ bev->axes_count = xev->num_valuators;
+ bev->first_axis = xev->first_valuator;
+ i = xev->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: bev->axis_data[5] = xev->valuator5;
+ case 5: bev->axis_data[4] = xev->valuator4;
+ case 4: bev->axis_data[3] = xev->valuator3;
+ case 3: bev->axis_data[2] = xev->valuator2;
+ case 2: bev->axis_data[1] = xev->valuator1;
+ case 1: bev->axis_data[0] = xev->valuator0;
+ }
+ }
+ else if (save_type == XI_DeviceMotionNotify)
+ {
+ XDeviceMotionEvent *mev = (XDeviceMotionEvent*) save;
+ mev->device_state = xev->device_state;
+ mev->axes_count = xev->num_valuators;
+ mev->first_axis = xev->first_valuator;
+ i = xev->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: mev->axis_data[5] = xev->valuator5;
+ case 5: mev->axis_data[4] = xev->valuator4;
+ case 4: mev->axis_data[3] = xev->valuator3;
+ case 3: mev->axis_data[2] = xev->valuator2;
+ case 2: mev->axis_data[1] = xev->valuator1;
+ case 1: mev->axis_data[0] = xev->valuator0;
+ }
+ }
+ else if (save_type == XI_ProximityIn ||
+ save_type == XI_ProximityOut)
+ {
+ XProximityNotifyEvent *pev =
+ (XProximityNotifyEvent*) save;
+ pev->device_state = xev->device_state;
+ pev->axes_count = xev->num_valuators;
+ pev->first_axis = xev->first_valuator;
+ i = xev->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: pev->axis_data[5] = xev->valuator5;
+ case 5: pev->axis_data[4] = xev->valuator4;
+ case 4: pev->axis_data[3] = xev->valuator3;
+ case 3: pev->axis_data[2] = xev->valuator2;
+ case 2: pev->axis_data[1] = xev->valuator1;
+ case 1: pev->axis_data[0] = xev->valuator0;
+ }
+ }
+ else if (save_type == XI_DeviceStateNotify)
+ {
+ XDeviceStateNotifyEvent *sev =
+ (XDeviceStateNotifyEvent*) save;
+ XInputClass *any = (XInputClass *) &sev->data[0];
+ XValuatorStatus *v;
+
+ for (i=0; i<sev->num_classes; i++)
+ if (any->class != ValuatorClass)
+ any = (XInputClass *) ((char *) any + any->length);
+ v = (XValuatorStatus *) any;
+ i = v->num_valuators;
+ j = xev->num_valuators;
+ if (j > 3) j = 3;
+ switch (j)
+ {
+ case 3: v->valuators[i + 2] = xev->valuator2;
+ case 2: v->valuators[i + 1] = xev->valuator1;
+ case 1: v->valuators[i + 0] = xev->valuator0;
+ }
+ v->num_valuators += j;
+
+ }
+ *re = *save;
+ return (ENQUEUE_EVENT);
+ }
+ break;
+ case XI_DeviceFocusIn:
+ case XI_DeviceFocusOut:
+ {
+ register XDeviceFocusChangeEvent *ev =
+ (XDeviceFocusChangeEvent *) re;
+ deviceFocus *fev = (deviceFocus *) event;
+
+ *ev = *((XDeviceFocusChangeEvent *) save);
+ ev->window = fev->window;
+ ev->time = fev->time;
+ ev->mode = fev->mode;
+ ev->detail = fev->detail;
+ ev->deviceid = fev->deviceid & DEVICE_BITS;
+ return (ENQUEUE_EVENT);
+ }
+ break;
+ case XI_DeviceStateNotify:
+ {
+ XDeviceStateNotifyEvent *stev =
+ (XDeviceStateNotifyEvent *) save;
+ deviceStateNotify *sev = (deviceStateNotify *) event;
+ char *data;
+
+ stev->window = None;
+ stev->deviceid = sev->deviceid & DEVICE_BITS;
+ stev->time = sev->time;
+ stev->num_classes = Ones ((Mask)sev->classes_reported & InputClassBits);
+ data = (char *) &stev->data[0];
+ if (sev->classes_reported & (1 << KeyClass))
+ {
+ register XKeyStatus *kstev = (XKeyStatus *) data;
+ kstev->class = KeyClass;
+ kstev->length = sizeof (XKeyStatus);
+ kstev->num_keys = sev->num_keys;
+ memcpy ((char *) &kstev->keys[0], (char *) &sev->keys[0], 4);
+ data += sizeof (XKeyStatus);
+ }
+ if (sev->classes_reported & (1 << ButtonClass))
+ {
+ register XButtonStatus *bev = (XButtonStatus *) data;
+ bev->class = ButtonClass;
+ bev->length = sizeof (XButtonStatus);
+ bev->num_buttons = sev->num_buttons;
+ memcpy ((char *) bev->buttons, (char *) sev->buttons, 4);
+ data += sizeof (XButtonStatus);
+ }
+ if (sev->classes_reported & (1 << ValuatorClass))
+ {
+ register XValuatorStatus *vev = (XValuatorStatus *) data;
+ vev->class = ValuatorClass;
+ vev->length = sizeof (XValuatorStatus);
+ vev->num_valuators = sev->num_valuators;
+ vev->mode = sev->classes_reported >> ModeBitsShift;
+ j = sev->num_valuators;
+ if (j > 3) j = 3;
+ switch (j)
+ {
+ case 3: vev->valuators[2] = sev->valuator2;
+ case 2: vev->valuators[1] = sev->valuator1;
+ case 1: vev->valuators[0] = sev->valuator0;
+ }
+ data += sizeof (XValuatorStatus);
+ }
+ if (sev->deviceid & MORE_EVENTS)
+ return (DONT_ENQUEUE);
+ else
+ {
+ *re = *save;
+ stev = (XDeviceStateNotifyEvent *) re;
+ return (ENQUEUE_EVENT);
+ }
+ }
+ break;
+ case XI_DeviceKeystateNotify:
+ {
+ int i;
+ XInputClass *anyclass;
+ register XKeyStatus *kv;
+ deviceKeyStateNotify *ksev = (deviceKeyStateNotify *) event;
+ XDeviceStateNotifyEvent *kstev =
+ (XDeviceStateNotifyEvent *) save;
+
+ anyclass = (XInputClass *) &kstev->data[0];
+ for (i=0; i<kstev->num_classes; i++)
+ if (anyclass->class == KeyClass)
+ break;
+ else
+ anyclass = (XInputClass *) ((char *) anyclass +
+ anyclass->length);
+
+ kv = (XKeyStatus *) anyclass;
+ kv->num_keys = 256;
+ memcpy ((char *) &kv->keys[4], (char *) ksev->keys, 28);
+ if (ksev->deviceid & MORE_EVENTS)
+ return (DONT_ENQUEUE);
+ else
+ {
+ *re = *save;
+ kstev = (XDeviceStateNotifyEvent *) re;
+ return (ENQUEUE_EVENT);
+ }
+ }
+ break;
+ case XI_DeviceButtonstateNotify:
+ {
+ int i;
+ XInputClass *anyclass;
+ register XButtonStatus *bv;
+ deviceButtonStateNotify *bsev = (deviceButtonStateNotify *) event;
+ XDeviceStateNotifyEvent *bstev =
+ (XDeviceStateNotifyEvent *) save;
+
+
+ anyclass = (XInputClass *) &bstev->data[0];
+ for (i=0; i<bstev->num_classes; i++)
+ if (anyclass->class == ButtonClass)
+ break;
+ else
+ anyclass = (XInputClass *) ((char *) anyclass +
+ anyclass->length);
+
+ bv = (XButtonStatus *) anyclass;
+ bv->num_buttons = 256;
+ memcpy ((char *) &bv->buttons[4], (char *) bsev->buttons, 28);
+ if (bsev->deviceid & MORE_EVENTS)
+ return (DONT_ENQUEUE);
+ else
+ {
+ *re = *save;
+ bstev = (XDeviceStateNotifyEvent *) re;
+ return (ENQUEUE_EVENT);
+ }
+ }
+ break;
+ case XI_DeviceMappingNotify:
+ {
+ register XDeviceMappingEvent *ev = (XDeviceMappingEvent *) re;
+ deviceMappingNotify *ev2 = (deviceMappingNotify *) event;
+
+ *ev = *((XDeviceMappingEvent *) save);
+ ev->window = 0;
+ ev->first_keycode = ev2->firstKeyCode;
+ ev->request = ev2->request;
+ ev->count = ev2->count;
+ ev->time = ev2->time;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ return (ENQUEUE_EVENT);
+ }
+ break;
+ case XI_ChangeDeviceNotify:
+ {
+ register XChangeDeviceNotifyEvent *ev =
+ (XChangeDeviceNotifyEvent *) re;
+ changeDeviceNotify *ev2 = (changeDeviceNotify *) event;
+
+ *ev = *((XChangeDeviceNotifyEvent *) save);
+ ev->window = 0;
+ ev->request = ev2->request;
+ ev->time = ev2->time;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ return (ENQUEUE_EVENT);
+ }
+ break;
+ default:
+ printf ("XInputWireToEvent: UNKNOWN WIRE EVENT! type=%d\n",type);
+ break;
+ }
+
+ return (DONT_ENQUEUE);
+ }
diff --git a/src/XExtToWire.c b/src/XExtToWire.c
new file mode 100644
index 0000000..abdaf14
--- /dev/null
+++ b/src/XExtToWire.c
@@ -0,0 +1,450 @@
+/* $Xorg: XExtToWire.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/****************************************************************
+ *
+ * XExtToWire.c - reformat an XEvent into a wire event.
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+
+#include "Xlibint.h"
+#include "XInput.h"
+#include "XIproto.h"
+#include "extutil.h"
+
+Status
+_XiEventToWire(dpy, re, event, count)
+ register Display *dpy; /* pointer to display structure */
+ register XEvent *re; /* pointer to client event */
+ register xEvent **event; /* wire protocol event */
+ register int *count;
+ {
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+ int i;
+
+ switch ((re->type & 0x7f) - info->codes->first_event)
+ {
+ case XI_DeviceKeyPress:
+ case XI_DeviceKeyRelease:
+ {
+ register XDeviceKeyEvent *ev = (XDeviceKeyEvent*) re;
+ register deviceKeyButtonPointer *kev;
+ register deviceValuator *vev;
+
+ *count = 2;
+ kev = (deviceKeyButtonPointer *) Xmalloc (*count * sizeof (xEvent));
+ if (!kev)
+ return(_XUnknownNativeEvent(dpy, re, event));
+ *event = (xEvent *) kev;
+
+ kev->type = ev->type;
+ kev->root = ev->root;
+ kev->event = ev->window;
+ kev->child = ev->subwindow;
+ kev->time = ev->time;
+ kev->event_x = ev->x ;
+ kev->event_y = ev->y ;
+ kev->root_x = ev->x_root;
+ kev->root_y = ev->y_root;
+ kev->state = ev->state;
+ kev->same_screen = ev->same_screen;
+ kev->detail = ev->keycode;
+ kev->deviceid = ev->deviceid | MORE_EVENTS;
+
+ vev = (deviceValuator *) ++kev;
+ vev->type = info->codes->first_event + XI_DeviceValuator;
+ vev->deviceid = ev->deviceid;
+ vev->device_state = ev->device_state;
+ vev->first_valuator = ev->first_axis;
+ vev->num_valuators = ev->axes_count;
+ i = vev->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: vev->valuator5 = ev->axis_data[5];
+ case 5: vev->valuator4 = ev->axis_data[4];
+ case 4: vev->valuator3 = ev->axis_data[3];
+ case 3: vev->valuator2 = ev->axis_data[2];
+ case 2: vev->valuator1 = ev->axis_data[1];
+ case 1: vev->valuator0 = ev->axis_data[0];
+ }
+ break;
+ }
+ case XI_ProximityIn:
+ case XI_ProximityOut:
+ {
+ register XProximityNotifyEvent *ev =
+ (XProximityNotifyEvent *) re;
+ register deviceKeyButtonPointer *pev;
+ register deviceValuator *vev;
+
+ *count = 2;
+ pev = (deviceKeyButtonPointer *) Xmalloc (*count * sizeof (xEvent));
+ if (!pev)
+ return(_XUnknownNativeEvent(dpy, re, event));
+ *event = (xEvent *) pev;
+
+ pev->type = ev->type;
+ pev->root = ev->root;
+ pev->event = ev->window;
+ pev->child = ev->subwindow;
+ pev->time = ev->time;
+ pev->event_x = ev->x ;
+ pev->event_y = ev->y ;
+ pev->root_x = ev->x_root;
+ pev->root_y = ev->y_root;
+ pev->state = ev->state;
+ pev->same_screen = ev->same_screen;
+ pev->deviceid = ev->deviceid | MORE_EVENTS;
+
+ vev = (deviceValuator *) ++pev;
+ vev->type = info->codes->first_event + XI_DeviceValuator;
+ vev->deviceid = ev->deviceid;
+ vev->device_state = ev->device_state;
+ vev->first_valuator = ev->first_axis;
+ vev->num_valuators = ev->axes_count;
+
+ i = vev->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: vev->valuator5 = ev->axis_data[5];
+ case 5: vev->valuator4 = ev->axis_data[4];
+ case 4: vev->valuator3 = ev->axis_data[3];
+ case 3: vev->valuator2 = ev->axis_data[2];
+ case 2: vev->valuator1 = ev->axis_data[1];
+ case 1: vev->valuator0 = ev->axis_data[0];
+ }
+ break;
+ }
+ case XI_DeviceButtonPress:
+ case XI_DeviceButtonRelease:
+ {
+ register XDeviceButtonEvent *ev =
+ (XDeviceButtonEvent *) re;
+ register deviceKeyButtonPointer *bev;
+ register deviceValuator *vev;
+
+ *count = 2;
+ bev = (deviceKeyButtonPointer *) Xmalloc (*count * sizeof (xEvent));
+ if (!bev)
+ return(_XUnknownNativeEvent(dpy, re, event));
+ *event = (xEvent *) bev;
+
+ bev->type = ev->type;
+ bev->root = ev->root;
+ bev->event = ev->window;
+ bev->child = ev->subwindow;
+ bev->time = ev->time;
+ bev->event_x = ev->x ;
+ bev->event_y = ev->y ;
+ bev->root_x = ev->x_root;
+ bev->root_y = ev->y_root;
+ bev->state = ev->state;
+ bev->same_screen = ev->same_screen;
+ bev->detail = ev->button;
+ bev->deviceid = ev->deviceid | MORE_EVENTS;
+
+ vev = (deviceValuator *) ++bev;
+ vev->type = info->codes->first_event + XI_DeviceValuator;
+ vev->deviceid = ev->deviceid;
+ vev->device_state = ev->device_state;
+ vev->first_valuator = ev->first_axis;
+ vev->num_valuators = ev->axes_count;
+
+ i = vev->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: vev->valuator5 = ev->axis_data[5];
+ case 5: vev->valuator4 = ev->axis_data[4];
+ case 4: vev->valuator3 = ev->axis_data[3];
+ case 3: vev->valuator2 = ev->axis_data[2];
+ case 2: vev->valuator1 = ev->axis_data[1];
+ case 1: vev->valuator0 = ev->axis_data[0];
+ }
+ break;
+ }
+ case XI_DeviceMotionNotify:
+ {
+ register XDeviceMotionEvent *ev =
+ (XDeviceMotionEvent *)re;
+ register deviceKeyButtonPointer *mev;
+ register deviceValuator *vev;
+
+ *count = 2;
+ mev = (deviceKeyButtonPointer *) Xmalloc (*count * sizeof (xEvent));
+ if (!mev)
+ return(_XUnknownNativeEvent(dpy, re, event));
+ *event = (xEvent *) mev;
+
+ mev->type = ev->type;
+ mev->root = ev->root;
+ mev->event = ev->window;
+ mev->child = ev->subwindow;
+ mev->time = ev->time;
+ mev->event_x = ev->x ;
+ mev->event_y = ev->y ;
+ mev->root_x = ev->x_root;
+ mev->root_y = ev->y_root;
+ mev->state = ev->state;
+ mev->same_screen = ev->same_screen;
+ mev->detail = ev->is_hint;
+ mev->deviceid = ev->deviceid | MORE_EVENTS;
+
+ vev = (deviceValuator *) ++mev;
+ vev->type = info->codes->first_event + XI_DeviceValuator;
+ vev->deviceid = ev->deviceid;
+ vev->device_state = ev->device_state;
+ vev->first_valuator = ev->first_axis;
+ vev->num_valuators = ev->axes_count;
+
+ i = vev->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: vev->valuator5 = ev->axis_data[5];
+ case 5: vev->valuator4 = ev->axis_data[4];
+ case 4: vev->valuator3 = ev->axis_data[3];
+ case 3: vev->valuator2 = ev->axis_data[2];
+ case 2: vev->valuator1 = ev->axis_data[1];
+ case 1: vev->valuator0 = ev->axis_data[0];
+ }
+ break;
+ }
+ case XI_DeviceFocusIn:
+ case XI_DeviceFocusOut:
+ {
+ register XDeviceFocusChangeEvent *ev =
+ (XDeviceFocusChangeEvent *) re;
+ register deviceFocus *fev;
+
+ *count = 1;
+ fev = (deviceFocus *) Xmalloc (*count * sizeof (xEvent));
+ if (!fev)
+ return(_XUnknownNativeEvent(dpy, re, event));
+ *event = (xEvent *) fev;
+
+ fev->type = ev->type;
+ fev->window = ev->window;
+ fev->mode = ev->mode;
+ fev->detail = ev->detail;
+ fev->time = ev->time;
+ fev->deviceid = ev->deviceid;
+ break;
+ }
+ case XI_DeviceMappingNotify:
+ {
+ register XDeviceMappingEvent *ev = (XDeviceMappingEvent *) re;
+ register deviceMappingNotify *mev;
+
+ *count = 1;
+ mev = (deviceMappingNotify *) Xmalloc (*count * sizeof (xEvent));
+ if (!mev)
+ return(_XUnknownNativeEvent(dpy, re, event));
+ *event = (xEvent *) mev;
+
+ mev->type = ev->type;
+ mev->firstKeyCode = ev->first_keycode;
+ mev->request = ev->request;
+ mev->count = ev->count;
+ mev->time = ev->time;
+ mev->deviceid = ev->deviceid;
+ break;
+ }
+ case XI_DeviceStateNotify:
+ {
+ register XDeviceStateNotifyEvent *ev =
+ (XDeviceStateNotifyEvent *) re;
+ register deviceStateNotify *sev;
+ register xEvent *tev;
+ XInputClass *any = (XInputClass *) &ev->data[0];
+ unsigned char *sav_id;
+ *count = 1;
+
+ for (i=0; i<ev->num_classes; i++)
+ {
+ if (any->class == KeyClass)
+ {
+ XKeyStatus *k = (XKeyStatus *) any;
+ if (k->num_keys > 32)
+ (*count)++;
+ }
+ else if (any->class == ButtonClass)
+ {
+ XButtonStatus *b = (XButtonStatus *) any;
+ if (b->num_buttons > 32)
+ (*count)++;
+ }
+ else if (any->class == ValuatorClass)
+ {
+ XValuatorStatus *v = (XValuatorStatus *) any;
+ if (v->num_valuators > 3)
+ (*count)++;
+ }
+ any = (XInputClass *) ((char *) any + any->length);
+ }
+
+ sev = (deviceStateNotify *) Xmalloc (*count * sizeof (xEvent));
+ if (!sev)
+ return(_XUnknownNativeEvent(dpy, re, event));
+ *event = (xEvent *) sev;
+ tev = (xEvent *) (sev+1);
+
+ sev->type = ev->type;
+ sev->deviceid = ev->deviceid;
+ sav_id = &(sev->deviceid);
+ sev->time = ev->time;
+ sev->classes_reported = 0;
+
+ any = (XInputClass *) &ev->data[0];
+ for (i=0; i<ev->num_classes; i++)
+ {
+ if (any->class == KeyClass)
+ {
+ XKeyStatus *k = (XKeyStatus *) any;
+ register deviceKeyStateNotify *kev;
+
+ sev->classes_reported |= (1 << KeyClass);
+ sev->num_keys = k->num_keys;
+ memcpy ((char *) (sev->keys), (char *) (k->keys), 4);
+ if (k->num_keys > 32)
+ {
+ kev = (deviceKeyStateNotify *) tev++;
+ kev->type = info->codes->first_event +
+ XI_DeviceKeystateNotify;
+ kev->deviceid = ev->deviceid;
+ *sav_id |= MORE_EVENTS;
+ sav_id = &(kev->deviceid);
+ memcpy ((char *) (kev->keys), (char *) (&k->keys[4]),
+ 28);
+ }
+ }
+ else if (any->class == ButtonClass)
+ {
+ XButtonStatus *b = (XButtonStatus *) any;
+ register deviceButtonStateNotify *bev;
+
+ sev->classes_reported |= (1 << ButtonClass);
+ sev->num_buttons = b->num_buttons;
+ memcpy ((char *) (sev->buttons), (char *) (b->buttons), 4);
+ if (b->num_buttons > 32)
+ {
+ bev = (deviceButtonStateNotify *) tev++;
+ bev->type = info->codes->first_event +
+ XI_DeviceButtonstateNotify;
+ bev->deviceid = ev->deviceid;
+ *sav_id |= MORE_EVENTS;
+ sav_id = &(bev->deviceid);
+ memcpy ((char *)(bev->buttons), (char *)(&b->buttons[4]),
+ 28);
+ }
+ }
+ else if (any->class == ValuatorClass)
+ {
+ XValuatorStatus *val = (XValuatorStatus *) any;
+ register deviceValuator *vev;
+
+ sev->classes_reported |= (1 << ValuatorClass);
+ sev->num_valuators = val->num_valuators < 3 ?
+ val->num_valuators : 3;
+ switch (sev->num_valuators)
+ {
+ case 3: sev->valuator2 = val->valuators[2];
+ case 2: sev->valuator1 = val->valuators[1];
+ case 1: sev->valuator0 = val->valuators[0];
+ }
+ if (val->num_valuators > 3)
+ {
+ vev = (deviceValuator *) tev++;
+ vev->type = info->codes->first_event +
+ XI_DeviceValuator;
+ vev->deviceid = ev->deviceid;
+ vev->first_valuator = 3;
+ vev->num_valuators = val->num_valuators - 3;
+ *sav_id |= MORE_EVENTS;
+ sav_id = &(vev->deviceid);
+ i = val->num_valuators;
+ if (i > 6) i = 6;
+ switch (i)
+ {
+ case 6: vev->valuator2 = val->valuators[5];
+ case 5: vev->valuator1 = val->valuators[4];
+ case 4: vev->valuator0 = val->valuators[3];
+ }
+ }
+ }
+ any = (XInputClass *) ((char *) any + any->length);
+ }
+ break;
+ }
+ case XI_ChangeDeviceNotify:
+ {
+ register XChangeDeviceNotifyEvent *ev =
+ (XChangeDeviceNotifyEvent *) re;
+ register changeDeviceNotify *cev;
+
+ *count = 1;
+ cev = (changeDeviceNotify *) Xmalloc (*count * sizeof (xEvent));
+ if (!cev)
+ return(_XUnknownNativeEvent(dpy, re, event));
+ *event = (xEvent *) cev;
+
+ cev->type = ev->type;
+ cev->request = ev->request;
+ cev->time = ev->time;
+ cev->deviceid = ev->deviceid;
+ break;
+ }
+ default:
+ return(_XUnknownNativeEvent(dpy, re, event));
+ }
+ return(1);
+ }
diff --git a/src/XFreeLst.c b/src/XFreeLst.c
new file mode 100644
index 0000000..63a5946
--- /dev/null
+++ b/src/XFreeLst.c
@@ -0,0 +1,72 @@
+/* $Xorg: XFreeLst.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XFreeDeviceList - free the input device list.
+ *
+ */
+
+#include <stdio.h>
+#include "Xlib.h"
+
+/***********************************************************************
+ *
+ * Free the list of input devices.
+ *
+ */
+
+XFreeDeviceList (list)
+ XDeviceList *list;
+ {
+ if (list != NULL)
+ {
+ XFree ((list->name) - sizeof(XDeviceList));
+ XFree ((XDeviceList *) list);
+ }
+ }
diff --git a/src/XGMotion.c b/src/XGMotion.c
new file mode 100644
index 0000000..14d2cba
--- /dev/null
+++ b/src/XGMotion.c
@@ -0,0 +1,140 @@
+/* $Xorg: XGMotion.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XGetDeviceMotionEvents - Get the motion history of an input device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+XDeviceTimeCoord
+*XGetDeviceMotionEvents (dpy, dev, start, stop, nEvents, mode, axis_count)
+ register Display *dpy;
+ XDevice *dev;
+ Time start;
+ Time stop;
+ int *nEvents;
+ int *mode;
+ int *axis_count;
+ {
+ xGetDeviceMotionEventsReq *req;
+ xGetDeviceMotionEventsReply rep;
+ XDeviceTimeCoord *tc;
+ int *data, *bufp, *readp, *savp;
+ long size, size2;
+ int i, j;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return ((XDeviceTimeCoord *) NoSuchExtension);
+
+ GetReq(GetDeviceMotionEvents,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetDeviceMotionEvents;
+ req->start = start;
+ req->stop = stop;
+ req->deviceid = dev->device_id;
+
+ if (!_XReply (dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *nEvents = 0;
+ return (NULL);
+ }
+
+ *mode = rep.mode;
+ *axis_count = rep.axes;
+ *nEvents = rep.nEvents;
+ if (!rep.nEvents)
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (NULL);
+ }
+ size = rep.length << 2;
+ size2 = rep.nEvents *
+ (sizeof (XDeviceTimeCoord) + (rep.axes * sizeof (int)));
+ savp = readp = (int *) Xmalloc (size);
+ bufp = (int *) Xmalloc (size2);
+ if (!bufp || !savp)
+ {
+ *nEvents = 0;
+ _XEatData (dpy, (unsigned long) size);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (NULL);
+ }
+ _XRead (dpy, (char *) readp, size);
+
+ tc = (XDeviceTimeCoord *) bufp;
+ data = (int *) (tc + rep.nEvents);
+ for (i=0; i<*nEvents; i++,tc++)
+ {
+ tc->time = *readp++;
+ tc->data = data;
+ for (j=0; j<*axis_count; j++)
+ *data++ = *readp++;
+ }
+ XFree ((char *)savp);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((XDeviceTimeCoord *) bufp);
+ }
+
+void XFreeDeviceMotionEvents (events)
+ XDeviceTimeCoord *events;
+ {
+ XFree ((char *)events);
+ }
diff --git a/src/XGetBMap.c b/src/XGetBMap.c
new file mode 100644
index 0000000..7c814fe
--- /dev/null
+++ b/src/XGetBMap.c
@@ -0,0 +1,105 @@
+/* $Xorg: XGetBMap.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XGetDeviceButtonMapping - Get the button mapping of an extension device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+#ifdef MIN /* some systems define this in <sys/param.h> */
+#undef MIN
+#endif
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+
+int
+XGetDeviceButtonMapping (dpy, device, map, nmap)
+ register Display *dpy;
+ XDevice *device;
+ unsigned char map[];
+ unsigned int nmap;
+ {
+ int status = 0;
+ unsigned char mapping[256]; /* known fixed size */
+ long nbytes;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ register xGetDeviceButtonMappingReq *req;
+ xGetDeviceButtonMappingReply rep;
+
+ LockDisplay(dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+ GetReq(GetDeviceButtonMapping, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetDeviceButtonMapping;
+ req->deviceid = device->device_id;
+
+ status = _XReply (dpy, (xReply *)&rep, 0, xFalse);
+ if (status == 1)
+ {
+ nbytes = (long)rep.length << 2;
+ _XRead (dpy, (char *)mapping, nbytes);
+
+ /* don't return more data than the user asked for. */
+ if (rep.nElts)
+ memcpy ((char *) map, (char *) mapping, MIN((int)rep.nElts, nmap));
+ status = rep.nElts;
+ }
+ else
+ status = 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (status);
+ }
diff --git a/src/XGetDCtl.c b/src/XGetDCtl.c
new file mode 100644
index 0000000..65c270c
--- /dev/null
+++ b/src/XGetDCtl.c
@@ -0,0 +1,171 @@
+/* $Xorg: XGetDCtl.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XGetDeviceControl - get the Device control state of an extension device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "Xlib.h"
+#include "XInput.h"
+#include "extutil.h"
+
+XDeviceControl
+*XGetDeviceControl (dpy, dev, control)
+ register Display *dpy;
+ XDevice *dev;
+ int control;
+ {
+ int size = 0;
+ int nbytes, i;
+ XDeviceControl *Device = NULL;
+ XDeviceControl *Sav = NULL;
+ xDeviceState *d = NULL;
+ xDeviceState *sav = NULL;
+ xGetDeviceControlReq *req;
+ xGetDeviceControlReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Add_XChangeDeviceControl) == -1)
+ return ((XDeviceControl *) NoSuchExtension);
+
+ GetReq(GetDeviceControl,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetDeviceControl;
+ req->deviceid = dev->device_id;
+ req->control = control;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XDeviceControl *) NULL;
+ }
+ if (rep.length > 0)
+ {
+ nbytes = (long)rep.length << 2;
+ d = (xDeviceState *) Xmalloc((unsigned) nbytes);
+ if (!d)
+ {
+ _XEatData (dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XDeviceControl *) NULL;
+ }
+ sav = d;
+ _XRead (dpy, (char *) d, nbytes);
+
+ switch (d->control)
+ {
+ case DEVICE_RESOLUTION:
+ {
+ xDeviceResolutionState *r;
+
+ r = (xDeviceResolutionState *) d;
+ size += sizeof (XDeviceResolutionState) +
+ (3 * sizeof(int) * r->num_valuators);
+ break;
+ }
+ default:
+ size += d->length;
+ break;
+ }
+
+ Device = (XDeviceControl *) Xmalloc((unsigned) size);
+ if (!Device)
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XDeviceControl *) NULL;
+ }
+ Sav = Device;
+
+ d = sav;
+ switch (control)
+ {
+ case DEVICE_RESOLUTION:
+ {
+ int *iptr, *iptr2;
+ xDeviceResolutionState *r;
+ XDeviceResolutionState *R;
+ r = (xDeviceResolutionState *) d;
+ R = (XDeviceResolutionState *) Device;
+
+ R->control = DEVICE_RESOLUTION;
+ R->length = sizeof (XDeviceResolutionState);
+ R->num_valuators = r->num_valuators;
+ iptr = (int *) (R+1);
+ iptr2 = (int *) (r+1);
+ R->resolutions = iptr;
+ R->min_resolutions = iptr + R->num_valuators;
+ R->max_resolutions = iptr + (2 * R->num_valuators);
+ for (i=0; i < (3 * R->num_valuators); i++)
+ *iptr++ = *iptr2++;
+ break;
+ }
+ default:
+ break;
+ }
+ XFree (sav);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Sav);
+ }
+
+void XFreeDeviceControl (control)
+ XDeviceControl *control;
+ {
+ XFree (control);
+ }
diff --git a/src/XGetFCtl.c b/src/XGetFCtl.c
new file mode 100644
index 0000000..b941bfb
--- /dev/null
+++ b/src/XGetFCtl.c
@@ -0,0 +1,271 @@
+/* $Xorg: XGetFCtl.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XGetFeedbackControl - get the feedback attributes of an extension device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "Xlib.h"
+#include "XInput.h"
+#include "extutil.h"
+
+XFeedbackState
+*XGetFeedbackControl (dpy, dev, num_feedbacks)
+ register Display *dpy;
+ XDevice *dev;
+ int *num_feedbacks;
+ {
+ int size = 0;
+ int nbytes, i;
+ XFeedbackState *Feedback = NULL;
+ XFeedbackState *Sav = NULL;
+ xFeedbackState *f = NULL;
+ xFeedbackState *sav = NULL;
+ xGetFeedbackControlReq *req;
+ xGetFeedbackControlReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return ((XFeedbackState *) NoSuchExtension);
+
+ GetReq(GetFeedbackControl,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetFeedbackControl;
+ req->deviceid = dev->device_id;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XFeedbackState *) NULL;
+ }
+ if (rep.length > 0)
+ {
+ *num_feedbacks = rep.num_feedbacks;
+ nbytes = (long)rep.length << 2;
+ f = (xFeedbackState *) Xmalloc((unsigned) nbytes);
+ if (!f)
+ {
+ _XEatData (dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XFeedbackState *) NULL;
+ }
+ sav = f;
+ _XRead (dpy, (char *) f, nbytes);
+
+ for (i=0; i<*num_feedbacks; i++)
+ {
+ switch (f->class)
+ {
+ case KbdFeedbackClass:
+ size += sizeof (XKbdFeedbackState);
+ break;
+ case PtrFeedbackClass:
+ size += sizeof (XPtrFeedbackState);
+ break;
+ case IntegerFeedbackClass:
+ size += sizeof (XIntegerFeedbackState);
+ break;
+ case StringFeedbackClass:
+ {
+ xStringFeedbackState *strf = (xStringFeedbackState *) f;
+
+ size += sizeof (XStringFeedbackState) +
+ (strf->num_syms_supported * sizeof (KeySym));
+ }
+ break;
+ case LedFeedbackClass:
+ size += sizeof (XLedFeedbackState);
+ break;
+ case BellFeedbackClass:
+ size += sizeof (XBellFeedbackState);
+ break;
+ default:
+ size += f->length;
+ break;
+ }
+ f = (xFeedbackState *) ((char *) f + f->length);
+ }
+
+ Feedback = (XFeedbackState *) Xmalloc((unsigned) size);
+ if (!Feedback)
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XFeedbackState *) NULL;
+ }
+ Sav = Feedback;
+
+ f = sav;
+ for (i=0; i<*num_feedbacks; i++)
+ {
+ switch (f->class)
+ {
+ case KbdFeedbackClass:
+ {
+ xKbdFeedbackState *k;
+ XKbdFeedbackState *K;
+ k = (xKbdFeedbackState *) f;
+ K = (XKbdFeedbackState *) Feedback;
+
+ K->class = k->class;
+ K->length = sizeof (XKbdFeedbackState);
+ K->id = k->id;
+ K->click = k->click;
+ K->percent = k->percent;
+ K->pitch = k->pitch;
+ K->duration = k->duration;
+ K->led_mask = k->led_mask;
+ K->global_auto_repeat = k->global_auto_repeat;
+ memcpy ((char *) &K->auto_repeats[0],
+ (char *) &k->auto_repeats[0], 32);
+ break;
+ }
+ case PtrFeedbackClass:
+ {
+ xPtrFeedbackState *p;
+ XPtrFeedbackState *P;
+ p = (xPtrFeedbackState *) f;
+ P = (XPtrFeedbackState *) Feedback;
+
+ P->class = p->class;
+ P->length = sizeof (XPtrFeedbackState);
+ P->id = p->id;
+ P->accelNum = p->accelNum;
+ P->accelDenom = p->accelDenom;
+ P->threshold = p->threshold;
+ break;
+ }
+ case IntegerFeedbackClass:
+ {
+ xIntegerFeedbackState *i;
+ XIntegerFeedbackState *I;
+ i = (xIntegerFeedbackState *) f;
+ I = (XIntegerFeedbackState *) Feedback;
+
+ I->class = i->class;
+ I->length = sizeof (XIntegerFeedbackState);
+ I->id = i->id;
+ I->resolution = i->resolution;
+ I->minVal = i->min_value;
+ I->maxVal = i->max_value;
+ break;
+ }
+ case StringFeedbackClass:
+ {
+ xStringFeedbackState *s;
+ XStringFeedbackState *S;
+ s = (xStringFeedbackState *) f;
+ S = (XStringFeedbackState *) Feedback;
+
+ S->class = s->class;
+ S->length = sizeof (XStringFeedbackState) +
+ (s->num_syms_supported * sizeof (KeySym));
+ S->id = s->id;
+ S->max_symbols = s->max_symbols;
+ S->num_syms_supported = s->num_syms_supported;
+ S->syms_supported = (KeySym *) (S+1);
+ memcpy ((char *) S->syms_supported, (char *) (s+1),
+ (S->num_syms_supported * sizeof (KeySym)));
+ break;
+ }
+ case LedFeedbackClass:
+ {
+ xLedFeedbackState *l;
+ XLedFeedbackState *L;
+ l = (xLedFeedbackState *) f;
+ L = (XLedFeedbackState *) Feedback;
+
+ L->class = l->class;
+ L->length = sizeof (XLedFeedbackState);
+ L->id = l->id;
+ L->led_values = l->led_values;
+ L->led_mask = l->led_mask;
+ break;
+ }
+ case BellFeedbackClass:
+ {
+ xBellFeedbackState *b;
+ XBellFeedbackState *B;
+ b = (xBellFeedbackState *) f;
+ B = (XBellFeedbackState *) Feedback;
+
+ B->class = b->class;
+ B->length = sizeof (XBellFeedbackState);
+ B->id = b->id;
+ B->percent = b->percent;
+ B->pitch = b->pitch;
+ B->duration = b->duration;
+ break;
+ }
+ default:
+ break;
+ }
+ f = (xFeedbackState *) ((char *) f + f->length);
+ Feedback = (XFeedbackState *) ((char *) Feedback+Feedback->length);
+ }
+ XFree ((char *)sav);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Sav);
+ }
+
+void XFreeFeedbackList (list)
+ XFeedbackState *list;
+ {
+ XFree ((char *)list);
+ }
diff --git a/src/XGetKMap.c b/src/XGetKMap.c
new file mode 100644
index 0000000..8813b8f
--- /dev/null
+++ b/src/XGetKMap.c
@@ -0,0 +1,118 @@
+/* $Xorg: XGetKMap.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XGetDeviceKeyMapping - get the keymap of an extension device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+KeySym
+#if NeedFunctionPrototypes
+*XGetDeviceKeyMapping (
+ register Display *dpy,
+ XDevice *dev,
+#if NeedWidePrototypes
+ unsigned int first,
+#else
+ KeyCode first,
+#endif
+ int keycount,
+ int *syms_per_code)
+#else
+*XGetDeviceKeyMapping (dpy, dev, first, keycount, syms_per_code)
+ register Display *dpy;
+ XDevice *dev;
+ KeyCode first;
+ int keycount;
+ int *syms_per_code; /* RETURN */
+#endif
+ {
+ long nbytes;
+ register KeySym *mapping = NULL;
+ xGetDeviceKeyMappingReq *req;
+ xGetDeviceKeyMappingReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return ((KeySym *) NoSuchExtension);
+
+ GetReq(GetDeviceKeyMapping,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetDeviceKeyMapping;
+ req->deviceid = dev->device_id;
+ req->firstKeyCode = first;
+ req->count = keycount;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (KeySym *) NULL;
+ }
+ if (rep.length > 0) {
+ *syms_per_code = rep.keySymsPerKeyCode;
+ nbytes = (long)rep.length << 2;
+ mapping = (KeySym *) Xmalloc((unsigned) nbytes);
+ if (mapping)
+ _XRead (dpy, (char *)mapping, nbytes);
+ else
+ _XEatData (dpy, (unsigned long) nbytes);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (mapping);
+ }
diff --git a/src/XGetMMap.c b/src/XGetMMap.c
new file mode 100644
index 0000000..04615b8
--- /dev/null
+++ b/src/XGetMMap.c
@@ -0,0 +1,102 @@
+/* $Xorg: XGetMMap.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XGetDeviceModifierMapping - get the modifier map of an extension device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+XModifierKeymap
+*XGetDeviceModifierMapping (dpy, dev)
+ register Display *dpy;
+ XDevice *dev;
+ {
+ unsigned long nbytes;
+ XModifierKeymap *res;
+ xGetDeviceModifierMappingReq *req;
+ xGetDeviceModifierMappingReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return ((XModifierKeymap *) NoSuchExtension);
+
+ GetReq(GetDeviceModifierMapping,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetDeviceModifierMapping;
+ req->deviceid = dev->device_id;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XModifierKeymap *) NULL;
+ }
+ nbytes = (unsigned long)rep.length << 2;
+ res = (XModifierKeymap *) Xmalloc(sizeof (XModifierKeymap));
+ if (res)
+ {
+ res->modifiermap = (KeyCode *) Xmalloc (nbytes);
+ if (res->modifiermap)
+ _XReadPad(dpy, (char *) res->modifiermap, nbytes);
+ else
+ _XEatData (dpy, (unsigned long) nbytes);
+ res->max_keypermod = rep.numKeyPerModifier;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (res);
+ }
diff --git a/src/XGetProp.c b/src/XGetProp.c
new file mode 100644
index 0000000..fdfaf8c
--- /dev/null
+++ b/src/XGetProp.c
@@ -0,0 +1,118 @@
+/* $Xorg: XGetProp.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XGetDeviceDontPropagateList - Get the dont_propagate_list for a
+ * window.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+XEventClass
+*XGetDeviceDontPropagateList (dpy, window, count)
+ register Display *dpy;
+ Window window;
+ int *count;
+ {
+ XEventClass *list = NULL;
+ int rlen;
+ xGetDeviceDontPropagateListReq *req;
+ xGetDeviceDontPropagateListReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return ((XEventClass *) NoSuchExtension);
+
+ GetReq(GetDeviceDontPropagateList,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetDeviceDontPropagateList;
+ req->window = window;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XEventClass *) NULL;
+ }
+ *count = rep.count;
+
+ if (*count)
+ {
+ rlen = rep.length << 2;
+ list = (XEventClass *) Xmalloc (rlen);
+ if (list)
+ {
+ int i;
+ CARD32 ec;
+
+ /* read and assign each XEventClass separately because
+ * the library representation may not be the same size
+ * as the wire representation (64 bit machines)
+ */
+ for (i = 0; i < rep.length; i++)
+ {
+ _XRead (dpy, (char *)(&ec), sizeof(CARD32));
+ list[i] = (XEventClass)ec;
+ }
+ }
+ else
+ _XEatData (dpy, (unsigned long) rlen);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (list);
+ }
+
diff --git a/src/XGetVers.c b/src/XGetVers.c
new file mode 100644
index 0000000..dba03d8
--- /dev/null
+++ b/src/XGetVers.c
@@ -0,0 +1,108 @@
+/* $Xorg: XGetVers.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XGetExtensionVersion - Get the version of the input extension.
+ *
+ */
+
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XI.h"
+#include "XInput.h"
+#include "extutil.h"
+
+XExtensionVersion
+#if NeedFunctionPrototypes
+*XGetExtensionVersion (
+ register Display *dpy,
+ _Xconst char *name)
+#else
+*XGetExtensionVersion (dpy, name)
+ register Display *dpy;
+ char *name;
+#endif
+ {
+ xGetExtensionVersionReq *req;
+ xGetExtensionVersionReply rep;
+ XExtensionVersion *ext;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, Dont_Check) == -1)
+ return ((XExtensionVersion *) NoSuchExtension);
+
+ GetReq(GetExtensionVersion,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetExtensionVersion;
+ req->nbytes = name ? strlen(name) : 0;
+ req->length += (unsigned)(req->nbytes+3)>>2;
+ _XSend(dpy, name, (long)req->nbytes);
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xTrue))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XExtensionVersion *) NULL;
+ }
+ ext = (XExtensionVersion *) Xmalloc (sizeof (XExtensionVersion));
+ if (ext)
+ {
+ ext->present = rep.present;
+ if (ext->present)
+ {
+ ext->major_version = rep.major_version;
+ ext->minor_version = rep.minor_version;
+ }
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (ext);
+ }
+
diff --git a/src/XGrDvBut.c b/src/XGrDvBut.c
new file mode 100644
index 0000000..fc6b400
--- /dev/null
+++ b/src/XGrDvBut.c
@@ -0,0 +1,112 @@
+/* $Xorg: XGrDvBut.c,v 1.4 2001/02/09 02:03:50 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XGrabDeviceBut - Grab a button on an extension device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XGrabDeviceButton (dpy, dev, button, modifiers, modifier_device,
+ grab_window, owner_events, event_count, event_list, this_device_mode,
+ other_devices_mode)
+ register Display *dpy;
+ XDevice *dev;
+ unsigned int button; /* CARD8 */
+ unsigned int modifiers; /* CARD16 */
+ XDevice *modifier_device;
+ Window grab_window;
+ Bool owner_events;
+ unsigned int event_count;
+ XEventClass *event_list;
+ int this_device_mode;
+ int other_devices_mode;
+ {
+ register xGrabDeviceButtonReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(GrabDeviceButton, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GrabDeviceButton;
+ req->grabbed_device = dev->device_id;
+ req->button = button;
+ req->modifiers = modifiers;
+ if (modifier_device)
+ req->modifier_device = modifier_device->device_id;
+ else
+ req->modifier_device = UseXKeyboard;
+ req->grabWindow = grab_window;
+ req->ownerEvents = owner_events;
+ req->event_count = event_count;
+ req->this_device_mode = this_device_mode;
+ req->other_devices_mode = other_devices_mode;
+ req->length += event_count;
+
+ /* note: Data is a macro that uses its arguments multiple
+ times, so "nvalues" is changed in a separate assignment
+ statement */
+
+ event_count <<= 2;
+ Data32 (dpy, (long *) event_list, event_count);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
diff --git a/src/XGrDvKey.c b/src/XGrDvKey.c
new file mode 100644
index 0000000..e17d55f
--- /dev/null
+++ b/src/XGrDvKey.c
@@ -0,0 +1,115 @@
+/* $Xorg: XGrDvKey.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XGrabDeviceKey - Grab a key on an extension device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XGrabDeviceKey (dpy, dev, key, modifiers, modifier_device,
+ grab_window, owner_events, event_count, event_list, this_device_mode,
+ other_devices_mode)
+ register Display *dpy;
+ XDevice *dev;
+ unsigned int key; /* CARD8 */
+ unsigned int modifiers; /* CARD16 */
+ XDevice *modifier_device;
+ Window grab_window;
+ Bool owner_events;
+ unsigned int event_count;
+ XEventClass *event_list;
+ int this_device_mode;
+ int other_devices_mode;
+ {
+ register xGrabDeviceKeyReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(GrabDeviceKey, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GrabDeviceKey;
+ req->grabbed_device = dev->device_id;
+ req->key = key;
+ req->modifiers = modifiers;
+ if (modifier_device)
+ req->modifier_device = modifier_device->device_id;
+ else
+ req->modifier_device = UseXKeyboard;
+ req->grabWindow = grab_window;
+ req->ownerEvents = owner_events;
+ req->event_count = event_count;
+ req->this_device_mode = this_device_mode;
+ req->other_devices_mode = other_devices_mode;
+ req->length += event_count;
+
+ /* note: Data is a macro that uses its arguments multiple
+ times, so "nvalues" is changed in a separate assignment
+ statement */
+
+ if (event_count)
+ {
+ event_count <<= 2;
+ Data32 (dpy, (long *) event_list, event_count);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
diff --git a/src/XGrabDev.c b/src/XGrabDev.c
new file mode 100644
index 0000000..6f5ee02
--- /dev/null
+++ b/src/XGrabDev.c
@@ -0,0 +1,107 @@
+/* $Xorg: XGrabDev.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XGrabDevice - grab an extension input device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XGrabDevice (dpy, dev, grab_window, ownerEvents, event_count, event_list,
+ this_device_mode, other_devices_mode, time)
+ register Display *dpy;
+ XDevice *dev;
+ Window grab_window;
+ Bool ownerEvents;
+ int event_count;
+ XEventClass *event_list;
+ int this_device_mode;
+ int other_devices_mode;
+ Time time;
+ {
+ xGrabDeviceReply rep;
+ register xGrabDeviceReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(GrabDevice,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GrabDevice;
+
+ req->deviceid = dev->device_id;
+ req->grabWindow = grab_window;
+ req->ownerEvents = ownerEvents;
+ req->event_count = event_count;
+ req->this_device_mode = this_device_mode;
+ req->other_devices_mode = other_devices_mode;
+ req->time = time;
+ req->length += event_count;
+
+ /* note: Data is a macro that uses its arguments multiple
+ times, so "nvalues" is changed in a separate assignment
+ statement */
+
+ event_count <<= 2;
+ Data32 (dpy, (long *) event_list, event_count);
+
+ if (_XReply (dpy, (xReply *) &rep, 0, xTrue) == 0)
+ rep.status = GrabSuccess;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.status);
+ }
diff --git a/src/XGtFocus.c b/src/XGtFocus.c
new file mode 100644
index 0000000..b4a00eb
--- /dev/null
+++ b/src/XGtFocus.c
@@ -0,0 +1,90 @@
+/* $Xorg: XGtFocus.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XGetDeviceFocus - Get the focus of an input device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XGetDeviceFocus (dpy, dev, focus, revert_to, time)
+ register Display *dpy;
+ XDevice *dev;
+ Window *focus;
+ int *revert_to;
+ Time *time;
+ {
+ xGetDeviceFocusReq *req;
+ xGetDeviceFocusReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(GetDeviceFocus,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetDeviceFocus;
+ req->deviceid = dev->device_id;
+
+ (void) _XReply (dpy, (xReply *) &rep, 0, xTrue);
+ *focus = rep.focus;
+ *revert_to = rep.revertTo;
+ *time = rep.time;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
+
diff --git a/src/XGtSelect.c b/src/XGtSelect.c
new file mode 100644
index 0000000..2d76a4f
--- /dev/null
+++ b/src/XGtSelect.c
@@ -0,0 +1,144 @@
+/* $Xorg: XGtSelect.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XGetSelectedExtensionEvents - return a list of currently selected events.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XGetSelectedExtensionEvents (dpy, w, this_client_count, this_client_list,
+ all_clients_count, all_clients_list)
+ register Display *dpy;
+ Window w;
+ int *this_client_count;
+ XEventClass **this_client_list;
+ int *all_clients_count;
+ XEventClass **all_clients_list;
+ {
+ int tlen, alen;
+ register xGetSelectedExtensionEventsReq *req;
+ xGetSelectedExtensionEventsReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+ GetReq(GetSelectedExtensionEvents,req);
+
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GetSelectedExtensionEvents;
+ req->window = w;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return Success;
+ }
+
+ *this_client_count = rep.this_client_count;
+ *all_clients_count = rep.all_clients_count;
+
+ if (rep.length)
+ {
+ int i;
+ CARD32 ec;
+ tlen = (*this_client_count) * sizeof(CARD32);
+ alen = (rep.length << 2) - tlen;
+
+ if (tlen)
+ {
+ *this_client_list = (XEventClass *) Xmalloc (
+ *this_client_count * sizeof(XEventClass));
+ if (!*this_client_list)
+ {
+ _XEatData (dpy, (unsigned long) tlen+alen);
+ return (Success);
+ }
+ for (i = 0; i < *this_client_count; i++)
+ {
+ _XRead (dpy, (char *)(&ec), sizeof(CARD32));
+ (*this_client_list)[i] = (XEventClass)ec;
+ }
+ }
+ else
+ *this_client_list = (XEventClass *) NULL;
+ if (alen)
+ {
+ *all_clients_list = (XEventClass *) Xmalloc (
+ *all_clients_count * sizeof(XEventClass));
+ if (!*all_clients_list)
+ {
+ Xfree((char *)*this_client_list);
+ *this_client_list = NULL;
+ _XEatData (dpy, (unsigned long) alen);
+ return (Success);
+ }
+ for (i = 0; i < *all_clients_count; i++)
+ {
+ _XRead (dpy, (char *)(&ec), sizeof(CARD32));
+ (*all_clients_list)[i] = (XEventClass)ec;
+ }
+ }
+ else
+ *all_clients_list = (XEventClass *) NULL;
+
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
diff --git a/src/XListDev.c b/src/XListDev.c
new file mode 100644
index 0000000..714e0c4
--- /dev/null
+++ b/src/XListDev.c
@@ -0,0 +1,257 @@
+/* $Xorg: XListDev.c,v 1.5 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XListInputDevices - Request the server to return a list of
+ * available input devices.
+ *
+ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "XIproto.h"
+#include "XI.h"
+#include "XInput.h"
+#include "extutil.h"
+
+XDeviceInfo
+*XListInputDevices(dpy, ndevices)
+ register Display *dpy;
+ int *ndevices;
+ {
+ int size;
+ xListInputDevicesReq *req;
+ xListInputDevicesReply rep;
+ xDeviceInfo *list, *slist;
+ XDeviceInfo *sclist;
+ XDeviceInfo *clist = NULL;
+ xAnyClassPtr any, sav_any;
+ XAnyClassPtr Any;
+ char *nptr, *Nptr;
+ register int i,j,k;
+ register long rlen;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return ((XDeviceInfo *) NULL);
+
+ GetReq(ListInputDevices,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_ListInputDevices;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XDeviceInfo *) NULL;
+ }
+
+ if ((*ndevices = rep.ndevices)) /* at least 1 input device */
+ {
+ size = *ndevices * sizeof (XDeviceInfo);
+ rlen = rep.length << 2; /* multiply length by 4 */
+ list = (xDeviceInfo *) Xmalloc (rlen);
+ slist = list;
+ if (!slist)
+ {
+ _XEatData (dpy, (unsigned long) rlen);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XDeviceInfo *) NULL;
+ }
+ _XRead (dpy, (char *)list, rlen);
+
+ any = (xAnyClassPtr) ((char *) list +
+ (*ndevices * sizeof(xDeviceInfo)));
+ sav_any = any;
+ for (i=0; i<*ndevices; i++, list++)
+ {
+ for (j=0; j<(int)list->num_classes; j++)
+ {
+ switch (any->class)
+ {
+ case KeyClass:
+ size += sizeof (XKeyInfo);
+ break;
+ case ButtonClass:
+ size += sizeof (XButtonInfo);
+ break;
+ case ValuatorClass:
+ {
+ xValuatorInfoPtr v;
+ v = (xValuatorInfoPtr) any;
+ size += sizeof (XValuatorInfo) +
+ (v->num_axes * sizeof (XAxisInfo));
+ break;
+ }
+ default:
+ break;
+ }
+ any = (xAnyClassPtr) ((char *) any + any->length);
+ }
+ }
+
+ for (i=0, nptr = (char *) any; i<*ndevices; i++)
+ {
+ size += *nptr +1;
+ nptr += (*nptr + 1);
+ }
+
+ clist = (XDeviceInfoPtr) Xmalloc (size);
+ if (!clist)
+ {
+ XFree ((char *)slist);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XDeviceInfo *) NULL;
+ }
+ sclist = clist;
+ Any = (XAnyClassPtr) ((char *) clist +
+ (*ndevices * sizeof (XDeviceInfo)));
+ list = slist;
+ any = sav_any;
+ for (i=0; i<*ndevices; i++, list++, clist++)
+ {
+ clist->type = list->type;
+ clist->id = list->id;
+ clist->use = list->use;
+ clist->num_classes = list->num_classes;
+ clist->inputclassinfo = Any;
+ for (j=0; j<(int)list->num_classes; j++)
+ {
+ switch (any->class)
+ {
+ case KeyClass:
+ {
+ XKeyInfoPtr K = (XKeyInfoPtr) Any;
+ xKeyInfoPtr k = (xKeyInfoPtr) any;
+ K->class = KeyClass;
+ K->length = sizeof (XKeyInfo);
+ K->min_keycode = k->min_keycode;
+ K->max_keycode = k->max_keycode;
+ K->num_keys = k->num_keys;
+ break;
+ }
+ case ButtonClass:
+ {
+ XButtonInfoPtr B = (XButtonInfoPtr) Any;
+ xButtonInfoPtr b = (xButtonInfoPtr) any;
+ B->class = ButtonClass;
+ B->length = sizeof (XButtonInfo);
+ B->num_buttons = b->num_buttons;
+ break;
+ }
+ case ValuatorClass:
+ {
+ XValuatorInfoPtr V = (XValuatorInfoPtr) Any;
+ xValuatorInfoPtr v = (xValuatorInfoPtr) any;
+ XAxisInfoPtr A;
+ xAxisInfoPtr a;
+
+ V->class = ValuatorClass;
+ V->length = sizeof (XValuatorInfo) +
+ (v->num_axes * sizeof (XAxisInfo));
+ V->num_axes = v->num_axes;
+ V->motion_buffer = v->motion_buffer_size;
+ V->mode = v->mode;
+ A = (XAxisInfoPtr) ((char *) V + sizeof(XValuatorInfo));
+ V->axes = A;
+ a = (xAxisInfoPtr) ((char *) any +
+ sizeof (xValuatorInfo));
+ for (k=0; k<(int)v->num_axes; k++,a++,A++)
+ {
+ A->min_value = a->min_value;
+ A->max_value = a->max_value;
+ A->resolution = a->resolution;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ any = (xAnyClassPtr) ((char *) any + any->length);
+ Any = (XAnyClassPtr) ((char *) Any + Any->length);
+ }
+ }
+
+ clist = sclist;
+ nptr = (char *) any;
+ Nptr = (char *) Any;
+ for (i=0; i<*ndevices; i++,clist++)
+ {
+ clist->name = (char *) Nptr;
+ memcpy (Nptr, nptr+1, *nptr);
+ Nptr += (*nptr);
+ *Nptr++ = '\0';
+ nptr += (*nptr + 1);
+ }
+ }
+
+ XFree ((char *)slist);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (sclist);
+ }
+
+/***********************************************************************
+ *
+ * Free the list of input devices.
+ *
+ */
+
+void XFreeDeviceList (list)
+ XDeviceInfo *list;
+ {
+ if (list != NULL)
+ {
+ XFree ((char *) list);
+ }
+ }
diff --git a/src/XOpenDev.c b/src/XOpenDev.c
new file mode 100644
index 0000000..ed1ffe1
--- /dev/null
+++ b/src/XOpenDev.c
@@ -0,0 +1,111 @@
+/* $Xorg: XOpenDev.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XOpenDevice - Request the server to open and extension input device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+XDevice
+*XOpenDevice(dpy, id)
+ register Display *dpy;
+ register XID id;
+ {
+ register long rlen; /* raw length */
+ xOpenDeviceReq *req;
+ xOpenDeviceReply rep;
+ XDevice *dev;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return ((XDevice *) NoSuchExtension);
+
+ GetReq(OpenDevice,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_OpenDevice;
+ req->deviceid = id;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XDevice *) NULL;
+ }
+
+ rlen = rep.length << 2;
+ dev = (XDevice *) Xmalloc (sizeof(XDevice) + rep.num_classes *
+ sizeof (XInputClassInfo));
+ if (dev)
+ {
+ int dlen; /* data length */
+
+ dev->device_id = req->deviceid;
+ dev->num_classes = rep.num_classes;
+ dev->classes = (XInputClassInfo *) ((char *) dev + sizeof (XDevice));
+ dlen = rep.num_classes * sizeof(xInputClassInfo);
+ _XRead (dpy, (char *)dev->classes, dlen);
+ /* could be padding that we still need to eat (yummy!) */
+ if(rlen - dlen > 0)
+ _XEatData (dpy, (unsigned long) rlen - dlen);
+ }
+ else
+ _XEatData (dpy, (unsigned long) rlen);
+
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return (dev);
+ }
+
diff --git a/src/XQueryDv.c b/src/XQueryDv.c
new file mode 100644
index 0000000..e9b3be7
--- /dev/null
+++ b/src/XQueryDv.c
@@ -0,0 +1,196 @@
+/* $Xorg: XQueryDv.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XQueryDeviceState - Query the state of an extension input device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+XDeviceState
+*XQueryDeviceState (dpy, dev)
+ register Display *dpy;
+ XDevice *dev;
+ {
+ int i,j;
+ int rlen;
+ int size = 0;
+ xQueryDeviceStateReq *req;
+ xQueryDeviceStateReply rep;
+ XDeviceState *state = NULL;
+ XInputClass *any, *Any;
+ char *data;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return ((XDeviceState *) NoSuchExtension);
+
+ GetReq(QueryDeviceState,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_QueryDeviceState;
+ req->deviceid = dev->device_id;
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XDeviceState *) NULL;
+ }
+
+ rlen = rep.length << 2;
+ if (rlen > 0)
+ {
+ data = Xmalloc (rlen);
+ if (!data)
+ {
+ _XEatData (dpy, (unsigned long) rlen);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((XDeviceState *) NULL);
+ }
+ _XRead (dpy, data, rlen);
+
+ for (i=0, any=(XInputClass *) data; i<(int)rep.num_classes; i++)
+ {
+ switch (any->class)
+ {
+ case KeyClass:
+ size += sizeof (XKeyState);
+ break;
+ case ButtonClass:
+ size += sizeof (XButtonState);
+ break;
+ case ValuatorClass:
+ {
+ xValuatorState *v = (xValuatorState *) any;
+ size += (sizeof (XValuatorState) +
+ (v->num_valuators * sizeof(int)));
+ }
+ break;
+ }
+ any = (XInputClass *) ((char *) any + any->length);
+ }
+ state = (XDeviceState *) Xmalloc (size + sizeof(XDeviceState));
+ if (!state)
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((XDeviceState *) NULL);
+ }
+ state->device_id = dev->device_id;
+ state->num_classes = rep.num_classes;
+ state->data = (XInputClass *) (state + 1);
+
+ Any = state->data;
+ for (i=0, any=(XInputClass *) data; i<(int)rep.num_classes; i++)
+ {
+ switch (any->class)
+ {
+ case KeyClass:
+ {
+ xKeyState *k = (xKeyState *) any;
+ XKeyState *K = (XKeyState *) Any;
+ K->class = k->class;
+ K->length = sizeof (XKeyState);
+ K->num_keys = k->num_keys;
+ memcpy ((char *) &K->keys[0], (char *) &k->keys[0], 32);
+ Any = (XInputClass *) (K+1);
+ }
+ break;
+ case ButtonClass:
+ {
+ xButtonState *b = (xButtonState *) any;
+ XButtonState *B = (XButtonState *) Any;
+ B->class = b->class;
+ B->length = sizeof (XButtonState);
+ B->num_buttons = b->num_buttons;
+ memcpy ((char *) &B->buttons[0], (char *) &b->buttons[0],
+ 32);
+ Any = (XInputClass *) (B+1);
+ }
+ break;
+ case ValuatorClass:
+ {
+ xValuatorState *v = (xValuatorState *) any;
+ XValuatorState *V = (XValuatorState *) Any;
+ CARD32 *valuators = (CARD32 *) (v+1);
+ V->class = v->class;
+ V->length = sizeof (XValuatorState);
+ V->num_valuators = v->num_valuators;
+ V->mode = v->mode;
+ Any = (XInputClass *) (V+1);
+ V->valuators = (int *) Any;
+ for (j=0; j<(int)V->num_valuators; j++)
+ *(V->valuators + j) = *valuators++;
+ Any = (XInputClass *)((char *) Any +
+ V->num_valuators * sizeof (int));
+ }
+ break;
+ }
+ any = (XInputClass *) ((char *) any + any->length);
+ }
+ Xfree(data);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (state);
+ }
+
+void XFreeDeviceState (list)
+ XDeviceState *list;
+ {
+ XFree ((char *)list);
+ }
diff --git a/src/XSelect.c b/src/XSelect.c
new file mode 100644
index 0000000..09ea2b4
--- /dev/null
+++ b/src/XSelect.c
@@ -0,0 +1,92 @@
+/* $Xorg: XSelect.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XSelectExtensionEvent - Select input from an extension device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XSelectExtensionEvent (dpy, w, event_list, count)
+ register Display *dpy;
+ Window w;
+ XEventClass *event_list;
+ int count;
+ {
+ register xSelectExtensionEventReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy,XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+ GetReq(SelectExtensionEvent,req);
+
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_SelectExtensionEvent;
+ req->window = w;
+ req->count = count;
+ req->length += count;
+
+ /* note: Data is a macro that uses its arguments multiple
+ times, so "nvalues" is changed in a separate assignment
+ statement */
+
+ count <<= 2;
+ Data (dpy, (char *) event_list, count);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
diff --git a/src/XSetBMap.c b/src/XSetBMap.c
new file mode 100644
index 0000000..29fc22e
--- /dev/null
+++ b/src/XSetBMap.c
@@ -0,0 +1,91 @@
+/* $Xorg: XSetBMap.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XSetDeviceButtonMapping - Set the button mapping of an extension device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+#define NEED_REPLIES
+
+/* returns either DeviceMappingSuccess or DeviceMappingBusy */
+
+int
+XSetDeviceButtonMapping (dpy, device, map, nmap)
+ register Display *dpy;
+ XDevice *device;
+ unsigned char map[];
+ int nmap;
+ {
+ register xSetDeviceButtonMappingReq *req;
+ xSetDeviceButtonMappingReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay(dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+ GetReq (SetDeviceButtonMapping, req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_SetDeviceButtonMapping;
+ req->map_length = nmap;
+ req->length += (nmap + 3)>>2;
+ req->deviceid = device->device_id;
+
+ Data (dpy, (char *)map, (long) nmap); /* note that map is char[] */
+ if (_XReply (dpy, (xReply *)&rep, 0, xFalse) == 0) /* suppress error */
+ rep.status = MappingSuccess;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((int) rep.status);
+ }
diff --git a/src/XSetDVal.c b/src/XSetDVal.c
new file mode 100644
index 0000000..55e9bff
--- /dev/null
+++ b/src/XSetDVal.c
@@ -0,0 +1,98 @@
+/* $Xorg: XSetDVal.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XSetDeviceValuators - Set the value of valuators on an extension input
+ * device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XSetDeviceValuators (dpy, dev, valuators, first_valuator, num_valuators)
+ register Display *dpy;
+ XDevice *dev;
+ int *valuators;
+ int first_valuator;
+ int num_valuators;
+ {
+ xSetDeviceValuatorsReq *req;
+ xSetDeviceValuatorsReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Add_XSetDeviceValuators) == -1)
+ return (NoSuchExtension);
+
+ GetReq(SetDeviceValuators,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_SetDeviceValuators;
+ req->deviceid = dev->device_id;
+ req->first_valuator = first_valuator;
+ req->num_valuators = num_valuators;
+ req->length += num_valuators;
+
+ /* note: Data is a macro that uses its arguments multiple
+ times, so "nvalues" is changed in a separate assignment
+ statement */
+
+ num_valuators <<= 2;
+ Data (dpy, (char *) valuators, num_valuators);
+
+ (void) _XReply (dpy, (xReply *) &rep, 0, xTrue);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.status);
+ }
+
diff --git a/src/XSetMMap.c b/src/XSetMMap.c
new file mode 100644
index 0000000..a6a97d7
--- /dev/null
+++ b/src/XSetMMap.c
@@ -0,0 +1,89 @@
+/* $Xorg: XSetMMap.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XSetDeviceModifierMapping - set the modifier map of an extension device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XSetDeviceModifierMapping (dpy, dev, modmap)
+ register Display *dpy;
+ XDevice *dev;
+ XModifierKeymap *modmap;
+ {
+ int mapSize = modmap->max_keypermod << 3; /* 8 modifiers */
+ xSetDeviceModifierMappingReq *req;
+ xSetDeviceModifierMappingReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReqExtra(SetDeviceModifierMapping, mapSize, req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_SetDeviceModifierMapping;
+ req->deviceid = dev->device_id;
+ req->numKeyPerModifier = modmap->max_keypermod;
+ memcpy((char *)&req[1], modmap->modifiermap, mapSize);
+
+ (void) _XReply(dpy, (xReply *) &rep,
+ (sizeof(xSetDeviceModifierMappingReply) - sizeof(xReply)) >> 2, xTrue);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.success);
+ }
diff --git a/src/XSetMode.c b/src/XSetMode.c
new file mode 100644
index 0000000..8ec69cb
--- /dev/null
+++ b/src/XSetMode.c
@@ -0,0 +1,86 @@
+/* $Xorg: XSetMode.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XSetDeviceMode - Set the mode of an extension input device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XSetDeviceMode (dpy, dev, mode)
+ register Display *dpy;
+ XDevice *dev;
+ int mode;
+ {
+ xSetDeviceModeReq *req;
+ xSetDeviceModeReply rep;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(SetDeviceMode,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_SetDeviceMode;
+ req->deviceid = dev->device_id;
+ req->mode = mode;
+
+ (void) _XReply (dpy, (xReply *) &rep, 0, xTrue);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.status);
+ }
+
diff --git a/src/XSndExEv.c b/src/XSndExEv.c
new file mode 100644
index 0000000..78642a5
--- /dev/null
+++ b/src/XSndExEv.c
@@ -0,0 +1,121 @@
+/* $Xorg: XSndExEv.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XSendExtensionEvent - send an extension event to a client.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+extern Status _XiEventToWire();
+
+Status
+XSendExtensionEvent (dpy, dev, dest, prop, count, list, event)
+ register Display *dpy;
+ XDevice *dev;
+ Window dest;
+ Bool prop;
+ int count;
+ XEventClass *list;
+ XEvent *event;
+ {
+ int num_events;
+ int ev_size;
+ xSendExtensionEventReq *req;
+ xEvent *ev;
+ register Status (**fp)();
+ Status status;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ /* call through display to find proper conversion routine */
+
+ fp = &dpy->wire_vec[event->type & 0177];
+ if (*fp == NULL)
+ *fp = _XiEventToWire;
+ status = (**fp)(dpy, event, &ev, &num_events);
+
+ if (status)
+ {
+ GetReq(SendExtensionEvent,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_SendExtensionEvent;
+ req->deviceid = dev->device_id;
+ req->destination = dest;
+ req->propagate = prop;
+ req->count = count;
+ req->num_events = num_events;
+ ev_size = num_events * sizeof (xEvent);
+ req->length += (count + (ev_size >> 2));
+
+ /* note: Data is a macro that uses its arguments multiple
+ times, so "count" is changed in a separate assignment
+ statement. Any extra events must be sent before the event
+ list, in order to ensure quad alignment. */
+
+ Data (dpy, (char *) ev, ev_size);
+
+ count <<= 2;
+ Data32 (dpy, (long *) list, count);
+ XFree ((char *)ev);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (status);
+ }
+
diff --git a/src/XStFocus.c b/src/XStFocus.c
new file mode 100644
index 0000000..e59f3b5
--- /dev/null
+++ b/src/XStFocus.c
@@ -0,0 +1,85 @@
+/* $Xorg: XStFocus.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XSetDeviceFocus - Set the focus of an extension device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XSetDeviceFocus(dpy, dev, focus, revert_to, time)
+ register Display *dpy;
+ XDevice *dev;
+ Window focus;
+ int revert_to;
+ Time time;
+ {
+ xSetDeviceFocusReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+
+ GetReq(SetDeviceFocus,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_SetDeviceFocus;
+ req->device = dev->device_id;
+ req->focus = focus;
+ req->revertTo = revert_to;
+ req->time = time;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
diff --git a/src/XUngrDev.c b/src/XUngrDev.c
new file mode 100644
index 0000000..a241fba
--- /dev/null
+++ b/src/XUngrDev.c
@@ -0,0 +1,84 @@
+/* $Xorg: XUngrDev.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XUngrabDevice - Ungrab an extension device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XUngrabDevice (dpy, dev, time)
+ register Display *dpy;
+ XDevice *dev;
+ Time time;
+ {
+ register xUngrabDeviceReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay (dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+
+ GetReq(UngrabDevice,req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_UngrabDevice;
+
+ req->deviceid = dev->device_id;
+ req->time = time;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
diff --git a/src/XUngrDvB.c b/src/XUngrDvB.c
new file mode 100644
index 0000000..03b7eb1
--- /dev/null
+++ b/src/XUngrDvB.c
@@ -0,0 +1,91 @@
+/* $Xorg: XUngrDvB.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XUngrabDeviceButton - Ungrab a button on an extension device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XUngrabDeviceButton(dpy, dev, button, modifiers, modifier_dev, grab_window)
+ register Display *dpy;
+ XDevice *dev;
+ unsigned int button; /* CARD8 */
+ unsigned int modifiers; /* CARD16 */
+ XDevice *modifier_dev;
+ Window grab_window;
+ {
+ register xUngrabDeviceButtonReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay(dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+ GetReq(UngrabDeviceButton, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_UngrabDeviceButton;
+ req->grabbed_device = dev->device_id;
+ req->button = button;
+ req->modifiers = modifiers;
+ if (modifier_dev)
+ req->modifier_device = modifier_dev->device_id;
+ else
+ req->modifier_device = UseXKeyboard;
+ req->grabWindow = grab_window;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }
diff --git a/src/XUngrDvK.c b/src/XUngrDvK.c
new file mode 100644
index 0000000..9c9cfb3
--- /dev/null
+++ b/src/XUngrDvK.c
@@ -0,0 +1,91 @@
+/* $Xorg: XUngrDvK.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/***********************************************************************
+ *
+ * XUngrabDeviceKey - Ungrab a key on an extension device.
+ *
+ */
+
+#include "XI.h"
+#include "XIproto.h"
+#include "Xlibint.h"
+#include "XInput.h"
+#include "extutil.h"
+
+int
+XUngrabDeviceKey (dpy, dev, key, modifiers, modifier_dev, grab_window)
+ register Display *dpy;
+ XDevice *dev;
+ unsigned int key; /* CARD8 */
+ unsigned int modifiers; /* CARD16 */
+ XDevice *modifier_dev;
+ Window grab_window;
+ {
+ register xUngrabDeviceKeyReq *req;
+ XExtDisplayInfo *info = (XExtDisplayInfo *) XInput_find_display (dpy);
+
+ LockDisplay(dpy);
+ if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1)
+ return (NoSuchExtension);
+ GetReq(UngrabDeviceKey, req);
+
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_UngrabDeviceKey;
+ req->grabbed_device = dev->device_id;
+ req->key = key;
+ req->modifiers = modifiers;
+ if (modifier_dev)
+ req->modifier_device = modifier_dev->device_id;
+ else
+ req->modifier_device = UseXKeyboard;
+ req->grabWindow = grab_window;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Success);
+ }