VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.10.0/input.h@ 107044

Last change on this file since 107044 was 36308, checked in by vboxsync, 14 years ago

fix OSE

  • Property svn:eol-style set to native
File size: 17.9 KB
Line 
1/************************************************************
2
3Copyright 1987, 1998 The Open Group
4
5Permission to use, copy, modify, distribute, and sell this software and its
6documentation for any purpose is hereby granted without fee, provided that
7the above copyright notice appear in all copies and that both that
8copyright notice and this permission notice appear in supporting
9documentation.
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21Except as contained in this notice, the name of The Open Group shall not be
22used in advertising or otherwise to promote the sale, use or other dealings
23in this Software without prior written authorization from The Open Group.
24
25
26Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
27
28 All Rights Reserved
29
30Permission to use, copy, modify, and distribute this software and its
31documentation for any purpose and without fee is hereby granted,
32provided that the above copyright notice appear in all copies and that
33both that copyright notice and this permission notice appear in
34supporting documentation, and that the name of Digital not be
35used in advertising or publicity pertaining to distribution of the
36software without specific, written prior permission.
37
38DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
44SOFTWARE.
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 <stdint.h>
56#include "window.h" /* for WindowPtr */
57#include "xkbrules.h"
58#include "events.h"
59
60#define DEVICE_INIT 0
61#define DEVICE_ON 1
62#define DEVICE_OFF 2
63#define DEVICE_CLOSE 3
64
65#define POINTER_RELATIVE (1 << 1)
66#define POINTER_ABSOLUTE (1 << 2)
67#define POINTER_ACCELERATE (1 << 3)
68#define POINTER_SCREEN (1 << 4) /* Data in screen coordinates */
69
70/*int constants for pointer acceleration schemes*/
71#define PtrAccelNoOp 0
72#define PtrAccelPredictable 1
73#define PtrAccelLightweight 2
74#define PtrAccelDefault PtrAccelPredictable
75
76#define MAX_VALUATORS 36
77/* Maximum number of valuators, divided by six, rounded up, to get number
78 * of events. */
79#define MAX_VALUATOR_EVENTS 6
80#define MAX_BUTTONS 256 /* completely arbitrarily chosen */
81
82#define NO_AXIS_LIMITS -1
83
84#define MAP_LENGTH 256
85#define DOWN_LENGTH 32 /* 256/8 => number of bytes to hold 256 bits */
86#define NullGrab ((GrabPtr)NULL)
87#define PointerRootWin ((WindowPtr)PointerRoot)
88#define NoneWin ((WindowPtr)None)
89#define NullDevice ((DevicePtr)NULL)
90
91#ifndef FollowKeyboard
92#define FollowKeyboard 3
93#endif
94#ifndef FollowKeyboardWin
95#define FollowKeyboardWin ((WindowPtr) FollowKeyboard)
96#endif
97#ifndef RevertToFollowKeyboard
98#define RevertToFollowKeyboard 3
99#endif
100
101typedef unsigned long Leds;
102typedef struct _OtherClients *OtherClientsPtr;
103typedef struct _InputClients *InputClientsPtr;
104typedef struct _DeviceIntRec *DeviceIntPtr;
105typedef struct _ClassesRec *ClassesPtr;
106typedef struct _SpriteRec *SpritePtr;
107typedef union _GrabMask GrabMask;
108
109typedef struct _EventList {
110 xEvent* event;
111 int evlen; /* length of allocated memory for event in bytes. This is not
112 the actual length of the event. The event's actual length is
113 32 for standard events or 32 +
114 ((xGenericEvent*)event)->length * 4 for GenericEvents.
115 For events in the EQ, the length is
116 ((InternalEvent*)event)->u.any.length */
117} EventList, *EventListPtr;
118
119/* The DIX stores incoming input events in this list */
120extern EventListPtr InputEventList;
121extern int InputEventListLen;
122
123typedef int (*DeviceProc)(
124 DeviceIntPtr /*device*/,
125 int /*what*/);
126
127typedef void (*ProcessInputProc)(
128 InternalEvent * /*event*/,
129 DeviceIntPtr /*device*/);
130
131typedef Bool (*DeviceHandleProc)(
132 DeviceIntPtr /*device*/,
133 void* /*data*/
134 );
135
136typedef void (*DeviceUnwrapProc)(
137 DeviceIntPtr /*device*/,
138 DeviceHandleProc /*proc*/,
139 void* /*data*/
140 );
141
142/* pointer acceleration handling */
143typedef void (*PointerAccelSchemeProc)(
144 DeviceIntPtr /*pDev*/,
145 int /*first_valuator*/,
146 int /*num_valuators*/,
147 int* /*valuators*/,
148 int /*evtime*/);
149
150typedef void (*DeviceCallbackProc)(
151 DeviceIntPtr /*pDev*/);
152
153typedef struct _DeviceRec {
154 pointer devicePrivate;
155 ProcessInputProc processInputProc; /* current */
156 ProcessInputProc realInputProc; /* deliver */
157 ProcessInputProc enqueueInputProc; /* enqueue */
158 Bool on; /* used by DDX to keep state */
159} DeviceRec, *DevicePtr;
160
161typedef struct _ValuatorMask ValuatorMask;
162
163typedef struct {
164 int click, bell, bell_pitch, bell_duration;
165 Bool autoRepeat;
166 unsigned char autoRepeats[32];
167 Leds leds;
168 unsigned char id;
169} KeybdCtrl;
170
171typedef struct {
172 KeySym *map;
173 KeyCode minKeyCode,
174 maxKeyCode;
175 int mapWidth;
176} KeySymsRec, *KeySymsPtr;
177
178typedef struct {
179 int num, den, threshold;
180 unsigned char id;
181} PtrCtrl;
182
183typedef struct {
184 int resolution, min_value, max_value;
185 int integer_displayed;
186 unsigned char id;
187} IntegerCtrl;
188
189typedef struct {
190 int max_symbols, num_symbols_supported;
191 int num_symbols_displayed;
192 KeySym *symbols_supported;
193 KeySym *symbols_displayed;
194 unsigned char id;
195} StringCtrl;
196
197typedef struct {
198 int percent, pitch, duration;
199 unsigned char id;
200} BellCtrl;
201
202typedef struct {
203 Leds led_values;
204 Mask led_mask;
205 unsigned char id;
206} LedCtrl;
207
208extern _X_EXPORT KeybdCtrl defaultKeyboardControl;
209extern _X_EXPORT PtrCtrl defaultPointerControl;
210
211typedef struct _InputOption {
212 char *key;
213 char *value;
214 struct _InputOption *next;
215} InputOption;
216
217typedef struct _InputAttributes {
218 char *product;
219 char *vendor;
220 char *device;
221 char *pnp_id;
222 char *usb_id;
223 char **tags; /* null-terminated */
224 uint32_t flags;
225} InputAttributes;
226
227#define ATTR_KEYBOARD (1<<0)
228#define ATTR_POINTER (1<<1)
229#define ATTR_JOYSTICK (1<<2)
230#define ATTR_TABLET (1<<3)
231#define ATTR_TOUCHPAD (1<<4)
232#define ATTR_TOUCHSCREEN (1<<5)
233
234/* Key/Button has been run through all input processing and events sent to clients. */
235#define KEY_PROCESSED 1
236#define BUTTON_PROCESSED 1
237/* Key/Button has not been fully processed, no events have been sent. */
238#define KEY_POSTED 2
239#define BUTTON_POSTED 2
240
241extern void set_key_down(DeviceIntPtr pDev, int key_code, int type);
242extern void set_key_up(DeviceIntPtr pDev, int key_code, int type);
243extern int key_is_down(DeviceIntPtr pDev, int key_code, int type);
244extern void set_button_down(DeviceIntPtr pDev, int button, int type);
245extern void set_button_up(DeviceIntPtr pDev, int button, int type);
246extern int button_is_down(DeviceIntPtr pDev, int button, int type);
247
248extern void InitCoreDevices(void);
249extern void InitXTestDevices(void);
250
251extern _X_EXPORT DeviceIntPtr AddInputDevice(
252 ClientPtr /*client*/,
253 DeviceProc /*deviceProc*/,
254 Bool /*autoStart*/);
255
256extern _X_EXPORT Bool EnableDevice(
257 DeviceIntPtr /*device*/,
258 BOOL /* sendevent */);
259
260extern _X_EXPORT Bool ActivateDevice(
261 DeviceIntPtr /*device*/,
262 BOOL /* sendevent */);
263
264extern _X_EXPORT Bool DisableDevice(
265 DeviceIntPtr /*device*/,
266 BOOL /* sendevent */);
267
268extern int InitAndStartDevices(void);
269
270extern void CloseDownDevices(void);
271
272extern void UndisplayDevices(void);
273
274extern _X_EXPORT int RemoveDevice(
275 DeviceIntPtr /*dev*/,
276 BOOL /* sendevent */);
277
278extern _X_EXPORT int NumMotionEvents(void);
279
280extern _X_EXPORT int dixLookupDevice(
281 DeviceIntPtr * /* dev */,
282 int /* id */,
283 ClientPtr /* client */,
284 Mask /* access_mode */);
285
286extern _X_EXPORT void QueryMinMaxKeyCodes(
287 KeyCode* /*minCode*/,
288 KeyCode* /*maxCode*/);
289
290extern _X_EXPORT Bool SetKeySymsMap(
291 KeySymsPtr /*dst*/,
292 KeySymsPtr /*src*/);
293
294extern _X_EXPORT Bool InitButtonClassDeviceStruct(
295 DeviceIntPtr /*device*/,
296 int /*numButtons*/,
297 Atom* /* labels */,
298 CARD8* /*map*/);
299
300extern _X_EXPORT Bool InitValuatorClassDeviceStruct(
301 DeviceIntPtr /*device*/,
302 int /*numAxes*/,
303 Atom* /* labels */,
304 int /*numMotionEvents*/,
305 int /*mode*/);
306
307extern _X_EXPORT Bool InitPointerAccelerationScheme(
308 DeviceIntPtr /*dev*/,
309 int /*scheme*/);
310
311extern _X_EXPORT Bool InitAbsoluteClassDeviceStruct(
312 DeviceIntPtr /*device*/);
313
314extern _X_EXPORT Bool InitFocusClassDeviceStruct(
315 DeviceIntPtr /*device*/);
316
317typedef void (*BellProcPtr)(
318 int /*percent*/,
319 DeviceIntPtr /*device*/,
320 pointer /*ctrl*/,
321 int);
322
323typedef void (*KbdCtrlProcPtr)(
324 DeviceIntPtr /*device*/,
325 KeybdCtrl * /*ctrl*/);
326
327typedef void (*PtrCtrlProcPtr)(
328 DeviceIntPtr /*device*/,
329 PtrCtrl * /*ctrl*/);
330
331extern _X_EXPORT Bool InitPtrFeedbackClassDeviceStruct(
332 DeviceIntPtr /*device*/,
333 PtrCtrlProcPtr /*controlProc*/);
334
335typedef void (*StringCtrlProcPtr)(
336 DeviceIntPtr /*device*/,
337 StringCtrl * /*ctrl*/);
338
339extern _X_EXPORT Bool InitStringFeedbackClassDeviceStruct(
340 DeviceIntPtr /*device*/,
341 StringCtrlProcPtr /*controlProc*/,
342 int /*max_symbols*/,
343 int /*num_symbols_supported*/,
344 KeySym* /*symbols*/);
345
346typedef void (*BellCtrlProcPtr)(
347 DeviceIntPtr /*device*/,
348 BellCtrl * /*ctrl*/);
349
350extern _X_EXPORT Bool InitBellFeedbackClassDeviceStruct(
351 DeviceIntPtr /*device*/,
352 BellProcPtr /*bellProc*/,
353 BellCtrlProcPtr /*controlProc*/);
354
355typedef void (*LedCtrlProcPtr)(
356 DeviceIntPtr /*device*/,
357 LedCtrl * /*ctrl*/);
358
359extern _X_EXPORT Bool InitLedFeedbackClassDeviceStruct(
360 DeviceIntPtr /*device*/,
361 LedCtrlProcPtr /*controlProc*/);
362
363typedef void (*IntegerCtrlProcPtr)(
364 DeviceIntPtr /*device*/,
365 IntegerCtrl * /*ctrl*/);
366
367
368extern _X_EXPORT Bool InitIntegerFeedbackClassDeviceStruct(
369 DeviceIntPtr /*device*/,
370 IntegerCtrlProcPtr /*controlProc*/);
371
372extern _X_EXPORT Bool InitPointerDeviceStruct(
373 DevicePtr /*device*/,
374 CARD8* /*map*/,
375 int /*numButtons*/,
376 Atom* /* btn_labels */,
377 PtrCtrlProcPtr /*controlProc*/,
378 int /*numMotionEvents*/,
379 int /*numAxes*/,
380 Atom* /* axes_labels */);
381
382extern _X_EXPORT Bool InitKeyboardDeviceStruct(
383 DeviceIntPtr /*device*/,
384 XkbRMLVOSet * /*rmlvo*/,
385 BellProcPtr /*bellProc*/,
386 KbdCtrlProcPtr /*controlProc*/);
387
388extern int ApplyPointerMapping(
389 DeviceIntPtr /* pDev */,
390 CARD8 * /* map */,
391 int /* len */,
392 ClientPtr /* client */);
393
394extern Bool BadDeviceMap(
395 BYTE* /*buff*/,
396 int /*length*/,
397 unsigned /*low*/,
398 unsigned /*high*/,
399 XID* /*errval*/);
400
401extern void NoteLedState(
402 DeviceIntPtr /*keybd*/,
403 int /*led*/,
404 Bool /*on*/);
405
406extern void MaybeStopHint(
407 DeviceIntPtr /*device*/,
408 ClientPtr /*client*/);
409
410extern void ProcessPointerEvent(
411 InternalEvent* /* ev */,
412 DeviceIntPtr /*mouse*/);
413
414extern void ProcessKeyboardEvent(
415 InternalEvent* /*ev*/,
416 DeviceIntPtr /*keybd*/);
417
418extern Bool LegalModifier(
419 unsigned int /*key*/,
420 DeviceIntPtr /*pDev*/);
421
422extern _X_EXPORT void ProcessInputEvents(void);
423
424extern _X_EXPORT void InitInput(
425 int /*argc*/,
426 char ** /*argv*/);
427extern _X_EXPORT void CloseInput(void);
428
429extern _X_EXPORT int GetMaximumEventsNum(void);
430
431extern _X_EXPORT int GetEventList(EventListPtr* list);
432extern _X_EXPORT EventListPtr InitEventList(int num_events);
433extern _X_EXPORT void FreeEventList(EventListPtr list, int num_events);
434
435extern void CreateClassesChangedEvent(EventListPtr event,
436 DeviceIntPtr master,
437 DeviceIntPtr slave,
438 int type);
439extern EventListPtr UpdateFromMaster(
440 EventListPtr events,
441 DeviceIntPtr pDev,
442 int type,
443 int *num_events);
444
445extern _X_EXPORT int GetPointerEvents(
446 EventListPtr events,
447 DeviceIntPtr pDev,
448 int type,
449 int buttons,
450 int flags,
451 const ValuatorMask *mask);
452
453extern _X_EXPORT int GetKeyboardEvents(
454 EventListPtr events,
455 DeviceIntPtr pDev,
456 int type,
457 int key_code);
458
459extern int GetKeyboardValuatorEvents(
460 EventListPtr events,
461 DeviceIntPtr pDev,
462 int type,
463 int key_code,
464 const ValuatorMask *mask);
465
466extern int GetProximityEvents(
467 EventListPtr events,
468 DeviceIntPtr pDev,
469 int type,
470 const ValuatorMask *mask);
471
472extern void PostSyntheticMotion(
473 DeviceIntPtr pDev,
474 int x,
475 int y,
476 int screen,
477 unsigned long time);
478
479extern _X_EXPORT int GetMotionHistorySize(
480 void);
481
482extern _X_EXPORT void AllocateMotionHistory(
483 DeviceIntPtr pDev);
484
485extern _X_EXPORT int GetMotionHistory(
486 DeviceIntPtr pDev,
487 xTimecoord **buff,
488 unsigned long start,
489 unsigned long stop,
490 ScreenPtr pScreen,
491 BOOL core);
492
493extern int AttachDevice(ClientPtr client,
494 DeviceIntPtr slave,
495 DeviceIntPtr master);
496
497extern _X_EXPORT DeviceIntPtr GetPairedDevice(DeviceIntPtr kbd);
498extern DeviceIntPtr GetMaster(DeviceIntPtr dev, int type);
499
500extern _X_EXPORT int AllocDevicePair(ClientPtr client,
501 char* name,
502 DeviceIntPtr* ptr,
503 DeviceIntPtr* keybd,
504 DeviceProc ptr_proc,
505 DeviceProc keybd_proc,
506 Bool master);
507extern void DeepCopyDeviceClasses(DeviceIntPtr from,
508 DeviceIntPtr to,
509 DeviceChangedEvent *dce);
510
511/* Helper functions. */
512extern _X_EXPORT int generate_modkeymap(ClientPtr client, DeviceIntPtr dev,
513 KeyCode **modkeymap, int *max_keys_per_mod);
514extern int change_modmap(ClientPtr client, DeviceIntPtr dev, KeyCode *map,
515 int max_keys_per_mod);
516extern int AllocXTestDevice(ClientPtr client,
517 char* name,
518 DeviceIntPtr* ptr,
519 DeviceIntPtr* keybd,
520 DeviceIntPtr master_ptr,
521 DeviceIntPtr master_keybd);
522extern BOOL IsXTestDevice(DeviceIntPtr dev, DeviceIntPtr master);
523extern DeviceIntPtr GetXTestDevice(DeviceIntPtr master);
524extern void SendDevicePresenceEvent(int deviceid, int type);
525extern _X_EXPORT InputAttributes *DuplicateInputAttributes(InputAttributes *attrs);
526extern _X_EXPORT void FreeInputAttributes(InputAttributes *attrs);
527
528/* misc event helpers */
529extern Mask GetEventMask(DeviceIntPtr dev, xEvent* ev, InputClientsPtr clients);
530extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event);
531extern Mask GetWindowXI2Mask(DeviceIntPtr dev, WindowPtr win, xEvent* ev);
532void FixUpEventFromWindow(SpritePtr pSprite,
533 xEvent *xE,
534 WindowPtr pWin,
535 Window child,
536 Bool calcChild);
537extern WindowPtr XYToWindow(SpritePtr pSprite, int x, int y);
538extern int EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event,
539 WindowPtr win);
540/**
541 * Return masks for EventIsDeliverable.
542 * @defgroup EventIsDeliverable return flags
543 * @{
544 */
545#define XI_MASK (1 << 0) /**< XI mask set on window */
546#define CORE_MASK (1 << 1) /**< Core mask set on window */
547#define DONT_PROPAGATE_MASK (1 << 2) /**< DontPropagate mask set on window */
548#define XI2_MASK (1 << 3) /**< XI2 mask set on window */
549/* @} */
550
551/* Implemented by the DDX. */
552extern _X_EXPORT int NewInputDeviceRequest(
553 InputOption *options,
554 InputAttributes *attrs,
555 DeviceIntPtr *dev);
556extern _X_EXPORT void DeleteInputDeviceRequest(
557 DeviceIntPtr dev);
558
559extern _X_EXPORT void DDXRingBell(
560 int volume,
561 int pitch,
562 int duration);
563
564#define VALUATOR_MODE_ALL_AXES -1
565extern _X_HIDDEN int valuator_get_mode(DeviceIntPtr dev, int axis);
566extern _X_HIDDEN void valuator_set_mode(DeviceIntPtr dev, int axis, int mode);
567
568/* Set to TRUE by default - os/utils.c sets it to FALSE on user request,
569 xfixes/cursor.c uses it to determine if the cursor is enabled */
570extern Bool EnableCursor;
571
572extern _X_EXPORT ValuatorMask *valuator_mask_new(int num_valuators);
573extern _X_EXPORT void valuator_mask_free(ValuatorMask **mask);
574extern _X_EXPORT void valuator_mask_set_range(ValuatorMask *mask,
575 int first_valuator, int num_valuators,
576 const int* valuators);
577extern _X_EXPORT void valuator_mask_set(ValuatorMask *mask,
578 int valuator,
579 int data);
580extern _X_EXPORT void valuator_mask_zero(ValuatorMask *mask);
581extern _X_EXPORT int valuator_mask_size(const ValuatorMask *mask);
582extern _X_EXPORT int valuator_mask_isset(const ValuatorMask *mask, int bit);
583extern _X_EXPORT void valuator_mask_unset(ValuatorMask *mask, int bit);
584extern _X_EXPORT int valuator_mask_num_valuators(const ValuatorMask *mask);
585extern _X_EXPORT void valuator_mask_copy(ValuatorMask *dest,
586 const ValuatorMask *src);
587extern _X_EXPORT int valuator_mask_get(const ValuatorMask *mask, int valnum);
588
589#endif /* INPUT_H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette