extinit.c revision 05b261ec
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 */ 5205b261ecSmrg 5305b261ecSmrg#define NUMTYPES 15 5405b261ecSmrg 5505b261ecSmrg#define NEED_EVENTS 5605b261ecSmrg#define NEED_REPLIES 5705b261ecSmrg#ifdef HAVE_DIX_CONFIG_H 5805b261ecSmrg#include <dix-config.h> 5905b261ecSmrg#endif 6005b261ecSmrg 6105b261ecSmrg#include <X11/X.h> 6205b261ecSmrg#include <X11/Xproto.h> 6305b261ecSmrg#include "inputstr.h" 6405b261ecSmrg#include "gcstruct.h" /* pointer for extnsionst.h */ 6505b261ecSmrg#include "extnsionst.h" /* extension entry */ 6605b261ecSmrg#include <X11/extensions/XI.h> 6705b261ecSmrg#include <X11/extensions/XIproto.h> 6805b261ecSmrg 6905b261ecSmrg#include "dixevents.h" 7005b261ecSmrg#include "exevents.h" 7105b261ecSmrg#include "extinit.h" 7205b261ecSmrg#include "exglobals.h" 7305b261ecSmrg#include "swaprep.h" 7405b261ecSmrg 7505b261ecSmrg/* modules local to Xi */ 7605b261ecSmrg#include "allowev.h" 7705b261ecSmrg#include "chgdctl.h" 7805b261ecSmrg#include "chgfctl.h" 7905b261ecSmrg#include "chgkbd.h" 8005b261ecSmrg#include "chgprop.h" 8105b261ecSmrg#include "chgptr.h" 8205b261ecSmrg#include "closedev.h" 8305b261ecSmrg#include "devbell.h" 8405b261ecSmrg#include "getbmap.h" 8505b261ecSmrg#include "getbmap.h" 8605b261ecSmrg#include "getdctl.h" 8705b261ecSmrg#include "getfctl.h" 8805b261ecSmrg#include "getfocus.h" 8905b261ecSmrg#include "getkmap.h" 9005b261ecSmrg#include "getmmap.h" 9105b261ecSmrg#include "getprop.h" 9205b261ecSmrg#include "getselev.h" 9305b261ecSmrg#include "getvers.h" 9405b261ecSmrg#include "getvers.h" 9505b261ecSmrg#include "grabdev.h" 9605b261ecSmrg#include "grabdevb.h" 9705b261ecSmrg#include "grabdevk.h" 9805b261ecSmrg#include "gtmotion.h" 9905b261ecSmrg#include "listdev.h" 10005b261ecSmrg#include "opendev.h" 10105b261ecSmrg#include "queryst.h" 10205b261ecSmrg#include "selectev.h" 10305b261ecSmrg#include "sendexev.h" 10405b261ecSmrg#include "chgkmap.h" 10505b261ecSmrg#include "setbmap.h" 10605b261ecSmrg#include "setdval.h" 10705b261ecSmrg#include "setfocus.h" 10805b261ecSmrg#include "setmmap.h" 10905b261ecSmrg#include "setmode.h" 11005b261ecSmrg#include "ungrdev.h" 11105b261ecSmrg#include "ungrdevb.h" 11205b261ecSmrg#include "ungrdevk.h" 11305b261ecSmrg 11405b261ecSmrgstatic Mask lastExtEventMask = 1; 11505b261ecSmrgint ExtEventIndex; 11605b261ecSmrgMask ExtValidMasks[EMASKSIZE]; 11705b261ecSmrgMask ExtExclusiveMasks[EMASKSIZE]; 11805b261ecSmrg 11905b261ecSmrgstatic struct dev_type 12005b261ecSmrg{ 12105b261ecSmrg Atom type; 12205b261ecSmrg char *name; 12305b261ecSmrg} dev_type[] = { 12405b261ecSmrg { 12505b261ecSmrg 0, XI_KEYBOARD}, { 12605b261ecSmrg 0, XI_MOUSE}, { 12705b261ecSmrg 0, XI_TABLET}, { 12805b261ecSmrg 0, XI_TOUCHSCREEN}, { 12905b261ecSmrg 0, XI_TOUCHPAD}, { 13005b261ecSmrg 0, XI_BARCODE}, { 13105b261ecSmrg 0, XI_BUTTONBOX}, { 13205b261ecSmrg 0, XI_KNOB_BOX}, { 13305b261ecSmrg 0, XI_ONE_KNOB}, { 13405b261ecSmrg 0, XI_NINE_KNOB}, { 13505b261ecSmrg 0, XI_TRACKBALL}, { 13605b261ecSmrg 0, XI_QUADRATURE}, { 13705b261ecSmrg 0, XI_ID_MODULE}, { 13805b261ecSmrg 0, XI_SPACEBALL}, { 13905b261ecSmrg 0, XI_DATAGLOVE}, { 14005b261ecSmrg 0, XI_EYETRACKER}, { 14105b261ecSmrg 0, XI_CURSORKEYS}, { 14205b261ecSmrg0, XI_FOOTMOUSE}}; 14305b261ecSmrg 14405b261ecSmrgCARD8 event_base[numInputClasses]; 14505b261ecSmrgXExtEventInfo EventInfo[32]; 14605b261ecSmrg 14705b261ecSmrg/***************************************************************** 14805b261ecSmrg * 14905b261ecSmrg * Globals referenced elsewhere in the server. 15005b261ecSmrg * 15105b261ecSmrg */ 15205b261ecSmrg 15305b261ecSmrgint IReqCode = 0; 15405b261ecSmrgint BadDevice = 0; 15505b261ecSmrgstatic int BadEvent = 1; 15605b261ecSmrgint BadMode = 2; 15705b261ecSmrgint DeviceBusy = 3; 15805b261ecSmrgint BadClass = 4; 15905b261ecSmrg 16005b261ecSmrgMask DevicePointerMotionMask; 16105b261ecSmrgMask DevicePointerMotionHintMask; 16205b261ecSmrgMask DeviceFocusChangeMask; 16305b261ecSmrgMask DeviceStateNotifyMask; 16405b261ecSmrgstatic Mask ChangeDeviceNotifyMask; 16505b261ecSmrgMask DeviceMappingNotifyMask; 16605b261ecSmrgMask DeviceOwnerGrabButtonMask; 16705b261ecSmrgMask DeviceButtonGrabMask; 16805b261ecSmrgMask DeviceButtonMotionMask; 16905b261ecSmrgMask DevicePresenceNotifyMask; 17005b261ecSmrg 17105b261ecSmrgint DeviceValuator; 17205b261ecSmrgint DeviceKeyPress; 17305b261ecSmrgint DeviceKeyRelease; 17405b261ecSmrgint DeviceButtonPress; 17505b261ecSmrgint DeviceButtonRelease; 17605b261ecSmrgint DeviceMotionNotify; 17705b261ecSmrgint DeviceFocusIn; 17805b261ecSmrgint DeviceFocusOut; 17905b261ecSmrgint ProximityIn; 18005b261ecSmrgint ProximityOut; 18105b261ecSmrgint DeviceStateNotify; 18205b261ecSmrgint DeviceKeyStateNotify; 18305b261ecSmrgint DeviceButtonStateNotify; 18405b261ecSmrgint DeviceMappingNotify; 18505b261ecSmrgint ChangeDeviceNotify; 18605b261ecSmrgint DevicePresenceNotify; 18705b261ecSmrg 18805b261ecSmrgint RT_INPUTCLIENT; 18905b261ecSmrg 19005b261ecSmrg/***************************************************************** 19105b261ecSmrg * 19205b261ecSmrg * Externs defined elsewhere in the X server. 19305b261ecSmrg * 19405b261ecSmrg */ 19505b261ecSmrg 19605b261ecSmrgextern XExtensionVersion AllExtensionVersions[]; 19705b261ecSmrg 19805b261ecSmrgMask PropagateMask[MAX_DEVICES]; 19905b261ecSmrg 20005b261ecSmrg/***************************************************************** 20105b261ecSmrg * 20205b261ecSmrg * Declarations of local routines. 20305b261ecSmrg * 20405b261ecSmrg */ 20505b261ecSmrg 20605b261ecSmrgstatic XExtensionVersion thisversion = { XI_Present, 20705b261ecSmrg XI_Add_DevicePresenceNotify_Major, 20805b261ecSmrg XI_Add_DevicePresenceNotify_Minor 20905b261ecSmrg}; 21005b261ecSmrg 21105b261ecSmrg/************************************************************************* 21205b261ecSmrg * 21305b261ecSmrg * ProcIDispatch - main dispatch routine for requests to this extension. 21405b261ecSmrg * This routine is used if server and client have the same byte ordering. 21505b261ecSmrg * 21605b261ecSmrg */ 21705b261ecSmrg 21805b261ecSmrgstatic int 21905b261ecSmrgProcIDispatch(ClientPtr client) 22005b261ecSmrg{ 22105b261ecSmrg REQUEST(xReq); 22205b261ecSmrg if (stuff->data == X_GetExtensionVersion) 22305b261ecSmrg return (ProcXGetExtensionVersion(client)); 22405b261ecSmrg if (stuff->data == X_ListInputDevices) 22505b261ecSmrg return (ProcXListInputDevices(client)); 22605b261ecSmrg else if (stuff->data == X_OpenDevice) 22705b261ecSmrg return (ProcXOpenDevice(client)); 22805b261ecSmrg else if (stuff->data == X_CloseDevice) 22905b261ecSmrg return (ProcXCloseDevice(client)); 23005b261ecSmrg else if (stuff->data == X_SetDeviceMode) 23105b261ecSmrg return (ProcXSetDeviceMode(client)); 23205b261ecSmrg else if (stuff->data == X_SelectExtensionEvent) 23305b261ecSmrg return (ProcXSelectExtensionEvent(client)); 23405b261ecSmrg else if (stuff->data == X_GetSelectedExtensionEvents) 23505b261ecSmrg return (ProcXGetSelectedExtensionEvents(client)); 23605b261ecSmrg else if (stuff->data == X_ChangeDeviceDontPropagateList) 23705b261ecSmrg return (ProcXChangeDeviceDontPropagateList(client)); 23805b261ecSmrg else if (stuff->data == X_GetDeviceDontPropagateList) 23905b261ecSmrg return (ProcXGetDeviceDontPropagateList(client)); 24005b261ecSmrg else if (stuff->data == X_GetDeviceMotionEvents) 24105b261ecSmrg return (ProcXGetDeviceMotionEvents(client)); 24205b261ecSmrg else if (stuff->data == X_ChangeKeyboardDevice) 24305b261ecSmrg return (ProcXChangeKeyboardDevice(client)); 24405b261ecSmrg else if (stuff->data == X_ChangePointerDevice) 24505b261ecSmrg return (ProcXChangePointerDevice(client)); 24605b261ecSmrg else if (stuff->data == X_GrabDevice) 24705b261ecSmrg return (ProcXGrabDevice(client)); 24805b261ecSmrg else if (stuff->data == X_UngrabDevice) 24905b261ecSmrg return (ProcXUngrabDevice(client)); 25005b261ecSmrg else if (stuff->data == X_GrabDeviceKey) 25105b261ecSmrg return (ProcXGrabDeviceKey(client)); 25205b261ecSmrg else if (stuff->data == X_UngrabDeviceKey) 25305b261ecSmrg return (ProcXUngrabDeviceKey(client)); 25405b261ecSmrg else if (stuff->data == X_GrabDeviceButton) 25505b261ecSmrg return (ProcXGrabDeviceButton(client)); 25605b261ecSmrg else if (stuff->data == X_UngrabDeviceButton) 25705b261ecSmrg return (ProcXUngrabDeviceButton(client)); 25805b261ecSmrg else if (stuff->data == X_AllowDeviceEvents) 25905b261ecSmrg return (ProcXAllowDeviceEvents(client)); 26005b261ecSmrg else if (stuff->data == X_GetDeviceFocus) 26105b261ecSmrg return (ProcXGetDeviceFocus(client)); 26205b261ecSmrg else if (stuff->data == X_SetDeviceFocus) 26305b261ecSmrg return (ProcXSetDeviceFocus(client)); 26405b261ecSmrg else if (stuff->data == X_GetFeedbackControl) 26505b261ecSmrg return (ProcXGetFeedbackControl(client)); 26605b261ecSmrg else if (stuff->data == X_ChangeFeedbackControl) 26705b261ecSmrg return (ProcXChangeFeedbackControl(client)); 26805b261ecSmrg else if (stuff->data == X_GetDeviceKeyMapping) 26905b261ecSmrg return (ProcXGetDeviceKeyMapping(client)); 27005b261ecSmrg else if (stuff->data == X_ChangeDeviceKeyMapping) 27105b261ecSmrg return (ProcXChangeDeviceKeyMapping(client)); 27205b261ecSmrg else if (stuff->data == X_GetDeviceModifierMapping) 27305b261ecSmrg return (ProcXGetDeviceModifierMapping(client)); 27405b261ecSmrg else if (stuff->data == X_SetDeviceModifierMapping) 27505b261ecSmrg return (ProcXSetDeviceModifierMapping(client)); 27605b261ecSmrg else if (stuff->data == X_GetDeviceButtonMapping) 27705b261ecSmrg return (ProcXGetDeviceButtonMapping(client)); 27805b261ecSmrg else if (stuff->data == X_SetDeviceButtonMapping) 27905b261ecSmrg return (ProcXSetDeviceButtonMapping(client)); 28005b261ecSmrg else if (stuff->data == X_QueryDeviceState) 28105b261ecSmrg return (ProcXQueryDeviceState(client)); 28205b261ecSmrg else if (stuff->data == X_SendExtensionEvent) 28305b261ecSmrg return (ProcXSendExtensionEvent(client)); 28405b261ecSmrg else if (stuff->data == X_DeviceBell) 28505b261ecSmrg return (ProcXDeviceBell(client)); 28605b261ecSmrg else if (stuff->data == X_SetDeviceValuators) 28705b261ecSmrg return (ProcXSetDeviceValuators(client)); 28805b261ecSmrg else if (stuff->data == X_GetDeviceControl) 28905b261ecSmrg return (ProcXGetDeviceControl(client)); 29005b261ecSmrg else if (stuff->data == X_ChangeDeviceControl) 29105b261ecSmrg return (ProcXChangeDeviceControl(client)); 29205b261ecSmrg else { 29305b261ecSmrg SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest); 29405b261ecSmrg } 29505b261ecSmrg return (BadRequest); 29605b261ecSmrg} 29705b261ecSmrg 29805b261ecSmrg/******************************************************************************* 29905b261ecSmrg * 30005b261ecSmrg * SProcXDispatch 30105b261ecSmrg * 30205b261ecSmrg * Main swapped dispatch routine for requests to this extension. 30305b261ecSmrg * This routine is used if server and client do not have the same byte ordering. 30405b261ecSmrg * 30505b261ecSmrg */ 30605b261ecSmrg 30705b261ecSmrgstatic int 30805b261ecSmrgSProcIDispatch(ClientPtr client) 30905b261ecSmrg{ 31005b261ecSmrg REQUEST(xReq); 31105b261ecSmrg if (stuff->data == X_GetExtensionVersion) 31205b261ecSmrg return (SProcXGetExtensionVersion(client)); 31305b261ecSmrg if (stuff->data == X_ListInputDevices) 31405b261ecSmrg return (SProcXListInputDevices(client)); 31505b261ecSmrg else if (stuff->data == X_OpenDevice) 31605b261ecSmrg return (SProcXOpenDevice(client)); 31705b261ecSmrg else if (stuff->data == X_CloseDevice) 31805b261ecSmrg return (SProcXCloseDevice(client)); 31905b261ecSmrg else if (stuff->data == X_SetDeviceMode) 32005b261ecSmrg return (SProcXSetDeviceMode(client)); 32105b261ecSmrg else if (stuff->data == X_SelectExtensionEvent) 32205b261ecSmrg return (SProcXSelectExtensionEvent(client)); 32305b261ecSmrg else if (stuff->data == X_GetSelectedExtensionEvents) 32405b261ecSmrg return (SProcXGetSelectedExtensionEvents(client)); 32505b261ecSmrg else if (stuff->data == X_ChangeDeviceDontPropagateList) 32605b261ecSmrg return (SProcXChangeDeviceDontPropagateList(client)); 32705b261ecSmrg else if (stuff->data == X_GetDeviceDontPropagateList) 32805b261ecSmrg return (SProcXGetDeviceDontPropagateList(client)); 32905b261ecSmrg else if (stuff->data == X_GetDeviceMotionEvents) 33005b261ecSmrg return (SProcXGetDeviceMotionEvents(client)); 33105b261ecSmrg else if (stuff->data == X_ChangeKeyboardDevice) 33205b261ecSmrg return (SProcXChangeKeyboardDevice(client)); 33305b261ecSmrg else if (stuff->data == X_ChangePointerDevice) 33405b261ecSmrg return (SProcXChangePointerDevice(client)); 33505b261ecSmrg else if (stuff->data == X_GrabDevice) 33605b261ecSmrg return (SProcXGrabDevice(client)); 33705b261ecSmrg else if (stuff->data == X_UngrabDevice) 33805b261ecSmrg return (SProcXUngrabDevice(client)); 33905b261ecSmrg else if (stuff->data == X_GrabDeviceKey) 34005b261ecSmrg return (SProcXGrabDeviceKey(client)); 34105b261ecSmrg else if (stuff->data == X_UngrabDeviceKey) 34205b261ecSmrg return (SProcXUngrabDeviceKey(client)); 34305b261ecSmrg else if (stuff->data == X_GrabDeviceButton) 34405b261ecSmrg return (SProcXGrabDeviceButton(client)); 34505b261ecSmrg else if (stuff->data == X_UngrabDeviceButton) 34605b261ecSmrg return (SProcXUngrabDeviceButton(client)); 34705b261ecSmrg else if (stuff->data == X_AllowDeviceEvents) 34805b261ecSmrg return (SProcXAllowDeviceEvents(client)); 34905b261ecSmrg else if (stuff->data == X_GetDeviceFocus) 35005b261ecSmrg return (SProcXGetDeviceFocus(client)); 35105b261ecSmrg else if (stuff->data == X_SetDeviceFocus) 35205b261ecSmrg return (SProcXSetDeviceFocus(client)); 35305b261ecSmrg else if (stuff->data == X_GetFeedbackControl) 35405b261ecSmrg return (SProcXGetFeedbackControl(client)); 35505b261ecSmrg else if (stuff->data == X_ChangeFeedbackControl) 35605b261ecSmrg return (SProcXChangeFeedbackControl(client)); 35705b261ecSmrg else if (stuff->data == X_GetDeviceKeyMapping) 35805b261ecSmrg return (SProcXGetDeviceKeyMapping(client)); 35905b261ecSmrg else if (stuff->data == X_ChangeDeviceKeyMapping) 36005b261ecSmrg return (SProcXChangeDeviceKeyMapping(client)); 36105b261ecSmrg else if (stuff->data == X_GetDeviceModifierMapping) 36205b261ecSmrg return (SProcXGetDeviceModifierMapping(client)); 36305b261ecSmrg else if (stuff->data == X_SetDeviceModifierMapping) 36405b261ecSmrg return (SProcXSetDeviceModifierMapping(client)); 36505b261ecSmrg else if (stuff->data == X_GetDeviceButtonMapping) 36605b261ecSmrg return (SProcXGetDeviceButtonMapping(client)); 36705b261ecSmrg else if (stuff->data == X_SetDeviceButtonMapping) 36805b261ecSmrg return (SProcXSetDeviceButtonMapping(client)); 36905b261ecSmrg else if (stuff->data == X_QueryDeviceState) 37005b261ecSmrg return (SProcXQueryDeviceState(client)); 37105b261ecSmrg else if (stuff->data == X_SendExtensionEvent) 37205b261ecSmrg return (SProcXSendExtensionEvent(client)); 37305b261ecSmrg else if (stuff->data == X_DeviceBell) 37405b261ecSmrg return (SProcXDeviceBell(client)); 37505b261ecSmrg else if (stuff->data == X_SetDeviceValuators) 37605b261ecSmrg return (SProcXSetDeviceValuators(client)); 37705b261ecSmrg else if (stuff->data == X_GetDeviceControl) 37805b261ecSmrg return (SProcXGetDeviceControl(client)); 37905b261ecSmrg else if (stuff->data == X_ChangeDeviceControl) 38005b261ecSmrg return (SProcXChangeDeviceControl(client)); 38105b261ecSmrg else { 38205b261ecSmrg SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest); 38305b261ecSmrg } 38405b261ecSmrg return (BadRequest); 38505b261ecSmrg} 38605b261ecSmrg 38705b261ecSmrg/********************************************************************** 38805b261ecSmrg * 38905b261ecSmrg * SReplyIDispatch 39005b261ecSmrg * Swap any replies defined in this extension. 39105b261ecSmrg * 39205b261ecSmrg */ 39305b261ecSmrg 39405b261ecSmrg/* FIXME: this would be more concise and readable in ANSI C */ 39505b261ecSmrg#define DISPATCH(code) \ 39605b261ecSmrg if (rep->RepType == X_##code) \ 39705b261ecSmrg SRepX##code (client, len, (x##code##Reply *) rep) 39805b261ecSmrg 39905b261ecSmrgstatic void 40005b261ecSmrgSReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep) 40105b261ecSmrg /* All we look at is the type field */ 40205b261ecSmrg{ /* This is common to all replies */ 40305b261ecSmrg if (rep->RepType == X_GetExtensionVersion) 40405b261ecSmrg SRepXGetExtensionVersion(client, len, 40505b261ecSmrg (xGetExtensionVersionReply *) rep); 40605b261ecSmrg else if (rep->RepType == X_ListInputDevices) 40705b261ecSmrg SRepXListInputDevices(client, len, (xListInputDevicesReply *) rep); 40805b261ecSmrg else if (rep->RepType == X_OpenDevice) 40905b261ecSmrg SRepXOpenDevice(client, len, (xOpenDeviceReply *) rep); 41005b261ecSmrg else if (rep->RepType == X_SetDeviceMode) 41105b261ecSmrg SRepXSetDeviceMode(client, len, (xSetDeviceModeReply *) rep); 41205b261ecSmrg else if (rep->RepType == X_GetSelectedExtensionEvents) 41305b261ecSmrg SRepXGetSelectedExtensionEvents(client, len, 41405b261ecSmrg (xGetSelectedExtensionEventsReply *) 41505b261ecSmrg rep); 41605b261ecSmrg else if (rep->RepType == X_GetDeviceDontPropagateList) 41705b261ecSmrg SRepXGetDeviceDontPropagateList(client, len, 41805b261ecSmrg (xGetDeviceDontPropagateListReply *) 41905b261ecSmrg rep); 42005b261ecSmrg else if (rep->RepType == X_GetDeviceMotionEvents) 42105b261ecSmrg SRepXGetDeviceMotionEvents(client, len, 42205b261ecSmrg (xGetDeviceMotionEventsReply *) rep); 42305b261ecSmrg else if (rep->RepType == X_GrabDevice) 42405b261ecSmrg SRepXGrabDevice(client, len, (xGrabDeviceReply *) rep); 42505b261ecSmrg else if (rep->RepType == X_GetDeviceFocus) 42605b261ecSmrg SRepXGetDeviceFocus(client, len, (xGetDeviceFocusReply *) rep); 42705b261ecSmrg else if (rep->RepType == X_GetFeedbackControl) 42805b261ecSmrg SRepXGetFeedbackControl(client, len, (xGetFeedbackControlReply *) rep); 42905b261ecSmrg else if (rep->RepType == X_GetDeviceKeyMapping) 43005b261ecSmrg SRepXGetDeviceKeyMapping(client, len, 43105b261ecSmrg (xGetDeviceKeyMappingReply *) rep); 43205b261ecSmrg else if (rep->RepType == X_GetDeviceModifierMapping) 43305b261ecSmrg SRepXGetDeviceModifierMapping(client, len, 43405b261ecSmrg (xGetDeviceModifierMappingReply *) rep); 43505b261ecSmrg else if (rep->RepType == X_SetDeviceModifierMapping) 43605b261ecSmrg SRepXSetDeviceModifierMapping(client, len, 43705b261ecSmrg (xSetDeviceModifierMappingReply *) rep); 43805b261ecSmrg else if (rep->RepType == X_GetDeviceButtonMapping) 43905b261ecSmrg SRepXGetDeviceButtonMapping(client, len, 44005b261ecSmrg (xGetDeviceButtonMappingReply *) rep); 44105b261ecSmrg else if (rep->RepType == X_SetDeviceButtonMapping) 44205b261ecSmrg SRepXSetDeviceButtonMapping(client, len, 44305b261ecSmrg (xSetDeviceButtonMappingReply *) rep); 44405b261ecSmrg else if (rep->RepType == X_QueryDeviceState) 44505b261ecSmrg SRepXQueryDeviceState(client, len, (xQueryDeviceStateReply *) rep); 44605b261ecSmrg else if (rep->RepType == X_SetDeviceValuators) 44705b261ecSmrg SRepXSetDeviceValuators(client, len, (xSetDeviceValuatorsReply *) rep); 44805b261ecSmrg else if (rep->RepType == X_GetDeviceControl) 44905b261ecSmrg SRepXGetDeviceControl(client, len, (xGetDeviceControlReply *) rep); 45005b261ecSmrg else if (rep->RepType == X_ChangeDeviceControl) 45105b261ecSmrg SRepXChangeDeviceControl(client, len, 45205b261ecSmrg (xChangeDeviceControlReply *) rep); 45305b261ecSmrg else { 45405b261ecSmrg FatalError("XINPUT confused sending swapped reply"); 45505b261ecSmrg } 45605b261ecSmrg} 45705b261ecSmrg 45805b261ecSmrg/************************************************************************ 45905b261ecSmrg * 46005b261ecSmrg * This function swaps the DeviceValuator event. 46105b261ecSmrg * 46205b261ecSmrg */ 46305b261ecSmrg 46405b261ecSmrgstatic void 46505b261ecSmrgSEventDeviceValuator(deviceValuator * from, deviceValuator * to) 46605b261ecSmrg{ 46705b261ecSmrg char n; 46805b261ecSmrg int i; 46905b261ecSmrg INT32 *ip B32; 47005b261ecSmrg 47105b261ecSmrg *to = *from; 47205b261ecSmrg swaps(&to->sequenceNumber, n); 47305b261ecSmrg swaps(&to->device_state, n); 47405b261ecSmrg ip = &to->valuator0; 47505b261ecSmrg for (i = 0; i < 6; i++) { 47605b261ecSmrg swapl((ip + i), n); /* macro - braces are required */ 47705b261ecSmrg } 47805b261ecSmrg} 47905b261ecSmrg 48005b261ecSmrgstatic void 48105b261ecSmrgSEventFocus(deviceFocus * from, deviceFocus * to) 48205b261ecSmrg{ 48305b261ecSmrg char n; 48405b261ecSmrg 48505b261ecSmrg *to = *from; 48605b261ecSmrg swaps(&to->sequenceNumber, n); 48705b261ecSmrg swapl(&to->time, n); 48805b261ecSmrg swapl(&to->window, n); 48905b261ecSmrg} 49005b261ecSmrg 49105b261ecSmrgstatic void 49205b261ecSmrgSDeviceStateNotifyEvent(deviceStateNotify * from, deviceStateNotify * to) 49305b261ecSmrg{ 49405b261ecSmrg int i; 49505b261ecSmrg char n; 49605b261ecSmrg INT32 *ip B32; 49705b261ecSmrg 49805b261ecSmrg *to = *from; 49905b261ecSmrg swaps(&to->sequenceNumber, n); 50005b261ecSmrg swapl(&to->time, n); 50105b261ecSmrg ip = &to->valuator0; 50205b261ecSmrg for (i = 0; i < 3; i++) { 50305b261ecSmrg swapl((ip + i), n); /* macro - braces are required */ 50405b261ecSmrg } 50505b261ecSmrg} 50605b261ecSmrg 50705b261ecSmrgstatic void 50805b261ecSmrgSDeviceKeyStateNotifyEvent(deviceKeyStateNotify * from, 50905b261ecSmrg deviceKeyStateNotify * to) 51005b261ecSmrg{ 51105b261ecSmrg char n; 51205b261ecSmrg 51305b261ecSmrg *to = *from; 51405b261ecSmrg swaps(&to->sequenceNumber, n); 51505b261ecSmrg} 51605b261ecSmrg 51705b261ecSmrgstatic void 51805b261ecSmrgSDeviceButtonStateNotifyEvent(deviceButtonStateNotify * from, 51905b261ecSmrg deviceButtonStateNotify * to) 52005b261ecSmrg{ 52105b261ecSmrg char n; 52205b261ecSmrg 52305b261ecSmrg *to = *from; 52405b261ecSmrg swaps(&to->sequenceNumber, n); 52505b261ecSmrg} 52605b261ecSmrg 52705b261ecSmrgstatic void 52805b261ecSmrgSChangeDeviceNotifyEvent(changeDeviceNotify * from, changeDeviceNotify * to) 52905b261ecSmrg{ 53005b261ecSmrg char n; 53105b261ecSmrg 53205b261ecSmrg *to = *from; 53305b261ecSmrg swaps(&to->sequenceNumber, n); 53405b261ecSmrg swapl(&to->time, n); 53505b261ecSmrg} 53605b261ecSmrg 53705b261ecSmrgstatic void 53805b261ecSmrgSDeviceMappingNotifyEvent(deviceMappingNotify * from, deviceMappingNotify * to) 53905b261ecSmrg{ 54005b261ecSmrg char n; 54105b261ecSmrg 54205b261ecSmrg *to = *from; 54305b261ecSmrg swaps(&to->sequenceNumber, n); 54405b261ecSmrg swapl(&to->time, n); 54505b261ecSmrg} 54605b261ecSmrg 54705b261ecSmrgstatic void 54805b261ecSmrgSDevicePresenceNotifyEvent (devicePresenceNotify *from, devicePresenceNotify *to) 54905b261ecSmrg{ 55005b261ecSmrg char n; 55105b261ecSmrg 55205b261ecSmrg *to = *from; 55305b261ecSmrg swaps(&to->sequenceNumber,n); 55405b261ecSmrg swapl(&to->time, n); 55505b261ecSmrg swaps(&to->control, n); 55605b261ecSmrg} 55705b261ecSmrg 55805b261ecSmrg/************************************************************************** 55905b261ecSmrg * 56005b261ecSmrg * Allow the specified event to have its propagation suppressed. 56105b261ecSmrg * The default is to not allow suppression of propagation. 56205b261ecSmrg * 56305b261ecSmrg */ 56405b261ecSmrg 56505b261ecSmrgstatic void 56605b261ecSmrgAllowPropagateSuppress(Mask mask) 56705b261ecSmrg{ 56805b261ecSmrg int i; 56905b261ecSmrg 57005b261ecSmrg for (i = 0; i < MAX_DEVICES; i++) 57105b261ecSmrg PropagateMask[i] |= mask; 57205b261ecSmrg} 57305b261ecSmrg 57405b261ecSmrg/************************************************************************** 57505b261ecSmrg * 57605b261ecSmrg * Return the next available extension event mask. 57705b261ecSmrg * 57805b261ecSmrg */ 57905b261ecSmrg 58005b261ecSmrgstatic Mask 58105b261ecSmrgGetNextExtEventMask(void) 58205b261ecSmrg{ 58305b261ecSmrg int i; 58405b261ecSmrg Mask mask = lastExtEventMask; 58505b261ecSmrg 58605b261ecSmrg if (lastExtEventMask == 0) { 58705b261ecSmrg FatalError("GetNextExtEventMask: no more events are available."); 58805b261ecSmrg } 58905b261ecSmrg lastExtEventMask <<= 1; 59005b261ecSmrg 59105b261ecSmrg for (i = 0; i < MAX_DEVICES; i++) 59205b261ecSmrg ExtValidMasks[i] |= mask; 59305b261ecSmrg return mask; 59405b261ecSmrg} 59505b261ecSmrg 59605b261ecSmrg/************************************************************************** 59705b261ecSmrg * 59805b261ecSmrg * Record an event mask where there is no unique corresponding event type. 59905b261ecSmrg * We can't call SetMaskForEvent, since that would clobber the existing 60005b261ecSmrg * mask for that event. MotionHint and ButtonMotion are examples. 60105b261ecSmrg * 60205b261ecSmrg * Since extension event types will never be less than 64, we can use 60305b261ecSmrg * 0-63 in the EventInfo array as the "type" to be used to look up this 60405b261ecSmrg * mask. This means that the corresponding macros such as 60505b261ecSmrg * DevicePointerMotionHint must have access to the same constants. 60605b261ecSmrg * 60705b261ecSmrg */ 60805b261ecSmrg 60905b261ecSmrgstatic void 61005b261ecSmrgSetEventInfo(Mask mask, int constant) 61105b261ecSmrg{ 61205b261ecSmrg EventInfo[ExtEventIndex].mask = mask; 61305b261ecSmrg EventInfo[ExtEventIndex++].type = constant; 61405b261ecSmrg} 61505b261ecSmrg 61605b261ecSmrg/************************************************************************** 61705b261ecSmrg * 61805b261ecSmrg * Allow the specified event to be restricted to being selected by one 61905b261ecSmrg * client at a time. 62005b261ecSmrg * The default is to allow more than one client to select the event. 62105b261ecSmrg * 62205b261ecSmrg */ 62305b261ecSmrg 62405b261ecSmrgstatic void 62505b261ecSmrgSetExclusiveAccess(Mask mask) 62605b261ecSmrg{ 62705b261ecSmrg int i; 62805b261ecSmrg 62905b261ecSmrg for (i = 0; i < MAX_DEVICES; i++) 63005b261ecSmrg ExtExclusiveMasks[i] |= mask; 63105b261ecSmrg} 63205b261ecSmrg 63305b261ecSmrg/************************************************************************** 63405b261ecSmrg * 63505b261ecSmrg * Assign the specified mask to the specified event. 63605b261ecSmrg * 63705b261ecSmrg */ 63805b261ecSmrg 63905b261ecSmrgstatic void 64005b261ecSmrgSetMaskForExtEvent(Mask mask, int event) 64105b261ecSmrg{ 64205b261ecSmrg 64305b261ecSmrg EventInfo[ExtEventIndex].mask = mask; 64405b261ecSmrg EventInfo[ExtEventIndex++].type = event; 64505b261ecSmrg 64605b261ecSmrg if ((event < LASTEvent) || (event >= 128)) 64705b261ecSmrg FatalError("MaskForExtensionEvent: bogus event number"); 64805b261ecSmrg SetMaskForEvent(mask, event); 64905b261ecSmrg} 65005b261ecSmrg 65105b261ecSmrg/************************************************************************ 65205b261ecSmrg * 65305b261ecSmrg * This function sets up extension event types and masks. 65405b261ecSmrg * 65505b261ecSmrg */ 65605b261ecSmrg 65705b261ecSmrgstatic void 65805b261ecSmrgFixExtensionEvents(ExtensionEntry * extEntry) 65905b261ecSmrg{ 66005b261ecSmrg Mask mask; 66105b261ecSmrg 66205b261ecSmrg DeviceValuator = extEntry->eventBase; 66305b261ecSmrg DeviceKeyPress = DeviceValuator + 1; 66405b261ecSmrg DeviceKeyRelease = DeviceKeyPress + 1; 66505b261ecSmrg DeviceButtonPress = DeviceKeyRelease + 1; 66605b261ecSmrg DeviceButtonRelease = DeviceButtonPress + 1; 66705b261ecSmrg DeviceMotionNotify = DeviceButtonRelease + 1; 66805b261ecSmrg DeviceFocusIn = DeviceMotionNotify + 1; 66905b261ecSmrg DeviceFocusOut = DeviceFocusIn + 1; 67005b261ecSmrg ProximityIn = DeviceFocusOut + 1; 67105b261ecSmrg ProximityOut = ProximityIn + 1; 67205b261ecSmrg DeviceStateNotify = ProximityOut + 1; 67305b261ecSmrg DeviceMappingNotify = DeviceStateNotify + 1; 67405b261ecSmrg ChangeDeviceNotify = DeviceMappingNotify + 1; 67505b261ecSmrg DeviceKeyStateNotify = ChangeDeviceNotify + 1; 67605b261ecSmrg DeviceButtonStateNotify = DeviceKeyStateNotify + 1; 67705b261ecSmrg DevicePresenceNotify = DeviceButtonStateNotify + 1; 67805b261ecSmrg 67905b261ecSmrg event_base[KeyClass] = DeviceKeyPress; 68005b261ecSmrg event_base[ButtonClass] = DeviceButtonPress; 68105b261ecSmrg event_base[ValuatorClass] = DeviceMotionNotify; 68205b261ecSmrg event_base[ProximityClass] = ProximityIn; 68305b261ecSmrg event_base[FocusClass] = DeviceFocusIn; 68405b261ecSmrg event_base[OtherClass] = DeviceStateNotify; 68505b261ecSmrg 68605b261ecSmrg BadDevice += extEntry->errorBase; 68705b261ecSmrg BadEvent += extEntry->errorBase; 68805b261ecSmrg BadMode += extEntry->errorBase; 68905b261ecSmrg DeviceBusy += extEntry->errorBase; 69005b261ecSmrg BadClass += extEntry->errorBase; 69105b261ecSmrg 69205b261ecSmrg mask = GetNextExtEventMask(); 69305b261ecSmrg SetMaskForExtEvent(mask, DeviceKeyPress); 69405b261ecSmrg AllowPropagateSuppress(mask); 69505b261ecSmrg 69605b261ecSmrg mask = GetNextExtEventMask(); 69705b261ecSmrg SetMaskForExtEvent(mask, DeviceKeyRelease); 69805b261ecSmrg AllowPropagateSuppress(mask); 69905b261ecSmrg 70005b261ecSmrg mask = GetNextExtEventMask(); 70105b261ecSmrg SetMaskForExtEvent(mask, DeviceButtonPress); 70205b261ecSmrg AllowPropagateSuppress(mask); 70305b261ecSmrg 70405b261ecSmrg mask = GetNextExtEventMask(); 70505b261ecSmrg SetMaskForExtEvent(mask, DeviceButtonRelease); 70605b261ecSmrg AllowPropagateSuppress(mask); 70705b261ecSmrg 70805b261ecSmrg mask = GetNextExtEventMask(); 70905b261ecSmrg SetMaskForExtEvent(mask, ProximityIn); 71005b261ecSmrg SetMaskForExtEvent(mask, ProximityOut); 71105b261ecSmrg AllowPropagateSuppress(mask); 71205b261ecSmrg 71305b261ecSmrg mask = GetNextExtEventMask(); 71405b261ecSmrg DeviceStateNotifyMask = mask; 71505b261ecSmrg SetMaskForExtEvent(mask, DeviceStateNotify); 71605b261ecSmrg 71705b261ecSmrg mask = GetNextExtEventMask(); 71805b261ecSmrg DevicePointerMotionMask = mask; 71905b261ecSmrg SetMaskForExtEvent(mask, DeviceMotionNotify); 72005b261ecSmrg AllowPropagateSuppress(mask); 72105b261ecSmrg 72205b261ecSmrg DevicePointerMotionHintMask = GetNextExtEventMask(); 72305b261ecSmrg SetEventInfo(DevicePointerMotionHintMask, _devicePointerMotionHint); 72405b261ecSmrg SetEventInfo(GetNextExtEventMask(), _deviceButton1Motion); 72505b261ecSmrg SetEventInfo(GetNextExtEventMask(), _deviceButton2Motion); 72605b261ecSmrg SetEventInfo(GetNextExtEventMask(), _deviceButton3Motion); 72705b261ecSmrg SetEventInfo(GetNextExtEventMask(), _deviceButton4Motion); 72805b261ecSmrg SetEventInfo(GetNextExtEventMask(), _deviceButton5Motion); 72905b261ecSmrg DeviceButtonMotionMask = GetNextExtEventMask(); 73005b261ecSmrg SetEventInfo(DeviceButtonMotionMask, _deviceButtonMotion); 73105b261ecSmrg 73205b261ecSmrg DeviceFocusChangeMask = GetNextExtEventMask(); 73305b261ecSmrg SetMaskForExtEvent(DeviceFocusChangeMask, DeviceFocusIn); 73405b261ecSmrg SetMaskForExtEvent(DeviceFocusChangeMask, DeviceFocusOut); 73505b261ecSmrg 73605b261ecSmrg mask = GetNextExtEventMask(); 73705b261ecSmrg SetMaskForExtEvent(mask, DeviceMappingNotify); 73805b261ecSmrg DeviceMappingNotifyMask = mask; 73905b261ecSmrg 74005b261ecSmrg mask = GetNextExtEventMask(); 74105b261ecSmrg SetMaskForExtEvent(mask, ChangeDeviceNotify); 74205b261ecSmrg ChangeDeviceNotifyMask = mask; 74305b261ecSmrg 74405b261ecSmrg DeviceButtonGrabMask = GetNextExtEventMask(); 74505b261ecSmrg SetEventInfo(DeviceButtonGrabMask, _deviceButtonGrab); 74605b261ecSmrg SetExclusiveAccess(DeviceButtonGrabMask); 74705b261ecSmrg 74805b261ecSmrg DeviceOwnerGrabButtonMask = GetNextExtEventMask(); 74905b261ecSmrg SetEventInfo(DeviceOwnerGrabButtonMask, _deviceOwnerGrabButton); 75005b261ecSmrg 75105b261ecSmrg DevicePresenceNotifyMask = GetNextExtEventMask(); 75205b261ecSmrg SetEventInfo(DevicePresenceNotifyMask, _devicePresence); 75305b261ecSmrg SetEventInfo(0, _noExtensionEvent); 75405b261ecSmrg} 75505b261ecSmrg 75605b261ecSmrg/************************************************************************ 75705b261ecSmrg * 75805b261ecSmrg * This function restores extension event types and masks to their 75905b261ecSmrg * initial state. 76005b261ecSmrg * 76105b261ecSmrg */ 76205b261ecSmrg 76305b261ecSmrgstatic void 76405b261ecSmrgRestoreExtensionEvents(void) 76505b261ecSmrg{ 76605b261ecSmrg int i; 76705b261ecSmrg 76805b261ecSmrg IReqCode = 0; 76905b261ecSmrg 77005b261ecSmrg for (i = 0; i < ExtEventIndex - 1; i++) { 77105b261ecSmrg if ((EventInfo[i].type >= LASTEvent) && (EventInfo[i].type < 128)) 77205b261ecSmrg SetMaskForEvent(0, EventInfo[i].type); 77305b261ecSmrg EventInfo[i].mask = 0; 77405b261ecSmrg EventInfo[i].type = 0; 77505b261ecSmrg } 77605b261ecSmrg ExtEventIndex = 0; 77705b261ecSmrg lastExtEventMask = 1; 77805b261ecSmrg DeviceValuator = 0; 77905b261ecSmrg DeviceKeyPress = 1; 78005b261ecSmrg DeviceKeyRelease = 2; 78105b261ecSmrg DeviceButtonPress = 3; 78205b261ecSmrg DeviceButtonRelease = 4; 78305b261ecSmrg DeviceMotionNotify = 5; 78405b261ecSmrg DeviceFocusIn = 6; 78505b261ecSmrg DeviceFocusOut = 7; 78605b261ecSmrg ProximityIn = 8; 78705b261ecSmrg ProximityOut = 9; 78805b261ecSmrg DeviceStateNotify = 10; 78905b261ecSmrg DeviceMappingNotify = 11; 79005b261ecSmrg ChangeDeviceNotify = 12; 79105b261ecSmrg DeviceKeyStateNotify = 13; 79205b261ecSmrg DeviceButtonStateNotify = 13; 79305b261ecSmrg DevicePresenceNotify = 14; 79405b261ecSmrg 79505b261ecSmrg BadDevice = 0; 79605b261ecSmrg BadEvent = 1; 79705b261ecSmrg BadMode = 2; 79805b261ecSmrg DeviceBusy = 3; 79905b261ecSmrg BadClass = 4; 80005b261ecSmrg 80105b261ecSmrg} 80205b261ecSmrg 80305b261ecSmrg/*********************************************************************** 80405b261ecSmrg * 80505b261ecSmrg * IResetProc. 80605b261ecSmrg * Remove reply-swapping routine. 80705b261ecSmrg * Remove event-swapping routine. 80805b261ecSmrg * 80905b261ecSmrg */ 81005b261ecSmrg 81105b261ecSmrgstatic void 81205b261ecSmrgIResetProc(ExtensionEntry * unused) 81305b261ecSmrg{ 81405b261ecSmrg 81505b261ecSmrg ReplySwapVector[IReqCode] = ReplyNotSwappd; 81605b261ecSmrg EventSwapVector[DeviceValuator] = NotImplemented; 81705b261ecSmrg EventSwapVector[DeviceKeyPress] = NotImplemented; 81805b261ecSmrg EventSwapVector[DeviceKeyRelease] = NotImplemented; 81905b261ecSmrg EventSwapVector[DeviceButtonPress] = NotImplemented; 82005b261ecSmrg EventSwapVector[DeviceButtonRelease] = NotImplemented; 82105b261ecSmrg EventSwapVector[DeviceMotionNotify] = NotImplemented; 82205b261ecSmrg EventSwapVector[DeviceFocusIn] = NotImplemented; 82305b261ecSmrg EventSwapVector[DeviceFocusOut] = NotImplemented; 82405b261ecSmrg EventSwapVector[ProximityIn] = NotImplemented; 82505b261ecSmrg EventSwapVector[ProximityOut] = NotImplemented; 82605b261ecSmrg EventSwapVector[DeviceStateNotify] = NotImplemented; 82705b261ecSmrg EventSwapVector[DeviceKeyStateNotify] = NotImplemented; 82805b261ecSmrg EventSwapVector[DeviceButtonStateNotify] = NotImplemented; 82905b261ecSmrg EventSwapVector[DeviceMappingNotify] = NotImplemented; 83005b261ecSmrg EventSwapVector[ChangeDeviceNotify] = NotImplemented; 83105b261ecSmrg EventSwapVector[DevicePresenceNotify] = NotImplemented; 83205b261ecSmrg RestoreExtensionEvents(); 83305b261ecSmrg} 83405b261ecSmrg 83505b261ecSmrg/*********************************************************************** 83605b261ecSmrg * 83705b261ecSmrg * Assign an id and type to an input device. 83805b261ecSmrg * 83905b261ecSmrg */ 84005b261ecSmrg 84105b261ecSmrg_X_EXPORT void 84205b261ecSmrgAssignTypeAndName(DeviceIntPtr dev, Atom type, char *name) 84305b261ecSmrg{ 84405b261ecSmrg dev->type = type; 84505b261ecSmrg dev->name = (char *)xalloc(strlen(name) + 1); 84605b261ecSmrg strcpy(dev->name, name); 84705b261ecSmrg} 84805b261ecSmrg 84905b261ecSmrg/*********************************************************************** 85005b261ecSmrg * 85105b261ecSmrg * Make device type atoms. 85205b261ecSmrg * 85305b261ecSmrg */ 85405b261ecSmrg 85505b261ecSmrgstatic void 85605b261ecSmrgMakeDeviceTypeAtoms(void) 85705b261ecSmrg{ 85805b261ecSmrg int i; 85905b261ecSmrg 86005b261ecSmrg for (i = 0; i < NUMTYPES; i++) 86105b261ecSmrg dev_type[i].type = 86205b261ecSmrg MakeAtom(dev_type[i].name, strlen(dev_type[i].name), 1); 86305b261ecSmrg} 86405b261ecSmrg 86505b261ecSmrg/************************************************************************** 86605b261ecSmrg * Return a DeviceIntPtr corresponding to a specified device id. 86705b261ecSmrg * 86805b261ecSmrg */ 86905b261ecSmrg 87005b261ecSmrgDeviceIntPtr 87105b261ecSmrgLookupDeviceIntRec(CARD8 id) 87205b261ecSmrg{ 87305b261ecSmrg DeviceIntPtr dev; 87405b261ecSmrg 87505b261ecSmrg for (dev = inputInfo.devices; dev; dev = dev->next) { 87605b261ecSmrg if (dev->id == id) 87705b261ecSmrg return dev; 87805b261ecSmrg } 87905b261ecSmrg 88005b261ecSmrg for (dev = inputInfo.off_devices; dev; dev = dev->next) { 88105b261ecSmrg if (dev->id == id) 88205b261ecSmrg return dev; 88305b261ecSmrg } 88405b261ecSmrg 88505b261ecSmrg return NULL; 88605b261ecSmrg} 88705b261ecSmrg 88805b261ecSmrg/***************************************************************************** 88905b261ecSmrg * 89005b261ecSmrg * SEventIDispatch 89105b261ecSmrg * 89205b261ecSmrg * Swap any events defined in this extension. 89305b261ecSmrg */ 89405b261ecSmrg#define DO_SWAP(func,type) func ((type *)from, (type *)to) 89505b261ecSmrg 89605b261ecSmrgstatic void 89705b261ecSmrgSEventIDispatch(xEvent * from, xEvent * to) 89805b261ecSmrg{ 89905b261ecSmrg int type = from->u.u.type & 0177; 90005b261ecSmrg 90105b261ecSmrg if (type == DeviceValuator) 90205b261ecSmrg DO_SWAP(SEventDeviceValuator, deviceValuator); 90305b261ecSmrg else if (type == DeviceKeyPress) { 90405b261ecSmrg SKeyButtonPtrEvent(from, to); 90505b261ecSmrg to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; 90605b261ecSmrg } else if (type == DeviceKeyRelease) { 90705b261ecSmrg SKeyButtonPtrEvent(from, to); 90805b261ecSmrg to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; 90905b261ecSmrg } else if (type == DeviceButtonPress) { 91005b261ecSmrg SKeyButtonPtrEvent(from, to); 91105b261ecSmrg to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; 91205b261ecSmrg } else if (type == DeviceButtonRelease) { 91305b261ecSmrg SKeyButtonPtrEvent(from, to); 91405b261ecSmrg to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; 91505b261ecSmrg } else if (type == DeviceMotionNotify) { 91605b261ecSmrg SKeyButtonPtrEvent(from, to); 91705b261ecSmrg to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; 91805b261ecSmrg } else if (type == DeviceFocusIn) 91905b261ecSmrg DO_SWAP(SEventFocus, deviceFocus); 92005b261ecSmrg else if (type == DeviceFocusOut) 92105b261ecSmrg DO_SWAP(SEventFocus, deviceFocus); 92205b261ecSmrg else if (type == ProximityIn) { 92305b261ecSmrg SKeyButtonPtrEvent(from, to); 92405b261ecSmrg to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; 92505b261ecSmrg } else if (type == ProximityOut) { 92605b261ecSmrg SKeyButtonPtrEvent(from, to); 92705b261ecSmrg to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; 92805b261ecSmrg } else if (type == DeviceStateNotify) 92905b261ecSmrg DO_SWAP(SDeviceStateNotifyEvent, deviceStateNotify); 93005b261ecSmrg else if (type == DeviceKeyStateNotify) 93105b261ecSmrg DO_SWAP(SDeviceKeyStateNotifyEvent, deviceKeyStateNotify); 93205b261ecSmrg else if (type == DeviceButtonStateNotify) 93305b261ecSmrg DO_SWAP(SDeviceButtonStateNotifyEvent, deviceButtonStateNotify); 93405b261ecSmrg else if (type == DeviceMappingNotify) 93505b261ecSmrg DO_SWAP(SDeviceMappingNotifyEvent, deviceMappingNotify); 93605b261ecSmrg else if (type == ChangeDeviceNotify) 93705b261ecSmrg DO_SWAP(SChangeDeviceNotifyEvent, changeDeviceNotify); 93805b261ecSmrg else { 93905b261ecSmrg FatalError("XInputExtension: Impossible event!\n"); 94005b261ecSmrg } 94105b261ecSmrg} 94205b261ecSmrg 94305b261ecSmrg/********************************************************************** 94405b261ecSmrg * 94505b261ecSmrg * IExtensionInit - initialize the input extension. 94605b261ecSmrg * 94705b261ecSmrg * Called from InitExtensions in main() or from QueryExtension() if the 94805b261ecSmrg * extension is dynamically loaded. 94905b261ecSmrg * 95005b261ecSmrg * This extension has several events and errors. 95105b261ecSmrg * 95205b261ecSmrg */ 95305b261ecSmrg 95405b261ecSmrgvoid 95505b261ecSmrgXInputExtensionInit(void) 95605b261ecSmrg{ 95705b261ecSmrg ExtensionEntry *extEntry; 95805b261ecSmrg 95905b261ecSmrg extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch, 96005b261ecSmrg SProcIDispatch, IResetProc, StandardMinorOpcode); 96105b261ecSmrg if (extEntry) { 96205b261ecSmrg IReqCode = extEntry->base; 96305b261ecSmrg AllExtensionVersions[IReqCode - 128] = thisversion; 96405b261ecSmrg MakeDeviceTypeAtoms(); 96505b261ecSmrg RT_INPUTCLIENT = CreateNewResourceType((DeleteType) InputClientGone); 96605b261ecSmrg FixExtensionEvents(extEntry); 96705b261ecSmrg ReplySwapVector[IReqCode] = (ReplySwapPtr) SReplyIDispatch; 96805b261ecSmrg EventSwapVector[DeviceValuator] = SEventIDispatch; 96905b261ecSmrg EventSwapVector[DeviceKeyPress] = SEventIDispatch; 97005b261ecSmrg EventSwapVector[DeviceKeyRelease] = SEventIDispatch; 97105b261ecSmrg EventSwapVector[DeviceButtonPress] = SEventIDispatch; 97205b261ecSmrg EventSwapVector[DeviceButtonRelease] = SEventIDispatch; 97305b261ecSmrg EventSwapVector[DeviceMotionNotify] = SEventIDispatch; 97405b261ecSmrg EventSwapVector[DeviceFocusIn] = SEventIDispatch; 97505b261ecSmrg EventSwapVector[DeviceFocusOut] = SEventIDispatch; 97605b261ecSmrg EventSwapVector[ProximityIn] = SEventIDispatch; 97705b261ecSmrg EventSwapVector[ProximityOut] = SEventIDispatch; 97805b261ecSmrg EventSwapVector[DeviceStateNotify] = SEventIDispatch; 97905b261ecSmrg EventSwapVector[DeviceKeyStateNotify] = SEventIDispatch; 98005b261ecSmrg EventSwapVector[DeviceButtonStateNotify] = SEventIDispatch; 98105b261ecSmrg EventSwapVector[DeviceMappingNotify] = SEventIDispatch; 98205b261ecSmrg EventSwapVector[ChangeDeviceNotify] = SEventIDispatch; 98305b261ecSmrg } else { 98405b261ecSmrg FatalError("IExtensionInit: AddExtensions failed\n"); 98505b261ecSmrg } 98605b261ecSmrg} 987