Imported Upstream version 1.15.1
[deb_xorg-server.git] / hw / dmx / input / dmxinputinit.h
CommitLineData
a09e091a
JB
1/*
2 * Copyright 2002 Red Hat Inc., Durham, North Carolina.
3 *
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation on the rights to use, copy, modify, merge,
10 * publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial
16 * portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
22 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 */
27
28/*
29 * Authors:
30 * Rickard E. (Rik) Faith <faith@redhat.com>
31 *
32 */
33
34/** \file
35 * Interface for low-level input support. \see dmxinputinit.c */
36
37#ifndef _DMXINPUTINIT_H_
38#define _DMXINPUTINIT_H_
39
40#include "dmx.h"
41#include "dmxinput.h"
42#include "dmxlog.h"
43
44#define DMX_LOCAL_DEFAULT_KEYBOARD "kbd"
45#define DMX_LOCAL_DEFAULT_POINTER "ps2"
46#define DMX_MAX_BUTTONS 256
47#define DMX_MOTION_SIZE 256
48#define DMX_MAX_VALUATORS 32
49#define DMX_MAX_AXES 32
50#define DMX_MAX_XINPUT_EVENT_TYPES 100
51#define DMX_MAP_ENTRIES 16 /* Must be a power of 2 */
52#define DMX_MAP_MASK (DMX_MAP_ENTRIES - 1)
53
54typedef enum {
55 DMX_FUNCTION_GRAB,
56 DMX_FUNCTION_TERMINATE,
57 DMX_FUNCTION_FINE
58} DMXFunctionType;
59
60typedef enum {
61 DMX_LOCAL_HIGHLEVEL,
62 DMX_LOCAL_KEYBOARD,
63 DMX_LOCAL_MOUSE,
64 DMX_LOCAL_OTHER
65} DMXLocalInputType;
66
67typedef enum {
68 DMX_LOCAL_TYPE_LOCAL,
69 DMX_LOCAL_TYPE_CONSOLE,
70 DMX_LOCAL_TYPE_BACKEND,
71 DMX_LOCAL_TYPE_COMMON
72} DMXLocalInputExtType;
73
74typedef enum {
75 DMX_RELATIVE,
76 DMX_ABSOLUTE,
77 DMX_ABSOLUTE_CONFINED
78} DMXMotionType;
79
80/** Stores information from low-level device that is used to initialize
81 * the device at the dix level. */
82typedef struct _DMXLocalInitInfo {
83 int keyboard; /**< Non-zero if the device is a keyboard */
84
85 int keyClass; /**< Non-zero if keys are present */
86 KeySymsRec keySyms; /**< Key symbols */
87 int freemap; /**< If non-zero, free keySyms.map */
88 CARD8 modMap[MAP_LENGTH]; /**< Modifier map */
89 XkbDescPtr xkb; /**< XKB description */
90 XkbComponentNamesRec names; /**< XKB component names */
91 int freenames; /**< Non-zero if names should be free'd */
92 int force; /**< Do not allow command line override */
93
94 int buttonClass; /**< Non-zero if buttons are present */
95 int numButtons; /**< Number of buttons */
96 unsigned char map[DMX_MAX_BUTTONS]; /**< Button map */
97
98 int valuatorClass; /**< Non-zero if valuators are
99 * present */
100 int numRelAxes; /**< Number of relative axes */
101 int numAbsAxes; /**< Number of absolute axes */
102 int minval[DMX_MAX_AXES]; /**< Minimum values */
103 int maxval[DMX_MAX_AXES]; /**< Maximum values */
104 int res[DMX_MAX_AXES]; /**< Resolution */
105 int minres[DMX_MAX_AXES]; /**< Minimum resolutions */
106 int maxres[DMX_MAX_AXES]; /**< Maximum resolutions */
107
108 int focusClass; /**< Non-zero if device can
109 * cause focus */
110 int proximityClass; /**< Non-zero if device
111 * causes proximity events */
112 int kbdFeedbackClass; /**< Non-zero if device has
113 * keyboard feedback */
114 int ptrFeedbackClass; /**< Non-zero if device has
115 * pointer feedback */
116 int ledFeedbackClass; /**< Non-zero if device has
117 * LED indicators */
118 int belFeedbackClass; /**< Non-zero if device has a
119 * bell */
120 int intFeedbackClass; /**< Non-zero if device has
121 * integer feedback */
122 int strFeedbackClass; /**< Non-zero if device has
123 * string feedback */
124
125 int maxSymbols; /**< Maximum symbols */
126 int maxSymbolsSupported; /**< Maximum symbols supported */
127 KeySym *symbols; /**< Key symbols */
128} DMXLocalInitInfo, *DMXLocalInitInfoPtr;
129
130typedef pointer (*dmxCreatePrivateProcPtr) (DeviceIntPtr);
131typedef void (*dmxDestroyPrivateProcPtr) (pointer);
132
133typedef void (*dmxInitProcPtr) (DevicePtr);
134typedef void (*dmxReInitProcPtr) (DevicePtr);
135typedef void (*dmxLateReInitProcPtr) (DevicePtr);
136typedef void (*dmxGetInfoProcPtr) (DevicePtr, DMXLocalInitInfoPtr);
137typedef int (*dmxOnProcPtr) (DevicePtr);
138typedef void (*dmxOffProcPtr) (DevicePtr);
139typedef void (*dmxUpdatePositionProcPtr) (pointer, int x, int y);
140
141typedef void (*dmxVTPreSwitchProcPtr) (pointer); /* Turn I/O Off */
142typedef void (*dmxVTPostSwitchProcPtr) (pointer); /* Turn I/O On */
143typedef void (*dmxVTSwitchReturnProcPtr) (pointer);
144typedef int (*dmxVTSwitchProcPtr) (pointer, int vt,
145 dmxVTSwitchReturnProcPtr, pointer);
146
147typedef void (*dmxMotionProcPtr) (DevicePtr,
148 int *valuators,
149 int firstAxis,
150 int axesCount,
151 DMXMotionType type, DMXBlockType block);
152typedef void (*dmxEnqueueProcPtr) (DevicePtr, int type, int detail,
153 KeySym keySym, XEvent * e,
154 DMXBlockType block);
155typedef int (*dmxCheckSpecialProcPtr) (DevicePtr, KeySym keySym);
156typedef void (*dmxCollectEventsProcPtr) (DevicePtr,
157 dmxMotionProcPtr,
158 dmxEnqueueProcPtr,
159 dmxCheckSpecialProcPtr, DMXBlockType);
160typedef void (*dmxProcessInputProcPtr) (pointer);
161typedef void (*dmxUpdateInfoProcPtr) (pointer, DMXUpdateType, WindowPtr);
162typedef int (*dmxFunctionsProcPtr) (pointer, DMXFunctionType);
163
164typedef void (*dmxKBCtrlProcPtr) (DevicePtr, KeybdCtrl * ctrl);
165typedef void (*dmxMCtrlProcPtr) (DevicePtr, PtrCtrl * ctrl);
166typedef void (*dmxKBBellProcPtr) (DevicePtr, int percent,
167 int volume, int pitch, int duration);
168
169/** Stores a mapping between the device id on the remote X server and
170 * the id on the DMX server */
171typedef struct _DMXEventMap {
172 int remote; /**< Event number on remote X server */
173 int server; /**< Event number (unbiased) on DMX server */
174} DMXEventMap;
175
176/** This is the device-independent structure used by the low-level input
177 * routines. The contents are not exposed to top-level .c files (except
178 * dmxextensions.c). \see dmxinput.h \see dmxextensions.c */
179typedef struct _DMXLocalInputInfo {
180 const char *name; /**< Device name */
181 DMXLocalInputType type; /**< Device type */
182 DMXLocalInputExtType extType; /**< Extended device type */
183 int binding; /**< Count of how many consecutive
184 * structs are bound to the same
185 * device */
186
187 /* Low-level (e.g., keyboard/mouse drivers) */
188
189 dmxCreatePrivateProcPtr create_private; /**< Create
190 * device-dependent
191 * private */
192 dmxDestroyPrivateProcPtr destroy_private; /**< Destroy
193 * device-dependent
194 * private */
195 dmxInitProcPtr init; /**< Initialize device */
196 dmxReInitProcPtr reinit; /**< Reinitialize device
197 * (during a
198 * reconfiguration) */
199 dmxLateReInitProcPtr latereinit; /**< Reinitialize a device
200 * (called very late
201 * during a
202 * reconfiguration) */
203 dmxGetInfoProcPtr get_info; /**< Get device information */
204 dmxOnProcPtr on; /**< Turn device on */
205 dmxOffProcPtr off; /**< Turn device off */
206 dmxUpdatePositionProcPtr update_position; /**< Called when another
207 * device updates the
208 * cursor position */
209 dmxVTPreSwitchProcPtr vt_pre_switch; /**< Called before a VT switch */
210 dmxVTPostSwitchProcPtr vt_post_switch; /**< Called after a VT switch */
211 dmxVTSwitchProcPtr vt_switch; /**< Causes a VT switch */
212
213 dmxCollectEventsProcPtr collect_events; /**< Collect and enqueue
214 * events from the
215 * device*/
216 dmxProcessInputProcPtr process_input; /**< Process event (from
217 * queue) */
218 dmxFunctionsProcPtr functions;
219 dmxUpdateInfoProcPtr update_info; /**< Update window layout
220 * information */
221
222 dmxMCtrlProcPtr mCtrl; /**< Pointer control */
223 dmxKBCtrlProcPtr kCtrl; /**< Keyboard control */
224 dmxKBBellProcPtr kBell; /**< Bell control */
225
226 pointer private; /**< Device-dependent private */
227 int isCore; /**< Is a DMX core device */
228 int sendsCore; /**< Sends DMX core events */
229 KeybdCtrl kctrl; /**< Keyboard control */
230 PtrCtrl mctrl; /**< Pointer control */
231
232 DeviceIntPtr pDevice; /**< X-level device */
233 int inputIdx; /**< High-level index */
234 int lastX, lastY; /**< Last known position;
235 * for XInput in
236 * dmxevents.c */
237
238 int head; /**< XInput motion history
239 * head */
240 int tail; /**< XInput motion history
241 * tail */
242 unsigned long *history; /**< XInput motion history */
243 int *valuators; /**< Cache of previous values */
244
245 /* for XInput ChangePointerDevice */
246 int (*savedMotionProc) (DeviceIntPtr,
247 xTimecoord *,
248 unsigned long, unsigned long, ScreenPtr);
249 int savedMotionEvents; /**< Saved motion events */
250 int savedSendsCore; /**< Saved sends-core flag */
251
252 DMXEventMap map[DMX_MAP_ENTRIES]; /**< XInput device id map */
253 int mapOptimize; /**< XInput device id
254 * map
255 * optimization */
256
257 long deviceId; /**< device id on remote side,
258 * if any */
259 const char *deviceName; /**< devive name on remote
260 * side, if any */
261} DMXLocalInputInfoRec;
262
263extern DMXLocalInputInfoPtr dmxLocalCorePointer, dmxLocalCoreKeyboard;
264
265extern void dmxLocalInitInput(DMXInputInfo * dmxInput);
266extern DMXLocalInputInfoPtr dmxInputCopyLocal(DMXInputInfo * dmxInput,
267 DMXLocalInputInfoPtr s);
268
269extern void dmxChangePointerControl(DeviceIntPtr pDevice, PtrCtrl * ctrl);
270extern void dmxKeyboardKbdCtrlProc(DeviceIntPtr pDevice, KeybdCtrl * ctrl);
271extern void dmxKeyboardBellProc(int percent, DeviceIntPtr pDevice,
272 pointer ctrl, int unknown);
273
274extern int dmxInputExtensionErrorHandler(Display * dsp, _Xconst char *name,
275 _Xconst char *reason);
276
277extern int dmxInputDetach(DMXInputInfo * dmxInput);
278extern void dmxInputDetachAll(DMXScreenInfo * dmxScreen);
279extern int dmxInputDetachId(int id);
280extern DMXInputInfo *dmxInputLocateId(int id);
281extern int dmxInputAttachConsole(const char *name, int isCore, int *id);
282extern int dmxInputAttachBackend(int physicalScreen, int isCore, int *id);
283
284#endif