1/************************************************************
2
3Copyright 1989, 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
25Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
26
27			All Rights Reserved
28
29Permission to use, copy, modify, and distribute this software and its
30documentation for any purpose and without fee is hereby granted,
31provided that the above copyright notice appear in all copies and that
32both that copyright notice and this permission notice appear in
33supporting documentation, and that the name of Hewlett-Packard not be
34used in advertising or publicity pertaining to distribution of the
35software without specific, written prior permission.
36
37HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
38ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
39HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
40ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
41WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
42ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
43SOFTWARE.
44
45********************************************************/
46
47/* Definitions used by the library and client */
48
49#ifndef _XINPUT_H_
50#define _XINPUT_H_
51
52#include <X11/Xlib.h>
53#include <X11/extensions/XI.h>
54
55#define _deviceKeyPress		0
56#define _deviceKeyRelease	1
57
58#define _deviceButtonPress	0
59#define _deviceButtonRelease	1
60
61#define _deviceMotionNotify	0
62
63#define _deviceFocusIn		0
64#define _deviceFocusOut		1
65
66#define _proximityIn		0
67#define _proximityOut		1
68
69#define _deviceStateNotify	0
70#define _deviceMappingNotify	1
71#define _changeDeviceNotify	2
72/* Space of 3 between is necessary! Reserved for DeviceKeyStateNotify,
73   DeviceButtonStateNotify, DevicePresenceNotify (essentially unused). This
74   code has to be in sync with FixExtensionEvents() in xserver/Xi/extinit.c */
75#define _propertyNotify		6
76
77#define FindTypeAndClass(d,type,_class,classid,offset) \
78    { int _i; XInputClassInfo *_ip; \
79    type = 0; _class = 0; \
80    for (_i=0, _ip= ((XDevice *) d)->classes; \
81	 _i< ((XDevice *) d)->num_classes; \
82	 _i++, _ip++) \
83	if (_ip->input_class == classid) \
84	    {type =  _ip->event_type_base + offset; \
85	     _class =  ((XDevice *) d)->device_id << 8 | type;}}
86
87#define DeviceKeyPress(d,type,_class) \
88    FindTypeAndClass(d, type, _class, KeyClass, _deviceKeyPress)
89
90#define DeviceKeyRelease(d,type,_class) \
91    FindTypeAndClass(d, type, _class, KeyClass, _deviceKeyRelease)
92
93#define DeviceButtonPress(d,type,_class) \
94    FindTypeAndClass(d, type, _class, ButtonClass, _deviceButtonPress)
95
96#define DeviceButtonRelease(d,type,_class) \
97    FindTypeAndClass(d, type, _class, ButtonClass, _deviceButtonRelease)
98
99#define DeviceMotionNotify(d,type,_class) \
100    FindTypeAndClass(d, type, _class, ValuatorClass, _deviceMotionNotify)
101
102#define DeviceFocusIn(d,type,_class) \
103    FindTypeAndClass(d, type, _class, FocusClass, _deviceFocusIn)
104
105#define DeviceFocusOut(d,type,_class) \
106    FindTypeAndClass(d, type, _class, FocusClass, _deviceFocusOut)
107
108#define ProximityIn(d,type,_class) \
109    FindTypeAndClass(d, type, _class, ProximityClass, _proximityIn)
110
111#define ProximityOut(d,type,_class) \
112    FindTypeAndClass(d, type, _class, ProximityClass, _proximityOut)
113
114#define DeviceStateNotify(d,type,_class) \
115    FindTypeAndClass(d, type, _class, OtherClass, _deviceStateNotify)
116
117#define DeviceMappingNotify(d,type,_class) \
118    FindTypeAndClass(d, type, _class, OtherClass, _deviceMappingNotify)
119
120#define ChangeDeviceNotify(d,type,_class) \
121    FindTypeAndClass(d, type, _class, OtherClass, _changeDeviceNotify)
122
123#define DevicePropertyNotify(d, type, _class) \
124    FindTypeAndClass(d, type, _class, OtherClass, _propertyNotify)
125
126#define DevicePointerMotionHint(d,type,_class) \
127    { _class =  ((XDevice *) d)->device_id << 8 | _devicePointerMotionHint;}
128
129#define DeviceButton1Motion(d,type,_class) \
130    { _class =  ((XDevice *) d)->device_id << 8 | _deviceButton1Motion;}
131
132#define DeviceButton2Motion(d,type,_class) \
133    { _class =  ((XDevice *) d)->device_id << 8 | _deviceButton2Motion;}
134
135#define DeviceButton3Motion(d,type,_class) \
136    { _class =  ((XDevice *) d)->device_id << 8 | _deviceButton3Motion;}
137
138#define DeviceButton4Motion(d,type, _class) \
139    { _class =  ((XDevice *) d)->device_id << 8 | _deviceButton4Motion;}
140
141#define DeviceButton5Motion(d,type,_class) \
142    { _class =  ((XDevice *) d)->device_id << 8 | _deviceButton5Motion;}
143
144#define DeviceButtonMotion(d,type, _class) \
145    { _class =  ((XDevice *) d)->device_id << 8 | _deviceButtonMotion;}
146
147#define DeviceOwnerGrabButton(d,type,_class) \
148    { _class =  ((XDevice *) d)->device_id << 8 | _deviceOwnerGrabButton;}
149
150#define DeviceButtonPressGrab(d,type,_class) \
151    { _class =  ((XDevice *) d)->device_id << 8 | _deviceButtonGrab;}
152
153#define NoExtensionEvent(d,type,_class) \
154    { _class =  ((XDevice *) d)->device_id << 8 | _noExtensionEvent;}
155
156
157/* We need the declaration for DevicePresence. */
158#if defined(__cplusplus) || defined(c_plusplus)
159extern "C" {
160#endif
161    extern int _XiGetDevicePresenceNotifyEvent(Display *);
162    extern void _xibaddevice( Display *dpy, int *error);
163    extern void _xibadclass( Display *dpy, int *error);
164    extern void _xibadevent( Display *dpy, int *error);
165    extern void _xibadmode( Display *dpy, int *error);
166    extern void _xidevicebusy( Display *dpy, int *error);
167#if defined(__cplusplus) || defined(c_plusplus)
168}
169#endif
170
171#define DevicePresence(dpy, type, _class)                       \
172    {                                                           \
173        type = _XiGetDevicePresenceNotifyEvent(dpy);            \
174        _class =  (0x10000 | _devicePresence);                  \
175    }
176
177/* Errors */
178#define BadDevice(dpy,error) _xibaddevice(dpy, &error)
179
180#define BadClass(dpy,error) _xibadclass(dpy, &error)
181
182#define BadEvent(dpy,error) _xibadevent(dpy, &error)
183
184#define BadMode(dpy,error) _xibadmode(dpy, &error)
185
186#define DeviceBusy(dpy,error) _xidevicebusy(dpy, &error)
187
188typedef struct _XAnyClassinfo *XAnyClassPtr;
189
190/***************************************************************
191 *
192 * DeviceKey events.  These events are sent by input devices that
193 * support input class Keys.
194 * The location of the X pointer is reported in the coordinate
195 * fields of the x,y and x_root,y_root fields.
196 *
197 */
198
199typedef struct
200    {
201    int            type;         /* of event */
202    unsigned long  serial;       /* # of last request processed */
203    Bool           send_event;   /* true if from SendEvent request */
204    Display        *display;     /* Display the event was read from */
205    Window         window;       /* "event" window reported relative to */
206    XID            deviceid;
207    Window         root;         /* root window event occured on */
208    Window         subwindow;    /* child window */
209    Time           time;         /* milliseconds */
210    int            x, y;         /* x, y coordinates in event window */
211    int            x_root;       /* coordinates relative to root */
212    int            y_root;       /* coordinates relative to root */
213    unsigned int   state;        /* key or button mask */
214    unsigned int   keycode;      /* detail */
215    Bool           same_screen;  /* same screen flag */
216    unsigned int   device_state; /* device key or button mask */
217    unsigned char  axes_count;
218    unsigned char  first_axis;
219    int            axis_data[6];
220    } XDeviceKeyEvent;
221
222typedef XDeviceKeyEvent XDeviceKeyPressedEvent;
223typedef XDeviceKeyEvent XDeviceKeyReleasedEvent;
224
225/*******************************************************************
226 *
227 * DeviceButton events.  These events are sent by extension devices
228 * that support input class Buttons.
229 *
230 */
231
232typedef struct {
233    int           type;         /* of event */
234    unsigned long serial;       /* # of last request processed by server */
235    Bool          send_event;   /* true if from a SendEvent request */
236    Display       *display;     /* Display the event was read from */
237    Window        window;       /* "event" window reported relative to */
238    XID           deviceid;
239    Window        root;         /* root window that the event occured on */
240    Window        subwindow;    /* child window */
241    Time          time;         /* milliseconds */
242    int           x, y;         /* x, y coordinates in event window */
243    int           x_root;       /* coordinates relative to root */
244    int           y_root;       /* coordinates relative to root */
245    unsigned int  state;        /* key or button mask */
246    unsigned int  button;       /* detail */
247    Bool          same_screen;  /* same screen flag */
248    unsigned int  device_state; /* device key or button mask */
249    unsigned char axes_count;
250    unsigned char first_axis;
251    int           axis_data[6];
252    } XDeviceButtonEvent;
253
254typedef XDeviceButtonEvent XDeviceButtonPressedEvent;
255typedef XDeviceButtonEvent XDeviceButtonReleasedEvent;
256
257/*******************************************************************
258 *
259 * DeviceMotionNotify event.  These events are sent by extension devices
260 * that support input class Valuators.
261 *
262 */
263
264typedef struct
265    {
266    int           type;        /* of event */
267    unsigned long serial;      /* # of last request processed by server */
268    Bool          send_event;  /* true if from a SendEvent request */
269    Display       *display;    /* Display the event was read from */
270    Window        window;      /* "event" window reported relative to */
271    XID           deviceid;
272    Window        root;        /* root window that the event occured on */
273    Window        subwindow;   /* child window */
274    Time          time;        /* milliseconds */
275    int           x, y;        /* x, y coordinates in event window */
276    int           x_root;      /* coordinates relative to root */
277    int           y_root;      /* coordinates relative to root */
278    unsigned int  state;       /* key or button mask */
279    char          is_hint;     /* detail */
280    Bool          same_screen; /* same screen flag */
281    unsigned int  device_state; /* device key or button mask */
282    unsigned char axes_count;
283    unsigned char first_axis;
284    int           axis_data[6];
285    } XDeviceMotionEvent;
286
287/*******************************************************************
288 *
289 * DeviceFocusChange events.  These events are sent when the focus
290 * of an extension device that can be focused is changed.
291 *
292 */
293
294typedef struct
295    {
296    int           type;       /* of event */
297    unsigned long serial;     /* # of last request processed by server */
298    Bool          send_event; /* true if from a SendEvent request */
299    Display       *display;   /* Display the event was read from */
300    Window        window;     /* "event" window reported relative to */
301    XID           deviceid;
302    int           mode;       /* NotifyNormal, NotifyGrab, NotifyUngrab */
303    int           detail;
304	/*
305	 * NotifyAncestor, NotifyVirtual, NotifyInferior,
306	 * NotifyNonLinear,NotifyNonLinearVirtual, NotifyPointer,
307	 * NotifyPointerRoot, NotifyDetailNone
308	 */
309    Time                time;
310    } XDeviceFocusChangeEvent;
311
312typedef XDeviceFocusChangeEvent XDeviceFocusInEvent;
313typedef XDeviceFocusChangeEvent XDeviceFocusOutEvent;
314
315/*******************************************************************
316 *
317 * ProximityNotify events.  These events are sent by those absolute
318 * positioning devices that are capable of generating proximity information.
319 *
320 */
321
322typedef struct
323    {
324    int             type;      /* ProximityIn or ProximityOut */
325    unsigned long   serial;    /* # of last request processed by server */
326    Bool            send_event; /* true if this came from a SendEvent request */
327    Display         *display;  /* Display the event was read from */
328    Window          window;
329    XID	            deviceid;
330    Window          root;
331    Window          subwindow;
332    Time            time;
333    int             x, y;
334    int             x_root, y_root;
335    unsigned int    state;
336    Bool            same_screen;
337    unsigned int    device_state; /* device key or button mask */
338    unsigned char   axes_count;
339    unsigned char   first_axis;
340    int             axis_data[6];
341    } XProximityNotifyEvent;
342typedef XProximityNotifyEvent XProximityInEvent;
343typedef XProximityNotifyEvent XProximityOutEvent;
344
345/*******************************************************************
346 *
347 * DeviceStateNotify events are generated on EnterWindow and FocusIn
348 * for those clients who have selected DeviceState.
349 *
350 */
351
352typedef struct
353    {
354#if defined(__cplusplus) || defined(c_plusplus)
355    unsigned char	c_class;
356#else
357    unsigned char	class;
358#endif
359    unsigned char	length;
360    } XInputClass;
361
362typedef struct {
363    int           type;
364    unsigned long serial;       /* # of last request processed by server */
365    Bool          send_event;   /* true if this came from a SendEvent request */
366    Display       *display;     /* Display the event was read from */
367    Window        window;
368    XID           deviceid;
369    Time          time;
370    int           num_classes;
371    char	  data[64];
372} XDeviceStateNotifyEvent;
373
374typedef struct {
375#if defined(__cplusplus) || defined(c_plusplus)
376    unsigned char	c_class;
377#else
378    unsigned char	class;
379#endif
380    unsigned char	length;
381    unsigned char	num_valuators;
382    unsigned char	mode;
383    int        		valuators[6];
384} XValuatorStatus;
385
386typedef struct {
387#if defined(__cplusplus) || defined(c_plusplus)
388    unsigned char	c_class;
389#else
390    unsigned char	class;
391#endif
392    unsigned char	length;
393    short		num_keys;
394    char        	keys[32];
395} XKeyStatus;
396
397typedef struct {
398#if defined(__cplusplus) || defined(c_plusplus)
399    unsigned char	c_class;
400#else
401    unsigned char	class;
402#endif
403    unsigned char	length;
404    short		num_buttons;
405    char        	buttons[32];
406} XButtonStatus;
407
408/*******************************************************************
409 *
410 * DeviceMappingNotify event.  This event is sent when the key mapping,
411 * modifier mapping, or button mapping of an extension device is changed.
412 *
413 */
414
415typedef struct {
416    int           type;
417    unsigned long serial;       /* # of last request processed by server */
418    Bool          send_event;   /* true if this came from a SendEvent request */
419    Display       *display;     /* Display the event was read from */
420    Window        window;       /* unused */
421    XID           deviceid;
422    Time          time;
423    int           request;      /* one of MappingModifier, MappingKeyboard,
424                                    MappingPointer */
425    int           first_keycode;/* first keycode */
426    int           count;        /* defines range of change w. first_keycode*/
427} XDeviceMappingEvent;
428
429/*******************************************************************
430 *
431 * ChangeDeviceNotify event.  This event is sent when an
432 * XChangeKeyboard or XChangePointer request is made.
433 *
434 */
435
436typedef struct {
437    int           type;
438    unsigned long serial;       /* # of last request processed by server */
439    Bool          send_event;   /* true if this came from a SendEvent request */
440    Display       *display;     /* Display the event was read from */
441    Window        window;       /* unused */
442    XID           deviceid;
443    Time          time;
444    int           request;      /* NewPointer or NewKeyboard */
445} XChangeDeviceNotifyEvent;
446
447/*******************************************************************
448 *
449 * DevicePresenceNotify event.  This event is sent when the list of
450 * input devices changes, in which case devchange will be false, and
451 * no information about the change will be contained in the event;
452 * the client should use XListInputDevices() to learn what has changed.
453 *
454 * If devchange is true, an attribute that the server believes is
455 * important has changed on a device, and the client should use
456 * XGetDeviceControl to examine the device.  If control is non-zero,
457 * then that control has changed meaningfully.
458 */
459
460typedef struct {
461    int           type;
462    unsigned long serial;       /* # of last request processed by server */
463    Bool          send_event;   /* true if this came from a SendEvent request */
464    Display       *display;     /* Display the event was read from */
465    Window        window;       /* unused */
466    Time          time;
467    Bool          devchange;
468    XID           deviceid;
469    XID           control;
470} XDevicePresenceNotifyEvent;
471
472/*
473 * Notifies the client that a property on a device has changed value. The
474 * client is expected to query the server for updated value of the property.
475 */
476typedef struct {
477    int           type;
478    unsigned long serial;       /* # of last request processed by server */
479    Bool          send_event;   /* true if this came from a SendEvent request */
480    Display       *display;     /* Display the event was read from */
481    Window        window;       /* unused */
482    Time          time;
483    XID           deviceid;     /* id of the device that changed */
484    Atom          atom;         /* the property that changed */
485    int           state;        /* PropertyNewValue or PropertyDeleted */
486} XDevicePropertyNotifyEvent;
487
488
489/*******************************************************************
490 *
491 * Control structures for input devices that support input class
492 * Feedback.  These are used by the XGetFeedbackControl and
493 * XChangeFeedbackControl functions.
494 *
495 */
496
497typedef struct {
498#if defined(__cplusplus) || defined(c_plusplus)
499     XID            c_class;
500#else
501     XID            class;
502#endif
503     int            length;
504     XID            id;
505} XFeedbackState;
506
507typedef struct {
508#if defined(__cplusplus) || defined(c_plusplus)
509    XID     c_class;
510#else
511    XID     class;
512#endif
513    int     length;
514    XID     id;
515    int     click;
516    int     percent;
517    int     pitch;
518    int     duration;
519    int     led_mask;
520    int     global_auto_repeat;
521    char    auto_repeats[32];
522} XKbdFeedbackState;
523
524typedef struct {
525#if defined(__cplusplus) || defined(c_plusplus)
526    XID     c_class;
527#else
528    XID     class;
529#endif
530    int     length;
531    XID     id;
532    int     accelNum;
533    int     accelDenom;
534    int     threshold;
535} XPtrFeedbackState;
536
537typedef struct {
538#if defined(__cplusplus) || defined(c_plusplus)
539    XID     c_class;
540#else
541    XID     class;
542#endif
543    int     length;
544    XID     id;
545    int     resolution;
546    int     minVal;
547    int     maxVal;
548} XIntegerFeedbackState;
549
550typedef struct {
551#if defined(__cplusplus) || defined(c_plusplus)
552    XID     c_class;
553#else
554    XID     class;
555#endif
556    int     length;
557    XID     id;
558    int     max_symbols;
559    int     num_syms_supported;
560    KeySym  *syms_supported;
561} XStringFeedbackState;
562
563typedef struct {
564#if defined(__cplusplus) || defined(c_plusplus)
565    XID     c_class;
566#else
567    XID     class;
568#endif
569    int     length;
570    XID     id;
571    int     percent;
572    int     pitch;
573    int     duration;
574} XBellFeedbackState;
575
576typedef struct {
577#if defined(__cplusplus) || defined(c_plusplus)
578    XID     c_class;
579#else
580    XID     class;
581#endif
582    int     length;
583    XID     id;
584    int     led_values;
585    int     led_mask;
586} XLedFeedbackState;
587
588typedef struct {
589#if defined(__cplusplus) || defined(c_plusplus)
590     XID            c_class;
591#else
592     XID            class;
593#endif
594     int            length;
595     XID	    id;
596} XFeedbackControl;
597
598typedef struct {
599#if defined(__cplusplus) || defined(c_plusplus)
600    XID     c_class;
601#else
602    XID     class;
603#endif
604    int     length;
605    XID     id;
606    int     accelNum;
607    int     accelDenom;
608    int     threshold;
609} XPtrFeedbackControl;
610
611typedef struct {
612#if defined(__cplusplus) || defined(c_plusplus)
613    XID     c_class;
614#else
615    XID     class;
616#endif
617    int     length;
618    XID     id;
619    int     click;
620    int     percent;
621    int     pitch;
622    int     duration;
623    int     led_mask;
624    int     led_value;
625    int     key;
626    int     auto_repeat_mode;
627} XKbdFeedbackControl;
628
629typedef struct {
630#if defined(__cplusplus) || defined(c_plusplus)
631    XID     c_class;
632#else
633    XID     class;
634#endif
635    int     length;
636    XID     id;
637    int     num_keysyms;
638    KeySym  *syms_to_display;
639} XStringFeedbackControl;
640
641typedef struct {
642#if defined(__cplusplus) || defined(c_plusplus)
643    XID     c_class;
644#else
645    XID     class;
646#endif
647    int     length;
648    XID     id;
649    int     int_to_display;
650} XIntegerFeedbackControl;
651
652typedef struct {
653#if defined(__cplusplus) || defined(c_plusplus)
654    XID     c_class;
655#else
656    XID     class;
657#endif
658    int     length;
659    XID     id;
660    int     percent;
661    int     pitch;
662    int     duration;
663} XBellFeedbackControl;
664
665typedef struct {
666#if defined(__cplusplus) || defined(c_plusplus)
667    XID     c_class;
668#else
669    XID     class;
670#endif
671    int     length;
672    XID     id;
673    int     led_mask;
674    int     led_values;
675} XLedFeedbackControl;
676
677/*******************************************************************
678 *
679 * Device control structures.
680 *
681 */
682
683typedef struct {
684     XID            control;
685     int            length;
686} XDeviceControl;
687
688typedef struct {
689     XID            control;
690     int            length;
691     int            first_valuator;
692     int            num_valuators;
693     int            *resolutions;
694} XDeviceResolutionControl;
695
696typedef struct {
697     XID            control;
698     int            length;
699     int            num_valuators;
700     int            *resolutions;
701     int            *min_resolutions;
702     int            *max_resolutions;
703} XDeviceResolutionState;
704
705typedef struct {
706    XID             control;
707    int             length;
708    int             min_x;
709    int             max_x;
710    int             min_y;
711    int             max_y;
712    int             flip_x;
713    int             flip_y;
714    int             rotation;
715    int             button_threshold;
716} XDeviceAbsCalibControl, XDeviceAbsCalibState;
717
718typedef struct {
719    XID             control;
720    int             length;
721    int             offset_x;
722    int             offset_y;
723    int             width;
724    int             height;
725    int             screen;
726    XID             following;
727} XDeviceAbsAreaControl, XDeviceAbsAreaState;
728
729typedef struct {
730    XID             control;
731    int             length;
732    int             status;
733} XDeviceCoreControl;
734
735typedef struct {
736    XID             control;
737    int             length;
738    int             status;
739    int             iscore;
740} XDeviceCoreState;
741
742typedef struct {
743    XID             control;
744    int             length;
745    int             enable;
746} XDeviceEnableControl, XDeviceEnableState;
747
748/*******************************************************************
749 *
750 * An array of XDeviceList structures is returned by the
751 * XListInputDevices function.  Each entry contains information
752 * about one input device.  Among that information is an array of
753 * pointers to structures that describe the characteristics of
754 * the input device.
755 *
756 */
757
758typedef struct _XAnyClassinfo {
759#if defined(__cplusplus) || defined(c_plusplus)
760    XID 	c_class;
761#else
762    XID 	class;
763#endif
764    int 	length;
765    } XAnyClassInfo;
766
767typedef struct _XDeviceInfo *XDeviceInfoPtr;
768
769typedef struct _XDeviceInfo
770    {
771    XID                 id;
772    Atom                type;
773    char                *name;
774    int                 num_classes;
775    int                 use;
776    XAnyClassPtr 	inputclassinfo;
777    } XDeviceInfo;
778
779typedef struct _XKeyInfo *XKeyInfoPtr;
780
781typedef struct _XKeyInfo
782    {
783#if defined(__cplusplus) || defined(c_plusplus)
784    XID			c_class;
785#else
786    XID			class;
787#endif
788    int			length;
789    unsigned short      min_keycode;
790    unsigned short      max_keycode;
791    unsigned short      num_keys;
792    } XKeyInfo;
793
794typedef struct _XButtonInfo *XButtonInfoPtr;
795
796typedef struct _XButtonInfo {
797#if defined(__cplusplus) || defined(c_plusplus)
798    XID		c_class;
799#else
800    XID		class;
801#endif
802    int		length;
803    short 	num_buttons;
804    } XButtonInfo;
805
806typedef struct _XAxisInfo *XAxisInfoPtr;
807
808typedef struct _XAxisInfo {
809    int 	resolution;
810    int 	min_value;
811    int 	max_value;
812    } XAxisInfo;
813
814typedef struct _XValuatorInfo *XValuatorInfoPtr;
815
816typedef struct	_XValuatorInfo
817    {
818#if defined(__cplusplus) || defined(c_plusplus)
819    XID			c_class;
820#else
821    XID			class;
822#endif
823    int			length;
824    unsigned char       num_axes;
825    unsigned char       mode;
826    unsigned long       motion_buffer;
827    XAxisInfoPtr        axes;
828    } XValuatorInfo;
829
830/*******************************************************************
831 *
832 * An XDevice structure is returned by the XOpenDevice function.
833 * It contains an array of pointers to XInputClassInfo structures.
834 * Each contains information about a class of input supported by the
835 * device, including a pointer to an array of data for each type of event
836 * the device reports.
837 *
838 */
839
840
841typedef struct {
842        unsigned char   input_class;
843        unsigned char   event_type_base;
844} XInputClassInfo;
845
846typedef struct {
847        XID                    device_id;
848        int                    num_classes;
849        XInputClassInfo        *classes;
850} XDevice;
851
852
853/*******************************************************************
854 *
855 * The following structure is used to return information for the
856 * XGetSelectedExtensionEvents function.
857 *
858 */
859
860typedef struct {
861        XEventClass     event_type;
862        XID             device;
863} XEventList;
864
865/*******************************************************************
866 *
867 * The following structure is used to return motion history data from
868 * an input device that supports the input class Valuators.
869 * This information is returned by the XGetDeviceMotionEvents function.
870 *
871 */
872
873typedef struct {
874        Time   time;
875        int    *data;
876} XDeviceTimeCoord;
877
878
879/*******************************************************************
880 *
881 * Device state structure.
882 * This is returned by the XQueryDeviceState request.
883 *
884 */
885
886typedef struct {
887        XID		device_id;
888        int		num_classes;
889        XInputClass	*data;
890} XDeviceState;
891
892/*******************************************************************
893 *
894 * Note that the mode field is a bitfield that reports the Proximity
895 * status of the device as well as the mode.  The mode field should
896 * be OR'd with the mask DeviceMode and compared with the values
897 * Absolute and Relative to determine the mode, and should be OR'd
898 * with the mask ProximityState and compared with the values InProximity
899 * and OutOfProximity to determine the proximity state.
900 *
901 */
902
903typedef struct {
904#if defined(__cplusplus) || defined(c_plusplus)
905    unsigned char	c_class;
906#else
907    unsigned char	class;
908#endif
909    unsigned char	length;
910    unsigned char	num_valuators;
911    unsigned char	mode;
912    int        		*valuators;
913} XValuatorState;
914
915typedef struct {
916#if defined(__cplusplus) || defined(c_plusplus)
917    unsigned char	c_class;
918#else
919    unsigned char	class;
920#endif
921    unsigned char	length;
922    short		num_keys;
923    char        	keys[32];
924} XKeyState;
925
926typedef struct {
927#if defined(__cplusplus) || defined(c_plusplus)
928    unsigned char	c_class;
929#else
930    unsigned char	class;
931#endif
932    unsigned char	length;
933    short		num_buttons;
934    char        	buttons[32];
935} XButtonState;
936
937
938
939/*******************************************************************
940 *
941 * Function definitions.
942 *
943 */
944
945_XFUNCPROTOBEGIN
946
947extern int	XChangeKeyboardDevice(
948    Display*		/* display */,
949    XDevice*		/* device */
950);
951
952extern int	XChangePointerDevice(
953    Display*		/* display */,
954    XDevice*		/* device */,
955    int			/* xaxis */,
956    int			/* yaxis */
957);
958
959extern int	XGrabDevice(
960    Display*		/* display */,
961    XDevice*		/* device */,
962    Window		/* grab_window */,
963    Bool		/* ownerEvents */,
964    int			/* event count */,
965    XEventClass*	/* event_list */,
966    int			/* this_device_mode */,
967    int			/* other_devices_mode */,
968    Time		/* time */
969);
970
971extern int	XUngrabDevice(
972    Display*		/* display */,
973    XDevice*		/* device */,
974    Time 		/* time */
975);
976
977extern int	XGrabDeviceKey(
978    Display*		/* display */,
979    XDevice*		/* device */,
980    unsigned int	/* key */,
981    unsigned int	/* modifiers */,
982    XDevice*		/* modifier_device */,
983    Window		/* grab_window */,
984    Bool		/* owner_events */,
985    unsigned int	/* event_count */,
986    XEventClass*	/* event_list */,
987    int			/* this_device_mode */,
988    int			/* other_devices_mode */
989);
990
991extern int	XUngrabDeviceKey(
992    Display*		/* display */,
993    XDevice*		/* device */,
994    unsigned int	/* key */,
995    unsigned int	/* modifiers */,
996    XDevice*		/* modifier_dev */,
997    Window		/* grab_window */
998);
999
1000extern int	XGrabDeviceButton(
1001    Display*		/* display */,
1002    XDevice*		/* device */,
1003    unsigned int	/* button */,
1004    unsigned int	/* modifiers */,
1005    XDevice*		/* modifier_device */,
1006    Window		/* grab_window */,
1007    Bool		/* owner_events */,
1008    unsigned int	/* event_count */,
1009    XEventClass*	/* event_list */,
1010    int			/* this_device_mode */,
1011    int			/* other_devices_mode */
1012);
1013
1014extern int	XUngrabDeviceButton(
1015    Display*		/* display */,
1016    XDevice*		/* device */,
1017    unsigned int	/* button */,
1018    unsigned int	/* modifiers */,
1019    XDevice*		/* modifier_dev */,
1020    Window		/* grab_window */
1021);
1022
1023extern int	XAllowDeviceEvents(
1024    Display*		/* display */,
1025    XDevice*		/* device */,
1026    int			/* event_mode */,
1027    Time		/* time */
1028);
1029
1030extern int	XGetDeviceFocus(
1031    Display*		/* display */,
1032    XDevice*		/* device */,
1033    Window*		/* focus */,
1034    int*		/* revert_to */,
1035    Time*		/* time */
1036);
1037
1038extern int	XSetDeviceFocus(
1039    Display*		/* display */,
1040    XDevice*		/* device */,
1041    Window		/* focus */,
1042    int			/* revert_to */,
1043    Time		/* time */
1044);
1045
1046extern XFeedbackState	*XGetFeedbackControl(
1047    Display*		/* display */,
1048    XDevice*		/* device */,
1049    int*		/* num_feedbacks */
1050);
1051
1052extern void	XFreeFeedbackList(
1053    XFeedbackState*	/* list */
1054);
1055
1056extern int	XChangeFeedbackControl(
1057    Display*		/* display */,
1058    XDevice*		/* device */,
1059    unsigned long	/* mask */,
1060    XFeedbackControl*	/* f */
1061);
1062
1063extern int	XDeviceBell(
1064    Display*		/* display */,
1065    XDevice*		/* device */,
1066    XID			/* feedbackclass */,
1067    XID			/* feedbackid */,
1068    int			/* percent */
1069);
1070
1071extern KeySym	*XGetDeviceKeyMapping(
1072    Display*		/* display */,
1073    XDevice*		/* device */,
1074#if NeedWidePrototypes
1075    unsigned int	/* first */,
1076#else
1077    KeyCode		/* first */,
1078#endif
1079    int			/* keycount */,
1080    int*		/* syms_per_code */
1081);
1082
1083extern int	XChangeDeviceKeyMapping(
1084    Display*		/* display */,
1085    XDevice*		/* device */,
1086    int			/* first */,
1087    int			/* syms_per_code */,
1088    KeySym*		/* keysyms */,
1089    int			/* count */
1090);
1091
1092extern XModifierKeymap	*XGetDeviceModifierMapping(
1093    Display*		/* display */,
1094    XDevice*		/* device */
1095);
1096
1097extern int	XSetDeviceModifierMapping(
1098    Display*		/* display */,
1099    XDevice*		/* device */,
1100    XModifierKeymap*	/* modmap */
1101);
1102
1103extern int	XSetDeviceButtonMapping(
1104    Display*		/* display */,
1105    XDevice*		/* device */,
1106    unsigned char*	/* map[] */,
1107    int			/* nmap */
1108);
1109
1110extern int	XGetDeviceButtonMapping(
1111    Display*		/* display */,
1112    XDevice*		/* device */,
1113    unsigned char*	/* map[] */,
1114    unsigned int	/* nmap */
1115);
1116
1117extern XDeviceState	*XQueryDeviceState(
1118    Display*		/* display */,
1119    XDevice*		/* device */
1120);
1121
1122extern void	XFreeDeviceState(
1123    XDeviceState*	/* list */
1124);
1125
1126extern XExtensionVersion	*XGetExtensionVersion(
1127    Display*		/* display */,
1128    _Xconst char*	/* name */
1129);
1130
1131extern XDeviceInfo	*XListInputDevices(
1132    Display*		/* display */,
1133    int*		/* ndevices */
1134);
1135
1136extern void	XFreeDeviceList(
1137    XDeviceInfo*	/* list */
1138);
1139
1140extern XDevice	*XOpenDevice(
1141    Display*		/* display */,
1142    XID			/* id */
1143);
1144
1145extern int	XCloseDevice(
1146    Display*		/* display */,
1147    XDevice*		/* device */
1148);
1149
1150extern int	XSetDeviceMode(
1151    Display*		/* display */,
1152    XDevice*		/* device */,
1153    int			/* mode */
1154);
1155
1156extern int	XSetDeviceValuators(
1157    Display*		/* display */,
1158    XDevice*		/* device */,
1159    int*		/* valuators */,
1160    int			/* first_valuator */,
1161    int			/* num_valuators */
1162);
1163
1164extern XDeviceControl	*XGetDeviceControl(
1165    Display*		/* display */,
1166    XDevice*		/* device */,
1167    int			/* control */
1168);
1169
1170extern int	XChangeDeviceControl(
1171    Display*		/* display */,
1172    XDevice*		/* device */,
1173    int			/* control */,
1174    XDeviceControl*	/* d */
1175);
1176
1177extern int	XSelectExtensionEvent(
1178    Display*		/* display */,
1179    Window		/* w */,
1180    XEventClass*	/* event_list */,
1181    int			/* count */
1182);
1183
1184extern int XGetSelectedExtensionEvents(
1185    Display*		/* display */,
1186    Window		/* w */,
1187    int*		/* this_client_count */,
1188    XEventClass**	/* this_client_list */,
1189    int*		/* all_clients_count */,
1190    XEventClass**	/* all_clients_list */
1191);
1192
1193extern int	XChangeDeviceDontPropagateList(
1194    Display*		/* display */,
1195    Window		/* window */,
1196    int			/* count */,
1197    XEventClass*	/* events */,
1198    int			/* mode */
1199);
1200
1201extern XEventClass	*XGetDeviceDontPropagateList(
1202    Display*		/* display */,
1203    Window		/* window */,
1204    int*		/* count */
1205);
1206
1207extern Status	XSendExtensionEvent(
1208    Display*		/* display */,
1209    XDevice*		/* device */,
1210    Window		/* dest */,
1211    Bool		/* prop */,
1212    int			/* count */,
1213    XEventClass*	/* list */,
1214    XEvent*		/* event */
1215);
1216
1217extern XDeviceTimeCoord	*XGetDeviceMotionEvents(
1218    Display*		/* display */,
1219    XDevice*		/* device */,
1220    Time		/* start */,
1221    Time		/* stop */,
1222    int*		/* nEvents */,
1223    int*		/* mode */,
1224    int*		/* axis_count */
1225);
1226
1227extern void	XFreeDeviceMotionEvents(
1228    XDeviceTimeCoord*	/* events */
1229);
1230
1231extern void	XFreeDeviceControl(
1232    XDeviceControl*	/* control */
1233);
1234
1235extern Atom*   XListDeviceProperties(
1236    Display*            /* dpy */,
1237    XDevice*            /* dev */,
1238    int*                /* nprops_return */
1239);
1240
1241extern void XChangeDeviceProperty(
1242    Display*            /* dpy */,
1243    XDevice*            /* dev */,
1244    Atom                /* property */,
1245    Atom                /* type */,
1246    int                 /* format */,
1247    int                 /* mode */,
1248    _Xconst unsigned char * /*data */,
1249    int                 /* nelements */
1250);
1251
1252extern void
1253XDeleteDeviceProperty(
1254    Display*            /* dpy */,
1255    XDevice*            /* dev */,
1256    Atom                /* property */
1257);
1258
1259extern Status
1260XGetDeviceProperty(
1261     Display*           /* dpy*/,
1262     XDevice*           /* dev*/,
1263     Atom               /* property*/,
1264     long               /* offset*/,
1265     long               /* length*/,
1266     Bool               /* delete*/,
1267     Atom               /* req_type*/,
1268     Atom*              /* actual_type*/,
1269     int*               /* actual_format*/,
1270     unsigned long*     /* nitems*/,
1271     unsigned long*     /* bytes_after*/,
1272     unsigned char**    /* prop*/
1273);
1274
1275_XFUNCPROTOEND
1276
1277#endif /* _XINPUT_H_ */
1278