Imported Upstream version 1.15.1
[deb_xorg-server.git] / hw / vfb / InitInput.c
CommitLineData
a09e091a
JB
1/*
2
3Copyright 1993, 1998 The Open Group
4
5Permission to use, copy, modify, distribute, and sell this software and its
6documentation for any purpose is hereby granted without fee, provided that
7the above copyright notice appear in all copies and that both that
8copyright notice and this permission notice appear in supporting
9documentation.
10
11The above copyright notice and this permission notice shall be included
12in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of The Open Group shall
23not be used in advertising or otherwise to promote the sale, use or
24other dealings in this Software without prior written authorization
25from The Open Group.
26
27*/
28
29#ifdef HAVE_DIX_CONFIG_H
30#include <dix-config.h>
31#endif
32
33#include <X11/X.h>
34#include "mi.h"
35#include <X11/Xproto.h>
36#include "scrnintstr.h"
37#include "inputstr.h"
38#include <X11/Xos.h>
39#include "mipointer.h"
40#include "xkbsrv.h"
41#include <X11/keysym.h>
42#include "xserver-properties.h"
43#include "exevents.h"
44#include "extinit.h"
45
46Bool
47LegalModifier(unsigned int key, DeviceIntPtr pDev)
48{
49 return TRUE;
50}
51
52void
53ProcessInputEvents(void)
54{
55 mieqProcessInputEvents();
56}
57
58void
59DDXRingBell(int volume, int pitch, int duration)
60{
61}
62
63#define VFB_MIN_KEY 8
64#define VFB_MAX_KEY 255
65
66static int
67vfbKeybdProc(DeviceIntPtr pDevice, int onoff)
68{
69 DevicePtr pDev = (DevicePtr) pDevice;
70
71 switch (onoff) {
72 case DEVICE_INIT:
73 InitKeyboardDeviceStruct(pDevice, NULL, NULL, NULL);
74 break;
75 case DEVICE_ON:
76 pDev->on = TRUE;
77 break;
78 case DEVICE_OFF:
79 pDev->on = FALSE;
80 break;
81 case DEVICE_CLOSE:
82 break;
83 }
84 return Success;
85}
86
87static int
88vfbMouseProc(DeviceIntPtr pDevice, int onoff)
89{
90#define NBUTTONS 3
91#define NAXES 2
92
93 BYTE map[NBUTTONS + 1];
94 DevicePtr pDev = (DevicePtr) pDevice;
95 Atom btn_labels[NBUTTONS] = { 0 };
96 Atom axes_labels[NAXES] = { 0 };
97
98 switch (onoff) {
99 case DEVICE_INIT:
100 map[1] = 1;
101 map[2] = 2;
102 map[3] = 3;
103
104 btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
105 btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
106 btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
107
108 axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
109 axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
110
111 InitPointerDeviceStruct(pDev, map, NBUTTONS, btn_labels,
112 (PtrCtrlProcPtr) NoopDDA,
113 GetMotionHistorySize(), NAXES, axes_labels);
114 break;
115
116 case DEVICE_ON:
117 pDev->on = TRUE;
118 break;
119
120 case DEVICE_OFF:
121 pDev->on = FALSE;
122 break;
123
124 case DEVICE_CLOSE:
125 break;
126 }
127 return Success;
128
129#undef NBUTTONS
130#undef NAXES
131}
132
133void
134InitInput(int argc, char *argv[])
135{
136 DeviceIntPtr p, k;
137 Atom xiclass;
138
139 p = AddInputDevice(serverClient, vfbMouseProc, TRUE);
140 k = AddInputDevice(serverClient, vfbKeybdProc, TRUE);
141 xiclass = MakeAtom(XI_MOUSE, sizeof(XI_MOUSE) - 1, TRUE);
142 AssignTypeAndName(p, xiclass, "Xvfb mouse");
143 xiclass = MakeAtom(XI_KEYBOARD, sizeof(XI_KEYBOARD) - 1, TRUE);
144 AssignTypeAndName(k, xiclass, "Xvfb keyboard");
145 (void) mieqInit();
146}
147
148void
149CloseInput(void)
150{
151 mieqFini();
152}