2006-11-26 11:13:41 -07:00
|
|
|
/************************************************************
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
********************************************************/
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
*
|
|
|
|
* Dispatch routines and initialization routines for the X input extension.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#define NUMTYPES 15
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "inputstr.h"
|
2012-06-10 07:21:05 -06:00
|
|
|
#include "gcstruct.h" /* pointer for extnsionst.h */
|
|
|
|
#include "extnsionst.h" /* extension entry */
|
2006-11-26 11:13:41 -07:00
|
|
|
#include <X11/extensions/XI.h>
|
|
|
|
#include <X11/extensions/XIproto.h>
|
2010-07-27 13:02:24 -06:00
|
|
|
#include <X11/extensions/XI2proto.h>
|
2009-09-06 13:44:18 -06:00
|
|
|
#include <X11/extensions/geproto.h>
|
2012-06-10 07:21:05 -06:00
|
|
|
#include "geext.h" /* extension interfaces for ge */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#include "dixevents.h"
|
|
|
|
#include "exevents.h"
|
|
|
|
#include "extinit.h"
|
|
|
|
#include "exglobals.h"
|
|
|
|
#include "swaprep.h"
|
2009-09-06 13:44:18 -06:00
|
|
|
#include "privates.h"
|
2010-07-27 13:02:24 -06:00
|
|
|
#include "protocol-versions.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* modules local to Xi */
|
|
|
|
#include "allowev.h"
|
|
|
|
#include "chgdctl.h"
|
|
|
|
#include "chgfctl.h"
|
|
|
|
#include "chgkbd.h"
|
|
|
|
#include "chgprop.h"
|
|
|
|
#include "chgptr.h"
|
|
|
|
#include "closedev.h"
|
|
|
|
#include "devbell.h"
|
|
|
|
#include "getbmap.h"
|
|
|
|
#include "getdctl.h"
|
|
|
|
#include "getfctl.h"
|
|
|
|
#include "getfocus.h"
|
|
|
|
#include "getkmap.h"
|
|
|
|
#include "getmmap.h"
|
|
|
|
#include "getprop.h"
|
|
|
|
#include "getselev.h"
|
|
|
|
#include "getvers.h"
|
|
|
|
#include "grabdev.h"
|
|
|
|
#include "grabdevb.h"
|
|
|
|
#include "grabdevk.h"
|
|
|
|
#include "gtmotion.h"
|
|
|
|
#include "listdev.h"
|
|
|
|
#include "opendev.h"
|
|
|
|
#include "queryst.h"
|
|
|
|
#include "selectev.h"
|
|
|
|
#include "sendexev.h"
|
|
|
|
#include "chgkmap.h"
|
|
|
|
#include "setbmap.h"
|
|
|
|
#include "setdval.h"
|
|
|
|
#include "setfocus.h"
|
|
|
|
#include "setmmap.h"
|
|
|
|
#include "setmode.h"
|
|
|
|
#include "ungrdev.h"
|
|
|
|
#include "ungrdevb.h"
|
|
|
|
#include "ungrdevk.h"
|
2010-07-27 13:02:24 -06:00
|
|
|
#include "xiallowev.h"
|
|
|
|
#include "xiselectev.h"
|
|
|
|
#include "xigrabdev.h"
|
|
|
|
#include "xipassivegrab.h"
|
|
|
|
#include "xisetdevfocus.h"
|
2009-09-06 13:44:18 -06:00
|
|
|
#include "xiproperty.h"
|
2010-07-27 13:02:24 -06:00
|
|
|
#include "xichangecursor.h"
|
|
|
|
#include "xichangehierarchy.h"
|
|
|
|
#include "xigetclientpointer.h"
|
|
|
|
#include "xiquerydevice.h"
|
|
|
|
#include "xiquerypointer.h"
|
|
|
|
#include "xiqueryversion.h"
|
|
|
|
#include "xisetclientpointer.h"
|
|
|
|
#include "xiwarppointer.h"
|
2013-06-07 11:28:45 -06:00
|
|
|
#include "xibarriers.h"
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
/* Masks for XI events have to be aligned with core event (partially anyway).
|
|
|
|
* If DeviceButtonMotionMask is != ButtonMotionMask, event delivery
|
|
|
|
* breaks down. The device needs the dev->button->motionMask. If DBMM is
|
|
|
|
* the same as BMM, we can ensure that both core and device events can be
|
|
|
|
* delivered, without the need for extra structures in the DeviceIntRec. */
|
2012-06-10 07:21:05 -06:00
|
|
|
const Mask DeviceKeyPressMask = KeyPressMask;
|
|
|
|
const Mask DeviceKeyReleaseMask = KeyReleaseMask;
|
|
|
|
const Mask DeviceButtonPressMask = ButtonPressMask;
|
|
|
|
const Mask DeviceButtonReleaseMask = ButtonReleaseMask;
|
|
|
|
const Mask DeviceProximityMask = (1L << 4);
|
|
|
|
const Mask DeviceStateNotifyMask = (1L << 5);
|
|
|
|
const Mask DevicePointerMotionMask = PointerMotionMask;
|
|
|
|
const Mask DevicePointerMotionHintMask = PointerMotionHintMask;
|
|
|
|
const Mask DeviceButton1MotionMask = Button1MotionMask;
|
|
|
|
const Mask DeviceButton2MotionMask = Button2MotionMask;
|
|
|
|
const Mask DeviceButton3MotionMask = Button3MotionMask;
|
|
|
|
const Mask DeviceButton4MotionMask = Button4MotionMask;
|
|
|
|
const Mask DeviceButton5MotionMask = Button5MotionMask;
|
|
|
|
const Mask DeviceButtonMotionMask = ButtonMotionMask;
|
|
|
|
const Mask DeviceFocusChangeMask = (1L << 14);
|
|
|
|
const Mask DeviceMappingNotifyMask = (1L << 15);
|
|
|
|
const Mask ChangeDeviceNotifyMask = (1L << 16);
|
|
|
|
const Mask DeviceButtonGrabMask = (1L << 17);
|
|
|
|
const Mask DeviceOwnerGrabButtonMask = (1L << 17);
|
|
|
|
const Mask DevicePresenceNotifyMask = (1L << 18);
|
2013-06-07 11:28:45 -06:00
|
|
|
const Mask DevicePropertyNotifyMask = (1L << 19);
|
|
|
|
const Mask XIAllMasks = (1L << 20) - 1;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
int ExtEventIndex;
|
|
|
|
Mask ExtExclusiveMasks[EMASKSIZE];
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static struct dev_type {
|
2006-11-26 11:13:41 -07:00
|
|
|
Atom type;
|
2012-06-10 07:21:05 -06:00
|
|
|
const char *name;
|
2006-11-26 11:13:41 -07:00
|
|
|
} dev_type[] = {
|
2013-06-07 11:28:45 -06:00
|
|
|
{0, XI_KEYBOARD},
|
|
|
|
{0, XI_MOUSE},
|
|
|
|
{0, XI_TABLET},
|
|
|
|
{0, XI_TOUCHSCREEN},
|
|
|
|
{0, XI_TOUCHPAD},
|
|
|
|
{0, XI_BARCODE},
|
|
|
|
{0, XI_BUTTONBOX},
|
|
|
|
{0, XI_KNOB_BOX},
|
|
|
|
{0, XI_ONE_KNOB},
|
|
|
|
{0, XI_NINE_KNOB},
|
|
|
|
{0, XI_TRACKBALL},
|
|
|
|
{0, XI_QUADRATURE},
|
|
|
|
{0, XI_ID_MODULE},
|
|
|
|
{0, XI_SPACEBALL},
|
|
|
|
{0, XI_DATAGLOVE},
|
|
|
|
{0, XI_EYETRACKER},
|
|
|
|
{0, XI_CURSORKEYS},
|
|
|
|
{0, XI_FOOTMOUSE}
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
CARD8 event_base[numInputClasses];
|
|
|
|
XExtEventInfo EventInfo[32];
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
static DeviceIntRec xi_all_devices;
|
|
|
|
static DeviceIntRec xi_all_master_devices;
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
/**
|
|
|
|
* Dispatch vector. Functions defined in here will be called when the matching
|
|
|
|
* request arrives.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
static int (*ProcIVector[]) (ClientPtr) = {
|
|
|
|
NULL, /* 0 */
|
|
|
|
ProcXGetExtensionVersion, /* 1 */
|
|
|
|
ProcXListInputDevices, /* 2 */
|
|
|
|
ProcXOpenDevice, /* 3 */
|
|
|
|
ProcXCloseDevice, /* 4 */
|
|
|
|
ProcXSetDeviceMode, /* 5 */
|
|
|
|
ProcXSelectExtensionEvent, /* 6 */
|
|
|
|
ProcXGetSelectedExtensionEvents, /* 7 */
|
|
|
|
ProcXChangeDeviceDontPropagateList, /* 8 */
|
|
|
|
ProcXGetDeviceDontPropagateList, /* 9 */
|
|
|
|
ProcXGetDeviceMotionEvents, /* 10 */
|
|
|
|
ProcXChangeKeyboardDevice, /* 11 */
|
|
|
|
ProcXChangePointerDevice, /* 12 */
|
|
|
|
ProcXGrabDevice, /* 13 */
|
|
|
|
ProcXUngrabDevice, /* 14 */
|
|
|
|
ProcXGrabDeviceKey, /* 15 */
|
|
|
|
ProcXUngrabDeviceKey, /* 16 */
|
|
|
|
ProcXGrabDeviceButton, /* 17 */
|
|
|
|
ProcXUngrabDeviceButton, /* 18 */
|
|
|
|
ProcXAllowDeviceEvents, /* 19 */
|
|
|
|
ProcXGetDeviceFocus, /* 20 */
|
|
|
|
ProcXSetDeviceFocus, /* 21 */
|
|
|
|
ProcXGetFeedbackControl, /* 22 */
|
|
|
|
ProcXChangeFeedbackControl, /* 23 */
|
|
|
|
ProcXGetDeviceKeyMapping, /* 24 */
|
|
|
|
ProcXChangeDeviceKeyMapping, /* 25 */
|
|
|
|
ProcXGetDeviceModifierMapping, /* 26 */
|
|
|
|
ProcXSetDeviceModifierMapping, /* 27 */
|
|
|
|
ProcXGetDeviceButtonMapping, /* 28 */
|
|
|
|
ProcXSetDeviceButtonMapping, /* 29 */
|
|
|
|
ProcXQueryDeviceState, /* 30 */
|
|
|
|
ProcXSendExtensionEvent, /* 31 */
|
|
|
|
ProcXDeviceBell, /* 32 */
|
|
|
|
ProcXSetDeviceValuators, /* 33 */
|
|
|
|
ProcXGetDeviceControl, /* 34 */
|
|
|
|
ProcXChangeDeviceControl, /* 35 */
|
2009-09-06 13:44:18 -06:00
|
|
|
/* XI 1.5 */
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXListDeviceProperties, /* 36 */
|
|
|
|
ProcXChangeDeviceProperty, /* 37 */
|
|
|
|
ProcXDeleteDeviceProperty, /* 38 */
|
|
|
|
ProcXGetDeviceProperty, /* 39 */
|
2010-07-27 13:02:24 -06:00
|
|
|
/* XI 2 */
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXIQueryPointer, /* 40 */
|
|
|
|
ProcXIWarpPointer, /* 41 */
|
|
|
|
ProcXIChangeCursor, /* 42 */
|
|
|
|
ProcXIChangeHierarchy, /* 43 */
|
|
|
|
ProcXISetClientPointer, /* 44 */
|
|
|
|
ProcXIGetClientPointer, /* 45 */
|
|
|
|
ProcXISelectEvents, /* 46 */
|
|
|
|
ProcXIQueryVersion, /* 47 */
|
|
|
|
ProcXIQueryDevice, /* 48 */
|
|
|
|
ProcXISetFocus, /* 49 */
|
|
|
|
ProcXIGetFocus, /* 50 */
|
|
|
|
ProcXIGrabDevice, /* 51 */
|
|
|
|
ProcXIUngrabDevice, /* 52 */
|
|
|
|
ProcXIAllowEvents, /* 53 */
|
|
|
|
ProcXIPassiveGrabDevice, /* 54 */
|
|
|
|
ProcXIPassiveUngrabDevice, /* 55 */
|
|
|
|
ProcXIListProperties, /* 56 */
|
|
|
|
ProcXIChangeProperty, /* 57 */
|
|
|
|
ProcXIDeleteProperty, /* 58 */
|
|
|
|
ProcXIGetProperty, /* 59 */
|
2013-06-07 11:28:45 -06:00
|
|
|
ProcXIGetSelectedEvents, /* 60 */
|
|
|
|
ProcXIBarrierReleasePointer /* 61 */
|
2009-09-06 13:44:18 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
/* For swapped clients */
|
2012-06-10 07:21:05 -06:00
|
|
|
static int (*SProcIVector[]) (ClientPtr) = {
|
|
|
|
NULL, /* 0 */
|
|
|
|
SProcXGetExtensionVersion, /* 1 */
|
|
|
|
SProcXListInputDevices, /* 2 */
|
|
|
|
SProcXOpenDevice, /* 3 */
|
|
|
|
SProcXCloseDevice, /* 4 */
|
|
|
|
SProcXSetDeviceMode, /* 5 */
|
|
|
|
SProcXSelectExtensionEvent, /* 6 */
|
|
|
|
SProcXGetSelectedExtensionEvents, /* 7 */
|
|
|
|
SProcXChangeDeviceDontPropagateList, /* 8 */
|
|
|
|
SProcXGetDeviceDontPropagateList, /* 9 */
|
|
|
|
SProcXGetDeviceMotionEvents, /* 10 */
|
|
|
|
SProcXChangeKeyboardDevice, /* 11 */
|
|
|
|
SProcXChangePointerDevice, /* 12 */
|
|
|
|
SProcXGrabDevice, /* 13 */
|
|
|
|
SProcXUngrabDevice, /* 14 */
|
|
|
|
SProcXGrabDeviceKey, /* 15 */
|
|
|
|
SProcXUngrabDeviceKey, /* 16 */
|
|
|
|
SProcXGrabDeviceButton, /* 17 */
|
|
|
|
SProcXUngrabDeviceButton, /* 18 */
|
|
|
|
SProcXAllowDeviceEvents, /* 19 */
|
|
|
|
SProcXGetDeviceFocus, /* 20 */
|
|
|
|
SProcXSetDeviceFocus, /* 21 */
|
|
|
|
SProcXGetFeedbackControl, /* 22 */
|
|
|
|
SProcXChangeFeedbackControl, /* 23 */
|
|
|
|
SProcXGetDeviceKeyMapping, /* 24 */
|
|
|
|
SProcXChangeDeviceKeyMapping, /* 25 */
|
|
|
|
SProcXGetDeviceModifierMapping, /* 26 */
|
|
|
|
SProcXSetDeviceModifierMapping, /* 27 */
|
|
|
|
SProcXGetDeviceButtonMapping, /* 28 */
|
|
|
|
SProcXSetDeviceButtonMapping, /* 29 */
|
|
|
|
SProcXQueryDeviceState, /* 30 */
|
|
|
|
SProcXSendExtensionEvent, /* 31 */
|
|
|
|
SProcXDeviceBell, /* 32 */
|
|
|
|
SProcXSetDeviceValuators, /* 33 */
|
|
|
|
SProcXGetDeviceControl, /* 34 */
|
|
|
|
SProcXChangeDeviceControl, /* 35 */
|
|
|
|
SProcXListDeviceProperties, /* 36 */
|
|
|
|
SProcXChangeDeviceProperty, /* 37 */
|
|
|
|
SProcXDeleteDeviceProperty, /* 38 */
|
|
|
|
SProcXGetDeviceProperty, /* 39 */
|
|
|
|
SProcXIQueryPointer, /* 40 */
|
|
|
|
SProcXIWarpPointer, /* 41 */
|
|
|
|
SProcXIChangeCursor, /* 42 */
|
|
|
|
SProcXIChangeHierarchy, /* 43 */
|
|
|
|
SProcXISetClientPointer, /* 44 */
|
|
|
|
SProcXIGetClientPointer, /* 45 */
|
|
|
|
SProcXISelectEvents, /* 46 */
|
|
|
|
SProcXIQueryVersion, /* 47 */
|
|
|
|
SProcXIQueryDevice, /* 48 */
|
|
|
|
SProcXISetFocus, /* 49 */
|
|
|
|
SProcXIGetFocus, /* 50 */
|
|
|
|
SProcXIGrabDevice, /* 51 */
|
|
|
|
SProcXIUngrabDevice, /* 52 */
|
|
|
|
SProcXIAllowEvents, /* 53 */
|
|
|
|
SProcXIPassiveGrabDevice, /* 54 */
|
|
|
|
SProcXIPassiveUngrabDevice, /* 55 */
|
|
|
|
SProcXIListProperties, /* 56 */
|
|
|
|
SProcXIChangeProperty, /* 57 */
|
|
|
|
SProcXIDeleteProperty, /* 58 */
|
|
|
|
SProcXIGetProperty, /* 59 */
|
2013-06-07 11:28:45 -06:00
|
|
|
SProcXIGetSelectedEvents, /* 60 */
|
|
|
|
SProcXIBarrierReleasePointer /* 61 */
|
2009-09-06 13:44:18 -06:00
|
|
|
};
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/*****************************************************************
|
|
|
|
*
|
|
|
|
* Globals referenced elsewhere in the server.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
int IReqCode = 0;
|
2009-09-06 13:44:18 -06:00
|
|
|
int IEventBase = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
int BadDevice = 0;
|
2007-11-24 10:55:21 -07:00
|
|
|
static int BadEvent = 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
int BadMode = 2;
|
|
|
|
int DeviceBusy = 3;
|
|
|
|
int BadClass = 4;
|
|
|
|
|
|
|
|
int DeviceValuator;
|
|
|
|
int DeviceKeyPress;
|
|
|
|
int DeviceKeyRelease;
|
|
|
|
int DeviceButtonPress;
|
|
|
|
int DeviceButtonRelease;
|
|
|
|
int DeviceMotionNotify;
|
|
|
|
int DeviceFocusIn;
|
|
|
|
int DeviceFocusOut;
|
|
|
|
int ProximityIn;
|
|
|
|
int ProximityOut;
|
|
|
|
int DeviceStateNotify;
|
|
|
|
int DeviceKeyStateNotify;
|
|
|
|
int DeviceButtonStateNotify;
|
|
|
|
int DeviceMappingNotify;
|
|
|
|
int ChangeDeviceNotify;
|
2007-11-24 10:55:21 -07:00
|
|
|
int DevicePresenceNotify;
|
2009-09-06 13:44:18 -06:00
|
|
|
int DevicePropertyNotify;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
RESTYPE RT_INPUTCLIENT;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
*
|
|
|
|
* Externs defined elsewhere in the X server.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
extern XExtensionVersion XIVersion;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-08-05 12:11:37 -06:00
|
|
|
Mask PropagateMask[EMASKSIZE];
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
*
|
2009-09-06 13:44:18 -06:00
|
|
|
* Versioning support
|
2006-11-26 11:13:41 -07:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
DevPrivateKeyRec XIClientPrivateKeyRec;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
*
|
|
|
|
* Declarations of local routines.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2014-09-27 11:52:59 -06:00
|
|
|
XIClientCallback(CallbackListPtr *list, void *closure, void *data)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
|
2009-09-06 13:44:18 -06:00
|
|
|
ClientPtr pClient = clientinfo->client;
|
|
|
|
XIClientPtr pXIClient;
|
|
|
|
|
|
|
|
pXIClient = dixLookupPrivate(&pClient->devPrivates, XIClientPrivateKey);
|
|
|
|
pXIClient->major_version = 0;
|
|
|
|
pXIClient->minor_version = 0;
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* ProcIDispatch - main dispatch routine for requests to this extension.
|
|
|
|
* This routine is used if server and client have the same byte ordering.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static int
|
|
|
|
ProcIDispatch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
2011-12-18 09:08:59 -07:00
|
|
|
if (stuff->data >= ARRAY_SIZE(ProcIVector) || !ProcIVector[stuff->data])
|
2009-09-06 13:44:18 -06:00
|
|
|
return BadRequest;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return (*ProcIVector[stuff->data]) (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
2009-09-06 13:44:18 -06:00
|
|
|
* SProcXDispatch
|
2006-11-26 11:13:41 -07:00
|
|
|
*
|
|
|
|
* Main swapped dispatch routine for requests to this extension.
|
|
|
|
* This routine is used if server and client do not have the same byte ordering.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static int
|
|
|
|
SProcIDispatch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
2011-12-18 09:08:59 -07:00
|
|
|
if (stuff->data >= ARRAY_SIZE(SProcIVector) || !SProcIVector[stuff->data])
|
2009-09-06 13:44:18 -06:00
|
|
|
return BadRequest;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return (*SProcIVector[stuff->data]) (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
*
|
|
|
|
* SReplyIDispatch
|
|
|
|
* Swap any replies defined in this extension.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2006-11-26 11:13:41 -07:00
|
|
|
SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
|
2013-06-07 11:28:45 -06:00
|
|
|
{
|
|
|
|
/* All we look at is the type field */
|
|
|
|
/* This is common to all replies */
|
2006-11-26 11:13:41 -07:00
|
|
|
if (rep->RepType == X_GetExtensionVersion)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXGetExtensionVersion(client, len,
|
|
|
|
(xGetExtensionVersionReply *) rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (rep->RepType == X_ListInputDevices)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXListInputDevices(client, len, (xListInputDevicesReply *) rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (rep->RepType == X_OpenDevice)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXOpenDevice(client, len, (xOpenDeviceReply *) rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (rep->RepType == X_SetDeviceMode)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXSetDeviceMode(client, len, (xSetDeviceModeReply *) rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (rep->RepType == X_GetSelectedExtensionEvents)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXGetSelectedExtensionEvents(client, len,
|
|
|
|
(xGetSelectedExtensionEventsReply *)
|
|
|
|
rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (rep->RepType == X_GetDeviceDontPropagateList)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXGetDeviceDontPropagateList(client, len,
|
|
|
|
(xGetDeviceDontPropagateListReply *)
|
|
|
|
rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (rep->RepType == X_GetDeviceMotionEvents)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXGetDeviceMotionEvents(client, len,
|
|
|
|
(xGetDeviceMotionEventsReply *) rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (rep->RepType == X_GrabDevice)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXGrabDevice(client, len, (xGrabDeviceReply *) rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (rep->RepType == X_GetDeviceFocus)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXGetDeviceFocus(client, len, (xGetDeviceFocusReply *) rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (rep->RepType == X_GetFeedbackControl)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXGetFeedbackControl(client, len, (xGetFeedbackControlReply *) rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (rep->RepType == X_GetDeviceKeyMapping)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXGetDeviceKeyMapping(client, len,
|
|
|
|
(xGetDeviceKeyMappingReply *) rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (rep->RepType == X_GetDeviceModifierMapping)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXGetDeviceModifierMapping(client, len,
|
|
|
|
(xGetDeviceModifierMappingReply *) rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (rep->RepType == X_SetDeviceModifierMapping)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXSetDeviceModifierMapping(client, len,
|
|
|
|
(xSetDeviceModifierMappingReply *) rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (rep->RepType == X_GetDeviceButtonMapping)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXGetDeviceButtonMapping(client, len,
|
|
|
|
(xGetDeviceButtonMappingReply *) rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (rep->RepType == X_SetDeviceButtonMapping)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXSetDeviceButtonMapping(client, len,
|
|
|
|
(xSetDeviceButtonMappingReply *) rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (rep->RepType == X_QueryDeviceState)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXQueryDeviceState(client, len, (xQueryDeviceStateReply *) rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (rep->RepType == X_SetDeviceValuators)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXSetDeviceValuators(client, len, (xSetDeviceValuatorsReply *) rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (rep->RepType == X_GetDeviceControl)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXGetDeviceControl(client, len, (xGetDeviceControlReply *) rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else if (rep->RepType == X_ChangeDeviceControl)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXChangeDeviceControl(client, len,
|
|
|
|
(xChangeDeviceControlReply *) rep);
|
2009-09-06 13:44:18 -06:00
|
|
|
else if (rep->RepType == X_ListDeviceProperties)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXListDeviceProperties(client, len,
|
|
|
|
(xListDevicePropertiesReply *) rep);
|
2009-09-06 13:44:18 -06:00
|
|
|
else if (rep->RepType == X_GetDeviceProperty)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXGetDeviceProperty(client, len, (xGetDevicePropertyReply *) rep);
|
2010-07-27 13:02:24 -06:00
|
|
|
else if (rep->RepType == X_XIQueryPointer)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXIQueryPointer(client, len, (xXIQueryPointerReply *) rep);
|
2010-07-27 13:02:24 -06:00
|
|
|
else if (rep->RepType == X_XIGetClientPointer)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXIGetClientPointer(client, len, (xXIGetClientPointerReply *) rep);
|
2010-07-27 13:02:24 -06:00
|
|
|
else if (rep->RepType == X_XIQueryVersion)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXIQueryVersion(client, len, (xXIQueryVersionReply *) rep);
|
2010-07-27 13:02:24 -06:00
|
|
|
else if (rep->RepType == X_XIQueryDevice)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXIQueryDevice(client, len, (xXIQueryDeviceReply *) rep);
|
2010-07-27 13:02:24 -06:00
|
|
|
else if (rep->RepType == X_XIGrabDevice)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXIGrabDevice(client, len, (xXIGrabDeviceReply *) rep);
|
2011-11-05 07:32:40 -06:00
|
|
|
else if (rep->RepType == X_XIPassiveGrabDevice)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXIPassiveGrabDevice(client, len, (xXIPassiveGrabDeviceReply *) rep);
|
2010-07-27 13:02:24 -06:00
|
|
|
else if (rep->RepType == X_XIListProperties)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXIListProperties(client, len, (xXIListPropertiesReply *) rep);
|
2010-07-27 13:02:24 -06:00
|
|
|
else if (rep->RepType == X_XIGetProperty)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXIGetProperty(client, len, (xXIGetPropertyReply *) rep);
|
2010-07-27 13:02:24 -06:00
|
|
|
else if (rep->RepType == X_XIGetSelectedEvents)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXIGetSelectedEvents(client, len, (xXIGetSelectedEventsReply *) rep);
|
2010-07-27 13:02:24 -06:00
|
|
|
else if (rep->RepType == X_XIGetFocus)
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXIGetFocus(client, len, (xXIGetFocusReply *) rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
else {
|
2012-06-10 07:21:05 -06:00
|
|
|
FatalError("XINPUT confused sending swapped reply");
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
*
|
|
|
|
* This function swaps the DeviceValuator event.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2006-11-26 11:13:41 -07:00
|
|
|
SEventDeviceValuator(deviceValuator * from, deviceValuator * to)
|
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
int i;
|
2006-11-26 11:13:41 -07:00
|
|
|
INT32 *ip B32;
|
|
|
|
|
|
|
|
*to = *from;
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&to->sequenceNumber);
|
|
|
|
swaps(&to->device_state);
|
2006-11-26 11:13:41 -07:00
|
|
|
ip = &to->valuator0;
|
|
|
|
for (i = 0; i < 6; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swapl(ip + i);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2006-11-26 11:13:41 -07:00
|
|
|
SEventFocus(deviceFocus * from, deviceFocus * to)
|
|
|
|
{
|
|
|
|
*to = *from;
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&to->sequenceNumber);
|
|
|
|
swapl(&to->time);
|
|
|
|
swapl(&to->window);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2006-11-26 11:13:41 -07:00
|
|
|
SDeviceStateNotifyEvent(deviceStateNotify * from, deviceStateNotify * to)
|
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
int i;
|
2006-11-26 11:13:41 -07:00
|
|
|
INT32 *ip B32;
|
|
|
|
|
|
|
|
*to = *from;
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&to->sequenceNumber);
|
|
|
|
swapl(&to->time);
|
2006-11-26 11:13:41 -07:00
|
|
|
ip = &to->valuator0;
|
|
|
|
for (i = 0; i < 3; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swapl(ip + i);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2006-11-26 11:13:41 -07:00
|
|
|
SDeviceKeyStateNotifyEvent(deviceKeyStateNotify * from,
|
2012-06-10 07:21:05 -06:00
|
|
|
deviceKeyStateNotify * to)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
*to = *from;
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&to->sequenceNumber);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2006-11-26 11:13:41 -07:00
|
|
|
SDeviceButtonStateNotifyEvent(deviceButtonStateNotify * from,
|
2012-06-10 07:21:05 -06:00
|
|
|
deviceButtonStateNotify * to)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
*to = *from;
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&to->sequenceNumber);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2006-11-26 11:13:41 -07:00
|
|
|
SChangeDeviceNotifyEvent(changeDeviceNotify * from, changeDeviceNotify * to)
|
|
|
|
{
|
|
|
|
*to = *from;
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&to->sequenceNumber);
|
|
|
|
swapl(&to->time);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2006-11-26 11:13:41 -07:00
|
|
|
SDeviceMappingNotifyEvent(deviceMappingNotify * from, deviceMappingNotify * to)
|
|
|
|
{
|
|
|
|
*to = *from;
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&to->sequenceNumber);
|
|
|
|
swapl(&to->time);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
SDevicePresenceNotifyEvent(devicePresenceNotify * from,
|
|
|
|
devicePresenceNotify * to)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
|
|
|
*to = *from;
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&to->sequenceNumber);
|
|
|
|
swapl(&to->time);
|
|
|
|
swaps(&to->control);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
SDevicePropertyNotifyEvent(devicePropertyNotify * from,
|
|
|
|
devicePropertyNotify * to)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
|
|
|
*to = *from;
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&to->sequenceNumber);
|
|
|
|
swapl(&to->time);
|
|
|
|
swapl(&to->atom);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
SDeviceLeaveNotifyEvent(xXILeaveEvent * from, xXILeaveEvent * to)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
|
|
|
*to = *from;
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&to->sequenceNumber);
|
|
|
|
swapl(&to->length);
|
|
|
|
swaps(&to->evtype);
|
|
|
|
swaps(&to->deviceid);
|
|
|
|
swapl(&to->time);
|
|
|
|
swapl(&to->root);
|
|
|
|
swapl(&to->event);
|
|
|
|
swapl(&to->child);
|
|
|
|
swapl(&to->root_x);
|
|
|
|
swapl(&to->root_y);
|
|
|
|
swapl(&to->event_x);
|
|
|
|
swapl(&to->event_y);
|
|
|
|
swaps(&to->sourceid);
|
|
|
|
swaps(&to->buttons_len);
|
|
|
|
swapl(&to->mods.base_mods);
|
|
|
|
swapl(&to->mods.latched_mods);
|
|
|
|
swapl(&to->mods.locked_mods);
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
SDeviceChangedEvent(xXIDeviceChangedEvent * from, xXIDeviceChangedEvent * to)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
xXIAnyInfo *any;
|
|
|
|
|
|
|
|
*to = *from;
|
|
|
|
memcpy(&to[1], &from[1], from->length * 4);
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
any = (xXIAnyInfo *) &to[1];
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < to->num_classes; i++) {
|
2010-07-27 13:02:24 -06:00
|
|
|
int length = any->length;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (any->type) {
|
|
|
|
case KeyClass:
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xXIKeyInfo *ki = (xXIKeyInfo *) any;
|
2013-06-07 11:28:45 -06:00
|
|
|
uint32_t *key = (uint32_t *) &ki[1];
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
for (j = 0; j < ki->num_keycodes; j++, key++)
|
|
|
|
swapl(key);
|
|
|
|
swaps(&ki->num_keycodes);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ButtonClass:
|
|
|
|
{
|
|
|
|
xXIButtonInfo *bi = (xXIButtonInfo *) any;
|
|
|
|
Atom *labels = (Atom *) ((char *) bi + sizeof(xXIButtonInfo) +
|
|
|
|
pad_to_int32(bits_to_bytes
|
|
|
|
(bi->num_buttons)));
|
|
|
|
for (j = 0; j < bi->num_buttons; j++)
|
|
|
|
swapl(&labels[j]);
|
|
|
|
swaps(&bi->num_buttons);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ValuatorClass:
|
|
|
|
{
|
|
|
|
xXIValuatorInfo *ai = (xXIValuatorInfo *) any;
|
|
|
|
|
|
|
|
swapl(&ai->label);
|
|
|
|
swapl(&ai->min.integral);
|
|
|
|
swapl(&ai->min.frac);
|
|
|
|
swapl(&ai->max.integral);
|
|
|
|
swapl(&ai->max.frac);
|
|
|
|
swapl(&ai->resolution);
|
|
|
|
swaps(&ai->number);
|
|
|
|
}
|
|
|
|
break;
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&any->type);
|
|
|
|
swaps(&any->length);
|
|
|
|
swaps(&any->sourceid);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
any = (xXIAnyInfo *) ((char *) any + length * 4);
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&to->sequenceNumber);
|
|
|
|
swapl(&to->length);
|
|
|
|
swaps(&to->evtype);
|
|
|
|
swaps(&to->deviceid);
|
|
|
|
swapl(&to->time);
|
|
|
|
swaps(&to->num_classes);
|
|
|
|
swaps(&to->sourceid);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
SDeviceEvent(xXIDeviceEvent * from, xXIDeviceEvent * to)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
|
|
|
int i;
|
2010-07-27 13:02:24 -06:00
|
|
|
char *ptr;
|
|
|
|
char *vmask;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
memcpy(to, from, sizeof(xEvent) + from->length * 4);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&to->sequenceNumber);
|
|
|
|
swapl(&to->length);
|
|
|
|
swaps(&to->evtype);
|
|
|
|
swaps(&to->deviceid);
|
|
|
|
swapl(&to->time);
|
|
|
|
swapl(&to->detail);
|
|
|
|
swapl(&to->root);
|
|
|
|
swapl(&to->event);
|
|
|
|
swapl(&to->child);
|
|
|
|
swapl(&to->root_x);
|
|
|
|
swapl(&to->root_y);
|
|
|
|
swapl(&to->event_x);
|
|
|
|
swapl(&to->event_y);
|
|
|
|
swaps(&to->buttons_len);
|
|
|
|
swaps(&to->valuators_len);
|
|
|
|
swaps(&to->sourceid);
|
|
|
|
swapl(&to->mods.base_mods);
|
|
|
|
swapl(&to->mods.latched_mods);
|
|
|
|
swapl(&to->mods.locked_mods);
|
|
|
|
swapl(&to->mods.effective_mods);
|
|
|
|
swapl(&to->flags);
|
|
|
|
|
|
|
|
ptr = (char *) (&to[1]);
|
2010-07-27 13:02:24 -06:00
|
|
|
ptr += from->buttons_len * 4;
|
2012-06-10 07:21:05 -06:00
|
|
|
vmask = ptr; /* valuator mask */
|
2010-07-27 13:02:24 -06:00
|
|
|
ptr += from->valuators_len * 4;
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < from->valuators_len * 32; i++) {
|
|
|
|
if (BitIsOn(vmask, i)) {
|
|
|
|
swapl(((uint32_t *) ptr));
|
2010-07-27 13:02:24 -06:00
|
|
|
ptr += 4;
|
2012-06-10 07:21:05 -06:00
|
|
|
swapl(((uint32_t *) ptr));
|
2010-07-27 13:02:24 -06:00
|
|
|
ptr += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
SDeviceHierarchyEvent(xXIHierarchyEvent * from, xXIHierarchyEvent * to)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
xXIHierarchyInfo *info;
|
|
|
|
|
|
|
|
*to = *from;
|
|
|
|
memcpy(&to[1], &from[1], from->length * 4);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&to->sequenceNumber);
|
|
|
|
swapl(&to->length);
|
|
|
|
swaps(&to->evtype);
|
|
|
|
swaps(&to->deviceid);
|
|
|
|
swapl(&to->time);
|
|
|
|
swapl(&to->flags);
|
|
|
|
swaps(&to->num_info);
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
info = (xXIHierarchyInfo *) &to[1];
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < from->num_info; i++) {
|
|
|
|
swaps(&info->deviceid);
|
|
|
|
swaps(&info->attachment);
|
2010-07-27 13:02:24 -06:00
|
|
|
info++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
SXIPropertyEvent(xXIPropertyEvent * from, xXIPropertyEvent * to)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
|
|
|
*to = *from;
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&to->sequenceNumber);
|
|
|
|
swapl(&to->length);
|
|
|
|
swaps(&to->evtype);
|
|
|
|
swaps(&to->deviceid);
|
|
|
|
swapl(&to->property);
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
SRawEvent(xXIRawEvent * from, xXIRawEvent * to)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
FP3232 *values;
|
|
|
|
unsigned char *mask;
|
|
|
|
|
|
|
|
memcpy(to, from, sizeof(xEvent) + from->length * 4);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&to->sequenceNumber);
|
|
|
|
swapl(&to->length);
|
|
|
|
swaps(&to->evtype);
|
|
|
|
swaps(&to->deviceid);
|
|
|
|
swapl(&to->time);
|
|
|
|
swapl(&to->detail);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
mask = (unsigned char *) &to[1];
|
|
|
|
values = (FP3232 *) (mask + from->valuators_len * 4);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < from->valuators_len * 4 * 8; i++) {
|
|
|
|
if (BitIsOn(mask, i)) {
|
2010-07-27 13:02:24 -06:00
|
|
|
/* for each bit set there are two FP3232 values on the wire, in
|
|
|
|
* the order abcABC for data and data_raw. Here we swap as if
|
|
|
|
* they were in aAbBcC order because it's easier and really
|
|
|
|
* doesn't matter.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
swapl(&values->integral);
|
|
|
|
swapl(&values->frac);
|
2010-07-27 13:02:24 -06:00
|
|
|
values++;
|
2012-06-10 07:21:05 -06:00
|
|
|
swapl(&values->integral);
|
|
|
|
swapl(&values->frac);
|
2010-07-27 13:02:24 -06:00
|
|
|
values++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&to->valuators_len);
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
STouchOwnershipEvent(xXITouchOwnershipEvent * from, xXITouchOwnershipEvent * to)
|
|
|
|
{
|
|
|
|
*to = *from;
|
|
|
|
swaps(&to->sequenceNumber);
|
|
|
|
swapl(&to->length);
|
|
|
|
swaps(&to->evtype);
|
|
|
|
swaps(&to->deviceid);
|
|
|
|
swapl(&to->time);
|
|
|
|
swaps(&to->sourceid);
|
|
|
|
swapl(&to->touchid);
|
|
|
|
swapl(&to->flags);
|
|
|
|
swapl(&to->root);
|
|
|
|
swapl(&to->event);
|
|
|
|
swapl(&to->child);
|
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
static void
|
|
|
|
SBarrierEvent(xXIBarrierEvent * from,
|
|
|
|
xXIBarrierEvent * to) {
|
|
|
|
|
|
|
|
*to = *from;
|
|
|
|
|
2013-08-24 13:44:25 -06:00
|
|
|
swaps(&to->sequenceNumber);
|
|
|
|
swapl(&to->length);
|
|
|
|
swaps(&to->evtype);
|
|
|
|
swapl(&to->time);
|
|
|
|
swaps(&to->deviceid);
|
|
|
|
swaps(&to->sourceid);
|
|
|
|
swapl(&to->event);
|
|
|
|
swapl(&to->root);
|
|
|
|
swapl(&to->root_x);
|
|
|
|
swapl(&to->root_y);
|
|
|
|
|
|
|
|
swapl(&to->dx.integral);
|
|
|
|
swapl(&to->dx.frac);
|
|
|
|
swapl(&to->dy.integral);
|
|
|
|
swapl(&to->dy.frac);
|
|
|
|
swapl(&to->dtime);
|
|
|
|
swapl(&to->barrier);
|
|
|
|
swapl(&to->eventid);
|
2013-06-07 11:28:45 -06:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
/** Event swapping function for XI2 events. */
|
|
|
|
void
|
|
|
|
XI2EventSwap(xGenericEvent *from, xGenericEvent *to)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (from->evtype) {
|
|
|
|
case XI_Enter:
|
|
|
|
case XI_Leave:
|
|
|
|
case XI_FocusIn:
|
|
|
|
case XI_FocusOut:
|
|
|
|
SDeviceLeaveNotifyEvent((xXILeaveEvent *) from, (xXILeaveEvent *) to);
|
|
|
|
break;
|
|
|
|
case XI_DeviceChanged:
|
|
|
|
SDeviceChangedEvent((xXIDeviceChangedEvent *) from,
|
|
|
|
(xXIDeviceChangedEvent *) to);
|
|
|
|
break;
|
|
|
|
case XI_HierarchyChanged:
|
|
|
|
SDeviceHierarchyEvent((xXIHierarchyEvent *) from,
|
|
|
|
(xXIHierarchyEvent *) to);
|
|
|
|
break;
|
|
|
|
case XI_PropertyEvent:
|
|
|
|
SXIPropertyEvent((xXIPropertyEvent *) from, (xXIPropertyEvent *) to);
|
|
|
|
break;
|
|
|
|
case XI_Motion:
|
|
|
|
case XI_KeyPress:
|
|
|
|
case XI_KeyRelease:
|
|
|
|
case XI_ButtonPress:
|
|
|
|
case XI_ButtonRelease:
|
|
|
|
case XI_TouchBegin:
|
|
|
|
case XI_TouchUpdate:
|
|
|
|
case XI_TouchEnd:
|
|
|
|
SDeviceEvent((xXIDeviceEvent *) from, (xXIDeviceEvent *) to);
|
|
|
|
break;
|
|
|
|
case XI_TouchOwnership:
|
|
|
|
STouchOwnershipEvent((xXITouchOwnershipEvent *) from,
|
|
|
|
(xXITouchOwnershipEvent *) to);
|
|
|
|
break;
|
|
|
|
case XI_RawMotion:
|
|
|
|
case XI_RawKeyPress:
|
|
|
|
case XI_RawKeyRelease:
|
|
|
|
case XI_RawButtonPress:
|
|
|
|
case XI_RawButtonRelease:
|
|
|
|
case XI_RawTouchBegin:
|
|
|
|
case XI_RawTouchUpdate:
|
|
|
|
case XI_RawTouchEnd:
|
|
|
|
SRawEvent((xXIRawEvent *) from, (xXIRawEvent *) to);
|
|
|
|
break;
|
2013-06-07 11:28:45 -06:00
|
|
|
case XI_BarrierHit:
|
|
|
|
case XI_BarrierLeave:
|
|
|
|
SBarrierEvent((xXIBarrierEvent *) from,
|
|
|
|
(xXIBarrierEvent *) to);
|
|
|
|
break;
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
|
|
|
ErrorF("[Xi] Unknown event type to swap. This is a bug.\n");
|
|
|
|
break;
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
2010-07-27 13:02:24 -06:00
|
|
|
* Allow the specified event to have its propagation suppressed.
|
|
|
|
* The default is to not allow suppression of propagation.
|
2007-11-24 10:55:21 -07:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
static void
|
|
|
|
AllowPropagateSuppress(Mask mask)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
for (i = 0; i < MAXDEVICES; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
PropagateMask[i] |= mask;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Record an event mask where there is no unique corresponding event type.
|
|
|
|
* We can't call SetMaskForEvent, since that would clobber the existing
|
|
|
|
* mask for that event. MotionHint and ButtonMotion are examples.
|
|
|
|
*
|
|
|
|
* Since extension event types will never be less than 64, we can use
|
|
|
|
* 0-63 in the EventInfo array as the "type" to be used to look up this
|
2009-09-06 13:44:18 -06:00
|
|
|
* mask. This means that the corresponding macros such as
|
2007-11-24 10:55:21 -07:00
|
|
|
* DevicePointerMotionHint must have access to the same constants.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
SetEventInfo(Mask mask, int constant)
|
|
|
|
{
|
|
|
|
EventInfo[ExtEventIndex].mask = mask;
|
|
|
|
EventInfo[ExtEventIndex++].type = constant;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Allow the specified event to be restricted to being selected by one
|
|
|
|
* client at a time.
|
|
|
|
* The default is to allow more than one client to select the event.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
SetExclusiveAccess(Mask mask)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
for (i = 0; i < MAXDEVICES; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
ExtExclusiveMasks[i] |= mask;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Assign the specified mask to the specified event.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
SetMaskForExtEvent(Mask mask, int event)
|
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
int i;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
EventInfo[ExtEventIndex].mask = mask;
|
|
|
|
EventInfo[ExtEventIndex++].type = event;
|
|
|
|
|
|
|
|
if ((event < LASTEvent) || (event >= 128))
|
2012-06-10 07:21:05 -06:00
|
|
|
FatalError("MaskForExtensionEvent: bogus event number");
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
for (i = 0; i < MAXDEVICES; i++)
|
|
|
|
SetMaskForEvent(i, mask, event);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/************************************************************************
|
|
|
|
*
|
|
|
|
* This function sets up extension event types and masks.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2006-11-26 11:13:41 -07:00
|
|
|
FixExtensionEvents(ExtensionEntry * extEntry)
|
|
|
|
{
|
|
|
|
DeviceValuator = extEntry->eventBase;
|
|
|
|
DeviceKeyPress = DeviceValuator + 1;
|
|
|
|
DeviceKeyRelease = DeviceKeyPress + 1;
|
|
|
|
DeviceButtonPress = DeviceKeyRelease + 1;
|
|
|
|
DeviceButtonRelease = DeviceButtonPress + 1;
|
|
|
|
DeviceMotionNotify = DeviceButtonRelease + 1;
|
|
|
|
DeviceFocusIn = DeviceMotionNotify + 1;
|
|
|
|
DeviceFocusOut = DeviceFocusIn + 1;
|
|
|
|
ProximityIn = DeviceFocusOut + 1;
|
|
|
|
ProximityOut = ProximityIn + 1;
|
|
|
|
DeviceStateNotify = ProximityOut + 1;
|
|
|
|
DeviceMappingNotify = DeviceStateNotify + 1;
|
|
|
|
ChangeDeviceNotify = DeviceMappingNotify + 1;
|
|
|
|
DeviceKeyStateNotify = ChangeDeviceNotify + 1;
|
|
|
|
DeviceButtonStateNotify = DeviceKeyStateNotify + 1;
|
2007-11-24 10:55:21 -07:00
|
|
|
DevicePresenceNotify = DeviceButtonStateNotify + 1;
|
2009-09-06 13:44:18 -06:00
|
|
|
DevicePropertyNotify = DevicePresenceNotify + 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
event_base[KeyClass] = DeviceKeyPress;
|
|
|
|
event_base[ButtonClass] = DeviceButtonPress;
|
|
|
|
event_base[ValuatorClass] = DeviceMotionNotify;
|
|
|
|
event_base[ProximityClass] = ProximityIn;
|
|
|
|
event_base[FocusClass] = DeviceFocusIn;
|
|
|
|
event_base[OtherClass] = DeviceStateNotify;
|
|
|
|
|
|
|
|
BadDevice += extEntry->errorBase;
|
|
|
|
BadEvent += extEntry->errorBase;
|
|
|
|
BadMode += extEntry->errorBase;
|
|
|
|
DeviceBusy += extEntry->errorBase;
|
|
|
|
BadClass += extEntry->errorBase;
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
SetMaskForExtEvent(DeviceKeyPressMask, DeviceKeyPress);
|
|
|
|
AllowPropagateSuppress(DeviceKeyPressMask);
|
|
|
|
SetCriticalEvent(DeviceKeyPress);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
SetMaskForExtEvent(DeviceKeyReleaseMask, DeviceKeyRelease);
|
|
|
|
AllowPropagateSuppress(DeviceKeyReleaseMask);
|
|
|
|
SetCriticalEvent(DeviceKeyRelease);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
SetMaskForExtEvent(DeviceButtonPressMask, DeviceButtonPress);
|
|
|
|
AllowPropagateSuppress(DeviceButtonPressMask);
|
|
|
|
SetCriticalEvent(DeviceButtonPress);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
SetMaskForExtEvent(DeviceButtonReleaseMask, DeviceButtonRelease);
|
|
|
|
AllowPropagateSuppress(DeviceButtonReleaseMask);
|
|
|
|
SetCriticalEvent(DeviceButtonRelease);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
SetMaskForExtEvent(DeviceProximityMask, ProximityIn);
|
|
|
|
SetMaskForExtEvent(DeviceProximityMask, ProximityOut);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
SetMaskForExtEvent(DeviceStateNotifyMask, DeviceStateNotify);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
SetMaskForExtEvent(DevicePointerMotionMask, DeviceMotionNotify);
|
|
|
|
AllowPropagateSuppress(DevicePointerMotionMask);
|
|
|
|
SetCriticalEvent(DeviceMotionNotify);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
SetEventInfo(DevicePointerMotionHintMask, _devicePointerMotionHint);
|
2010-07-27 13:02:24 -06:00
|
|
|
SetEventInfo(DeviceButton1MotionMask, _deviceButton1Motion);
|
|
|
|
SetEventInfo(DeviceButton2MotionMask, _deviceButton2Motion);
|
|
|
|
SetEventInfo(DeviceButton3MotionMask, _deviceButton3Motion);
|
|
|
|
SetEventInfo(DeviceButton4MotionMask, _deviceButton4Motion);
|
|
|
|
SetEventInfo(DeviceButton5MotionMask, _deviceButton5Motion);
|
2006-11-26 11:13:41 -07:00
|
|
|
SetEventInfo(DeviceButtonMotionMask, _deviceButtonMotion);
|
|
|
|
|
|
|
|
SetMaskForExtEvent(DeviceFocusChangeMask, DeviceFocusIn);
|
|
|
|
SetMaskForExtEvent(DeviceFocusChangeMask, DeviceFocusOut);
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
SetMaskForExtEvent(DeviceMappingNotifyMask, DeviceMappingNotify);
|
|
|
|
SetMaskForExtEvent(ChangeDeviceNotifyMask, ChangeDeviceNotify);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
SetEventInfo(DeviceButtonGrabMask, _deviceButtonGrab);
|
|
|
|
SetExclusiveAccess(DeviceButtonGrabMask);
|
|
|
|
|
|
|
|
SetEventInfo(DeviceOwnerGrabButtonMask, _deviceOwnerGrabButton);
|
2007-11-24 10:55:21 -07:00
|
|
|
SetEventInfo(DevicePresenceNotifyMask, _devicePresence);
|
2009-09-06 13:44:18 -06:00
|
|
|
SetMaskForExtEvent(DevicePropertyNotifyMask, DevicePropertyNotify);
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
SetEventInfo(0, _noExtensionEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
*
|
2009-09-06 13:44:18 -06:00
|
|
|
* This function restores extension event types and masks to their
|
2006-11-26 11:13:41 -07:00
|
|
|
* initial state.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2006-11-26 11:13:41 -07:00
|
|
|
RestoreExtensionEvents(void)
|
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
int i, j;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
IReqCode = 0;
|
2009-09-06 13:44:18 -06:00
|
|
|
IEventBase = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
for (i = 0; i < ExtEventIndex - 1; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((EventInfo[i].type >= LASTEvent) && (EventInfo[i].type < 128)) {
|
2009-09-06 13:44:18 -06:00
|
|
|
for (j = 0; j < MAXDEVICES; j++)
|
|
|
|
SetMaskForEvent(j, 0, EventInfo[i].type);
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
EventInfo[i].mask = 0;
|
|
|
|
EventInfo[i].type = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
ExtEventIndex = 0;
|
|
|
|
DeviceValuator = 0;
|
|
|
|
DeviceKeyPress = 1;
|
|
|
|
DeviceKeyRelease = 2;
|
|
|
|
DeviceButtonPress = 3;
|
|
|
|
DeviceButtonRelease = 4;
|
|
|
|
DeviceMotionNotify = 5;
|
|
|
|
DeviceFocusIn = 6;
|
|
|
|
DeviceFocusOut = 7;
|
|
|
|
ProximityIn = 8;
|
|
|
|
ProximityOut = 9;
|
|
|
|
DeviceStateNotify = 10;
|
|
|
|
DeviceMappingNotify = 11;
|
|
|
|
ChangeDeviceNotify = 12;
|
|
|
|
DeviceKeyStateNotify = 13;
|
|
|
|
DeviceButtonStateNotify = 13;
|
2007-11-24 10:55:21 -07:00
|
|
|
DevicePresenceNotify = 14;
|
2009-09-06 13:44:18 -06:00
|
|
|
DevicePropertyNotify = 15;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
BadDevice = 0;
|
|
|
|
BadEvent = 1;
|
|
|
|
BadMode = 2;
|
|
|
|
DeviceBusy = 3;
|
|
|
|
BadClass = 4;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* IResetProc.
|
|
|
|
* Remove reply-swapping routine.
|
|
|
|
* Remove event-swapping routine.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2006-11-26 11:13:41 -07:00
|
|
|
IResetProc(ExtensionEntry * unused)
|
|
|
|
{
|
|
|
|
ReplySwapVector[IReqCode] = ReplyNotSwappd;
|
|
|
|
EventSwapVector[DeviceValuator] = NotImplemented;
|
|
|
|
EventSwapVector[DeviceKeyPress] = NotImplemented;
|
|
|
|
EventSwapVector[DeviceKeyRelease] = NotImplemented;
|
|
|
|
EventSwapVector[DeviceButtonPress] = NotImplemented;
|
|
|
|
EventSwapVector[DeviceButtonRelease] = NotImplemented;
|
|
|
|
EventSwapVector[DeviceMotionNotify] = NotImplemented;
|
|
|
|
EventSwapVector[DeviceFocusIn] = NotImplemented;
|
|
|
|
EventSwapVector[DeviceFocusOut] = NotImplemented;
|
|
|
|
EventSwapVector[ProximityIn] = NotImplemented;
|
|
|
|
EventSwapVector[ProximityOut] = NotImplemented;
|
|
|
|
EventSwapVector[DeviceStateNotify] = NotImplemented;
|
|
|
|
EventSwapVector[DeviceKeyStateNotify] = NotImplemented;
|
|
|
|
EventSwapVector[DeviceButtonStateNotify] = NotImplemented;
|
|
|
|
EventSwapVector[DeviceMappingNotify] = NotImplemented;
|
|
|
|
EventSwapVector[ChangeDeviceNotify] = NotImplemented;
|
2007-11-24 10:55:21 -07:00
|
|
|
EventSwapVector[DevicePresenceNotify] = NotImplemented;
|
2009-09-06 13:44:18 -06:00
|
|
|
EventSwapVector[DevicePropertyNotify] = NotImplemented;
|
2006-11-26 11:13:41 -07:00
|
|
|
RestoreExtensionEvents();
|
2013-06-07 11:28:45 -06:00
|
|
|
|
|
|
|
free(xi_all_devices.name);
|
|
|
|
free(xi_all_master_devices.name);
|
2014-05-02 13:27:46 -06:00
|
|
|
|
|
|
|
XIBarrierReset();
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* Assign an id and type to an input device.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
AssignTypeAndName(DeviceIntPtr dev, Atom type, const char *name)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2010-07-27 13:02:24 -06:00
|
|
|
dev->xinput_type = type;
|
2011-11-05 07:32:40 -06:00
|
|
|
dev->name = strdup(name);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* Make device type atoms.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2006-11-26 11:13:41 -07:00
|
|
|
MakeDeviceTypeAtoms(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < NUMTYPES; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
dev_type[i].type =
|
|
|
|
MakeAtom(dev_type[i].name, strlen(dev_type[i].name), 1);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
/*****************************************************************************
|
2006-11-26 11:13:41 -07:00
|
|
|
*
|
2007-11-24 10:55:21 -07:00
|
|
|
* SEventIDispatch
|
2006-11-26 11:13:41 -07:00
|
|
|
*
|
2007-11-24 10:55:21 -07:00
|
|
|
* Swap any events defined in this extension.
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
2007-11-24 10:55:21 -07:00
|
|
|
#define DO_SWAP(func,type) func ((type *)from, (type *)to)
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
SEventIDispatch(xEvent *from, xEvent *to)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
int type = from->u.u.type & 0177;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
if (type == DeviceValuator)
|
2012-06-10 07:21:05 -06:00
|
|
|
DO_SWAP(SEventDeviceValuator, deviceValuator);
|
2007-11-24 10:55:21 -07:00
|
|
|
else if (type == DeviceKeyPress) {
|
2012-06-10 07:21:05 -06:00
|
|
|
SKeyButtonPtrEvent(from, to);
|
|
|
|
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
|
|
|
|
}
|
|
|
|
else if (type == DeviceKeyRelease) {
|
|
|
|
SKeyButtonPtrEvent(from, to);
|
|
|
|
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
|
|
|
|
}
|
|
|
|
else if (type == DeviceButtonPress) {
|
|
|
|
SKeyButtonPtrEvent(from, to);
|
|
|
|
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
|
|
|
|
}
|
|
|
|
else if (type == DeviceButtonRelease) {
|
|
|
|
SKeyButtonPtrEvent(from, to);
|
|
|
|
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
|
|
|
|
}
|
|
|
|
else if (type == DeviceMotionNotify) {
|
|
|
|
SKeyButtonPtrEvent(from, to);
|
|
|
|
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
|
|
|
|
}
|
|
|
|
else if (type == DeviceFocusIn)
|
|
|
|
DO_SWAP(SEventFocus, deviceFocus);
|
2007-11-24 10:55:21 -07:00
|
|
|
else if (type == DeviceFocusOut)
|
2012-06-10 07:21:05 -06:00
|
|
|
DO_SWAP(SEventFocus, deviceFocus);
|
2007-11-24 10:55:21 -07:00
|
|
|
else if (type == ProximityIn) {
|
2012-06-10 07:21:05 -06:00
|
|
|
SKeyButtonPtrEvent(from, to);
|
|
|
|
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
|
|
|
|
}
|
|
|
|
else if (type == ProximityOut) {
|
|
|
|
SKeyButtonPtrEvent(from, to);
|
|
|
|
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
|
|
|
|
}
|
|
|
|
else if (type == DeviceStateNotify)
|
|
|
|
DO_SWAP(SDeviceStateNotifyEvent, deviceStateNotify);
|
2007-11-24 10:55:21 -07:00
|
|
|
else if (type == DeviceKeyStateNotify)
|
2012-06-10 07:21:05 -06:00
|
|
|
DO_SWAP(SDeviceKeyStateNotifyEvent, deviceKeyStateNotify);
|
2007-11-24 10:55:21 -07:00
|
|
|
else if (type == DeviceButtonStateNotify)
|
2012-06-10 07:21:05 -06:00
|
|
|
DO_SWAP(SDeviceButtonStateNotifyEvent, deviceButtonStateNotify);
|
2007-11-24 10:55:21 -07:00
|
|
|
else if (type == DeviceMappingNotify)
|
2012-06-10 07:21:05 -06:00
|
|
|
DO_SWAP(SDeviceMappingNotifyEvent, deviceMappingNotify);
|
2007-11-24 10:55:21 -07:00
|
|
|
else if (type == ChangeDeviceNotify)
|
2012-06-10 07:21:05 -06:00
|
|
|
DO_SWAP(SChangeDeviceNotifyEvent, changeDeviceNotify);
|
2008-11-02 08:26:08 -07:00
|
|
|
else if (type == DevicePresenceNotify)
|
2012-06-10 07:21:05 -06:00
|
|
|
DO_SWAP(SDevicePresenceNotifyEvent, devicePresenceNotify);
|
2009-09-06 13:44:18 -06:00
|
|
|
else if (type == DevicePropertyNotify)
|
2012-06-10 07:21:05 -06:00
|
|
|
DO_SWAP(SDevicePropertyNotifyEvent, devicePropertyNotify);
|
2007-11-24 10:55:21 -07:00
|
|
|
else {
|
2012-06-10 07:21:05 -06:00
|
|
|
FatalError("XInputExtension: Impossible event!\n");
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
/**********************************************************************
|
2006-11-26 11:13:41 -07:00
|
|
|
*
|
2007-11-24 10:55:21 -07:00
|
|
|
* IExtensionInit - initialize the input extension.
|
2006-11-26 11:13:41 -07:00
|
|
|
*
|
2007-11-24 10:55:21 -07:00
|
|
|
* Called from InitExtensions in main() or from QueryExtension() if the
|
|
|
|
* extension is dynamically loaded.
|
2006-11-26 11:13:41 -07:00
|
|
|
*
|
2007-11-24 10:55:21 -07:00
|
|
|
* This extension has several events and errors.
|
2006-11-26 11:13:41 -07:00
|
|
|
*
|
2009-09-06 13:44:18 -06:00
|
|
|
* XI is mandatory nowadays, so if we fail to init XI, we die.
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2007-11-24 10:55:21 -07:00
|
|
|
XInputExtensionInit(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
ExtensionEntry *extEntry;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
XExtensionVersion thisversion = { XI_Present,
|
|
|
|
SERVER_XI_MAJOR_VERSION,
|
|
|
|
SERVER_XI_MINOR_VERSION,
|
|
|
|
};
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!dixRegisterPrivateKey
|
|
|
|
(&XIClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(XIClientRec)))
|
2009-09-06 13:44:18 -06:00
|
|
|
FatalError("Cannot request private for XI.\n");
|
|
|
|
|
|
|
|
if (!AddCallback(&ClientStateCallback, XIClientCallback, 0))
|
|
|
|
FatalError("Failed to add callback to XI.\n");
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
if (!XIBarrierInit())
|
|
|
|
FatalError("Could not initialize barriers.\n");
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch,
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcIDispatch, IResetProc, StandardMinorOpcode);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (extEntry) {
|
2012-06-10 07:21:05 -06:00
|
|
|
IReqCode = extEntry->base;
|
|
|
|
IEventBase = extEntry->eventBase;
|
|
|
|
XIVersion = thisversion;
|
|
|
|
MakeDeviceTypeAtoms();
|
|
|
|
RT_INPUTCLIENT = CreateNewResourceType((DeleteType) InputClientGone,
|
|
|
|
"INPUTCLIENT");
|
|
|
|
if (!RT_INPUTCLIENT)
|
|
|
|
FatalError("Failed to add resource type for XI.\n");
|
|
|
|
FixExtensionEvents(extEntry);
|
|
|
|
ReplySwapVector[IReqCode] = (ReplySwapPtr) SReplyIDispatch;
|
|
|
|
EventSwapVector[DeviceValuator] = SEventIDispatch;
|
|
|
|
EventSwapVector[DeviceKeyPress] = SEventIDispatch;
|
|
|
|
EventSwapVector[DeviceKeyRelease] = SEventIDispatch;
|
|
|
|
EventSwapVector[DeviceButtonPress] = SEventIDispatch;
|
|
|
|
EventSwapVector[DeviceButtonRelease] = SEventIDispatch;
|
|
|
|
EventSwapVector[DeviceMotionNotify] = SEventIDispatch;
|
|
|
|
EventSwapVector[DeviceFocusIn] = SEventIDispatch;
|
|
|
|
EventSwapVector[DeviceFocusOut] = SEventIDispatch;
|
|
|
|
EventSwapVector[ProximityIn] = SEventIDispatch;
|
|
|
|
EventSwapVector[ProximityOut] = SEventIDispatch;
|
|
|
|
EventSwapVector[DeviceStateNotify] = SEventIDispatch;
|
|
|
|
EventSwapVector[DeviceKeyStateNotify] = SEventIDispatch;
|
|
|
|
EventSwapVector[DeviceButtonStateNotify] = SEventIDispatch;
|
|
|
|
EventSwapVector[DeviceMappingNotify] = SEventIDispatch;
|
|
|
|
EventSwapVector[ChangeDeviceNotify] = SEventIDispatch;
|
|
|
|
EventSwapVector[DevicePresenceNotify] = SEventIDispatch;
|
|
|
|
|
|
|
|
GERegisterExtension(IReqCode, XI2EventSwap);
|
|
|
|
|
|
|
|
memset(&xi_all_devices, 0, sizeof(xi_all_devices));
|
|
|
|
memset(&xi_all_master_devices, 0, sizeof(xi_all_master_devices));
|
|
|
|
xi_all_devices.id = XIAllDevices;
|
2013-06-07 11:28:45 -06:00
|
|
|
xi_all_devices.name = strdup("XIAllDevices");
|
2012-06-10 07:21:05 -06:00
|
|
|
xi_all_master_devices.id = XIAllMasterDevices;
|
2013-06-07 11:28:45 -06:00
|
|
|
xi_all_master_devices.name = strdup("XIAllMasterDevices");
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
inputInfo.all_devices = &xi_all_devices;
|
|
|
|
inputInfo.all_master_devices = &xi_all_master_devices;
|
|
|
|
|
|
|
|
XIResetProperties();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
FatalError("IExtensionInit: AddExtensions failed\n");
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|