Debian Codegraph @

hw/vfb/InitInput.c

raw
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_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
46 void
47 ProcessInputEvents(void)
48 {
49 mieqProcessInputEvents();
50 }
51
52 void
53 DDXRingBell(int volume, int pitch, int duration)
54 {
55 }
56
57 #define VFB_MIN_KEY 8
58 #define VFB_MAX_KEY 255
59
60 static int
61 vfbKeybdProc(DeviceIntPtr pDevice, int onoff)
62 {
63 DevicePtr pDev = (DevicePtr) pDevice;
64
65 switch (onoff) {
66 case DEVICE_INIT:
67 InitKeyboardDeviceStruct(pDevice, NULL, NULL, NULL);
68 break;
69 case DEVICE_ON:
70 pDev->on = TRUE;
71 break;
72 case DEVICE_OFF:
73 pDev->on = FALSE;
74 break;
75 case DEVICE_CLOSE:
76 break;
77 }
78 return Success;
79 }
80
81 static int
82 vfbMouseProc(DeviceIntPtr pDevice, int onoff)
83 {
84 #define NBUTTONS 13
85 #define NAXES 2
86
87 BYTE map[NBUTTONS + 1];
88 DevicePtr pDev = (DevicePtr) pDevice;
89 Atom btn_labels[NBUTTONS] = { 0 };
90 Atom axes_labels[NAXES] = { 0 };
91
92 switch (onoff) {
93 case DEVICE_INIT:
94 for (int i = 1; i <= NBUTTONS; ++i) {
95 map[i] = i;
96 }
97
98 btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
99 btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
100 btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
101 btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
102 btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
103 btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
104 btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
105 btn_labels[7] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_UNKNOWN);
106 btn_labels[8] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_UNKNOWN);
107 btn_labels[9] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_UNKNOWN);
108 btn_labels[10] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_UNKNOWN);
109 btn_labels[11] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_UNKNOWN);
110 btn_labels[12] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_UNKNOWN);
111
112 axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
113 axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
114
115 InitPointerDeviceStruct(pDev, map, NBUTTONS, btn_labels,
116 (PtrCtrlProcPtr) NoopDDA,
117 GetMotionHistorySize(), NAXES, axes_labels);
118 break;
119
120 case DEVICE_ON:
121 pDev->on = TRUE;
122 break;
123
124 case DEVICE_OFF:
125 pDev->on = FALSE;
126 break;
127
128 case DEVICE_CLOSE:
129 break;
130 }
131 return Success;
132
133 #undef NBUTTONS
134 #undef NAXES
135 }
136
137 void
138 InitInput(int argc, char *argv[])
139 {
140 DeviceIntPtr p, k;
141 Atom xiclass;
142
143 p = AddInputDevice(serverClient, vfbMouseProc, TRUE);
144 k = AddInputDevice(serverClient, vfbKeybdProc, TRUE);
145 xiclass = MakeAtom(XI_MOUSE, sizeof(XI_MOUSE) - 1, TRUE);
146 AssignTypeAndName(p, xiclass, "Xvfb mouse");
147 xiclass = MakeAtom(XI_KEYBOARD, sizeof(XI_KEYBOARD) - 1, TRUE);
148 AssignTypeAndName(k, xiclass, "Xvfb keyboard");
149 (void) mieqInit();
150 }
151
152 void
153 CloseInput(void)
154 {
155 mieqFini();
156 }