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