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_
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)
56 DMX_FUNCTION_TERMINATE
,
69 DMX_LOCAL_TYPE_CONSOLE
,
70 DMX_LOCAL_TYPE_BACKEND
,
72 } DMXLocalInputExtType
;
80 /** Stores information from low-level device that is used to initialize
81 * the device at the dix level. */
82 typedef struct _DMXLocalInitInfo
{
83 int keyboard
; /**< Non-zero if the device is a keyboard */
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 */
94 int buttonClass
; /**< Non-zero if buttons are present */
95 int numButtons
; /**< Number of buttons */
96 unsigned char map
[DMX_MAX_BUTTONS
]; /**< Button map */
98 int valuatorClass
; /**< Non-zero if valuators are
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 */
108 int focusClass
; /**< Non-zero if device can
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
118 int belFeedbackClass
; /**< Non-zero if device has a
120 int intFeedbackClass
; /**< Non-zero if device has
121 * integer feedback */
122 int strFeedbackClass
; /**< Non-zero if device has
125 int maxSymbols
; /**< Maximum symbols */
126 int maxSymbolsSupported
; /**< Maximum symbols supported */
127 KeySym
*symbols
; /**< Key symbols */
128 } DMXLocalInitInfo
, *DMXLocalInitInfoPtr
;
130 typedef pointer (*dmxCreatePrivateProcPtr
) (DeviceIntPtr
);
131 typedef void (*dmxDestroyPrivateProcPtr
) (pointer
);
133 typedef void (*dmxInitProcPtr
) (DevicePtr
);
134 typedef void (*dmxReInitProcPtr
) (DevicePtr
);
135 typedef void (*dmxLateReInitProcPtr
) (DevicePtr
);
136 typedef void (*dmxGetInfoProcPtr
) (DevicePtr
, DMXLocalInitInfoPtr
);
137 typedef int (*dmxOnProcPtr
) (DevicePtr
);
138 typedef void (*dmxOffProcPtr
) (DevicePtr
);
139 typedef void (*dmxUpdatePositionProcPtr
) (pointer
, int x
, int y
);
141 typedef void (*dmxVTPreSwitchProcPtr
) (pointer
); /* Turn I/O Off */
142 typedef void (*dmxVTPostSwitchProcPtr
) (pointer
); /* Turn I/O On */
143 typedef void (*dmxVTSwitchReturnProcPtr
) (pointer
);
144 typedef int (*dmxVTSwitchProcPtr
) (pointer
, int vt
,
145 dmxVTSwitchReturnProcPtr
, pointer
);
147 typedef void (*dmxMotionProcPtr
) (DevicePtr
,
151 DMXMotionType type
, DMXBlockType block
);
152 typedef void (*dmxEnqueueProcPtr
) (DevicePtr
, int type
, int detail
,
153 KeySym keySym
, XEvent
* e
,
155 typedef int (*dmxCheckSpecialProcPtr
) (DevicePtr
, KeySym keySym
);
156 typedef void (*dmxCollectEventsProcPtr
) (DevicePtr
,
159 dmxCheckSpecialProcPtr
, DMXBlockType
);
160 typedef void (*dmxProcessInputProcPtr
) (pointer
);
161 typedef void (*dmxUpdateInfoProcPtr
) (pointer
, DMXUpdateType
, WindowPtr
);
162 typedef int (*dmxFunctionsProcPtr
) (pointer
, DMXFunctionType
);
164 typedef void (*dmxKBCtrlProcPtr
) (DevicePtr
, KeybdCtrl
* ctrl
);
165 typedef void (*dmxMCtrlProcPtr
) (DevicePtr
, PtrCtrl
* ctrl
);
166 typedef void (*dmxKBBellProcPtr
) (DevicePtr
, int percent
,
167 int volume
, int pitch
, int duration
);
169 /** Stores a mapping between the device id on the remote X server and
170 * the id on the DMX server */
171 typedef struct _DMXEventMap
{
172 int remote
; /**< Event number on remote X server */
173 int server
; /**< Event number (unbiased) on DMX server */
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 */
179 typedef 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
187 /* Low-level (e.g., keyboard/mouse drivers) */
189 dmxCreatePrivateProcPtr create_private
; /**< Create
192 dmxDestroyPrivateProcPtr destroy_private
; /**< Destroy
195 dmxInitProcPtr init
; /**< Initialize device */
196 dmxReInitProcPtr reinit
; /**< Reinitialize device
198 * reconfiguration) */
199 dmxLateReInitProcPtr latereinit
; /**< Reinitialize a device
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
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 */
213 dmxCollectEventsProcPtr collect_events
; /**< Collect and enqueue
216 dmxProcessInputProcPtr process_input
; /**< Process event (from
218 dmxFunctionsProcPtr functions
;
219 dmxUpdateInfoProcPtr update_info
; /**< Update window layout
222 dmxMCtrlProcPtr mCtrl
; /**< Pointer control */
223 dmxKBCtrlProcPtr kCtrl
; /**< Keyboard control */
224 dmxKBBellProcPtr kBell
; /**< Bell control */
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 */
232 DeviceIntPtr pDevice
; /**< X-level device */
233 int inputIdx
; /**< High-level index */
234 int lastX
, lastY
; /**< Last known position;
238 int head
; /**< XInput motion history
240 int tail
; /**< XInput motion history
242 unsigned long *history
; /**< XInput motion history */
243 int *valuators
; /**< Cache of previous values */
245 /* for XInput ChangePointerDevice */
246 int (*savedMotionProc
) (DeviceIntPtr
,
248 unsigned long, unsigned long, ScreenPtr
);
249 int savedMotionEvents
; /**< Saved motion events */
250 int savedSendsCore
; /**< Saved sends-core flag */
252 DMXEventMap map
[DMX_MAP_ENTRIES
]; /**< XInput device id map */
253 int mapOptimize
; /**< XInput device id
257 long deviceId
; /**< device id on remote side,
259 const char *deviceName
; /**< devive name on remote
261 } DMXLocalInputInfoRec
;
263 extern DMXLocalInputInfoPtr dmxLocalCorePointer
, dmxLocalCoreKeyboard
;
265 extern void dmxLocalInitInput(DMXInputInfo
* dmxInput
);
266 extern DMXLocalInputInfoPtr
dmxInputCopyLocal(DMXInputInfo
* dmxInput
,
267 DMXLocalInputInfoPtr s
);
269 extern void dmxChangePointerControl(DeviceIntPtr pDevice
, PtrCtrl
* ctrl
);
270 extern void dmxKeyboardKbdCtrlProc(DeviceIntPtr pDevice
, KeybdCtrl
* ctrl
);
271 extern void dmxKeyboardBellProc(int percent
, DeviceIntPtr pDevice
,
272 pointer ctrl
, int unknown
);
274 extern int dmxInputExtensionErrorHandler(Display
* dsp
, _Xconst
char *name
,
275 _Xconst
char *reason
);
277 extern int dmxInputDetach(DMXInputInfo
* dmxInput
);
278 extern void dmxInputDetachAll(DMXScreenInfo
* dmxScreen
);
279 extern int dmxInputDetachId(int id
);
280 extern DMXInputInfo
*dmxInputLocateId(int id
);
281 extern int dmxInputAttachConsole(const char *name
, int isCore
, int *id
);
282 extern int dmxInputAttachBackend(int physicalScreen
, int isCore
, int *id
);