~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to hw/dmx/input/dmxinputinit.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

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