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