2 * Copyright 2002 Red Hat Inc., Durham, North Carolina.
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:
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.
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
30 * Rickard E. (Rik) Faith <faith@redhat.com>
35 * Interface for low-level input support. \see dmxinputinit.c */
37 #ifndef _DMXINPUTINIT_H_
38 #define _DMXINPUTINIT_H_
45 #define DMX_LOCAL_DEFAULT_KEYBOARD "kbd"
46 #define DMX_LOCAL_DEFAULT_POINTER "ps2"
47 #define DMX_MAX_BUTTONS 256
48 #define DMX_MOTION_SIZE 256
49 #define DMX_MAX_VALUATORS 32
50 #define DMX_MAX_AXES 32
51 #define DMX_MAX_XINPUT_EVENT_TYPES 100
52 #define DMX_MAP_ENTRIES 16 /* Must be a power of 2 */
53 #define DMX_MAP_MASK (DMX_MAP_ENTRIES - 1)
57 DMX_FUNCTION_TERMINATE
,
70 DMX_LOCAL_TYPE_CONSOLE
,
71 DMX_LOCAL_TYPE_BACKEND
,
73 } DMXLocalInputExtType
;
81 /** Stores information from low-level device that is used to initialize
82 * the device at the dix level. */
83 typedef struct _DMXLocalInitInfo
{
84 int keyboard
; /**< Non-zero if the device is a keyboard */
86 int keyClass
; /**< Non-zero if keys are present */
87 KeySymsRec keySyms
; /**< Key symbols */
88 int freemap
; /**< If non-zero, free keySyms.map */
89 CARD8 modMap
[MAP_LENGTH
]; /**< Modifier map */
91 XkbDescPtr xkb
; /**< XKB description */
92 XkbComponentNamesRec names
; /**< XKB component names */
93 int freenames
; /**< Non-zero if names should be free'd */
94 int force
; /**< Do not allow command line override */
97 int buttonClass
; /**< Non-zero if buttons are present */
98 int numButtons
; /**< Number of buttons */
99 unsigned char map
[DMX_MAX_BUTTONS
]; /**< Button map */
101 int valuatorClass
; /**< Non-zero if valuators are
103 int numRelAxes
; /**< Number of relative axes */
104 int numAbsAxes
; /**< Number of absolute axes */
105 int minval
[DMX_MAX_AXES
]; /**< Minimum values */
106 int maxval
[DMX_MAX_AXES
]; /**< Maximum values */
107 int res
[DMX_MAX_AXES
]; /**< Resolution */
108 int minres
[DMX_MAX_AXES
]; /**< Minimum resolutions */
109 int maxres
[DMX_MAX_AXES
]; /**< Maximum resolutions */
111 int focusClass
; /**< Non-zero if device can
113 int proximityClass
; /**< Non-zero if device
114 * causes proximity events */
115 int kbdFeedbackClass
; /**< Non-zero if device has
116 * keyboard feedback */
117 int ptrFeedbackClass
; /**< Non-zero if device has
118 * pointer feedback */
119 int ledFeedbackClass
; /**< Non-zero if device has
121 int belFeedbackClass
; /**< Non-zero if device has a
123 int intFeedbackClass
; /**< Non-zero if device has
124 * integer feedback */
125 int strFeedbackClass
; /**< Non-zero if device has
128 int maxSymbols
; /**< Maximum symbols */
129 int maxSymbolsSupported
; /**< Maximum symbols supported */
130 KeySym
*symbols
; /**< Key symbols */
131 } DMXLocalInitInfo
, *DMXLocalInitInfoPtr
;
133 typedef pointer (*dmxCreatePrivateProcPtr
)(DeviceIntPtr
);
134 typedef void (*dmxDestroyPrivateProcPtr
)(pointer
);
136 typedef void (*dmxInitProcPtr
)(DevicePtr
);
137 typedef void (*dmxReInitProcPtr
)(DevicePtr
);
138 typedef void (*dmxLateReInitProcPtr
)(DevicePtr
);
139 typedef void (*dmxGetInfoProcPtr
)(DevicePtr
, DMXLocalInitInfoPtr
);
140 typedef int (*dmxOnProcPtr
)(DevicePtr
);
141 typedef void (*dmxOffProcPtr
)(DevicePtr
);
142 typedef void (*dmxUpdatePositionProcPtr
)(pointer
, int x
, int y
);
144 typedef void (*dmxVTPreSwitchProcPtr
)(pointer
); /* Turn I/O Off */
145 typedef void (*dmxVTPostSwitchProcPtr
)(pointer
); /* Turn I/O On */
146 typedef void (*dmxVTSwitchReturnProcPtr
)(pointer
);
147 typedef int (*dmxVTSwitchProcPtr
)(pointer
, int vt
,
148 dmxVTSwitchReturnProcPtr
, pointer
);
150 typedef void (*dmxMotionProcPtr
)(DevicePtr
,
156 typedef void (*dmxEnqueueProcPtr
)(DevicePtr
, int type
, int detail
,
157 KeySym keySym
, XEvent
*e
,
159 typedef int (*dmxCheckSpecialProcPtr
)(DevicePtr
, KeySym keySym
);
160 typedef void (*dmxCollectEventsProcPtr
)(DevicePtr
,
163 dmxCheckSpecialProcPtr
,
165 typedef void (*dmxProcessInputProcPtr
)(pointer
);
166 typedef void (*dmxUpdateInfoProcPtr
)(pointer
, DMXUpdateType
, WindowPtr
);
167 typedef int (*dmxFunctionsProcPtr
)(pointer
, DMXFunctionType
);
169 typedef void (*dmxKBCtrlProcPtr
)(DevicePtr
, KeybdCtrl
*ctrl
);
170 typedef void (*dmxMCtrlProcPtr
)(DevicePtr
, PtrCtrl
*ctrl
);
171 typedef void (*dmxKBBellProcPtr
)(DevicePtr
, int percent
,
172 int volume
, int pitch
, int duration
);
174 /** Stores a mapping between the device id on the remote X server and
175 * the id on the DMX server */
176 typedef struct _DMXEventMap
{
177 int remote
; /**< Event number on remote X server */
178 int server
; /**< Event number (unbiased) on DMX server */
181 /** This is the device-independent structure used by the low-level input
182 * routines. The contents are not exposed to top-level .c files (except
183 * dmxextensions.c). \see dmxinput.h \see dmxextensions.c */
184 typedef struct _DMXLocalInputInfo
{
185 const char *name
; /**< Device name */
186 DMXLocalInputType type
; /**< Device type */
187 DMXLocalInputExtType extType
; /**< Extended device type */
188 int binding
; /**< Count of how many consecutive
189 * structs are bound to the same
192 /* Low-level (e.g., keyboard/mouse drivers) */
194 dmxCreatePrivateProcPtr create_private
; /**< Create
197 dmxDestroyPrivateProcPtr destroy_private
; /**< Destroy
200 dmxInitProcPtr init
; /**< Initialize device */
201 dmxReInitProcPtr reinit
; /**< Reinitialize device
203 * reconfiguration) */
204 dmxLateReInitProcPtr latereinit
; /**< Reinitialize a device
207 * reconfiguration) */
208 dmxGetInfoProcPtr get_info
; /**< Get device information */
209 dmxOnProcPtr on
; /**< Turn device on */
210 dmxOffProcPtr off
; /**< Turn device off */
211 dmxUpdatePositionProcPtr update_position
; /**< Called when another
214 dmxVTPreSwitchProcPtr vt_pre_switch
; /**< Called before a VT switch */
215 dmxVTPostSwitchProcPtr vt_post_switch
; /**< Called after a VT switch */
216 dmxVTSwitchProcPtr vt_switch
; /**< Causes a VT switch */
218 dmxCollectEventsProcPtr collect_events
; /**< Collect and enqueue
221 dmxProcessInputProcPtr process_input
; /**< Process event (from
223 dmxFunctionsProcPtr functions
;
224 dmxUpdateInfoProcPtr update_info
; /**< Update window layout
227 dmxMCtrlProcPtr mCtrl
; /**< Pointer control */
228 dmxKBCtrlProcPtr kCtrl
; /**< Keyboard control */
229 dmxKBBellProcPtr kBell
; /**< Bell control */
231 pointer
private; /**< Device-dependent private */
232 int isCore
; /**< Is a DMX core device */
233 int sendsCore
; /**< Sends DMX core events */
234 KeybdCtrl kctrl
; /**< Keyboard control */
235 PtrCtrl mctrl
; /**< Pointer control */
237 DeviceIntPtr pDevice
; /**< X-level device */
238 int inputIdx
; /**< High-level index */
239 int lastX
, lastY
; /**< Last known position;
243 int head
; /**< XInput motion history
245 int tail
; /**< XInput motion history
247 unsigned long *history
; /**< XInput motion history */
248 int *valuators
; /**< Cache of previous values */
250 /* for XInput ChangePointerDevice */
251 int (*savedMotionProc
)(DeviceIntPtr
,
256 int savedMotionEvents
; /**< Saved motion events */
257 int savedSendsCore
; /**< Saved sends-core flag */
259 DMXEventMap map
[DMX_MAP_ENTRIES
]; /**< XInput device id map */
260 int mapOptimize
; /**< XInput device id
264 long deviceId
; /**< device id on remote side,
266 const char *deviceName
; /**< devive name on remote
268 } DMXLocalInputInfoRec
;
270 extern DMXLocalInputInfoPtr dmxLocalCorePointer
, dmxLocalCoreKeyboard
;
272 extern void dmxLocalInitInput(DMXInputInfo
*dmxInput
);
273 extern DMXLocalInputInfoPtr
dmxInputCopyLocal(DMXInputInfo
*dmxInput
,
274 DMXLocalInputInfoPtr s
);
276 extern void dmxChangePointerControl(DeviceIntPtr pDevice
, PtrCtrl
*ctrl
);
277 extern void dmxKeyboardKbdCtrlProc(DeviceIntPtr pDevice
, KeybdCtrl
*ctrl
);
278 extern void dmxKeyboardBellProc(int percent
, DeviceIntPtr pDevice
,
279 pointer ctrl
, int unknown
);
281 extern int dmxInputExtensionErrorHandler(Display
*dsp
, char *name
,
284 extern int dmxInputDetach(DMXInputInfo
*dmxInput
);
285 extern void dmxInputDetachAll(DMXScreenInfo
*dmxScreen
);
286 extern int dmxInputDetachId(int id
);
287 extern DMXInputInfo
*dmxInputLocateId(int id
);
288 extern int dmxInputAttachConsole(const char *name
, int isCore
,
290 extern int dmxInputAttachBackend(int physicalScreen
, int isCore
,