InitInput.c revision 6747b715
1/* 2 3 Copyright 1993, 1998 The Open Group 4 5 Permission to use, copy, modify, distribute, and sell this software and its 6 documentation for any purpose is hereby granted without fee, provided that 7 the above copyright notice appear in all copies and that both that 8 copyright notice and this permission notice appear in supporting 9 documentation. 10 11 The above copyright notice and this permission notice shall be included 12 in all copies or substantial portions of the Software. 13 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 OTHER DEALINGS IN THE SOFTWARE. 21 22 Except as contained in this notice, the name of The Open Group shall 23 not be used in advertising or otherwise to promote the sale, use or 24 other dealings in this Software without prior written authorization 25 from The Open Group. 26 27*/ 28 29#ifdef HAVE_XWIN_CONFIG_H 30#include <xwin-config.h> 31#endif 32#include "win.h" 33#include "dixstruct.h" 34#include "inputstr.h" 35 36 37/* 38 * Local function prototypes 39 */ 40 41#ifdef XWIN_CLIPBOARD 42DISPATCH_PROC(winProcEstablishConnection); 43DISPATCH_PROC(winProcQueryTree); 44DISPATCH_PROC(winProcSetSelectionOwner); 45#endif 46 47 48/* 49 * Local global declarations 50 */ 51 52DeviceIntPtr g_pwinPointer; 53DeviceIntPtr g_pwinKeyboard; 54 55 56/* 57 * References to external symbols 58 */ 59 60#ifdef HAS_DEVWINDOWS 61extern int g_fdMessageQueue; 62#endif 63extern Bool g_fXdmcpEnabled; 64#ifdef XWIN_CLIPBOARD 65extern winDispatchProcPtr winProcEstablishConnectionOrig; 66extern winDispatchProcPtr winProcQueryTreeOrig; 67#endif 68 69 70/* Called from dix/devices.c */ 71/* 72 * All of our keys generate up and down transition notifications, 73 * so all of our keys can be used as modifiers. 74 * 75 * An example of a modifier is mapping the A key to the Control key. 76 * A has to be a legal modifier. I think. 77 */ 78 79Bool 80LegalModifier (unsigned int uiKey, DeviceIntPtr pDevice) 81{ 82 return TRUE; 83} 84 85 86/* Called from dix/dispatch.c */ 87/* 88 * Run through the Windows message queue(s) one more time. 89 * Tell mi to dequeue the events that we have sent it. 90 */ 91void 92ProcessInputEvents (void) 93{ 94#if 0 95 ErrorF ("ProcessInputEvents\n"); 96#endif 97 98 mieqProcessInputEvents (); 99 100#if 0 101 ErrorF ("ProcessInputEvents - returning\n"); 102#endif 103} 104 105 106void DDXRingBell(int volume, int pitch, int duration) 107{ 108 /* winKeybdBell is used instead */ 109 return; 110} 111 112 113/* See Porting Layer Definition - p. 17 */ 114void 115InitInput (int argc, char *argv[]) 116{ 117#if CYGDEBUG 118 winDebug ("InitInput\n"); 119#endif 120 121#ifdef XWIN_CLIPBOARD 122 /* 123 * Wrap some functions at every generation of the server. 124 */ 125 if (InitialVector[2] != winProcEstablishConnection) 126 { 127 winProcEstablishConnectionOrig = InitialVector[2]; 128 InitialVector[2] = winProcEstablishConnection; 129 } 130 if (g_fXdmcpEnabled 131 && ProcVector[X_QueryTree] != winProcQueryTree) 132 { 133 winProcQueryTreeOrig = ProcVector[X_QueryTree]; 134 ProcVector[X_QueryTree] = winProcQueryTree; 135 } 136#endif 137 138 g_pwinPointer = AddInputDevice (serverClient, winMouseProc, TRUE); 139 g_pwinKeyboard = AddInputDevice (serverClient, winKeybdProc, TRUE); 140 141 RegisterPointerDevice (g_pwinPointer); 142 RegisterKeyboardDevice (g_pwinKeyboard); 143 144 g_pwinPointer->name = strdup("Windows mouse"); 145 g_pwinKeyboard->name = strdup("Windows keyboard"); 146 147 mieqInit (); 148 149 /* Initialize the mode key states */ 150 winInitializeModeKeyStates (); 151 152#ifdef HAS_DEVWINDOWS 153 /* Only open the windows message queue device once */ 154 if (g_fdMessageQueue == WIN_FD_INVALID) 155 { 156 /* Open a file descriptor for the Windows message queue */ 157 g_fdMessageQueue = open (WIN_MSG_QUEUE_FNAME, O_RDONLY); 158 159 if (g_fdMessageQueue == -1) 160 { 161 FatalError ("InitInput - Failed opening %s\n", 162 WIN_MSG_QUEUE_FNAME); 163 } 164 165 /* Add the message queue as a device to wait for in WaitForSomething */ 166 AddEnabledDevice (g_fdMessageQueue); 167 } 168#endif 169 170#if CYGDEBUG 171 winDebug ("InitInput - returning\n"); 172#endif 173} 174 175void 176CloseInput (void) 177{ 178} 179