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 int AllocateDevicePrivateIndex(void);
|
---|
162 | extern Bool AllocateDevicePrivate(DeviceIntPtr device, int index);
|
---|
163 | extern void ResetDevicePrivateIndex(void);
|
---|
164 |
|
---|
165 | extern KeybdCtrl defaultKeyboardControl;
|
---|
166 | extern PtrCtrl defaultPointerControl;
|
---|
167 |
|
---|
168 | typedef struct _InputOption {
|
---|
169 | char *key;
|
---|
170 | char *value;
|
---|
171 | struct _InputOption *next;
|
---|
172 | } InputOption;
|
---|
173 |
|
---|
174 | extern void InitCoreDevices(void);
|
---|
175 |
|
---|
176 | extern DeviceIntPtr AddInputDevice(
|
---|
177 | DeviceProc /*deviceProc*/,
|
---|
178 | Bool /*autoStart*/);
|
---|
179 |
|
---|
180 | extern Bool EnableDevice(
|
---|
181 | DeviceIntPtr /*device*/);
|
---|
182 |
|
---|
183 | extern Bool ActivateDevice(
|
---|
184 | DeviceIntPtr /*device*/);
|
---|
185 |
|
---|
186 | extern Bool DisableDevice(
|
---|
187 | DeviceIntPtr /*device*/);
|
---|
188 |
|
---|
189 | extern int InitAndStartDevices(void);
|
---|
190 |
|
---|
191 | extern void CloseDownDevices(void);
|
---|
192 |
|
---|
193 | extern int RemoveDevice(
|
---|
194 | DeviceIntPtr /*dev*/);
|
---|
195 |
|
---|
196 | extern int NumMotionEvents(void);
|
---|
197 |
|
---|
198 | extern void RegisterPointerDevice(
|
---|
199 | DeviceIntPtr /*device*/);
|
---|
200 |
|
---|
201 | extern void RegisterKeyboardDevice(
|
---|
202 | DeviceIntPtr /*device*/);
|
---|
203 |
|
---|
204 | extern DevicePtr LookupKeyboardDevice(void);
|
---|
205 |
|
---|
206 | extern DevicePtr LookupPointerDevice(void);
|
---|
207 |
|
---|
208 | extern DevicePtr LookupDevice(
|
---|
209 | int /* id */);
|
---|
210 |
|
---|
211 | extern void QueryMinMaxKeyCodes(
|
---|
212 | KeyCode* /*minCode*/,
|
---|
213 | KeyCode* /*maxCode*/);
|
---|
214 |
|
---|
215 | extern Bool SetKeySymsMap(
|
---|
216 | KeySymsPtr /*dst*/,
|
---|
217 | KeySymsPtr /*src*/);
|
---|
218 |
|
---|
219 | extern Bool InitKeyClassDeviceStruct(
|
---|
220 | DeviceIntPtr /*device*/,
|
---|
221 | KeySymsPtr /*pKeySyms*/,
|
---|
222 | CARD8 /*pModifiers*/[]);
|
---|
223 |
|
---|
224 | extern Bool InitButtonClassDeviceStruct(
|
---|
225 | DeviceIntPtr /*device*/,
|
---|
226 | int /*numButtons*/,
|
---|
227 | CARD8* /*map*/);
|
---|
228 |
|
---|
229 | typedef int (*ValuatorMotionProcPtr)(
|
---|
230 | DeviceIntPtr /*pdevice*/,
|
---|
231 | xTimecoord * /*coords*/,
|
---|
232 | unsigned long /*start*/,
|
---|
233 | unsigned long /*stop*/,
|
---|
234 | ScreenPtr /*pScreen*/);
|
---|
235 |
|
---|
236 | extern Bool InitValuatorClassDeviceStruct(
|
---|
237 | DeviceIntPtr /*device*/,
|
---|
238 | int /*numAxes*/,
|
---|
239 | ValuatorMotionProcPtr /* motionProc */,
|
---|
240 | int /*numMotionEvents*/,
|
---|
241 | int /*mode*/);
|
---|
242 |
|
---|
243 | extern Bool InitAbsoluteClassDeviceStruct(
|
---|
244 | DeviceIntPtr /*device*/);
|
---|
245 |
|
---|
246 | extern Bool InitFocusClassDeviceStruct(
|
---|
247 | DeviceIntPtr /*device*/);
|
---|
248 |
|
---|
249 | typedef void (*BellProcPtr)(
|
---|
250 | int /*percent*/,
|
---|
251 | DeviceIntPtr /*device*/,
|
---|
252 | pointer /*ctrl*/,
|
---|
253 | int);
|
---|
254 |
|
---|
255 | typedef void (*KbdCtrlProcPtr)(
|
---|
256 | DeviceIntPtr /*device*/,
|
---|
257 | KeybdCtrl * /*ctrl*/);
|
---|
258 |
|
---|
259 | extern Bool InitKbdFeedbackClassDeviceStruct(
|
---|
260 | DeviceIntPtr /*device*/,
|
---|
261 | BellProcPtr /*bellProc*/,
|
---|
262 | KbdCtrlProcPtr /*controlProc*/);
|
---|
263 |
|
---|
264 | typedef void (*PtrCtrlProcPtr)(
|
---|
265 | DeviceIntPtr /*device*/,
|
---|
266 | PtrCtrl * /*ctrl*/);
|
---|
267 |
|
---|
268 | extern Bool InitPtrFeedbackClassDeviceStruct(
|
---|
269 | DeviceIntPtr /*device*/,
|
---|
270 | PtrCtrlProcPtr /*controlProc*/);
|
---|
271 |
|
---|
272 | typedef void (*StringCtrlProcPtr)(
|
---|
273 | DeviceIntPtr /*device*/,
|
---|
274 | StringCtrl * /*ctrl*/);
|
---|
275 |
|
---|
276 | extern Bool InitStringFeedbackClassDeviceStruct(
|
---|
277 | DeviceIntPtr /*device*/,
|
---|
278 | StringCtrlProcPtr /*controlProc*/,
|
---|
279 | int /*max_symbols*/,
|
---|
280 | int /*num_symbols_supported*/,
|
---|
281 | KeySym* /*symbols*/);
|
---|
282 |
|
---|
283 | typedef void (*BellCtrlProcPtr)(
|
---|
284 | DeviceIntPtr /*device*/,
|
---|
285 | BellCtrl * /*ctrl*/);
|
---|
286 |
|
---|
287 | extern Bool InitBellFeedbackClassDeviceStruct(
|
---|
288 | DeviceIntPtr /*device*/,
|
---|
289 | BellProcPtr /*bellProc*/,
|
---|
290 | BellCtrlProcPtr /*controlProc*/);
|
---|
291 |
|
---|
292 | typedef void (*LedCtrlProcPtr)(
|
---|
293 | DeviceIntPtr /*device*/,
|
---|
294 | LedCtrl * /*ctrl*/);
|
---|
295 |
|
---|
296 | extern Bool InitLedFeedbackClassDeviceStruct(
|
---|
297 | DeviceIntPtr /*device*/,
|
---|
298 | LedCtrlProcPtr /*controlProc*/);
|
---|
299 |
|
---|
300 | typedef void (*IntegerCtrlProcPtr)(
|
---|
301 | DeviceIntPtr /*device*/,
|
---|
302 | IntegerCtrl * /*ctrl*/);
|
---|
303 |
|
---|
304 |
|
---|
305 | extern Bool InitIntegerFeedbackClassDeviceStruct(
|
---|
306 | DeviceIntPtr /*device*/,
|
---|
307 | IntegerCtrlProcPtr /*controlProc*/);
|
---|
308 |
|
---|
309 | extern Bool InitPointerDeviceStruct(
|
---|
310 | DevicePtr /*device*/,
|
---|
311 | CARD8* /*map*/,
|
---|
312 | int /*numButtons*/,
|
---|
313 | ValuatorMotionProcPtr /*motionProc*/,
|
---|
314 | PtrCtrlProcPtr /*controlProc*/,
|
---|
315 | int /*numMotionEvents*/,
|
---|
316 | int /*numAxes*/);
|
---|
317 |
|
---|
318 | extern Bool InitKeyboardDeviceStruct(
|
---|
319 | DevicePtr /*device*/,
|
---|
320 | KeySymsPtr /*pKeySyms*/,
|
---|
321 | CARD8 /*pModifiers*/[],
|
---|
322 | BellProcPtr /*bellProc*/,
|
---|
323 | KbdCtrlProcPtr /*controlProc*/);
|
---|
324 |
|
---|
325 | extern void SendMappingNotify(
|
---|
326 | unsigned int /*request*/,
|
---|
327 | unsigned int /*firstKeyCode*/,
|
---|
328 | unsigned int /*count*/,
|
---|
329 | ClientPtr /* client */);
|
---|
330 |
|
---|
331 | extern Bool BadDeviceMap(
|
---|
332 | BYTE* /*buff*/,
|
---|
333 | int /*length*/,
|
---|
334 | unsigned /*low*/,
|
---|
335 | unsigned /*high*/,
|
---|
336 | XID* /*errval*/);
|
---|
337 |
|
---|
338 | extern Bool AllModifierKeysAreUp(
|
---|
339 | DeviceIntPtr /*device*/,
|
---|
340 | CARD8* /*map1*/,
|
---|
341 | int /*per1*/,
|
---|
342 | CARD8* /*map2*/,
|
---|
343 | int /*per2*/);
|
---|
344 |
|
---|
345 | extern void NoteLedState(
|
---|
346 | DeviceIntPtr /*keybd*/,
|
---|
347 | int /*led*/,
|
---|
348 | Bool /*on*/);
|
---|
349 |
|
---|
350 | extern void MaybeStopHint(
|
---|
351 | DeviceIntPtr /*device*/,
|
---|
352 | ClientPtr /*client*/);
|
---|
353 |
|
---|
354 | extern void ProcessPointerEvent(
|
---|
355 | xEventPtr /*xE*/,
|
---|
356 | DeviceIntPtr /*mouse*/,
|
---|
357 | int /*count*/);
|
---|
358 |
|
---|
359 | extern void ProcessKeyboardEvent(
|
---|
360 | xEventPtr /*xE*/,
|
---|
361 | DeviceIntPtr /*keybd*/,
|
---|
362 | int /*count*/);
|
---|
363 |
|
---|
364 | #ifdef XKB
|
---|
365 | extern void CoreProcessPointerEvent(
|
---|
366 | xEventPtr /*xE*/,
|
---|
367 | DeviceIntPtr /*mouse*/,
|
---|
368 | int /*count*/);
|
---|
369 |
|
---|
370 | extern void CoreProcessKeyboardEvent(
|
---|
371 | xEventPtr /*xE*/,
|
---|
372 | DeviceIntPtr /*keybd*/,
|
---|
373 | int /*count*/);
|
---|
374 | #endif
|
---|
375 |
|
---|
376 | extern Bool LegalModifier(
|
---|
377 | unsigned int /*key*/,
|
---|
378 | DeviceIntPtr /*pDev*/);
|
---|
379 |
|
---|
380 | extern void ProcessInputEvents(void);
|
---|
381 |
|
---|
382 | extern void InitInput(
|
---|
383 | int /*argc*/,
|
---|
384 | char ** /*argv*/);
|
---|
385 |
|
---|
386 | extern int GetMaximumEventsNum(void);
|
---|
387 |
|
---|
388 | extern int GetPointerEvents(
|
---|
389 | xEvent *events,
|
---|
390 | DeviceIntPtr pDev,
|
---|
391 | int type,
|
---|
392 | int buttons,
|
---|
393 | int flags,
|
---|
394 | int first_valuator,
|
---|
395 | int num_valuators,
|
---|
396 | int *valuators);
|
---|
397 |
|
---|
398 | extern int GetKeyboardEvents(
|
---|
399 | xEvent *events,
|
---|
400 | DeviceIntPtr pDev,
|
---|
401 | int type,
|
---|
402 | int key_code);
|
---|
403 |
|
---|
404 | extern int GetKeyboardValuatorEvents(
|
---|
405 | xEvent *events,
|
---|
406 | DeviceIntPtr pDev,
|
---|
407 | int type,
|
---|
408 | int key_code,
|
---|
409 | int first_valuator,
|
---|
410 | int num_valuator,
|
---|
411 | int *valuators);
|
---|
412 |
|
---|
413 | extern int GetProximityEvents(
|
---|
414 | xEvent *events,
|
---|
415 | DeviceIntPtr pDev,
|
---|
416 | int type,
|
---|
417 | int first_valuator,
|
---|
418 | int num_valuators,
|
---|
419 | int *valuators);
|
---|
420 |
|
---|
421 | extern void PostSyntheticMotion(
|
---|
422 | int x,
|
---|
423 | int y,
|
---|
424 | int screen,
|
---|
425 | unsigned long time);
|
---|
426 |
|
---|
427 | extern int GetMotionHistorySize(
|
---|
428 | void);
|
---|
429 |
|
---|
430 | extern void AllocateMotionHistory(
|
---|
431 | DeviceIntPtr pDev);
|
---|
432 |
|
---|
433 | extern int GetMotionHistory(
|
---|
434 | DeviceIntPtr pDev,
|
---|
435 | xTimecoord *buff,
|
---|
436 | unsigned long start,
|
---|
437 | unsigned long stop,
|
---|
438 | ScreenPtr pScreen);
|
---|
439 |
|
---|
440 | extern void SwitchCoreKeyboard(DeviceIntPtr pDev);
|
---|
441 | extern void SwitchCorePointer(DeviceIntPtr pDev);
|
---|
442 |
|
---|
443 | extern DeviceIntPtr LookupDeviceIntRec(
|
---|
444 | CARD8 deviceid);
|
---|
445 |
|
---|
446 | /* Implemented by the DDX. */
|
---|
447 | extern int NewInputDeviceRequest(
|
---|
448 | InputOption *options,
|
---|
449 | DeviceIntPtr *dev);
|
---|
450 | extern void DeleteInputDeviceRequest(
|
---|
451 | DeviceIntPtr dev);
|
---|
452 |
|
---|
453 | extern void DDXRingBell(
|
---|
454 | int volume,
|
---|
455 | int pitch,
|
---|
456 | int duration);
|
---|
457 |
|
---|
458 | #endif /* INPUT_H */
|
---|