#define NUMTYPES 15
#define NEED_EVENTS
#define NEED_REPLIES
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "inputstr.h"
#include "gcstruct.h"
#include "extnsionst.h"
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include <X11/extensions/geproto.h>
#include "geext.h"
#include "dixevents.h"
#include "exevents.h"
#include "extinit.h"
#include "exglobals.h"
#include "swaprep.h"
#include "registry.h"
#include "privates.h"
#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 "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 "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"
#include "xiproperty.h"
static Mask lastExtEventMask = 1;
int ExtEventIndex;
Mask ExtValidMasks[EMASKSIZE];
Mask ExtExclusiveMasks[EMASKSIZE];
static struct dev_type
{
Atom type;
char *name;
} dev_type[] = {
{
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}};
CARD8 event_base[numInputClasses];
XExtEventInfo EventInfo[32];
static int (*ProcIVector[])(ClientPtr) = {
NULL,
ProcXGetExtensionVersion,
ProcXListInputDevices,
ProcXOpenDevice,
ProcXCloseDevice,
ProcXSetDeviceMode,
ProcXSelectExtensionEvent,
ProcXGetSelectedExtensionEvents,
ProcXChangeDeviceDontPropagateList,
ProcXGetDeviceDontPropagateList,
ProcXGetDeviceMotionEvents,
ProcXChangeKeyboardDevice,
ProcXChangePointerDevice,
ProcXGrabDevice,
ProcXUngrabDevice,
ProcXGrabDeviceKey,
ProcXUngrabDeviceKey,
ProcXGrabDeviceButton,
ProcXUngrabDeviceButton,
ProcXAllowDeviceEvents,
ProcXGetDeviceFocus,
ProcXSetDeviceFocus,
ProcXGetFeedbackControl,
ProcXChangeFeedbackControl,
ProcXGetDeviceKeyMapping,
ProcXChangeDeviceKeyMapping,
ProcXGetDeviceModifierMapping,
ProcXSetDeviceModifierMapping,
ProcXGetDeviceButtonMapping,
ProcXSetDeviceButtonMapping,
ProcXQueryDeviceState,
ProcXSendExtensionEvent,
ProcXDeviceBell,
ProcXSetDeviceValuators,
ProcXGetDeviceControl,
ProcXChangeDeviceControl,
ProcXListDeviceProperties,
ProcXChangeDeviceProperty,
ProcXDeleteDeviceProperty,
ProcXGetDeviceProperty
};
static int (*SProcIVector[])(ClientPtr) = {
NULL,
SProcXGetExtensionVersion,
SProcXListInputDevices,
SProcXOpenDevice,
SProcXCloseDevice,
SProcXSetDeviceMode,
SProcXSelectExtensionEvent,
SProcXGetSelectedExtensionEvents,
SProcXChangeDeviceDontPropagateList,
SProcXGetDeviceDontPropagateList,
SProcXGetDeviceMotionEvents,
SProcXChangeKeyboardDevice,
SProcXChangePointerDevice,
SProcXGrabDevice,
SProcXUngrabDevice,
SProcXGrabDeviceKey,
SProcXUngrabDeviceKey,
SProcXGrabDeviceButton,
SProcXUngrabDeviceButton,
SProcXAllowDeviceEvents,
SProcXGetDeviceFocus,
SProcXSetDeviceFocus,
SProcXGetFeedbackControl,
SProcXChangeFeedbackControl,
SProcXGetDeviceKeyMapping,
SProcXChangeDeviceKeyMapping,
SProcXGetDeviceModifierMapping,
SProcXSetDeviceModifierMapping,
SProcXGetDeviceButtonMapping,
SProcXSetDeviceButtonMapping,
SProcXQueryDeviceState,
SProcXSendExtensionEvent,
SProcXDeviceBell,
SProcXSetDeviceValuators,
SProcXGetDeviceControl,
SProcXChangeDeviceControl,
SProcXListDeviceProperties,
SProcXChangeDeviceProperty,
SProcXDeleteDeviceProperty,
SProcXGetDeviceProperty
};
int IReqCode = 0;
int IEventBase = 0;
int BadDevice = 0;
static int BadEvent = 1;
int BadMode = 2;
int DeviceBusy = 3;
int BadClass = 4;
Mask DevicePointerMotionMask;
Mask DevicePointerMotionHintMask;
Mask DeviceFocusChangeMask;
Mask DeviceStateNotifyMask;
static Mask ChangeDeviceNotifyMask;
Mask DeviceMappingNotifyMask;
Mask DeviceOwnerGrabButtonMask;
Mask DeviceButtonGrabMask;
Mask DeviceButtonMotionMask;
Mask DevicePresenceNotifyMask;
Mask DevicePropertyNotifyMask;
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;
int DevicePresenceNotify;
int DevicePropertyNotify;
int RT_INPUTCLIENT;
extern XExtensionVersion AllExtensionVersions[];
Mask PropagateMask[MAXDEVICES];
static int XIClientPrivateKeyIndex;
DevPrivateKey XIClientPrivateKey = &XIClientPrivateKeyIndex;
static XExtensionVersion thisversion = { XI_Present,
XI_Add_DeviceProperties_Major,
XI_Add_DeviceProperties_Minor
};
static void
XIClientCallback(CallbackListPtr *list,
pointer closure,
pointer data)
{
NewClientInfoRec *clientinfo = (NewClientInfoRec*)data;
ClientPtr pClient = clientinfo->client;
XIClientPtr pXIClient;
pXIClient = dixLookupPrivate(&pClient->devPrivates, XIClientPrivateKey);
pXIClient->major_version = 0;
pXIClient->minor_version = 0;
}
static int
ProcIDispatch(ClientPtr client)
{
REQUEST(xReq);
if (stuff->data > IREQUESTS || !ProcIVector[stuff->data])
return BadRequest;
return (*ProcIVector[stuff->data])(client);
}
static int
SProcIDispatch(ClientPtr client)
{
REQUEST(xReq);
if (stuff->data > IREQUESTS || !SProcIVector[stuff->data])
return BadRequest;
return (*SProcIVector[stuff->data])(client);
}
static void
SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
{
if (rep->RepType == X_GetExtensionVersion)
SRepXGetExtensionVersion(client, len,
(xGetExtensionVersionReply *) rep);
else if (rep->RepType == X_ListInputDevices)
SRepXListInputDevices(client, len, (xListInputDevicesReply *) rep);
else if (rep->RepType == X_OpenDevice)
SRepXOpenDevice(client, len, (xOpenDeviceReply *) rep);
else if (rep->RepType == X_SetDeviceMode)
SRepXSetDeviceMode(client, len, (xSetDeviceModeReply *) rep);
else if (rep->RepType == X_GetSelectedExtensionEvents)
SRepXGetSelectedExtensionEvents(client, len,
(xGetSelectedExtensionEventsReply *)
rep);
else if (rep->RepType == X_GetDeviceDontPropagateList)
SRepXGetDeviceDontPropagateList(client, len,
(xGetDeviceDontPropagateListReply *)
rep);
else if (rep->RepType == X_GetDeviceMotionEvents)
SRepXGetDeviceMotionEvents(client, len,
(xGetDeviceMotionEventsReply *) rep);
else if (rep->RepType == X_GrabDevice)
SRepXGrabDevice(client, len, (xGrabDeviceReply *) rep);
else if (rep->RepType == X_GetDeviceFocus)
SRepXGetDeviceFocus(client, len, (xGetDeviceFocusReply *) rep);
else if (rep->RepType == X_GetFeedbackControl)
SRepXGetFeedbackControl(client, len, (xGetFeedbackControlReply *) rep);
else if (rep->RepType == X_GetDeviceKeyMapping)
SRepXGetDeviceKeyMapping(client, len,
(xGetDeviceKeyMappingReply *) rep);
else if (rep->RepType == X_GetDeviceModifierMapping)
SRepXGetDeviceModifierMapping(client, len,
(xGetDeviceModifierMappingReply *) rep);
else if (rep->RepType == X_SetDeviceModifierMapping)
SRepXSetDeviceModifierMapping(client, len,
(xSetDeviceModifierMappingReply *) rep);
else if (rep->RepType == X_GetDeviceButtonMapping)
SRepXGetDeviceButtonMapping(client, len,
(xGetDeviceButtonMappingReply *) rep);
else if (rep->RepType == X_SetDeviceButtonMapping)
SRepXSetDeviceButtonMapping(client, len,
(xSetDeviceButtonMappingReply *) rep);
else if (rep->RepType == X_QueryDeviceState)
SRepXQueryDeviceState(client, len, (xQueryDeviceStateReply *) rep);
else if (rep->RepType == X_SetDeviceValuators)
SRepXSetDeviceValuators(client, len, (xSetDeviceValuatorsReply *) rep);
else if (rep->RepType == X_GetDeviceControl)
SRepXGetDeviceControl(client, len, (xGetDeviceControlReply *) rep);
else if (rep->RepType == X_ChangeDeviceControl)
SRepXChangeDeviceControl(client, len,
(xChangeDeviceControlReply *) rep);
else if (rep->RepType == X_ListDeviceProperties)
SRepXListDeviceProperties(client, len, (xListDevicePropertiesReply*)rep);
else if (rep->RepType == X_GetDeviceProperty)
SRepXGetDeviceProperty(client, len, (xGetDevicePropertyReply *) rep);
else {
FatalError("XINPUT confused sending swapped reply");
}
}
static void
SEventDeviceValuator(deviceValuator * from, deviceValuator * to)
{
char n;
int i;
INT32 *ip B32;
*to = *from;
swaps(&to->sequenceNumber, n);
swaps(&to->device_state, n);
ip = &to->valuator0;
for (i = 0; i < 6; i++) {
swapl((ip + i), n);
}
}
static void
SEventFocus(deviceFocus * from, deviceFocus * to)
{
char n;
*to = *from;
swaps(&to->sequenceNumber, n);
swapl(&to->time, n);
swapl(&to->window, n);
}
static void
SDeviceStateNotifyEvent(deviceStateNotify * from, deviceStateNotify * to)
{
int i;
char n;
INT32 *ip B32;
*to = *from;
swaps(&to->sequenceNumber, n);
swapl(&to->time, n);
ip = &to->valuator0;
for (i = 0; i < 3; i++) {
swapl((ip + i), n);
}
}
static void
SDeviceKeyStateNotifyEvent(deviceKeyStateNotify * from,
deviceKeyStateNotify * to)
{
char n;
*to = *from;
swaps(&to->sequenceNumber, n);
}
static void
SDeviceButtonStateNotifyEvent(deviceButtonStateNotify * from,
deviceButtonStateNotify * to)
{
char n;
*to = *from;
swaps(&to->sequenceNumber, n);
}
static void
SChangeDeviceNotifyEvent(changeDeviceNotify * from, changeDeviceNotify * to)
{
char n;
*to = *from;
swaps(&to->sequenceNumber, n);
swapl(&to->time, n);
}
static void
SDeviceMappingNotifyEvent(deviceMappingNotify * from, deviceMappingNotify * to)
{
char n;
*to = *from;
swaps(&to->sequenceNumber, n);
swapl(&to->time, n);
}
static void
SDevicePresenceNotifyEvent (devicePresenceNotify *from, devicePresenceNotify *to)
{
char n;
*to = *from;
swaps(&to->sequenceNumber,n);
swapl(&to->time, n);
swaps(&to->control, n);
}
static void
SDevicePropertyNotifyEvent (devicePropertyNotify *from, devicePropertyNotify *to)
{
char n;
*to = *from;
swaps(&to->sequenceNumber,n);
swapl(&to->time, n);
swapl(&to->atom, n);
}
static void
AllowPropagateSuppress(Mask mask)
{
int i;
for (i = 0; i < MAXDEVICES; i++)
PropagateMask[i] |= mask;
}
static Mask
GetNextExtEventMask(void)
{
int i;
Mask mask = lastExtEventMask;
if (lastExtEventMask == 0) {
FatalError("GetNextExtEventMask: no more events are available.");
}
lastExtEventMask <<= 1;
for (i = 0; i < MAXDEVICES; i++)
ExtValidMasks[i] |= mask;
return mask;
}
static void
SetEventInfo(Mask mask, int constant)
{
EventInfo[ExtEventIndex].mask = mask;
EventInfo[ExtEventIndex++].type = constant;
}
static void
SetExclusiveAccess(Mask mask)
{
int i;
for (i = 0; i < MAXDEVICES; i++)
ExtExclusiveMasks[i] |= mask;
}
static void
SetMaskForExtEvent(Mask mask, int event)
{
int i;
EventInfo[ExtEventIndex].mask = mask;
EventInfo[ExtEventIndex++].type = event;
if ((event < LASTEvent) || (event >= 128))
FatalError("MaskForExtensionEvent: bogus event number");
for (i = 0; i < MAXDEVICES; i++)
SetMaskForEvent(i, mask, event);
}
static void
FixExtensionEvents(ExtensionEntry * extEntry)
{
Mask mask;
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;
DevicePresenceNotify = DeviceButtonStateNotify + 1;
DevicePropertyNotify = DevicePresenceNotify + 1;
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;
mask = GetNextExtEventMask();
SetMaskForExtEvent(mask, DeviceKeyPress);
AllowPropagateSuppress(mask);
mask = GetNextExtEventMask();
SetMaskForExtEvent(mask, DeviceKeyRelease);
AllowPropagateSuppress(mask);
mask = GetNextExtEventMask();
SetMaskForExtEvent(mask, DeviceButtonPress);
AllowPropagateSuppress(mask);
mask = GetNextExtEventMask();
SetMaskForExtEvent(mask, DeviceButtonRelease);
AllowPropagateSuppress(mask);
mask = GetNextExtEventMask();
SetMaskForExtEvent(mask, ProximityIn);
SetMaskForExtEvent(mask, ProximityOut);
AllowPropagateSuppress(mask);
mask = GetNextExtEventMask();
DeviceStateNotifyMask = mask;
SetMaskForExtEvent(mask, DeviceStateNotify);
mask = GetNextExtEventMask();
DevicePointerMotionMask = mask;
SetMaskForExtEvent(mask, DeviceMotionNotify);
AllowPropagateSuppress(mask);
DevicePointerMotionHintMask = GetNextExtEventMask();
SetEventInfo(DevicePointerMotionHintMask, _devicePointerMotionHint);
SetEventInfo(GetNextExtEventMask(), _deviceButton1Motion);
SetEventInfo(GetNextExtEventMask(), _deviceButton2Motion);
SetEventInfo(GetNextExtEventMask(), _deviceButton3Motion);
SetEventInfo(GetNextExtEventMask(), _deviceButton4Motion);
SetEventInfo(GetNextExtEventMask(), _deviceButton5Motion);
DeviceButtonMotionMask = GetNextExtEventMask();
SetEventInfo(DeviceButtonMotionMask, _deviceButtonMotion);
if (DeviceButtonMotionMask != ButtonMotionMask)
{
ErrorF("[Xi] DeviceButtonMotionMask != ButtonMotionMask. Trouble!\n");
}
DeviceFocusChangeMask = GetNextExtEventMask();
SetMaskForExtEvent(DeviceFocusChangeMask, DeviceFocusIn);
SetMaskForExtEvent(DeviceFocusChangeMask, DeviceFocusOut);
mask = GetNextExtEventMask();
SetMaskForExtEvent(mask, DeviceMappingNotify);
DeviceMappingNotifyMask = mask;
mask = GetNextExtEventMask();
SetMaskForExtEvent(mask, ChangeDeviceNotify);
ChangeDeviceNotifyMask = mask;
DeviceButtonGrabMask = GetNextExtEventMask();
SetEventInfo(DeviceButtonGrabMask, _deviceButtonGrab);
SetExclusiveAccess(DeviceButtonGrabMask);
DeviceOwnerGrabButtonMask = GetNextExtEventMask();
SetEventInfo(DeviceOwnerGrabButtonMask, _deviceOwnerGrabButton);
DevicePresenceNotifyMask = GetNextExtEventMask();
SetEventInfo(DevicePresenceNotifyMask, _devicePresence);
DevicePropertyNotifyMask = GetNextExtEventMask();
SetMaskForExtEvent(DevicePropertyNotifyMask, DevicePropertyNotify);
SetEventInfo(0, _noExtensionEvent);
}
static void
RestoreExtensionEvents(void)
{
int i, j;
IReqCode = 0;
IEventBase = 0;
for (i = 0; i < ExtEventIndex - 1; i++) {
if ((EventInfo[i].type >= LASTEvent) && (EventInfo[i].type < 128))
{
for (j = 0; j < MAXDEVICES; j++)
SetMaskForEvent(j, 0, EventInfo[i].type);
}
EventInfo[i].mask = 0;
EventInfo[i].type = 0;
}
ExtEventIndex = 0;
lastExtEventMask = 1;
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;
DevicePresenceNotify = 14;
DevicePropertyNotify = 15;
BadDevice = 0;
BadEvent = 1;
BadMode = 2;
DeviceBusy = 3;
BadClass = 4;
}
static void
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;
EventSwapVector[DevicePresenceNotify] = NotImplemented;
EventSwapVector[DevicePropertyNotify] = NotImplemented;
RestoreExtensionEvents();
}
Bool
DeviceIsPointerType(DeviceIntPtr dev)
{
if (dev_type[1].type == dev->type)
return TRUE;
return FALSE;
}
void
AssignTypeAndName(DeviceIntPtr dev, Atom type, char *name)
{
dev->type = type;
dev->name = (char *)xalloc(strlen(name) + 1);
strcpy(dev->name, name);
}
static void
MakeDeviceTypeAtoms(void)
{
int i;
for (i = 0; i < NUMTYPES; i++)
dev_type[i].type =
MakeAtom(dev_type[i].name, strlen(dev_type[i].name), 1);
}
#define DO_SWAP(func,type) func ((type *)from, (type *)to)
static void
SEventIDispatch(xEvent * from, xEvent * to)
{
int type = from->u.u.type & 0177;
if (type == DeviceValuator)
DO_SWAP(SEventDeviceValuator, deviceValuator);
else if (type == DeviceKeyPress) {
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);
else if (type == DeviceFocusOut)
DO_SWAP(SEventFocus, deviceFocus);
else if (type == ProximityIn) {
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);
else if (type == DeviceKeyStateNotify)
DO_SWAP(SDeviceKeyStateNotifyEvent, deviceKeyStateNotify);
else if (type == DeviceButtonStateNotify)
DO_SWAP(SDeviceButtonStateNotifyEvent, deviceButtonStateNotify);
else if (type == DeviceMappingNotify)
DO_SWAP(SDeviceMappingNotifyEvent, deviceMappingNotify);
else if (type == ChangeDeviceNotify)
DO_SWAP(SChangeDeviceNotifyEvent, changeDeviceNotify);
else if (type == DevicePresenceNotify)
DO_SWAP(SDevicePresenceNotifyEvent, devicePresenceNotify);
else if (type == DevicePropertyNotify)
DO_SWAP(SDevicePropertyNotifyEvent, devicePropertyNotify);
else {
FatalError("XInputExtension: Impossible event!\n");
}
}
void
XInputExtensionInit(void)
{
ExtensionEntry *extEntry;
if (!dixRequestPrivate(XIClientPrivateKey, sizeof(XIClientRec)))
FatalError("Cannot request private for XI.\n");
if (!AddCallback(&ClientStateCallback, XIClientCallback, 0))
FatalError("Failed to add callback to XI.\n");
extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch,
SProcIDispatch, IResetProc, StandardMinorOpcode);
if (extEntry) {
IReqCode = extEntry->base;
IEventBase = extEntry->eventBase;
AllExtensionVersions[IReqCode - 128] = thisversion;
MakeDeviceTypeAtoms();
XIInitKnownProperties();
RT_INPUTCLIENT = CreateNewResourceType((DeleteType) InputClientGone);
RegisterResourceName(RT_INPUTCLIENT, "INPUTCLIENT");
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;
} else {
FatalError("IExtensionInit: AddExtensions failed\n");
}
}