InitInput.c revision 1b5d61b8
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 * Local function prototypes
38 */
39
40int winProcEstablishConnection(ClientPtr /* client */ );
41
42/*
43 * Local global declarations
44 */
45
46DeviceIntPtr g_pwinPointer;
47DeviceIntPtr g_pwinKeyboard;
48
49/* Called from dix/devices.c */
50/*
51 * All of our keys generate up and down transition notifications,
52 * so all of our keys can be used as modifiers.
53 *
54 * An example of a modifier is mapping the A key to the Control key.
55 * A has to be a legal modifier.  I think.
56 */
57
58Bool
59LegalModifier(unsigned int uiKey, DeviceIntPtr pDevice)
60{
61    return TRUE;
62}
63
64/* Called from dix/dispatch.c */
65/*
66 * Run through the Windows message queue(s) one more time.
67 * Tell mi to dequeue the events that we have sent it.
68 */
69void
70ProcessInputEvents(void)
71{
72#if 0
73    ErrorF("ProcessInputEvents\n");
74#endif
75
76    mieqProcessInputEvents();
77
78#if 0
79    ErrorF("ProcessInputEvents - returning\n");
80#endif
81}
82
83void
84DDXRingBell(int volume, int pitch, int duration)
85{
86    /* winKeybdBell is used instead */
87    return;
88}
89
90
91#ifdef HAS_DEVWINDOWS
92static void
93xwinDevWindowsHandlerNotify(int fd, int ready, void *data)
94{
95    /* This should process Windows messages, but instead all of that is delayed
96     * until the wakeup handler is called.
97     */
98    ;
99}
100#endif
101
102/* See Porting Layer Definition - p. 17 */
103void
104InitInput(int argc, char *argv[])
105{
106#if CYGDEBUG
107    winDebug("InitInput\n");
108#endif
109
110    /*
111     * Wrap some functions at every generation of the server.
112     */
113    if (InitialVector[2] != winProcEstablishConnection) {
114        winProcEstablishConnectionOrig = InitialVector[2];
115        InitialVector[2] = winProcEstablishConnection;
116    }
117
118    if (AllocDevicePair(serverClient, "Windows",
119                        &g_pwinPointer, &g_pwinKeyboard,
120                        winMouseProc, winKeybdProc,
121                        FALSE) != Success)
122        FatalError("InitInput - Failed to allocate slave devices.\n");
123
124    mieqInit();
125
126    /* Initialize the mode key states */
127    winInitializeModeKeyStates();
128
129#ifdef HAS_DEVWINDOWS
130    /* Only open the windows message queue device once */
131    if (g_fdMessageQueue == WIN_FD_INVALID) {
132        /* Open a file descriptor for the Windows message queue */
133        g_fdMessageQueue = open(WIN_MSG_QUEUE_FNAME, O_RDONLY);
134
135        if (g_fdMessageQueue == -1) {
136            FatalError("InitInput - Failed opening %s\n", WIN_MSG_QUEUE_FNAME);
137        }
138
139        /* Add the message queue as a device to wait for in WaitForSomething */
140        SetNotifyFd(g_fdMessageQueue, xwinDevWindowsHandlerNotify, X_NOTIFY_READ, NULL);
141    }
142#endif
143
144#if CYGDEBUG
145    winDebug("InitInput - returning\n");
146#endif
147}
148
149void
150CloseInput(void)
151{
152    mieqFini();
153}
154