1 | /************************************************************
|
---|
2 |
|
---|
3 | Copyright 1987, 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 in
|
---|
12 | all copies or substantial portions of the Software.
|
---|
13 |
|
---|
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
---|
17 | OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
---|
18 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
---|
19 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
20 |
|
---|
21 | Except as contained in this notice, the name of The Open Group shall not be
|
---|
22 | used in advertising or otherwise to promote the sale, use or other dealings
|
---|
23 | in this Software without prior written authorization from The Open Group.
|
---|
24 |
|
---|
25 |
|
---|
26 | Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
|
---|
27 |
|
---|
28 | All Rights Reserved
|
---|
29 |
|
---|
30 | Permission to use, copy, modify, and distribute this software and its
|
---|
31 | documentation for any purpose and without fee is hereby granted,
|
---|
32 | provided that the above copyright notice appear in all copies and that
|
---|
33 | both that copyright notice and this permission notice appear in
|
---|
34 | supporting documentation, and that the name of Digital not be
|
---|
35 | used in advertising or publicity pertaining to distribution of the
|
---|
36 | software without specific, written prior permission.
|
---|
37 |
|
---|
38 | DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
---|
39 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
---|
40 | DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
---|
41 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
---|
42 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
---|
43 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
---|
44 | SOFTWARE.
|
---|
45 |
|
---|
46 | ********************************************************/
|
---|
47 |
|
---|
48 | #ifndef INPUT_H
|
---|
49 | #define INPUT_H
|
---|
50 |
|
---|
51 | #include "misc.h"
|
---|
52 | #include "screenint.h"
|
---|
53 | #include <X11/Xmd.h>
|
---|
54 | #include <X11/Xproto.h>
|
---|
55 | #include "window.h" /* for WindowPtr */
|
---|
56 |
|
---|
57 | #define DEVICE_INIT 0
|
---|
58 | #define DEVICE_ON 1
|
---|
59 | #define DEVICE_OFF 2
|
---|
60 | #define DEVICE_CLOSE 3
|
---|
61 |
|
---|
62 | #define POINTER_RELATIVE (1 << 1)
|
---|
63 | #define POINTER_ABSOLUTE (1 << 2)
|
---|
64 | #define POINTER_ACCELERATE (1 << 3)
|
---|
65 |
|
---|
66 | #define MAP_LENGTH 256
|
---|
67 | #define DOWN_LENGTH 32 /* 256/8 => number of bytes to hold 256 bits */
|
---|
68 | #define NullGrab ((GrabPtr)NULL)
|
---|
69 | #define PointerRootWin ((WindowPtr)PointerRoot)
|
---|
70 | #define NoneWin ((WindowPtr)None)
|
---|
71 | #define NullDevice ((DevicePtr)NULL)
|
---|
72 |
|
---|
73 | #ifndef FollowKeyboard
|
---|
74 | #define FollowKeyboard 3
|
---|
75 | #endif
|
---|
76 | #ifndef FollowKeyboardWin
|
---|
77 | #define FollowKeyboardWin ((WindowPtr) FollowKeyboard)
|
---|
78 | #endif
|
---|
79 | #ifndef RevertToFollowKeyboard
|
---|
80 | #define RevertToFollowKeyboard 3
|
---|
81 | #endif
|
---|
82 |
|
---|
83 | typedef unsigned long Leds;
|
---|
84 | typedef struct _OtherClients *OtherClientsPtr;
|
---|
85 | typedef struct _InputClients *InputClientsPtr;
|
---|
86 | typedef struct _DeviceIntRec *DeviceIntPtr;
|
---|
87 |
|
---|
88 | typedef int (*DeviceProc)(
|
---|
89 | DeviceIntPtr /*device*/,
|
---|
90 | int /*what*/);
|
---|
91 |
|
---|
92 | typedef void (*ProcessInputProc)(
|
---|
93 | xEventPtr /*events*/,
|
---|
94 | DeviceIntPtr /*device*/,
|
---|
95 | int /*count*/);
|
---|
96 |
|
---|
97 | typedef Bool (*DeviceHandleProc)(
|
---|
98 | DeviceIntPtr /*device*/,
|
---|
99 | void* /*data*/
|
---|
100 | );
|
---|
101 |
|
---|
102 | typedef void (*DeviceUnwrapProc)(
|
---|
103 | DeviceIntPtr /*device*/,
|
---|
104 | DeviceHandleProc /*proc*/,
|
---|
105 | void* /*data*/
|
---|
106 | );
|
---|
107 |
|
---|
108 | typedef struct _DeviceRec {
|
---|
109 | pointer devicePrivate;
|
---|
110 | ProcessInputProc processInputProc; /* current */
|
---|
111 | ProcessInputProc realInputProc; /* deliver */
|
---|
112 | ProcessInputProc enqueueInputProc; /* enqueue */
|
---|
113 | Bool on; /* used by DDX to keep state */
|
---|
114 | } DeviceRec, *DevicePtr;
|
---|
115 |
|
---|
116 | typedef struct {
|
---|
117 | int click, bell, bell_pitch, bell_duration;
|
---|
118 | Bool autoRepeat;
|
---|
119 | unsigned char autoRepeats[32];
|
---|
120 | Leds leds;
|
---|
121 | unsigned char id;
|
---|
122 | } KeybdCtrl;
|
---|
123 |
|
---|
124 | typedef struct {
|
---|
125 | KeySym *map;
|
---|
126 | KeyCode minKeyCode,
|
---|
127 | maxKeyCode;
|
---|
128 | int mapWidth;
|
---|
129 | } KeySymsRec, *KeySymsPtr;
|
---|
130 |
|
---|
131 | typedef struct {
|
---|
132 | int num, den, threshold;
|
---|
133 | unsigned char id;
|
---|
134 | } PtrCtrl;
|
---|
135 |
|
---|
136 | typedef struct {
|
---|
137 | int resolution, min_value, max_value;
|
---|
138 | int integer_displayed;
|
---|
139 | unsigned char id;
|
---|
140 | } IntegerCtrl;
|
---|
141 |
|
---|
142 | typedef struct {
|
---|
143 | int max_symbols, num_symbols_supported;
|
---|
144 | int num_symbols_displayed;
|
---|
145 | KeySym *symbols_supported;
|
---|
146 | KeySym *symbols_displayed;
|
---|
147 | unsigned char id;
|
---|
148 | } StringCtrl;
|
---|
149 |
|
---|
150 | typedef struct {
|
---|
151 | int percent, pitch, duration;
|
---|
152 | unsigned char id;
|
---|
153 | } BellCtrl;
|
---|
154 |
|
---|
155 | typedef struct {
|
---|
156 | Leds led_values;
|
---|
157 | Mask led_mask;
|
---|
158 | unsigned char id;
|
---|
159 | } LedCtrl;
|
---|
160 |
|
---|
161 | extern KeybdCtrl defaultKeyboardControl;
|
---|
162 | extern PtrCtrl defaultPointerControl;
|
---|
163 |
|
---|
164 | typedef struct _InputOption {
|
---|
165 | char *key;
|
---|
166 | char *value;
|
---|
167 | struct _InputOption *next;
|
---|
168 | } InputOption;
|
---|
169 |
|
---|
170 | extern void InitCoreDevices(void);
|
---|
171 |
|
---|
172 | extern DeviceIntPtr AddInputDevice(
|
---|
173 | DeviceProc /*deviceProc*/,
|
---|
174 | Bool /*autoStart*/);
|
---|
175 |
|
---|
176 | extern Bool EnableDevice(
|
---|
177 | DeviceIntPtr /*device*/);
|
---|
178 |
|
---|
179 | extern Bool ActivateDevice(
|
---|
180 | DeviceIntPtr /*device*/);
|
---|
181 |
|
---|
182 | extern Bool DisableDevice(
|
---|
183 | DeviceIntPtr /*device*/);
|
---|
184 |
|
---|
185 | extern int InitAndStartDevices(void);
|
---|
186 |
|
---|
187 | extern void CloseDownDevices(void);
|
---|
188 |
|
---|
189 | extern int RemoveDevice(
|
---|
190 | DeviceIntPtr /*dev*/);
|
---|
191 |
|
---|
192 | extern int NumMotionEvents(void);
|
---|
193 |
|
---|
194 | extern void RegisterPointerDevice(
|
---|
195 | DeviceIntPtr /*device*/);
|
---|
196 |
|
---|
197 | extern void RegisterKeyboardDevice(
|
---|
198 | DeviceIntPtr /*device*/);
|
---|
199 |
|
---|
200 | extern int dixLookupDevice(
|
---|
201 | DeviceIntPtr * /* dev */,
|
---|
202 | int /* id */,
|
---|
203 | ClientPtr /* client */,
|
---|
204 | Mask /* access_mode */);
|
---|
205 |
|
---|
206 | extern void QueryMinMaxKeyCodes(
|
---|
207 | KeyCode* /*minCode*/,
|
---|
208 | KeyCode* /*maxCode*/);
|
---|
209 |
|
---|
210 | extern Bool SetKeySymsMap(
|
---|
211 | KeySymsPtr /*dst*/,
|
---|
212 | KeySymsPtr /*src*/);
|
---|
213 |
|
---|
214 | extern Bool InitKeyClassDeviceStruct(
|
---|
215 | DeviceIntPtr /*device*/,
|
---|
216 | KeySymsPtr /*pKeySyms*/,
|
---|
217 | CARD8 /*pModifiers*/[]);
|
---|
218 |
|
---|
219 | extern Bool InitButtonClassDeviceStruct(
|
---|
220 | DeviceIntPtr /*device*/,
|
---|
221 | int /*numButtons*/,
|
---|
222 | CARD8* /*map*/);
|
---|
223 |
|
---|
224 | typedef int (*ValuatorMotionProcPtr)(
|
---|
225 | DeviceIntPtr /*pdevice*/,
|
---|
226 | xTimecoord * /*coords*/,
|
---|
227 | unsigned long /*start*/,
|
---|
228 | unsigned long /*stop*/,
|
---|
229 | ScreenPtr /*pScreen*/);
|
---|
230 |
|
---|
231 | extern Bool InitValuatorClassDeviceStruct(
|
---|
232 | DeviceIntPtr /*device*/,
|
---|
233 | int /*numAxes*/,
|
---|
234 | ValuatorMotionProcPtr /* motionProc */,
|
---|
235 | int /*numMotionEvents*/,
|
---|
236 | int /*mode*/);
|
---|
237 |
|
---|
238 | extern Bool InitAbsoluteClassDeviceStruct(
|
---|
239 | DeviceIntPtr /*device*/);
|
---|
240 |
|
---|
241 | extern Bool InitFocusClassDeviceStruct(
|
---|
242 | DeviceIntPtr /*device*/);
|
---|
243 |
|
---|
244 | typedef void (*BellProcPtr)(
|
---|
245 | int /*percent*/,
|
---|
246 | DeviceIntPtr /*device*/,
|
---|
247 | pointer /*ctrl*/,
|
---|
248 | int);
|
---|
249 |
|
---|
250 | typedef void (*KbdCtrlProcPtr)(
|
---|
251 | DeviceIntPtr /*device*/,
|
---|
252 | KeybdCtrl * /*ctrl*/);
|
---|
253 |
|
---|
254 | extern Bool InitKbdFeedbackClassDeviceStruct(
|
---|
255 | DeviceIntPtr /*device*/,
|
---|
256 | BellProcPtr /*bellProc*/,
|
---|
257 | KbdCtrlProcPtr /*controlProc*/);
|
---|
258 |
|
---|
259 | typedef void (*PtrCtrlProcPtr)(
|
---|
260 | DeviceIntPtr /*device*/,
|
---|
261 | PtrCtrl * /*ctrl*/);
|
---|
262 |
|
---|
263 | extern Bool InitPtrFeedbackClassDeviceStruct(
|
---|
264 | DeviceIntPtr /*device*/,
|
---|
265 | PtrCtrlProcPtr /*controlProc*/);
|
---|
266 |
|
---|
267 | typedef void (*StringCtrlProcPtr)(
|
---|
268 | DeviceIntPtr /*device*/,
|
---|
269 | StringCtrl * /*ctrl*/);
|
---|
270 |
|
---|
271 | extern Bool InitStringFeedbackClassDeviceStruct(
|
---|
272 | DeviceIntPtr /*device*/,
|
---|
273 | StringCtrlProcPtr /*controlProc*/,
|
---|
274 | int /*max_symbols*/,
|
---|
275 | int /*num_symbols_supported*/,
|
---|
276 | KeySym* /*symbols*/);
|
---|
277 |
|
---|
278 | typedef void (*BellCtrlProcPtr)(
|
---|
279 | DeviceIntPtr /*device*/,
|
---|
280 | BellCtrl * /*ctrl*/);
|
---|
281 |
|
---|
282 | extern Bool InitBellFeedbackClassDeviceStruct(
|
---|
283 | DeviceIntPtr /*device*/,
|
---|
284 | BellProcPtr /*bellProc*/,
|
---|
285 | BellCtrlProcPtr /*controlProc*/);
|
---|
286 |
|
---|
287 | typedef void (*LedCtrlProcPtr)(
|
---|
288 | DeviceIntPtr /*device*/,
|
---|
289 | LedCtrl * /*ctrl*/);
|
---|
290 |
|
---|
291 | extern Bool InitLedFeedbackClassDeviceStruct(
|
---|
292 | DeviceIntPtr /*device*/,
|
---|
293 | LedCtrlProcPtr /*controlProc*/);
|
---|
294 |
|
---|
295 | typedef void (*IntegerCtrlProcPtr)(
|
---|
296 | DeviceIntPtr /*device*/,
|
---|
297 | IntegerCtrl * /*ctrl*/);
|
---|
298 |
|
---|
299 |
|
---|
300 | extern Bool InitIntegerFeedbackClassDeviceStruct(
|
---|
301 | DeviceIntPtr /*device*/,
|
---|
302 | IntegerCtrlProcPtr /*controlProc*/);
|
---|
303 |
|
---|
304 | extern Bool InitPointerDeviceStruct(
|
---|
305 | DevicePtr /*device*/,
|
---|
306 | CARD8* /*map*/,
|
---|
307 | int /*numButtons*/,
|
---|
308 | ValuatorMotionProcPtr /*motionProc*/,
|
---|
309 | PtrCtrlProcPtr /*controlProc*/,
|
---|
310 | int /*numMotionEvents*/,
|
---|
311 | int /*numAxes*/);
|
---|
312 |
|
---|
313 | extern Bool InitKeyboardDeviceStruct(
|
---|
314 | DevicePtr /*device*/,
|
---|
315 | KeySymsPtr /*pKeySyms*/,
|
---|
316 | CARD8 /*pModifiers*/[],
|
---|
317 | BellProcPtr /*bellProc*/,
|
---|
318 | KbdCtrlProcPtr /*controlProc*/);
|
---|
319 |
|
---|
320 | extern void SendMappingNotify(
|
---|
321 | unsigned int /*request*/,
|
---|
322 | unsigned int /*firstKeyCode*/,
|
---|
323 | unsigned int /*count*/,
|
---|
324 | ClientPtr /* client */);
|
---|
325 |
|
---|
326 | extern Bool BadDeviceMap(
|
---|
327 | BYTE* /*buff*/,
|
---|
328 | int /*length*/,
|
---|
329 | unsigned /*low*/,
|
---|
330 | unsigned /*high*/,
|
---|
331 | XID* /*errval*/);
|
---|
332 |
|
---|
333 | extern Bool AllModifierKeysAreUp(
|
---|
334 | DeviceIntPtr /*device*/,
|
---|
335 | CARD8* /*map1*/,
|
---|
336 | int /*per1*/,
|
---|
337 | CARD8* /*map2*/,
|
---|
338 | int /*per2*/);
|
---|
339 |
|
---|
340 | extern void NoteLedState(
|
---|
341 | DeviceIntPtr /*keybd*/,
|
---|
342 | int /*led*/,
|
---|
343 | Bool /*on*/);
|
---|
344 |
|
---|
345 | extern void MaybeStopHint(
|
---|
346 | DeviceIntPtr /*device*/,
|
---|
347 | ClientPtr /*client*/);
|
---|
348 |
|
---|
349 | extern void ProcessPointerEvent(
|
---|
350 | xEventPtr /*xE*/,
|
---|
351 | DeviceIntPtr /*mouse*/,
|
---|
352 | int /*count*/);
|
---|
353 |
|
---|
354 | extern void ProcessKeyboardEvent(
|
---|
355 | xEventPtr /*xE*/,
|
---|
356 | DeviceIntPtr /*keybd*/,
|
---|
357 | int /*count*/);
|
---|
358 |
|
---|
359 | #ifdef XKB
|
---|
360 | extern void CoreProcessPointerEvent(
|
---|
361 | xEventPtr /*xE*/,
|
---|
362 | DeviceIntPtr /*mouse*/,
|
---|
363 | int /*count*/);
|
---|
364 |
|
---|
365 | extern void CoreProcessKeyboardEvent(
|
---|
366 | xEventPtr /*xE*/,
|
---|
367 | DeviceIntPtr /*keybd*/,
|
---|
368 | int /*count*/);
|
---|
369 | #endif
|
---|
370 |
|
---|
371 | extern Bool LegalModifier(
|
---|
372 | unsigned int /*key*/,
|
---|
373 | DeviceIntPtr /*pDev*/);
|
---|
374 |
|
---|
375 | extern void ProcessInputEvents(void);
|
---|
376 |
|
---|
377 | extern void InitInput(
|
---|
378 | int /*argc*/,
|
---|
379 | char ** /*argv*/);
|
---|
380 |
|
---|
381 | extern int GetMaximumEventsNum(void);
|
---|
382 |
|
---|
383 | extern int GetPointerEvents(
|
---|
384 | xEvent *events,
|
---|
385 | DeviceIntPtr pDev,
|
---|
386 | int type,
|
---|
387 | int buttons,
|
---|
388 | int flags,
|
---|
389 | int first_valuator,
|
---|
390 | int num_valuators,
|
---|
391 | int *valuators);
|
---|
392 |
|
---|
393 | extern int GetKeyboardEvents(
|
---|
394 | xEvent *events,
|
---|
395 | DeviceIntPtr pDev,
|
---|
396 | int type,
|
---|
397 | int key_code);
|
---|
398 |
|
---|
399 | extern int GetKeyboardValuatorEvents(
|
---|
400 | xEvent *events,
|
---|
401 | DeviceIntPtr pDev,
|
---|
402 | int type,
|
---|
403 | int key_code,
|
---|
404 | int first_valuator,
|
---|
405 | int num_valuator,
|
---|
406 | int *valuators);
|
---|
407 |
|
---|
408 | extern int GetProximityEvents(
|
---|
409 | xEvent *events,
|
---|
410 | DeviceIntPtr pDev,
|
---|
411 | int type,
|
---|
412 | int first_valuator,
|
---|
413 | int num_valuators,
|
---|
414 | int *valuators);
|
---|
415 |
|
---|
416 | extern void PostSyntheticMotion(
|
---|
417 | int x,
|
---|
418 | int y,
|
---|
419 | int screen,
|
---|
420 | unsigned long time);
|
---|
421 |
|
---|
422 | extern int GetMotionHistorySize(
|
---|
423 | void);
|
---|
424 |
|
---|
425 | extern void AllocateMotionHistory(
|
---|
426 | DeviceIntPtr pDev);
|
---|
427 |
|
---|
428 | extern int GetMotionHistory(
|
---|
429 | DeviceIntPtr pDev,
|
---|
430 | xTimecoord *buff,
|
---|
431 | unsigned long start,
|
---|
432 | unsigned long stop,
|
---|
433 | ScreenPtr pScreen);
|
---|
434 |
|
---|
435 | extern void SwitchCoreKeyboard(DeviceIntPtr pDev);
|
---|
436 | extern void SwitchCorePointer(DeviceIntPtr pDev);
|
---|
437 |
|
---|
438 | /* Implemented by the DDX. */
|
---|
439 | extern int NewInputDeviceRequest(
|
---|
440 | InputOption *options,
|
---|
441 | DeviceIntPtr *dev);
|
---|
442 | extern void DeleteInputDeviceRequest(
|
---|
443 | DeviceIntPtr dev);
|
---|
444 |
|
---|
445 | extern void DDXRingBell(
|
---|
446 | int volume,
|
---|
447 | int pitch,
|
---|
448 | int duration);
|
---|
449 |
|
---|
450 | #endif /* INPUT_H */
|
---|