extinit.c revision 475c125c
105b261ecSmrg/************************************************************ 205b261ecSmrg 305b261ecSmrgCopyright 1989, 1998 The Open Group 405b261ecSmrg 505b261ecSmrgPermission to use, copy, modify, distribute, and sell this software and its 605b261ecSmrgdocumentation for any purpose is hereby granted without fee, provided that 705b261ecSmrgthe above copyright notice appear in all copies and that both that 805b261ecSmrgcopyright notice and this permission notice appear in supporting 905b261ecSmrgdocumentation. 1005b261ecSmrg 1105b261ecSmrgThe above copyright notice and this permission notice shall be included in 1205b261ecSmrgall copies or substantial portions of the Software. 1305b261ecSmrg 1405b261ecSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1505b261ecSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1605b261ecSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1705b261ecSmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 1805b261ecSmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 1905b261ecSmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2005b261ecSmrg 2105b261ecSmrgExcept as contained in this notice, the name of The Open Group shall not be 2205b261ecSmrgused in advertising or otherwise to promote the sale, use or other dealings 2305b261ecSmrgin this Software without prior written authorization from The Open Group. 2405b261ecSmrg 2505b261ecSmrgCopyright 1989 by Hewlett-Packard Company, Palo Alto, California. 2605b261ecSmrg 2705b261ecSmrg All Rights Reserved 2805b261ecSmrg 2905b261ecSmrgPermission to use, copy, modify, and distribute this software and its 3005b261ecSmrgdocumentation for any purpose and without fee is hereby granted, 3105b261ecSmrgprovided that the above copyright notice appear in all copies and that 3205b261ecSmrgboth that copyright notice and this permission notice appear in 3305b261ecSmrgsupporting documentation, and that the name of Hewlett-Packard not be 3405b261ecSmrgused in advertising or publicity pertaining to distribution of the 3505b261ecSmrgsoftware without specific, written prior permission. 3605b261ecSmrg 3705b261ecSmrgHEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 3805b261ecSmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 3905b261ecSmrgHEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 4005b261ecSmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 4105b261ecSmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 4205b261ecSmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 4305b261ecSmrgSOFTWARE. 4405b261ecSmrg 4505b261ecSmrg********************************************************/ 4605b261ecSmrg 4705b261ecSmrg/******************************************************************** 4805b261ecSmrg * 4905b261ecSmrg * Dispatch routines and initialization routines for the X input extension. 5005b261ecSmrg * 5105b261ecSmrg */ 529ace9065Smrg#define ARRAY_SIZE(_a) (sizeof((_a)) / sizeof((_a)[0])) 5305b261ecSmrg 5405b261ecSmrg#define NUMTYPES 15 5505b261ecSmrg 5605b261ecSmrg#ifdef HAVE_DIX_CONFIG_H 5705b261ecSmrg#include <dix-config.h> 5805b261ecSmrg#endif 5905b261ecSmrg 6005b261ecSmrg#include "inputstr.h" 6105b261ecSmrg#include "gcstruct.h" /* pointer for extnsionst.h */ 6205b261ecSmrg#include "extnsionst.h" /* extension entry */ 6305b261ecSmrg#include <X11/extensions/XI.h> 6405b261ecSmrg#include <X11/extensions/XIproto.h> 656747b715Smrg#include <X11/extensions/XI2proto.h> 664642e01fSmrg#include <X11/extensions/geproto.h> 674642e01fSmrg#include "geext.h" /* extension interfaces for ge */ 6805b261ecSmrg 6905b261ecSmrg#include "dixevents.h" 7005b261ecSmrg#include "exevents.h" 7105b261ecSmrg#include "extinit.h" 7205b261ecSmrg#include "exglobals.h" 7305b261ecSmrg#include "swaprep.h" 744642e01fSmrg#include "privates.h" 756747b715Smrg#include "protocol-versions.h" 7605b261ecSmrg 7705b261ecSmrg/* modules local to Xi */ 7805b261ecSmrg#include "allowev.h" 7905b261ecSmrg#include "chgdctl.h" 8005b261ecSmrg#include "chgfctl.h" 8105b261ecSmrg#include "chgkbd.h" 8205b261ecSmrg#include "chgprop.h" 8305b261ecSmrg#include "chgptr.h" 8405b261ecSmrg#include "closedev.h" 8505b261ecSmrg#include "devbell.h" 8605b261ecSmrg#include "getbmap.h" 8705b261ecSmrg#include "getbmap.h" 8805b261ecSmrg#include "getdctl.h" 8905b261ecSmrg#include "getfctl.h" 9005b261ecSmrg#include "getfocus.h" 9105b261ecSmrg#include "getkmap.h" 9205b261ecSmrg#include "getmmap.h" 9305b261ecSmrg#include "getprop.h" 9405b261ecSmrg#include "getselev.h" 9505b261ecSmrg#include "getvers.h" 9605b261ecSmrg#include "getvers.h" 9705b261ecSmrg#include "grabdev.h" 9805b261ecSmrg#include "grabdevb.h" 9905b261ecSmrg#include "grabdevk.h" 10005b261ecSmrg#include "gtmotion.h" 10105b261ecSmrg#include "listdev.h" 10205b261ecSmrg#include "opendev.h" 10305b261ecSmrg#include "queryst.h" 10405b261ecSmrg#include "selectev.h" 10505b261ecSmrg#include "sendexev.h" 10605b261ecSmrg#include "chgkmap.h" 10705b261ecSmrg#include "setbmap.h" 10805b261ecSmrg#include "setdval.h" 10905b261ecSmrg#include "setfocus.h" 11005b261ecSmrg#include "setmmap.h" 11105b261ecSmrg#include "setmode.h" 11205b261ecSmrg#include "ungrdev.h" 11305b261ecSmrg#include "ungrdevb.h" 11405b261ecSmrg#include "ungrdevk.h" 1156747b715Smrg#include "xiallowev.h" 1166747b715Smrg#include "xiselectev.h" 1176747b715Smrg#include "xigrabdev.h" 1186747b715Smrg#include "xipassivegrab.h" 1196747b715Smrg#include "xisetdevfocus.h" 1204642e01fSmrg#include "xiproperty.h" 1216747b715Smrg#include "xichangecursor.h" 1226747b715Smrg#include "xichangehierarchy.h" 1236747b715Smrg#include "xigetclientpointer.h" 1246747b715Smrg#include "xiquerydevice.h" 1256747b715Smrg#include "xiquerypointer.h" 1266747b715Smrg#include "xiqueryversion.h" 1276747b715Smrg#include "xisetclientpointer.h" 1286747b715Smrg#include "xiwarppointer.h" 1296747b715Smrg 1306747b715Smrg 1316747b715Smrg/* Masks for XI events have to be aligned with core event (partially anyway). 1326747b715Smrg * If DeviceButtonMotionMask is != ButtonMotionMask, event delivery 1336747b715Smrg * breaks down. The device needs the dev->button->motionMask. If DBMM is 1346747b715Smrg * the same as BMM, we can ensure that both core and device events can be 1356747b715Smrg * delivered, without the need for extra structures in the DeviceIntRec. */ 1366747b715Smrgconst Mask DeviceKeyPressMask = KeyPressMask; 1376747b715Smrgconst Mask DeviceKeyReleaseMask = KeyReleaseMask; 1386747b715Smrgconst Mask DeviceButtonPressMask = ButtonPressMask; 1396747b715Smrgconst Mask DeviceButtonReleaseMask = ButtonReleaseMask; 1406747b715Smrgconst Mask DeviceProximityMask = (1L << 4); 1416747b715Smrgconst Mask DeviceStateNotifyMask = (1L << 5); 1426747b715Smrgconst Mask DevicePointerMotionMask = PointerMotionMask; 1436747b715Smrgconst Mask DevicePointerMotionHintMask = PointerMotionHintMask; 1446747b715Smrgconst Mask DeviceButton1MotionMask = Button1MotionMask; 1456747b715Smrgconst Mask DeviceButton2MotionMask = Button2MotionMask; 1466747b715Smrgconst Mask DeviceButton3MotionMask = Button3MotionMask; 1476747b715Smrgconst Mask DeviceButton4MotionMask = Button4MotionMask; 1486747b715Smrgconst Mask DeviceButton5MotionMask = Button5MotionMask; 1496747b715Smrgconst Mask DeviceButtonMotionMask = ButtonMotionMask; 1506747b715Smrgconst Mask DeviceFocusChangeMask = (1L << 14); 1516747b715Smrgconst Mask DeviceMappingNotifyMask = (1L << 15); 1526747b715Smrgconst Mask ChangeDeviceNotifyMask = (1L << 16); 1536747b715Smrgconst Mask DeviceButtonGrabMask = (1L << 17); 1546747b715Smrgconst Mask DeviceOwnerGrabButtonMask = (1L << 17); 1556747b715Smrgconst Mask DevicePresenceNotifyMask = (1L << 18); 1566747b715Smrgconst Mask DeviceEnterWindowMask = (1L << 18); 1576747b715Smrgconst Mask DeviceLeaveWindowMask = (1L << 19); 1586747b715Smrgconst Mask DevicePropertyNotifyMask = (1L << 20); 1596747b715Smrgconst Mask XIAllMasks = (1L << 21) - 1; 1604642e01fSmrg 16105b261ecSmrgint ExtEventIndex; 16205b261ecSmrgMask ExtExclusiveMasks[EMASKSIZE]; 16305b261ecSmrg 16405b261ecSmrgstatic struct dev_type 16505b261ecSmrg{ 16605b261ecSmrg Atom type; 16705b261ecSmrg char *name; 16805b261ecSmrg} dev_type[] = { 16905b261ecSmrg { 17005b261ecSmrg 0, XI_KEYBOARD}, { 17105b261ecSmrg 0, XI_MOUSE}, { 17205b261ecSmrg 0, XI_TABLET}, { 17305b261ecSmrg 0, XI_TOUCHSCREEN}, { 17405b261ecSmrg 0, XI_TOUCHPAD}, { 17505b261ecSmrg 0, XI_BARCODE}, { 17605b261ecSmrg 0, XI_BUTTONBOX}, { 17705b261ecSmrg 0, XI_KNOB_BOX}, { 17805b261ecSmrg 0, XI_ONE_KNOB}, { 17905b261ecSmrg 0, XI_NINE_KNOB}, { 18005b261ecSmrg 0, XI_TRACKBALL}, { 18105b261ecSmrg 0, XI_QUADRATURE}, { 18205b261ecSmrg 0, XI_ID_MODULE}, { 18305b261ecSmrg 0, XI_SPACEBALL}, { 18405b261ecSmrg 0, XI_DATAGLOVE}, { 18505b261ecSmrg 0, XI_EYETRACKER}, { 18605b261ecSmrg 0, XI_CURSORKEYS}, { 18705b261ecSmrg0, XI_FOOTMOUSE}}; 18805b261ecSmrg 18905b261ecSmrgCARD8 event_base[numInputClasses]; 19005b261ecSmrgXExtEventInfo EventInfo[32]; 19105b261ecSmrg 1926747b715Smrgstatic DeviceIntRec xi_all_devices; 1936747b715Smrgstatic DeviceIntRec xi_all_master_devices; 1946747b715Smrg 1954642e01fSmrg/** 1964642e01fSmrg * Dispatch vector. Functions defined in here will be called when the matching 1974642e01fSmrg * request arrives. 1984642e01fSmrg */ 1994642e01fSmrgstatic int (*ProcIVector[])(ClientPtr) = { 2004642e01fSmrg NULL, /* 0 */ 2014642e01fSmrg ProcXGetExtensionVersion, /* 1 */ 2024642e01fSmrg ProcXListInputDevices, /* 2 */ 2034642e01fSmrg ProcXOpenDevice, /* 3 */ 2044642e01fSmrg ProcXCloseDevice, /* 4 */ 2054642e01fSmrg ProcXSetDeviceMode, /* 5 */ 2064642e01fSmrg ProcXSelectExtensionEvent, /* 6 */ 2074642e01fSmrg ProcXGetSelectedExtensionEvents, /* 7 */ 2084642e01fSmrg ProcXChangeDeviceDontPropagateList, /* 8 */ 2094642e01fSmrg ProcXGetDeviceDontPropagateList, /* 9 */ 2104642e01fSmrg ProcXGetDeviceMotionEvents, /* 10 */ 2114642e01fSmrg ProcXChangeKeyboardDevice, /* 11 */ 2124642e01fSmrg ProcXChangePointerDevice, /* 12 */ 2134642e01fSmrg ProcXGrabDevice, /* 13 */ 2144642e01fSmrg ProcXUngrabDevice, /* 14 */ 2154642e01fSmrg ProcXGrabDeviceKey, /* 15 */ 2164642e01fSmrg ProcXUngrabDeviceKey, /* 16 */ 2174642e01fSmrg ProcXGrabDeviceButton, /* 17 */ 2184642e01fSmrg ProcXUngrabDeviceButton, /* 18 */ 2194642e01fSmrg ProcXAllowDeviceEvents, /* 19 */ 2204642e01fSmrg ProcXGetDeviceFocus, /* 20 */ 2214642e01fSmrg ProcXSetDeviceFocus, /* 21 */ 2224642e01fSmrg ProcXGetFeedbackControl, /* 22 */ 2234642e01fSmrg ProcXChangeFeedbackControl, /* 23 */ 2244642e01fSmrg ProcXGetDeviceKeyMapping, /* 24 */ 2254642e01fSmrg ProcXChangeDeviceKeyMapping, /* 25 */ 2264642e01fSmrg ProcXGetDeviceModifierMapping, /* 26 */ 2274642e01fSmrg ProcXSetDeviceModifierMapping, /* 27 */ 2284642e01fSmrg ProcXGetDeviceButtonMapping, /* 28 */ 2294642e01fSmrg ProcXSetDeviceButtonMapping, /* 29 */ 2304642e01fSmrg ProcXQueryDeviceState, /* 30 */ 2314642e01fSmrg ProcXSendExtensionEvent, /* 31 */ 2324642e01fSmrg ProcXDeviceBell, /* 32 */ 2334642e01fSmrg ProcXSetDeviceValuators, /* 33 */ 2344642e01fSmrg ProcXGetDeviceControl, /* 34 */ 2354642e01fSmrg ProcXChangeDeviceControl, /* 35 */ 2364642e01fSmrg /* XI 1.5 */ 2374642e01fSmrg ProcXListDeviceProperties, /* 36 */ 2384642e01fSmrg ProcXChangeDeviceProperty, /* 37 */ 2394642e01fSmrg ProcXDeleteDeviceProperty, /* 38 */ 2406747b715Smrg ProcXGetDeviceProperty, /* 39 */ 2416747b715Smrg /* XI 2 */ 2426747b715Smrg ProcXIQueryPointer, /* 40 */ 2436747b715Smrg ProcXIWarpPointer, /* 41 */ 2446747b715Smrg ProcXIChangeCursor, /* 42 */ 2456747b715Smrg ProcXIChangeHierarchy, /* 43 */ 2466747b715Smrg ProcXISetClientPointer, /* 44 */ 2476747b715Smrg ProcXIGetClientPointer, /* 45 */ 2486747b715Smrg ProcXISelectEvents, /* 46 */ 2496747b715Smrg ProcXIQueryVersion, /* 47 */ 2506747b715Smrg ProcXIQueryDevice, /* 48 */ 2516747b715Smrg ProcXISetFocus, /* 49 */ 2526747b715Smrg ProcXIGetFocus, /* 50 */ 2536747b715Smrg ProcXIGrabDevice, /* 51 */ 2546747b715Smrg ProcXIUngrabDevice, /* 52 */ 2556747b715Smrg ProcXIAllowEvents, /* 53 */ 2566747b715Smrg ProcXIPassiveGrabDevice, /* 54 */ 2576747b715Smrg ProcXIPassiveUngrabDevice, /* 55 */ 2586747b715Smrg ProcXIListProperties, /* 56 */ 2596747b715Smrg ProcXIChangeProperty, /* 57 */ 2606747b715Smrg ProcXIDeleteProperty, /* 58 */ 2616747b715Smrg ProcXIGetProperty, /* 59 */ 2626747b715Smrg ProcXIGetSelectedEvents /* 60 */ 2634642e01fSmrg}; 2644642e01fSmrg 2654642e01fSmrg/* For swapped clients */ 2664642e01fSmrgstatic int (*SProcIVector[])(ClientPtr) = { 2674642e01fSmrg NULL, /* 0 */ 2684642e01fSmrg SProcXGetExtensionVersion, /* 1 */ 2694642e01fSmrg SProcXListInputDevices, /* 2 */ 2704642e01fSmrg SProcXOpenDevice, /* 3 */ 2714642e01fSmrg SProcXCloseDevice, /* 4 */ 2724642e01fSmrg SProcXSetDeviceMode, /* 5 */ 2734642e01fSmrg SProcXSelectExtensionEvent, /* 6 */ 2744642e01fSmrg SProcXGetSelectedExtensionEvents, /* 7 */ 2754642e01fSmrg SProcXChangeDeviceDontPropagateList, /* 8 */ 2764642e01fSmrg SProcXGetDeviceDontPropagateList, /* 9 */ 2774642e01fSmrg SProcXGetDeviceMotionEvents, /* 10 */ 2784642e01fSmrg SProcXChangeKeyboardDevice, /* 11 */ 2794642e01fSmrg SProcXChangePointerDevice, /* 12 */ 2804642e01fSmrg SProcXGrabDevice, /* 13 */ 2814642e01fSmrg SProcXUngrabDevice, /* 14 */ 2824642e01fSmrg SProcXGrabDeviceKey, /* 15 */ 2834642e01fSmrg SProcXUngrabDeviceKey, /* 16 */ 2844642e01fSmrg SProcXGrabDeviceButton, /* 17 */ 2854642e01fSmrg SProcXUngrabDeviceButton, /* 18 */ 2864642e01fSmrg SProcXAllowDeviceEvents, /* 19 */ 2874642e01fSmrg SProcXGetDeviceFocus, /* 20 */ 2884642e01fSmrg SProcXSetDeviceFocus, /* 21 */ 2894642e01fSmrg SProcXGetFeedbackControl, /* 22 */ 2904642e01fSmrg SProcXChangeFeedbackControl, /* 23 */ 2914642e01fSmrg SProcXGetDeviceKeyMapping, /* 24 */ 2924642e01fSmrg SProcXChangeDeviceKeyMapping, /* 25 */ 2934642e01fSmrg SProcXGetDeviceModifierMapping, /* 26 */ 2944642e01fSmrg SProcXSetDeviceModifierMapping, /* 27 */ 2954642e01fSmrg SProcXGetDeviceButtonMapping, /* 28 */ 2964642e01fSmrg SProcXSetDeviceButtonMapping, /* 29 */ 2974642e01fSmrg SProcXQueryDeviceState, /* 30 */ 2984642e01fSmrg SProcXSendExtensionEvent, /* 31 */ 2994642e01fSmrg SProcXDeviceBell, /* 32 */ 3004642e01fSmrg SProcXSetDeviceValuators, /* 33 */ 3014642e01fSmrg SProcXGetDeviceControl, /* 34 */ 3024642e01fSmrg SProcXChangeDeviceControl, /* 35 */ 3034642e01fSmrg SProcXListDeviceProperties, /* 36 */ 3044642e01fSmrg SProcXChangeDeviceProperty, /* 37 */ 3054642e01fSmrg SProcXDeleteDeviceProperty, /* 38 */ 3066747b715Smrg SProcXGetDeviceProperty, /* 39 */ 3076747b715Smrg SProcXIQueryPointer, /* 40 */ 3086747b715Smrg SProcXIWarpPointer, /* 41 */ 3096747b715Smrg SProcXIChangeCursor, /* 42 */ 3106747b715Smrg SProcXIChangeHierarchy, /* 43 */ 3116747b715Smrg SProcXISetClientPointer, /* 44 */ 3126747b715Smrg SProcXIGetClientPointer, /* 45 */ 3136747b715Smrg SProcXISelectEvents, /* 46 */ 3146747b715Smrg SProcXIQueryVersion, /* 47 */ 3156747b715Smrg SProcXIQueryDevice, /* 48 */ 3166747b715Smrg SProcXISetFocus, /* 49 */ 3176747b715Smrg SProcXIGetFocus, /* 50 */ 3186747b715Smrg SProcXIGrabDevice, /* 51 */ 3196747b715Smrg SProcXIUngrabDevice, /* 52 */ 3206747b715Smrg SProcXIAllowEvents, /* 53 */ 3216747b715Smrg SProcXIPassiveGrabDevice, /* 54 */ 3226747b715Smrg SProcXIPassiveUngrabDevice, /* 55 */ 3236747b715Smrg SProcXIListProperties, /* 56 */ 3246747b715Smrg SProcXIChangeProperty, /* 57 */ 3256747b715Smrg SProcXIDeleteProperty, /* 58 */ 3266747b715Smrg SProcXIGetProperty, /* 59 */ 3276747b715Smrg SProcXIGetSelectedEvents /* 60 */ 3284642e01fSmrg}; 3294642e01fSmrg 33005b261ecSmrg/***************************************************************** 33105b261ecSmrg * 33205b261ecSmrg * Globals referenced elsewhere in the server. 33305b261ecSmrg * 33405b261ecSmrg */ 33505b261ecSmrg 33605b261ecSmrgint IReqCode = 0; 3374642e01fSmrgint IEventBase = 0; 33805b261ecSmrgint BadDevice = 0; 33905b261ecSmrgstatic int BadEvent = 1; 34005b261ecSmrgint BadMode = 2; 34105b261ecSmrgint DeviceBusy = 3; 34205b261ecSmrgint BadClass = 4; 34305b261ecSmrg 34405b261ecSmrgint DeviceValuator; 34505b261ecSmrgint DeviceKeyPress; 34605b261ecSmrgint DeviceKeyRelease; 34705b261ecSmrgint DeviceButtonPress; 34805b261ecSmrgint DeviceButtonRelease; 34905b261ecSmrgint DeviceMotionNotify; 35005b261ecSmrgint DeviceFocusIn; 35105b261ecSmrgint DeviceFocusOut; 35205b261ecSmrgint ProximityIn; 35305b261ecSmrgint ProximityOut; 35405b261ecSmrgint DeviceStateNotify; 35505b261ecSmrgint DeviceKeyStateNotify; 35605b261ecSmrgint DeviceButtonStateNotify; 35705b261ecSmrgint DeviceMappingNotify; 35805b261ecSmrgint ChangeDeviceNotify; 35905b261ecSmrgint DevicePresenceNotify; 3604642e01fSmrgint DevicePropertyNotify; 36105b261ecSmrg 36205b261ecSmrgint RT_INPUTCLIENT; 36305b261ecSmrg 36405b261ecSmrg/***************************************************************** 36505b261ecSmrg * 36605b261ecSmrg * Externs defined elsewhere in the X server. 36705b261ecSmrg * 36805b261ecSmrg */ 36905b261ecSmrg 3706747b715Smrgextern XExtensionVersion XIVersion; 37105b261ecSmrg 3724642e01fSmrg 3734642e01fSmrgMask PropagateMask[MAXDEVICES]; 37405b261ecSmrg 37505b261ecSmrg/***************************************************************** 37605b261ecSmrg * 3774642e01fSmrg * Versioning support 37805b261ecSmrg * 37905b261ecSmrg */ 38005b261ecSmrg 3816747b715SmrgDevPrivateKeyRec XIClientPrivateKeyRec; 3824642e01fSmrg 3834642e01fSmrg/***************************************************************** 3844642e01fSmrg * 3854642e01fSmrg * Declarations of local routines. 3864642e01fSmrg * 3874642e01fSmrg */ 3884642e01fSmrg 3894642e01fSmrgstatic void 3904642e01fSmrgXIClientCallback(CallbackListPtr *list, 3914642e01fSmrg pointer closure, 3924642e01fSmrg pointer data) 3934642e01fSmrg{ 3944642e01fSmrg NewClientInfoRec *clientinfo = (NewClientInfoRec*)data; 3954642e01fSmrg ClientPtr pClient = clientinfo->client; 3964642e01fSmrg XIClientPtr pXIClient; 3974642e01fSmrg 3984642e01fSmrg pXIClient = dixLookupPrivate(&pClient->devPrivates, XIClientPrivateKey); 3994642e01fSmrg pXIClient->major_version = 0; 4004642e01fSmrg pXIClient->minor_version = 0; 4014642e01fSmrg} 4024642e01fSmrg 40305b261ecSmrg/************************************************************************* 40405b261ecSmrg * 40505b261ecSmrg * ProcIDispatch - main dispatch routine for requests to this extension. 40605b261ecSmrg * This routine is used if server and client have the same byte ordering. 40705b261ecSmrg * 40805b261ecSmrg */ 40905b261ecSmrg 41005b261ecSmrgstatic int 41105b261ecSmrgProcIDispatch(ClientPtr client) 41205b261ecSmrg{ 41305b261ecSmrg REQUEST(xReq); 414475c125cSmrg if (stuff->data >= ARRAY_SIZE(ProcIVector) || !ProcIVector[stuff->data]) 4154642e01fSmrg return BadRequest; 4164642e01fSmrg 4174642e01fSmrg return (*ProcIVector[stuff->data])(client); 41805b261ecSmrg} 41905b261ecSmrg 42005b261ecSmrg/******************************************************************************* 42105b261ecSmrg * 4224642e01fSmrg * SProcXDispatch 42305b261ecSmrg * 42405b261ecSmrg * Main swapped dispatch routine for requests to this extension. 42505b261ecSmrg * This routine is used if server and client do not have the same byte ordering. 42605b261ecSmrg * 42705b261ecSmrg */ 42805b261ecSmrg 42905b261ecSmrgstatic int 43005b261ecSmrgSProcIDispatch(ClientPtr client) 43105b261ecSmrg{ 43205b261ecSmrg REQUEST(xReq); 433475c125cSmrg if (stuff->data >= ARRAY_SIZE(SProcIVector) || !SProcIVector[stuff->data]) 4344642e01fSmrg return BadRequest; 4354642e01fSmrg 4364642e01fSmrg return (*SProcIVector[stuff->data])(client); 43705b261ecSmrg} 43805b261ecSmrg 43905b261ecSmrg/********************************************************************** 44005b261ecSmrg * 44105b261ecSmrg * SReplyIDispatch 44205b261ecSmrg * Swap any replies defined in this extension. 44305b261ecSmrg * 44405b261ecSmrg */ 44505b261ecSmrg 44605b261ecSmrgstatic void 44705b261ecSmrgSReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep) 44805b261ecSmrg /* All we look at is the type field */ 44905b261ecSmrg{ /* This is common to all replies */ 45005b261ecSmrg if (rep->RepType == X_GetExtensionVersion) 45105b261ecSmrg SRepXGetExtensionVersion(client, len, 45205b261ecSmrg (xGetExtensionVersionReply *) rep); 45305b261ecSmrg else if (rep->RepType == X_ListInputDevices) 45405b261ecSmrg SRepXListInputDevices(client, len, (xListInputDevicesReply *) rep); 45505b261ecSmrg else if (rep->RepType == X_OpenDevice) 45605b261ecSmrg SRepXOpenDevice(client, len, (xOpenDeviceReply *) rep); 45705b261ecSmrg else if (rep->RepType == X_SetDeviceMode) 45805b261ecSmrg SRepXSetDeviceMode(client, len, (xSetDeviceModeReply *) rep); 45905b261ecSmrg else if (rep->RepType == X_GetSelectedExtensionEvents) 46005b261ecSmrg SRepXGetSelectedExtensionEvents(client, len, 46105b261ecSmrg (xGetSelectedExtensionEventsReply *) 46205b261ecSmrg rep); 46305b261ecSmrg else if (rep->RepType == X_GetDeviceDontPropagateList) 46405b261ecSmrg SRepXGetDeviceDontPropagateList(client, len, 46505b261ecSmrg (xGetDeviceDontPropagateListReply *) 46605b261ecSmrg rep); 46705b261ecSmrg else if (rep->RepType == X_GetDeviceMotionEvents) 46805b261ecSmrg SRepXGetDeviceMotionEvents(client, len, 46905b261ecSmrg (xGetDeviceMotionEventsReply *) rep); 47005b261ecSmrg else if (rep->RepType == X_GrabDevice) 47105b261ecSmrg SRepXGrabDevice(client, len, (xGrabDeviceReply *) rep); 47205b261ecSmrg else if (rep->RepType == X_GetDeviceFocus) 47305b261ecSmrg SRepXGetDeviceFocus(client, len, (xGetDeviceFocusReply *) rep); 47405b261ecSmrg else if (rep->RepType == X_GetFeedbackControl) 47505b261ecSmrg SRepXGetFeedbackControl(client, len, (xGetFeedbackControlReply *) rep); 47605b261ecSmrg else if (rep->RepType == X_GetDeviceKeyMapping) 47705b261ecSmrg SRepXGetDeviceKeyMapping(client, len, 47805b261ecSmrg (xGetDeviceKeyMappingReply *) rep); 47905b261ecSmrg else if (rep->RepType == X_GetDeviceModifierMapping) 48005b261ecSmrg SRepXGetDeviceModifierMapping(client, len, 48105b261ecSmrg (xGetDeviceModifierMappingReply *) rep); 48205b261ecSmrg else if (rep->RepType == X_SetDeviceModifierMapping) 48305b261ecSmrg SRepXSetDeviceModifierMapping(client, len, 48405b261ecSmrg (xSetDeviceModifierMappingReply *) rep); 48505b261ecSmrg else if (rep->RepType == X_GetDeviceButtonMapping) 48605b261ecSmrg SRepXGetDeviceButtonMapping(client, len, 48705b261ecSmrg (xGetDeviceButtonMappingReply *) rep); 48805b261ecSmrg else if (rep->RepType == X_SetDeviceButtonMapping) 48905b261ecSmrg SRepXSetDeviceButtonMapping(client, len, 49005b261ecSmrg (xSetDeviceButtonMappingReply *) rep); 49105b261ecSmrg else if (rep->RepType == X_QueryDeviceState) 49205b261ecSmrg SRepXQueryDeviceState(client, len, (xQueryDeviceStateReply *) rep); 49305b261ecSmrg else if (rep->RepType == X_SetDeviceValuators) 49405b261ecSmrg SRepXSetDeviceValuators(client, len, (xSetDeviceValuatorsReply *) rep); 49505b261ecSmrg else if (rep->RepType == X_GetDeviceControl) 49605b261ecSmrg SRepXGetDeviceControl(client, len, (xGetDeviceControlReply *) rep); 49705b261ecSmrg else if (rep->RepType == X_ChangeDeviceControl) 49805b261ecSmrg SRepXChangeDeviceControl(client, len, 49905b261ecSmrg (xChangeDeviceControlReply *) rep); 5004642e01fSmrg else if (rep->RepType == X_ListDeviceProperties) 5014642e01fSmrg SRepXListDeviceProperties(client, len, (xListDevicePropertiesReply*)rep); 5024642e01fSmrg else if (rep->RepType == X_GetDeviceProperty) 5034642e01fSmrg SRepXGetDeviceProperty(client, len, (xGetDevicePropertyReply *) rep); 5046747b715Smrg else if (rep->RepType == X_XIQueryPointer) 5056747b715Smrg SRepXIQueryPointer(client, len, (xXIQueryPointerReply *) rep); 5066747b715Smrg else if (rep->RepType == X_XIGetClientPointer) 5076747b715Smrg SRepXIGetClientPointer(client, len, (xXIGetClientPointerReply*) rep); 5086747b715Smrg else if (rep->RepType == X_XIQueryVersion) 5096747b715Smrg SRepXIQueryVersion(client, len, (xXIQueryVersionReply*)rep); 5106747b715Smrg else if (rep->RepType == X_XIQueryDevice) 5116747b715Smrg SRepXIQueryDevice(client, len, (xXIQueryDeviceReply*)rep); 5126747b715Smrg else if (rep->RepType == X_XIGrabDevice) 5136747b715Smrg SRepXIGrabDevice(client, len, (xXIGrabDeviceReply *) rep); 5149ace9065Smrg else if (rep->RepType == X_XIPassiveGrabDevice) 5156747b715Smrg SRepXIPassiveGrabDevice(client, len, (xXIPassiveGrabDeviceReply *) rep); 5166747b715Smrg else if (rep->RepType == X_XIListProperties) 5176747b715Smrg SRepXIListProperties(client, len, (xXIListPropertiesReply *) rep); 5186747b715Smrg else if (rep->RepType == X_XIGetProperty) 5196747b715Smrg SRepXIGetProperty(client, len, (xXIGetPropertyReply *) rep); 5206747b715Smrg else if (rep->RepType == X_XIGetSelectedEvents) 5216747b715Smrg SRepXIGetSelectedEvents(client, len, (xXIGetSelectedEventsReply *) rep); 5226747b715Smrg else if (rep->RepType == X_XIGetFocus) 5236747b715Smrg SRepXIGetFocus(client, len, (xXIGetFocusReply *) rep); 52405b261ecSmrg else { 52505b261ecSmrg FatalError("XINPUT confused sending swapped reply"); 52605b261ecSmrg } 52705b261ecSmrg} 52805b261ecSmrg 52905b261ecSmrg/************************************************************************ 53005b261ecSmrg * 53105b261ecSmrg * This function swaps the DeviceValuator event. 53205b261ecSmrg * 53305b261ecSmrg */ 53405b261ecSmrg 53505b261ecSmrgstatic void 53605b261ecSmrgSEventDeviceValuator(deviceValuator * from, deviceValuator * to) 53705b261ecSmrg{ 53805b261ecSmrg char n; 53905b261ecSmrg int i; 54005b261ecSmrg INT32 *ip B32; 54105b261ecSmrg 54205b261ecSmrg *to = *from; 54305b261ecSmrg swaps(&to->sequenceNumber, n); 54405b261ecSmrg swaps(&to->device_state, n); 54505b261ecSmrg ip = &to->valuator0; 54605b261ecSmrg for (i = 0; i < 6; i++) { 54705b261ecSmrg swapl((ip + i), n); /* macro - braces are required */ 54805b261ecSmrg } 54905b261ecSmrg} 55005b261ecSmrg 55105b261ecSmrgstatic void 55205b261ecSmrgSEventFocus(deviceFocus * from, deviceFocus * to) 55305b261ecSmrg{ 55405b261ecSmrg char n; 55505b261ecSmrg 55605b261ecSmrg *to = *from; 55705b261ecSmrg swaps(&to->sequenceNumber, n); 55805b261ecSmrg swapl(&to->time, n); 55905b261ecSmrg swapl(&to->window, n); 56005b261ecSmrg} 56105b261ecSmrg 56205b261ecSmrgstatic void 56305b261ecSmrgSDeviceStateNotifyEvent(deviceStateNotify * from, deviceStateNotify * to) 56405b261ecSmrg{ 56505b261ecSmrg int i; 56605b261ecSmrg char n; 56705b261ecSmrg INT32 *ip B32; 56805b261ecSmrg 56905b261ecSmrg *to = *from; 57005b261ecSmrg swaps(&to->sequenceNumber, n); 57105b261ecSmrg swapl(&to->time, n); 57205b261ecSmrg ip = &to->valuator0; 57305b261ecSmrg for (i = 0; i < 3; i++) { 57405b261ecSmrg swapl((ip + i), n); /* macro - braces are required */ 57505b261ecSmrg } 57605b261ecSmrg} 57705b261ecSmrg 57805b261ecSmrgstatic void 57905b261ecSmrgSDeviceKeyStateNotifyEvent(deviceKeyStateNotify * from, 58005b261ecSmrg deviceKeyStateNotify * to) 58105b261ecSmrg{ 58205b261ecSmrg char n; 58305b261ecSmrg 58405b261ecSmrg *to = *from; 58505b261ecSmrg swaps(&to->sequenceNumber, n); 58605b261ecSmrg} 58705b261ecSmrg 58805b261ecSmrgstatic void 58905b261ecSmrgSDeviceButtonStateNotifyEvent(deviceButtonStateNotify * from, 59005b261ecSmrg deviceButtonStateNotify * to) 59105b261ecSmrg{ 59205b261ecSmrg char n; 59305b261ecSmrg 59405b261ecSmrg *to = *from; 59505b261ecSmrg swaps(&to->sequenceNumber, n); 59605b261ecSmrg} 59705b261ecSmrg 59805b261ecSmrgstatic void 59905b261ecSmrgSChangeDeviceNotifyEvent(changeDeviceNotify * from, changeDeviceNotify * to) 60005b261ecSmrg{ 60105b261ecSmrg char n; 60205b261ecSmrg 60305b261ecSmrg *to = *from; 60405b261ecSmrg swaps(&to->sequenceNumber, n); 60505b261ecSmrg swapl(&to->time, n); 60605b261ecSmrg} 60705b261ecSmrg 60805b261ecSmrgstatic void 60905b261ecSmrgSDeviceMappingNotifyEvent(deviceMappingNotify * from, deviceMappingNotify * to) 61005b261ecSmrg{ 61105b261ecSmrg char n; 61205b261ecSmrg 61305b261ecSmrg *to = *from; 61405b261ecSmrg swaps(&to->sequenceNumber, n); 61505b261ecSmrg swapl(&to->time, n); 61605b261ecSmrg} 61705b261ecSmrg 61805b261ecSmrgstatic void 61905b261ecSmrgSDevicePresenceNotifyEvent (devicePresenceNotify *from, devicePresenceNotify *to) 62005b261ecSmrg{ 62105b261ecSmrg char n; 62205b261ecSmrg 62305b261ecSmrg *to = *from; 62405b261ecSmrg swaps(&to->sequenceNumber,n); 62505b261ecSmrg swapl(&to->time, n); 62605b261ecSmrg swaps(&to->control, n); 62705b261ecSmrg} 62805b261ecSmrg 6294642e01fSmrgstatic void 6304642e01fSmrgSDevicePropertyNotifyEvent (devicePropertyNotify *from, devicePropertyNotify *to) 6314642e01fSmrg{ 6324642e01fSmrg char n; 6334642e01fSmrg 6344642e01fSmrg *to = *from; 6354642e01fSmrg swaps(&to->sequenceNumber,n); 6364642e01fSmrg swapl(&to->time, n); 6374642e01fSmrg swapl(&to->atom, n); 6384642e01fSmrg} 6394642e01fSmrg 6406747b715Smrgstatic void 6416747b715SmrgSDeviceLeaveNotifyEvent (xXILeaveEvent *from, xXILeaveEvent *to) 6426747b715Smrg{ 6436747b715Smrg char n; 6446747b715Smrg 6456747b715Smrg *to = *from; 6466747b715Smrg swaps(&to->sequenceNumber,n); 6476747b715Smrg swapl(&to->length, n); 6486747b715Smrg swaps(&to->evtype, n); 6496747b715Smrg swaps(&to->deviceid, n); 6506747b715Smrg swapl(&to->time, n); 6516747b715Smrg swapl(&to->root, n); 6526747b715Smrg swapl(&to->event, n); 6536747b715Smrg swapl(&to->child, n); 6546747b715Smrg swapl(&to->root_x, n); 6556747b715Smrg swapl(&to->root_y, n); 6566747b715Smrg swapl(&to->event_x, n); 6576747b715Smrg swapl(&to->event_y, n); 6586747b715Smrg swaps(&to->sourceid, n); 6596747b715Smrg swaps(&to->buttons_len, n); 6606747b715Smrg swapl(&to->mods.base_mods, n); 6616747b715Smrg swapl(&to->mods.latched_mods, n); 6626747b715Smrg swapl(&to->mods.locked_mods, n); 6636747b715Smrg} 66405b261ecSmrg 66505b261ecSmrgstatic void 6666747b715SmrgSDeviceChangedEvent(xXIDeviceChangedEvent* from, xXIDeviceChangedEvent* to) 6676747b715Smrg{ 6686747b715Smrg char n; 6696747b715Smrg int i, j; 6706747b715Smrg xXIAnyInfo *any; 6716747b715Smrg 6726747b715Smrg *to = *from; 6736747b715Smrg memcpy(&to[1], &from[1], from->length * 4); 6746747b715Smrg 6756747b715Smrg any = (xXIAnyInfo*)&to[1]; 6766747b715Smrg for (i = 0; i < to->num_classes; i++) 6776747b715Smrg { 6786747b715Smrg int length = any->length; 6796747b715Smrg 6806747b715Smrg switch(any->type) 6816747b715Smrg { 6826747b715Smrg case KeyClass: 6836747b715Smrg { 6846747b715Smrg xXIKeyInfo *ki = (xXIKeyInfo*)any; 6856747b715Smrg uint32_t *key = (uint32_t*)&ki[1]; 6866747b715Smrg for (j = 0; j < ki->num_keycodes; j++, key++) 6876747b715Smrg swapl(key, n); 6886747b715Smrg swaps(&ki->num_keycodes, n); 6896747b715Smrg } 6906747b715Smrg break; 6916747b715Smrg case ButtonClass: 6926747b715Smrg { 6936747b715Smrg xXIButtonInfo *bi = (xXIButtonInfo*)any; 6946747b715Smrg Atom *labels = (Atom*)((char*)bi + sizeof(xXIButtonInfo) + 6956747b715Smrg pad_to_int32(bits_to_bytes(bi->num_buttons))); 6966747b715Smrg for (j = 0; j < bi->num_buttons; j++) 6976747b715Smrg swapl(&labels[j], n); 6986747b715Smrg swaps(&bi->num_buttons, n); 6996747b715Smrg } 7006747b715Smrg break; 7016747b715Smrg case ValuatorClass: 7026747b715Smrg { 7036747b715Smrg xXIValuatorInfo* ai = (xXIValuatorInfo*)any; 7046747b715Smrg swapl(&ai->label, n); 7056747b715Smrg swapl(&ai->min.integral, n); 7066747b715Smrg swapl(&ai->min.frac, n); 7076747b715Smrg swapl(&ai->max.integral, n); 7086747b715Smrg swapl(&ai->max.frac, n); 7096747b715Smrg swapl(&ai->resolution, n); 7106747b715Smrg swaps(&ai->number, n); 7116747b715Smrg } 7126747b715Smrg break; 7136747b715Smrg } 7146747b715Smrg 7156747b715Smrg swaps(&any->type, n); 7166747b715Smrg swaps(&any->length, n); 7176747b715Smrg swaps(&any->sourceid, n); 7186747b715Smrg 7196747b715Smrg any = (xXIAnyInfo*)((char*)any + length * 4); 7206747b715Smrg } 7216747b715Smrg 7226747b715Smrg swaps(&to->sequenceNumber, n); 7236747b715Smrg swapl(&to->length, n); 7246747b715Smrg swaps(&to->evtype, n); 7256747b715Smrg swaps(&to->deviceid, n); 7266747b715Smrg swapl(&to->time, n); 7276747b715Smrg swaps(&to->num_classes, n); 7286747b715Smrg swaps(&to->sourceid, n); 7296747b715Smrg 7306747b715Smrg} 7316747b715Smrg 7326747b715Smrgstatic void SDeviceEvent(xXIDeviceEvent *from, xXIDeviceEvent *to) 73305b261ecSmrg{ 73405b261ecSmrg int i; 7356747b715Smrg char n; 7366747b715Smrg char *ptr; 7376747b715Smrg char *vmask; 73805b261ecSmrg 7396747b715Smrg memcpy(to, from, sizeof(xEvent) + from->length * 4); 7406747b715Smrg 7416747b715Smrg swaps(&to->sequenceNumber, n); 7426747b715Smrg swapl(&to->length, n); 7436747b715Smrg swaps(&to->evtype, n); 7446747b715Smrg swaps(&to->deviceid, n); 7456747b715Smrg swapl(&to->time, n); 7466747b715Smrg swapl(&to->detail, n); 7476747b715Smrg swapl(&to->root, n); 7486747b715Smrg swapl(&to->event, n); 7496747b715Smrg swapl(&to->child, n); 7506747b715Smrg swapl(&to->root_x, n); 7516747b715Smrg swapl(&to->root_y, n); 7526747b715Smrg swapl(&to->event_x, n); 7536747b715Smrg swapl(&to->event_y, n); 7546747b715Smrg swaps(&to->buttons_len, n); 7556747b715Smrg swaps(&to->valuators_len, n); 7566747b715Smrg swaps(&to->sourceid, n); 7576747b715Smrg swapl(&to->mods.base_mods, n); 7586747b715Smrg swapl(&to->mods.latched_mods, n); 7596747b715Smrg swapl(&to->mods.locked_mods, n); 7606747b715Smrg swapl(&to->mods.effective_mods, n); 7619ace9065Smrg swapl(&to->flags, n); 7626747b715Smrg 7636747b715Smrg ptr = (char*)(&to[1]); 7646747b715Smrg ptr += from->buttons_len * 4; 7656747b715Smrg vmask = ptr; /* valuator mask */ 7666747b715Smrg ptr += from->valuators_len * 4; 7676747b715Smrg for (i = 0; i < from->valuators_len * 32; i++) 7686747b715Smrg { 7696747b715Smrg if (BitIsOn(vmask, i)) 7706747b715Smrg { 7716747b715Smrg swapl(((uint32_t*)ptr), n); 7726747b715Smrg ptr += 4; 7736747b715Smrg swapl(((uint32_t*)ptr), n); 7746747b715Smrg ptr += 4; 7756747b715Smrg } 7766747b715Smrg } 7776747b715Smrg} 7786747b715Smrg 7796747b715Smrgstatic void SDeviceHierarchyEvent(xXIHierarchyEvent *from, 7806747b715Smrg xXIHierarchyEvent *to) 7816747b715Smrg{ 7826747b715Smrg int i; 7836747b715Smrg char n; 7846747b715Smrg xXIHierarchyInfo *info; 7856747b715Smrg 7866747b715Smrg *to = *from; 7876747b715Smrg memcpy(&to[1], &from[1], from->length * 4); 7886747b715Smrg swaps(&to->sequenceNumber, n); 7896747b715Smrg swapl(&to->length, n); 7906747b715Smrg swaps(&to->evtype, n); 7916747b715Smrg swaps(&to->deviceid, n); 7926747b715Smrg swapl(&to->time, n); 7936747b715Smrg swapl(&to->flags, n); 7946747b715Smrg swaps(&to->num_info, n); 7956747b715Smrg 7966747b715Smrg info = (xXIHierarchyInfo*)&to[1]; 7976747b715Smrg for (i = 0; i< from->num_info; i++) 7986747b715Smrg { 7996747b715Smrg swaps(&info->deviceid, n); 8006747b715Smrg swaps(&info->attachment, n); 8016747b715Smrg info++; 8026747b715Smrg } 8036747b715Smrg} 8046747b715Smrg 8056747b715Smrgstatic void SXIPropertyEvent(xXIPropertyEvent *from, xXIPropertyEvent *to) 8066747b715Smrg{ 8076747b715Smrg char n; 8086747b715Smrg 8096747b715Smrg *to = *from; 8106747b715Smrg swaps(&to->sequenceNumber, n); 8116747b715Smrg swapl(&to->length, n); 8126747b715Smrg swaps(&to->evtype, n); 8136747b715Smrg swaps(&to->deviceid, n); 8146747b715Smrg swapl(&to->property, n); 8156747b715Smrg} 8166747b715Smrg 8176747b715Smrgstatic void SRawEvent(xXIRawEvent *from, xXIRawEvent *to) 8186747b715Smrg{ 8196747b715Smrg char n; 8206747b715Smrg int i; 8216747b715Smrg FP3232 *values; 8226747b715Smrg unsigned char *mask; 8236747b715Smrg 8246747b715Smrg memcpy(to, from, sizeof(xEvent) + from->length * 4); 8256747b715Smrg 8266747b715Smrg swaps(&to->sequenceNumber, n); 8276747b715Smrg swapl(&to->length, n); 8286747b715Smrg swaps(&to->evtype, n); 8296747b715Smrg swaps(&to->deviceid, n); 8306747b715Smrg swapl(&to->time, n); 8316747b715Smrg swapl(&to->detail, n); 8326747b715Smrg 8336747b715Smrg 8346747b715Smrg mask = (unsigned char*)&to[1]; 8356747b715Smrg values = (FP3232*)(mask + from->valuators_len * 4); 8366747b715Smrg 8376747b715Smrg for (i = 0; i < from->valuators_len * 4 * 8; i++) 8386747b715Smrg { 8396747b715Smrg if (BitIsOn(mask, i)) 8406747b715Smrg { 8416747b715Smrg /* for each bit set there are two FP3232 values on the wire, in 8426747b715Smrg * the order abcABC for data and data_raw. Here we swap as if 8436747b715Smrg * they were in aAbBcC order because it's easier and really 8446747b715Smrg * doesn't matter. 8456747b715Smrg */ 8466747b715Smrg swapl(&values->integral, n); 8476747b715Smrg swapl(&values->frac, n); 8486747b715Smrg values++; 8496747b715Smrg swapl(&values->integral, n); 8506747b715Smrg swapl(&values->frac, n); 8516747b715Smrg values++; 8526747b715Smrg } 8536747b715Smrg } 8546747b715Smrg 8556747b715Smrg swaps(&to->valuators_len, n); 8566747b715Smrg} 8576747b715Smrg 8586747b715Smrg 8596747b715Smrg/** Event swapping function for XI2 events. */ 8606747b715Smrgvoid 8616747b715SmrgXI2EventSwap(xGenericEvent *from, xGenericEvent *to) 8626747b715Smrg{ 8636747b715Smrg switch(from->evtype) 8646747b715Smrg { 8656747b715Smrg case XI_Enter: 8666747b715Smrg case XI_Leave: 8679ace9065Smrg case XI_FocusIn: 8689ace9065Smrg case XI_FocusOut: 8696747b715Smrg SDeviceLeaveNotifyEvent((xXILeaveEvent*)from, (xXILeaveEvent*)to); 8706747b715Smrg break; 8716747b715Smrg case XI_DeviceChanged: 8726747b715Smrg SDeviceChangedEvent((xXIDeviceChangedEvent*)from, 8736747b715Smrg (xXIDeviceChangedEvent*)to); 8746747b715Smrg break; 8756747b715Smrg case XI_HierarchyChanged: 8766747b715Smrg SDeviceHierarchyEvent((xXIHierarchyEvent*)from, (xXIHierarchyEvent*)to); 8776747b715Smrg break; 8786747b715Smrg case XI_PropertyEvent: 8796747b715Smrg SXIPropertyEvent((xXIPropertyEvent*)from, 8806747b715Smrg (xXIPropertyEvent*)to); 8816747b715Smrg break; 8826747b715Smrg case XI_Motion: 8836747b715Smrg case XI_KeyPress: 8846747b715Smrg case XI_KeyRelease: 8856747b715Smrg case XI_ButtonPress: 8866747b715Smrg case XI_ButtonRelease: 8876747b715Smrg SDeviceEvent((xXIDeviceEvent*)from, (xXIDeviceEvent*)to); 8886747b715Smrg break; 8896747b715Smrg case XI_RawMotion: 8906747b715Smrg case XI_RawKeyPress: 8916747b715Smrg case XI_RawKeyRelease: 8926747b715Smrg case XI_RawButtonPress: 8936747b715Smrg case XI_RawButtonRelease: 8946747b715Smrg SRawEvent((xXIRawEvent*)from, (xXIRawEvent*)to); 8956747b715Smrg break; 8966747b715Smrg default: 8976747b715Smrg ErrorF("[Xi] Unknown event type to swap. This is a bug.\n"); 8986747b715Smrg break; 8996747b715Smrg } 90005b261ecSmrg} 90105b261ecSmrg 90205b261ecSmrg/************************************************************************** 90305b261ecSmrg * 9046747b715Smrg * Allow the specified event to have its propagation suppressed. 9056747b715Smrg * The default is to not allow suppression of propagation. 90605b261ecSmrg * 90705b261ecSmrg */ 90805b261ecSmrg 9096747b715Smrgstatic void 9106747b715SmrgAllowPropagateSuppress(Mask mask) 91105b261ecSmrg{ 91205b261ecSmrg int i; 91305b261ecSmrg 9144642e01fSmrg for (i = 0; i < MAXDEVICES; i++) 9156747b715Smrg PropagateMask[i] |= mask; 91605b261ecSmrg} 91705b261ecSmrg 91805b261ecSmrg/************************************************************************** 91905b261ecSmrg * 92005b261ecSmrg * Record an event mask where there is no unique corresponding event type. 92105b261ecSmrg * We can't call SetMaskForEvent, since that would clobber the existing 92205b261ecSmrg * mask for that event. MotionHint and ButtonMotion are examples. 92305b261ecSmrg * 92405b261ecSmrg * Since extension event types will never be less than 64, we can use 92505b261ecSmrg * 0-63 in the EventInfo array as the "type" to be used to look up this 9264642e01fSmrg * mask. This means that the corresponding macros such as 92705b261ecSmrg * DevicePointerMotionHint must have access to the same constants. 92805b261ecSmrg * 92905b261ecSmrg */ 93005b261ecSmrg 93105b261ecSmrgstatic void 93205b261ecSmrgSetEventInfo(Mask mask, int constant) 93305b261ecSmrg{ 93405b261ecSmrg EventInfo[ExtEventIndex].mask = mask; 93505b261ecSmrg EventInfo[ExtEventIndex++].type = constant; 93605b261ecSmrg} 93705b261ecSmrg 93805b261ecSmrg/************************************************************************** 93905b261ecSmrg * 94005b261ecSmrg * Allow the specified event to be restricted to being selected by one 94105b261ecSmrg * client at a time. 94205b261ecSmrg * The default is to allow more than one client to select the event. 94305b261ecSmrg * 94405b261ecSmrg */ 94505b261ecSmrg 94605b261ecSmrgstatic void 94705b261ecSmrgSetExclusiveAccess(Mask mask) 94805b261ecSmrg{ 94905b261ecSmrg int i; 95005b261ecSmrg 9514642e01fSmrg for (i = 0; i < MAXDEVICES; i++) 95205b261ecSmrg ExtExclusiveMasks[i] |= mask; 95305b261ecSmrg} 95405b261ecSmrg 95505b261ecSmrg/************************************************************************** 95605b261ecSmrg * 95705b261ecSmrg * Assign the specified mask to the specified event. 95805b261ecSmrg * 95905b261ecSmrg */ 96005b261ecSmrg 96105b261ecSmrgstatic void 96205b261ecSmrgSetMaskForExtEvent(Mask mask, int event) 96305b261ecSmrg{ 9644642e01fSmrg int i; 96505b261ecSmrg 96605b261ecSmrg EventInfo[ExtEventIndex].mask = mask; 96705b261ecSmrg EventInfo[ExtEventIndex++].type = event; 96805b261ecSmrg 96905b261ecSmrg if ((event < LASTEvent) || (event >= 128)) 97005b261ecSmrg FatalError("MaskForExtensionEvent: bogus event number"); 9714642e01fSmrg 9724642e01fSmrg for (i = 0; i < MAXDEVICES; i++) 9734642e01fSmrg SetMaskForEvent(i, mask, event); 97405b261ecSmrg} 97505b261ecSmrg 97605b261ecSmrg/************************************************************************ 97705b261ecSmrg * 97805b261ecSmrg * This function sets up extension event types and masks. 97905b261ecSmrg * 98005b261ecSmrg */ 98105b261ecSmrg 98205b261ecSmrgstatic void 98305b261ecSmrgFixExtensionEvents(ExtensionEntry * extEntry) 98405b261ecSmrg{ 98505b261ecSmrg DeviceValuator = extEntry->eventBase; 98605b261ecSmrg DeviceKeyPress = DeviceValuator + 1; 98705b261ecSmrg DeviceKeyRelease = DeviceKeyPress + 1; 98805b261ecSmrg DeviceButtonPress = DeviceKeyRelease + 1; 98905b261ecSmrg DeviceButtonRelease = DeviceButtonPress + 1; 99005b261ecSmrg DeviceMotionNotify = DeviceButtonRelease + 1; 99105b261ecSmrg DeviceFocusIn = DeviceMotionNotify + 1; 99205b261ecSmrg DeviceFocusOut = DeviceFocusIn + 1; 99305b261ecSmrg ProximityIn = DeviceFocusOut + 1; 99405b261ecSmrg ProximityOut = ProximityIn + 1; 99505b261ecSmrg DeviceStateNotify = ProximityOut + 1; 99605b261ecSmrg DeviceMappingNotify = DeviceStateNotify + 1; 99705b261ecSmrg ChangeDeviceNotify = DeviceMappingNotify + 1; 99805b261ecSmrg DeviceKeyStateNotify = ChangeDeviceNotify + 1; 99905b261ecSmrg DeviceButtonStateNotify = DeviceKeyStateNotify + 1; 100005b261ecSmrg DevicePresenceNotify = DeviceButtonStateNotify + 1; 10014642e01fSmrg DevicePropertyNotify = DevicePresenceNotify + 1; 100205b261ecSmrg 100305b261ecSmrg event_base[KeyClass] = DeviceKeyPress; 100405b261ecSmrg event_base[ButtonClass] = DeviceButtonPress; 100505b261ecSmrg event_base[ValuatorClass] = DeviceMotionNotify; 100605b261ecSmrg event_base[ProximityClass] = ProximityIn; 100705b261ecSmrg event_base[FocusClass] = DeviceFocusIn; 100805b261ecSmrg event_base[OtherClass] = DeviceStateNotify; 100905b261ecSmrg 101005b261ecSmrg BadDevice += extEntry->errorBase; 101105b261ecSmrg BadEvent += extEntry->errorBase; 101205b261ecSmrg BadMode += extEntry->errorBase; 101305b261ecSmrg DeviceBusy += extEntry->errorBase; 101405b261ecSmrg BadClass += extEntry->errorBase; 101505b261ecSmrg 10166747b715Smrg SetMaskForExtEvent(DeviceKeyPressMask, DeviceKeyPress); 10176747b715Smrg AllowPropagateSuppress(DeviceKeyPressMask); 10186747b715Smrg SetCriticalEvent(DeviceKeyPress); 101905b261ecSmrg 10206747b715Smrg SetMaskForExtEvent(DeviceKeyReleaseMask, DeviceKeyRelease); 10216747b715Smrg AllowPropagateSuppress(DeviceKeyReleaseMask); 10226747b715Smrg SetCriticalEvent(DeviceKeyRelease); 102305b261ecSmrg 10246747b715Smrg SetMaskForExtEvent(DeviceButtonPressMask, DeviceButtonPress); 10256747b715Smrg AllowPropagateSuppress(DeviceButtonPressMask); 10266747b715Smrg SetCriticalEvent(DeviceButtonPress); 102705b261ecSmrg 10286747b715Smrg SetMaskForExtEvent(DeviceButtonReleaseMask, DeviceButtonRelease); 10296747b715Smrg AllowPropagateSuppress(DeviceButtonReleaseMask); 10306747b715Smrg SetCriticalEvent(DeviceButtonRelease); 103105b261ecSmrg 10326747b715Smrg SetMaskForExtEvent(DeviceProximityMask, ProximityIn); 10336747b715Smrg SetMaskForExtEvent(DeviceProximityMask, ProximityOut); 103405b261ecSmrg 10356747b715Smrg SetMaskForExtEvent(DeviceStateNotifyMask, DeviceStateNotify); 103605b261ecSmrg 10376747b715Smrg SetMaskForExtEvent(DevicePointerMotionMask, DeviceMotionNotify); 10386747b715Smrg AllowPropagateSuppress(DevicePointerMotionMask); 10396747b715Smrg SetCriticalEvent(DeviceMotionNotify); 104005b261ecSmrg 104105b261ecSmrg SetEventInfo(DevicePointerMotionHintMask, _devicePointerMotionHint); 10426747b715Smrg SetEventInfo(DeviceButton1MotionMask, _deviceButton1Motion); 10436747b715Smrg SetEventInfo(DeviceButton2MotionMask, _deviceButton2Motion); 10446747b715Smrg SetEventInfo(DeviceButton3MotionMask, _deviceButton3Motion); 10456747b715Smrg SetEventInfo(DeviceButton4MotionMask, _deviceButton4Motion); 10466747b715Smrg SetEventInfo(DeviceButton5MotionMask, _deviceButton5Motion); 104705b261ecSmrg SetEventInfo(DeviceButtonMotionMask, _deviceButtonMotion); 104805b261ecSmrg 104905b261ecSmrg SetMaskForExtEvent(DeviceFocusChangeMask, DeviceFocusIn); 105005b261ecSmrg SetMaskForExtEvent(DeviceFocusChangeMask, DeviceFocusOut); 105105b261ecSmrg 10526747b715Smrg SetMaskForExtEvent(DeviceMappingNotifyMask, DeviceMappingNotify); 10536747b715Smrg SetMaskForExtEvent(ChangeDeviceNotifyMask, ChangeDeviceNotify); 105405b261ecSmrg 105505b261ecSmrg SetEventInfo(DeviceButtonGrabMask, _deviceButtonGrab); 105605b261ecSmrg SetExclusiveAccess(DeviceButtonGrabMask); 105705b261ecSmrg 105805b261ecSmrg SetEventInfo(DeviceOwnerGrabButtonMask, _deviceOwnerGrabButton); 105905b261ecSmrg SetEventInfo(DevicePresenceNotifyMask, _devicePresence); 10604642e01fSmrg SetMaskForExtEvent(DevicePropertyNotifyMask, DevicePropertyNotify); 10614642e01fSmrg 106205b261ecSmrg SetEventInfo(0, _noExtensionEvent); 106305b261ecSmrg} 106405b261ecSmrg 106505b261ecSmrg/************************************************************************ 106605b261ecSmrg * 10674642e01fSmrg * This function restores extension event types and masks to their 106805b261ecSmrg * initial state. 106905b261ecSmrg * 107005b261ecSmrg */ 107105b261ecSmrg 107205b261ecSmrgstatic void 107305b261ecSmrgRestoreExtensionEvents(void) 107405b261ecSmrg{ 10754642e01fSmrg int i, j; 107605b261ecSmrg 107705b261ecSmrg IReqCode = 0; 10784642e01fSmrg IEventBase = 0; 107905b261ecSmrg 108005b261ecSmrg for (i = 0; i < ExtEventIndex - 1; i++) { 108105b261ecSmrg if ((EventInfo[i].type >= LASTEvent) && (EventInfo[i].type < 128)) 10824642e01fSmrg { 10834642e01fSmrg for (j = 0; j < MAXDEVICES; j++) 10844642e01fSmrg SetMaskForEvent(j, 0, EventInfo[i].type); 10854642e01fSmrg } 108605b261ecSmrg EventInfo[i].mask = 0; 108705b261ecSmrg EventInfo[i].type = 0; 108805b261ecSmrg } 108905b261ecSmrg ExtEventIndex = 0; 109005b261ecSmrg DeviceValuator = 0; 109105b261ecSmrg DeviceKeyPress = 1; 109205b261ecSmrg DeviceKeyRelease = 2; 109305b261ecSmrg DeviceButtonPress = 3; 109405b261ecSmrg DeviceButtonRelease = 4; 109505b261ecSmrg DeviceMotionNotify = 5; 109605b261ecSmrg DeviceFocusIn = 6; 109705b261ecSmrg DeviceFocusOut = 7; 109805b261ecSmrg ProximityIn = 8; 109905b261ecSmrg ProximityOut = 9; 110005b261ecSmrg DeviceStateNotify = 10; 110105b261ecSmrg DeviceMappingNotify = 11; 110205b261ecSmrg ChangeDeviceNotify = 12; 110305b261ecSmrg DeviceKeyStateNotify = 13; 110405b261ecSmrg DeviceButtonStateNotify = 13; 110505b261ecSmrg DevicePresenceNotify = 14; 11064642e01fSmrg DevicePropertyNotify = 15; 110705b261ecSmrg 110805b261ecSmrg BadDevice = 0; 110905b261ecSmrg BadEvent = 1; 111005b261ecSmrg BadMode = 2; 111105b261ecSmrg DeviceBusy = 3; 111205b261ecSmrg BadClass = 4; 111305b261ecSmrg 111405b261ecSmrg} 111505b261ecSmrg 111605b261ecSmrg/*********************************************************************** 111705b261ecSmrg * 111805b261ecSmrg * IResetProc. 111905b261ecSmrg * Remove reply-swapping routine. 112005b261ecSmrg * Remove event-swapping routine. 112105b261ecSmrg * 112205b261ecSmrg */ 112305b261ecSmrg 112405b261ecSmrgstatic void 112505b261ecSmrgIResetProc(ExtensionEntry * unused) 112605b261ecSmrg{ 112705b261ecSmrg ReplySwapVector[IReqCode] = ReplyNotSwappd; 112805b261ecSmrg EventSwapVector[DeviceValuator] = NotImplemented; 112905b261ecSmrg EventSwapVector[DeviceKeyPress] = NotImplemented; 113005b261ecSmrg EventSwapVector[DeviceKeyRelease] = NotImplemented; 113105b261ecSmrg EventSwapVector[DeviceButtonPress] = NotImplemented; 113205b261ecSmrg EventSwapVector[DeviceButtonRelease] = NotImplemented; 113305b261ecSmrg EventSwapVector[DeviceMotionNotify] = NotImplemented; 113405b261ecSmrg EventSwapVector[DeviceFocusIn] = NotImplemented; 113505b261ecSmrg EventSwapVector[DeviceFocusOut] = NotImplemented; 113605b261ecSmrg EventSwapVector[ProximityIn] = NotImplemented; 113705b261ecSmrg EventSwapVector[ProximityOut] = NotImplemented; 113805b261ecSmrg EventSwapVector[DeviceStateNotify] = NotImplemented; 113905b261ecSmrg EventSwapVector[DeviceKeyStateNotify] = NotImplemented; 114005b261ecSmrg EventSwapVector[DeviceButtonStateNotify] = NotImplemented; 114105b261ecSmrg EventSwapVector[DeviceMappingNotify] = NotImplemented; 114205b261ecSmrg EventSwapVector[ChangeDeviceNotify] = NotImplemented; 114305b261ecSmrg EventSwapVector[DevicePresenceNotify] = NotImplemented; 11444642e01fSmrg EventSwapVector[DevicePropertyNotify] = NotImplemented; 114505b261ecSmrg RestoreExtensionEvents(); 114605b261ecSmrg} 114705b261ecSmrg 11484642e01fSmrg 114905b261ecSmrg/*********************************************************************** 115005b261ecSmrg * 115105b261ecSmrg * Assign an id and type to an input device. 115205b261ecSmrg * 115305b261ecSmrg */ 115405b261ecSmrg 11554642e01fSmrgvoid 115605b261ecSmrgAssignTypeAndName(DeviceIntPtr dev, Atom type, char *name) 115705b261ecSmrg{ 11586747b715Smrg dev->xinput_type = type; 11599ace9065Smrg dev->name = strdup(name); 116005b261ecSmrg} 116105b261ecSmrg 116205b261ecSmrg/*********************************************************************** 116305b261ecSmrg * 116405b261ecSmrg * Make device type atoms. 116505b261ecSmrg * 116605b261ecSmrg */ 116705b261ecSmrg 116805b261ecSmrgstatic void 116905b261ecSmrgMakeDeviceTypeAtoms(void) 117005b261ecSmrg{ 117105b261ecSmrg int i; 117205b261ecSmrg 117305b261ecSmrg for (i = 0; i < NUMTYPES; i++) 117405b261ecSmrg dev_type[i].type = 117505b261ecSmrg MakeAtom(dev_type[i].name, strlen(dev_type[i].name), 1); 117605b261ecSmrg} 117705b261ecSmrg 117805b261ecSmrg/***************************************************************************** 117905b261ecSmrg * 118005b261ecSmrg * SEventIDispatch 118105b261ecSmrg * 118205b261ecSmrg * Swap any events defined in this extension. 118305b261ecSmrg */ 118405b261ecSmrg#define DO_SWAP(func,type) func ((type *)from, (type *)to) 118505b261ecSmrg 118605b261ecSmrgstatic void 118705b261ecSmrgSEventIDispatch(xEvent * from, xEvent * to) 118805b261ecSmrg{ 118905b261ecSmrg int type = from->u.u.type & 0177; 119005b261ecSmrg 119105b261ecSmrg if (type == DeviceValuator) 119205b261ecSmrg DO_SWAP(SEventDeviceValuator, deviceValuator); 119305b261ecSmrg else if (type == DeviceKeyPress) { 119405b261ecSmrg SKeyButtonPtrEvent(from, to); 119505b261ecSmrg to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; 119605b261ecSmrg } else if (type == DeviceKeyRelease) { 119705b261ecSmrg SKeyButtonPtrEvent(from, to); 119805b261ecSmrg to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; 119905b261ecSmrg } else if (type == DeviceButtonPress) { 120005b261ecSmrg SKeyButtonPtrEvent(from, to); 120105b261ecSmrg to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; 120205b261ecSmrg } else if (type == DeviceButtonRelease) { 120305b261ecSmrg SKeyButtonPtrEvent(from, to); 120405b261ecSmrg to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; 120505b261ecSmrg } else if (type == DeviceMotionNotify) { 120605b261ecSmrg SKeyButtonPtrEvent(from, to); 120705b261ecSmrg to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; 120805b261ecSmrg } else if (type == DeviceFocusIn) 120905b261ecSmrg DO_SWAP(SEventFocus, deviceFocus); 121005b261ecSmrg else if (type == DeviceFocusOut) 121105b261ecSmrg DO_SWAP(SEventFocus, deviceFocus); 121205b261ecSmrg else if (type == ProximityIn) { 121305b261ecSmrg SKeyButtonPtrEvent(from, to); 121405b261ecSmrg to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; 121505b261ecSmrg } else if (type == ProximityOut) { 121605b261ecSmrg SKeyButtonPtrEvent(from, to); 121705b261ecSmrg to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; 121805b261ecSmrg } else if (type == DeviceStateNotify) 121905b261ecSmrg DO_SWAP(SDeviceStateNotifyEvent, deviceStateNotify); 122005b261ecSmrg else if (type == DeviceKeyStateNotify) 122105b261ecSmrg DO_SWAP(SDeviceKeyStateNotifyEvent, deviceKeyStateNotify); 122205b261ecSmrg else if (type == DeviceButtonStateNotify) 122305b261ecSmrg DO_SWAP(SDeviceButtonStateNotifyEvent, deviceButtonStateNotify); 122405b261ecSmrg else if (type == DeviceMappingNotify) 122505b261ecSmrg DO_SWAP(SDeviceMappingNotifyEvent, deviceMappingNotify); 122605b261ecSmrg else if (type == ChangeDeviceNotify) 122705b261ecSmrg DO_SWAP(SChangeDeviceNotifyEvent, changeDeviceNotify); 12284642e01fSmrg else if (type == DevicePresenceNotify) 12294642e01fSmrg DO_SWAP(SDevicePresenceNotifyEvent, devicePresenceNotify); 12304642e01fSmrg else if (type == DevicePropertyNotify) 12314642e01fSmrg DO_SWAP(SDevicePropertyNotifyEvent, devicePropertyNotify); 123205b261ecSmrg else { 123305b261ecSmrg FatalError("XInputExtension: Impossible event!\n"); 123405b261ecSmrg } 123505b261ecSmrg} 123605b261ecSmrg 123705b261ecSmrg/********************************************************************** 123805b261ecSmrg * 123905b261ecSmrg * IExtensionInit - initialize the input extension. 124005b261ecSmrg * 124105b261ecSmrg * Called from InitExtensions in main() or from QueryExtension() if the 124205b261ecSmrg * extension is dynamically loaded. 124305b261ecSmrg * 124405b261ecSmrg * This extension has several events and errors. 124505b261ecSmrg * 12464642e01fSmrg * XI is mandatory nowadays, so if we fail to init XI, we die. 124705b261ecSmrg */ 124805b261ecSmrg 124905b261ecSmrgvoid 125005b261ecSmrgXInputExtensionInit(void) 125105b261ecSmrg{ 125205b261ecSmrg ExtensionEntry *extEntry; 12536747b715Smrg XExtensionVersion thisversion = { XI_Present, 12546747b715Smrg SERVER_XI_MAJOR_VERSION, 12556747b715Smrg SERVER_XI_MINOR_VERSION, 12566747b715Smrg }; 125705b261ecSmrg 12586747b715Smrg if (!dixRegisterPrivateKey(&XIClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(XIClientRec))) 12594642e01fSmrg FatalError("Cannot request private for XI.\n"); 12604642e01fSmrg 12614642e01fSmrg if (!AddCallback(&ClientStateCallback, XIClientCallback, 0)) 12624642e01fSmrg FatalError("Failed to add callback to XI.\n"); 12634642e01fSmrg 126405b261ecSmrg extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch, 126505b261ecSmrg SProcIDispatch, IResetProc, StandardMinorOpcode); 126605b261ecSmrg if (extEntry) { 126705b261ecSmrg IReqCode = extEntry->base; 12684642e01fSmrg IEventBase = extEntry->eventBase; 12696747b715Smrg XIVersion = thisversion; 127005b261ecSmrg MakeDeviceTypeAtoms(); 12716747b715Smrg RT_INPUTCLIENT = CreateNewResourceType((DeleteType) InputClientGone, 12726747b715Smrg "INPUTCLIENT"); 12736747b715Smrg if (!RT_INPUTCLIENT) 12746747b715Smrg FatalError("Failed to add resource type for XI.\n"); 127505b261ecSmrg FixExtensionEvents(extEntry); 127605b261ecSmrg ReplySwapVector[IReqCode] = (ReplySwapPtr) SReplyIDispatch; 127705b261ecSmrg EventSwapVector[DeviceValuator] = SEventIDispatch; 127805b261ecSmrg EventSwapVector[DeviceKeyPress] = SEventIDispatch; 127905b261ecSmrg EventSwapVector[DeviceKeyRelease] = SEventIDispatch; 128005b261ecSmrg EventSwapVector[DeviceButtonPress] = SEventIDispatch; 128105b261ecSmrg EventSwapVector[DeviceButtonRelease] = SEventIDispatch; 128205b261ecSmrg EventSwapVector[DeviceMotionNotify] = SEventIDispatch; 128305b261ecSmrg EventSwapVector[DeviceFocusIn] = SEventIDispatch; 128405b261ecSmrg EventSwapVector[DeviceFocusOut] = SEventIDispatch; 128505b261ecSmrg EventSwapVector[ProximityIn] = SEventIDispatch; 128605b261ecSmrg EventSwapVector[ProximityOut] = SEventIDispatch; 128705b261ecSmrg EventSwapVector[DeviceStateNotify] = SEventIDispatch; 128805b261ecSmrg EventSwapVector[DeviceKeyStateNotify] = SEventIDispatch; 128905b261ecSmrg EventSwapVector[DeviceButtonStateNotify] = SEventIDispatch; 129005b261ecSmrg EventSwapVector[DeviceMappingNotify] = SEventIDispatch; 129105b261ecSmrg EventSwapVector[ChangeDeviceNotify] = SEventIDispatch; 12924642e01fSmrg EventSwapVector[DevicePresenceNotify] = SEventIDispatch; 12934642e01fSmrg 12946747b715Smrg GERegisterExtension(IReqCode, XI2EventSwap); 12956747b715Smrg 12966747b715Smrg 12976747b715Smrg memset(&xi_all_devices, 0, sizeof(xi_all_devices)); 12986747b715Smrg memset(&xi_all_master_devices, 0, sizeof(xi_all_master_devices)); 12996747b715Smrg xi_all_devices.id = XIAllDevices; 13006747b715Smrg xi_all_devices.name = "XIAllDevices"; 13016747b715Smrg xi_all_master_devices.id = XIAllMasterDevices; 13026747b715Smrg xi_all_master_devices.name = "XIAllMasterDevices"; 13036747b715Smrg 13046747b715Smrg inputInfo.all_devices = &xi_all_devices; 13056747b715Smrg inputInfo.all_master_devices = &xi_all_master_devices; 13068223e2f2Smrg 13078223e2f2Smrg XIResetProperties(); 130805b261ecSmrg } else { 130905b261ecSmrg FatalError("IExtensionInit: AddExtensions failed\n"); 131005b261ecSmrg } 131105b261ecSmrg} 13126747b715Smrg 1313