1 module x11.extensions.XI;
2 
3 import core.stdc.config;
4 
5 /* Definitions used by the server, library and client */
6 
7 const int sz_xGetExtensionVersionReq            = 8;
8 const int sz_xGetExtensionVersionReply          = 32;
9 const int sz_xListInputDevicesReq               = 4;
10 const int sz_xListInputDevicesReply             = 32;
11 const int sz_xOpenDeviceReq                     = 8;
12 const int sz_xOpenDeviceReply                   = 32;
13 const int sz_xCloseDeviceReq                    = 8;
14 const int sz_xSetDeviceModeReq                  = 8;
15 const int sz_xSetDeviceModeReply                = 32;
16 const int sz_xSelectExtensionEventReq           = 12;
17 const int sz_xGetSelectedExtensionEventsReq     = 8;
18 const int sz_xGetSelectedExtensionEventsReply   = 32;
19 const int sz_xChangeDeviceDontPropagateListReq  = 12;
20 const int sz_xGetDeviceDontPropagateListReq     = 8;
21 const int sz_xGetDeviceDontPropagateListReply   = 32;
22 const int sz_xGetDeviceMotionEventsReq          = 16;
23 const int sz_xGetDeviceMotionEventsReply        = 32;
24 const int sz_xChangeKeyboardDeviceReq           = 8;
25 const int sz_xChangeKeyboardDeviceReply         = 32;
26 const int sz_xChangePointerDeviceReq            = 8;
27 const int sz_xChangePointerDeviceReply          = 32;
28 const int sz_xGrabDeviceReq                     = 20;
29 const int sz_xGrabDeviceReply                   = 32;
30 const int sz_xUngrabDeviceReq                   = 12;
31 const int sz_xGrabDeviceKeyReq                  = 20;
32 const int sz_xGrabDeviceKeyReply                = 32;
33 const int sz_xUngrabDeviceKeyReq                = 16;
34 const int sz_xGrabDeviceButtonReq               = 20;
35 const int sz_xGrabDeviceButtonReply             = 32;
36 const int sz_xUngrabDeviceButtonReq             = 16;
37 const int sz_xAllowDeviceEventsReq              = 12;
38 const int sz_xGetDeviceFocusReq                 = 8;
39 const int sz_xGetDeviceFocusReply               = 32;
40 const int sz_xSetDeviceFocusReq                 = 16;
41 const int sz_xGetFeedbackControlReq             = 8;
42 const int sz_xGetFeedbackControlReply           = 32;
43 const int sz_xChangeFeedbackControlReq          = 12;
44 const int sz_xGetDeviceKeyMappingReq            = 8;
45 const int sz_xGetDeviceKeyMappingReply          = 32;
46 const int sz_xChangeDeviceKeyMappingReq         = 8;
47 const int sz_xGetDeviceModifierMappingReq       = 8;
48 const int sz_xSetDeviceModifierMappingReq       = 8;
49 const int sz_xSetDeviceModifierMappingReply     = 32;
50 const int sz_xGetDeviceButtonMappingReq         = 8;
51 const int sz_xGetDeviceButtonMappingReply       = 32;
52 const int sz_xSetDeviceButtonMappingReq         = 8;
53 const int sz_xSetDeviceButtonMappingReply       = 32;
54 const int sz_xQueryDeviceStateReq               = 8;
55 const int sz_xQueryDeviceStateReply             = 32;
56 const int sz_xSendExtensionEventReq             = 16;
57 const int sz_xDeviceBellReq                     = 8;
58 const int sz_xSetDeviceValuatorsReq             = 8;
59 const int sz_xSetDeviceValuatorsReply           = 32;
60 const int sz_xGetDeviceControlReq               = 8;
61 const int sz_xGetDeviceControlReply             = 32;
62 const int sz_xChangeDeviceControlReq            = 8;
63 const int sz_xChangeDeviceControlReply          = 32;
64 const int sz_xListDevicePropertiesReq           = 8;
65 const int sz_xListDevicePropertiesReply         = 32;
66 const int sz_xChangeDevicePropertyReq           = 20;
67 const int sz_xDeleteDevicePropertyReq           = 12;
68 const int sz_xGetDevicePropertyReq              = 24;
69 const int sz_xGetDevicePropertyReply            = 32;
70 
71 const string INAME = "XInputExtension";
72 
73 enum {
74     XI_KEYBOARD                         = "KEYBOARD",
75     XI_MOUSE                            = "MOUSE",
76     XI_TABLET                           = "TABLET",
77     XI_TOUCHSCREEN                      = "TOUCHSCREEN",
78     XI_TOUCHPAD                         = "TOUCHPAD",
79     XI_BARCODE                          = "BARCODE",
80     XI_BUTTONBOX                        = "BUTTONBOX",
81     XI_KNOB_BOX                         = "KNOB_BOX",
82     XI_ONE_KNOB                         = "ONE_KNOB",
83     XI_NINE_KNOB                        = "NINE_KNOB",
84     XI_TRACKBALL                        = "TRACKBALL",
85     XI_QUADRATURE                       = "QUADRATURE",
86     XI_ID_MODULE                        = "ID_MODULE",
87     XI_SPACEBALL                        = "SPACEBALL",
88     XI_DATAGLOVE                        = "DATAGLOVE",
89     XI_EYETRACKER                       = "EYETRACKER",
90     XI_CURSORKEYS                       = "CURSORKEYS",
91     XI_FOOTMOUSE                        = "FOOTMOUSE",
92     XI_JOYSTICK                         = "JOYSTICK"
93 }
94 
95 /* Indices into the versions[] array (XExtInt.c). Used as a index to
96  * retrieve the minimum version of XI from _XiCheckExtInit */
97 enum {
98     Dont_Check                          = 0,
99     XInput_Initial_Release              = 1,
100     XInput_Add_XDeviceBell              = 2,
101     XInput_Add_XSetDeviceValuators      = 3,
102     XInput_Add_XChangeDeviceControl     = 4,
103     XInput_Add_DevicePresenceNotify     = 5,
104     XInput_Add_DeviceProperties         = 6
105 }
106 /* DO NOT ADD TO HERE -> XI2 */
107 
108 enum {
109     XI_Absent                           = 0,
110     XI_Present                          = 1
111 }
112 
113 enum {
114     XI_Initial_Release_Major            = 1,
115     XI_Initial_Release_Minor            = 0
116 }
117 
118 enum {
119     XI_Add_XDeviceBell_Major            = 1,
120     XI_Add_XDeviceBell_Minor            = 1
121 }
122 
123 enum {
124     XI_Add_XSetDeviceValuators_Major    = 1,
125     XI_Add_XSetDeviceValuators_Minor    = 2
126 }
127 
128 enum {
129     XI_Add_XChangeDeviceControl_Major   = 1,
130     XI_Add_XChangeDeviceControl_Minor   = 3
131 }
132 
133 enum {
134     XI_Add_DevicePresenceNotify_Major   = 1,
135     XI_Add_DevicePresenceNotify_Minor   = 4
136 }
137 
138 enum {
139     XI_Add_DeviceProperties_Major       = 1,
140     XI_Add_DeviceProperties_Minor       = 5
141 }
142 
143 enum {
144     DEVICE_RESOLUTION                   = 1,
145     DEVICE_ABS_CALIB                    = 2,
146     DEVICE_CORE                         = 3,
147     DEVICE_ENABLE                       = 4,
148     DEVICE_ABS_AREA                     = 5
149 }
150 
151 const int NoSuchExtension           = 1;
152 
153 const int COUNT                     = 0;
154 const int CREATE                    = 1;
155 
156 const int NewPointer                = 0;
157 const int NewKeyboard               = 1;
158 
159 const int XPOINTER                  = 0;
160 const int XKEYBOARD                 = 1;
161 
162 const int UseXKeyboard              = 0xFF;
163 
164 enum {
165     IsXPointer                          = 0,
166     IsXKeyboard                         = 1,
167     IsXExtensionDevice                  = 2,
168     IsXExtensionKeyboard                = 3,
169     IsXExtensionPointer                 = 4
170 }
171 
172 enum {
173     AsyncThisDevice                     = 0,
174     SyncThisDevice                      = 1,
175     ReplayThisDevice                    = 2,
176     AsyncOtherDevices                   = 3,
177     AsyncAll                            = 4,
178     SyncAll                             = 5
179 }
180 
181     const int FollowKeyboard            = 3;
182     const int RevertToFollowKeyboard    = 3;
183 
184     const c_long DvAccelNum             = (1L << 0);
185     const c_long DvAccelDenom           = (1L << 1);
186     const c_long DvThreshold            = (1L << 2);
187 
188     const c_long DvKeyClickPercent      = (1L<<0);
189     const c_long DvPercent              = (1L<<1);
190     const c_long DvPitch                = (1L<<2);
191     const c_long DvDuration             = (1L<<3);
192     const c_long DvLed                  = (1L<<4);
193     const c_long DvLedMode              = (1L<<5);
194     const c_long DvKey                  = (1L<<6);
195     const c_long DvAutoRepeatMode       = (1L<<7);
196 
197     const c_long DvString               = (1L << 0);
198 
199     const c_long DvInteger              = (1L << 0);
200 
201 enum {
202     DeviceMode                          = (1L << 0),
203     Relative                            = 0,
204     Absolute                            = 1
205 }
206 
207 enum {
208     ProximityState                      = (1L << 1),
209     InProximity                         = (0L << 1),
210     OutOfProximity                      = (1L << 1)
211 }
212 
213 const int AddToList                 = 0;
214 const int DeleteFromList            = 1;
215 
216 enum {
217     KeyClass                            = 0,
218     ButtonClass                         = 1,
219     ValuatorClass                       = 2,
220     FeedbackClass                       = 3,
221     ProximityClass                      = 4,
222     FocusClass                          = 5,
223     OtherClass                          = 6,
224     AttachClass                         = 7
225 }
226 
227 enum {
228     KbdFeedbackClass                    = 0,
229     PtrFeedbackClass                    = 1,
230     StringFeedbackClass                 = 2,
231     IntegerFeedbackClass                = 3,
232     LedFeedbackClass                    = 4,
233     BellFeedbackClass                   = 5
234 }
235 
236 enum {
237     _devicePointerMotionHint            = 0,
238     _deviceButton1Motion                = 1,
239     _deviceButton2Motion                = 2,
240     _deviceButton3Motion                = 3,
241     _deviceButton4Motion                = 4,
242     _deviceButton5Motion                = 5,
243     _deviceButtonMotion                 = 6,
244     _deviceButtonGrab                   = 7,
245     _deviceOwnerGrabButton              = 8,
246     _noExtensionEvent                   = 9
247 }
248 
249 const int _devicePresence           = 0;
250 
251 const int _deviceEnter              = 0;
252 const int _deviceLeave              = 1;
253 
254 /* Device presence notify states */
255 enum {
256     DeviceAdded                         = 0,
257     DeviceRemoved                       = 1,
258     DeviceEnabled                       = 2,
259     DeviceDisabled                      = 3,
260     DeviceUnrecoverable                 = 4,
261     DeviceControlChanged                = 5
262 }
263 
264 /* XI Errors */
265 enum {
266     XI_BadDevice                        = 0,
267     XI_BadEvent                         = 1,
268     XI_BadMode                          = 2,
269     XI_DeviceBusy                       = 3,
270     XI_BadClass                         = 4
271 }
272 
273 /*
274  * Make XEventClass be a CARD32 for 64 bit servers.  Don't affect client
275  * definition of XEventClass since that would be a library interface change.
276  * See the top of X.h for more _XSERVER64 magic.
277  *
278  * But, don't actually use the CARD32 type.  We can't get it defined here
279  * without polluting the namespace.
280  */
281 version(_XSERVER64){
282     alias XEventClass = uint;
283 }else{
284     alias XEventClass = c_ulong;
285 }
286 
287 /*******************************************************************
288  *
289  * Extension version structure.
290  *
291  */
292 
293 struct XExtensionVersion{
294     int     present;
295     short   major_version;
296     short   minor_version;
297 }