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