1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
|
/*
* Copyright © 2009 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
/* Definitions used by the library and client */
#ifndef _XINPUT2_H_
#define _XINPUT2_H_
#include <X11/Xlib.h>
#include <X11/extensions/XI2.h>
#include <X11/extensions/Xge.h>
/*******************************************************************
*
*/
typedef struct {
int type;
char* name;
Bool sendCore;
Bool enable;
} XICreateMasterInfo;
typedef struct {
int type;
int device;
int returnMode; /* AttachToMaster, Floating */
int returnPointer;
int returnKeyboard;
} XIRemoveMasterInfo;
typedef struct {
int type;
int device;
int newMaster;
} XIAttachSlaveInfo;
typedef struct {
int type;
int device;
} XIDetachSlaveInfo;
typedef union {
int type; /* must be first element */
XICreateMasterInfo create;
XIRemoveMasterInfo remove;
XIAttachSlaveInfo attach;
XIDetachSlaveInfo detach;
} XIAnyHierarchyChangeInfo;
typedef struct
{
int deviceid;
int mask_len;
unsigned char* mask;
} XIEventMask;
typedef struct
{
int type;
} XIAnyClassInfo;
typedef struct
{
int type;
int num_buttons;
Atom *buttons;
} XIButtonClassInfo;
typedef struct
{
int type;
int num_keycodes;
int *keycodes;
} XIKeyClassInfo;
typedef struct
{
int type;
int number;
Atom name;
double min;
double max;
int resolution;
int mode;
} XIValuatorClassInfo;
typedef struct
{
int deviceid;
char* name;
int use;
int attachment;
Bool enabled;
int num_classes;
XIAnyClassInfo **classes;
} XIDeviceInfo;
typedef struct
{
int modifiers;
int status;
} XIGrabModifiers;
/**
* Generic XI2 event. All XI2 events have the same header.
* Note: this event is padded to be the same size as libX11's XEvent.
*/
typedef struct {
int type; /* GenericEvent */
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
int extension; /* XI extension offset */
int evtype;
Time time;
char pad[68]; /* force same size as XEvent */
} XIEvent;
typedef struct {
int deviceid;
int attachment;
int use;
Bool enabled;
int flags;
} XIHierarchyInfo;
/*
* Notifies the client that the device hierarchy has been changed. The client
* is expected to re-query the server for the device hierarchy.
*/
typedef struct {
int type; /* GenericEvent */
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
int extension; /* XI extension offset */
int evtype; /* XI_DeviceHierarchyChangedNotify */
Time time;
int flags;
int num_devices;
XIHierarchyInfo *info;
} XIHierarchyEvent;
/*
* Notifies the client that the classes have been changed. This happens when
* the slave device that sends through the master changes.
*/
typedef struct {
int type; /* GenericEvent */
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
int extension; /* XI extension offset */
int evtype; /* XI_DeviceHierarchyChangedNotify */
Time time;
int deviceid; /* id of the device that changed */
int sourceid; /* Source for the new classes. */
int reason; /* Reason for the change */
int num_classes;
XIAnyClassInfo **classes; /* same as in XIDeviceInfo */
} XIDeviceChangedEvent;
typedef struct
{
int base;
int latched;
int locked;
} XIModifierState;
typedef XIModifierState XIGroupState;
typedef struct {
int mask_len;
unsigned char *mask;
} XIButtonState;
typedef struct {
int mask_len;
unsigned char *mask;
double *values;
} XIValuatorState;
typedef struct {
int type; /* GenericEvent */
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
int extension; /* XI extension offset */
int evtype;
Time time;
int detail;
Window root;
Window event;
Window child;
int deviceid;
int sourceid;
float root_x;
float root_y;
float event_x;
float event_y;
XIButtonState *buttons;
XIValuatorState *valuators;
XIModifierState *mods;
XIGroupState *group;
} XIDeviceEvent;
typedef struct {
int type; /* GenericEvent */
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
int extension; /* XI extension offset */
int evtype;
Time time;
int detail;
int deviceid;
int sourceid;
int eventtype;
XIValuatorState *valuators;
double *raw_values;
} XIRawEvent;
typedef struct {
int type; /* GenericEvent */
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
int extension; /* XI extension offset */
int evtype;
Time time;
int detail;
Window root;
Window event;
Window child;
int deviceid;
int sourceid;
float root_x;
float root_y;
float event_x;
float event_y;
int mode;
Bool focus;
Bool same_screen;
XIButtonState *buttons;
XIModifierState *mods;
XIGroupState *group;
} XIEnterEvent;
typedef XIEnterEvent XILeaveEvent;
typedef struct {
int type; /* GenericEvent */
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
int extension; /* XI extension offset */
int evtype;
Time time;
Atom property;
int what;
} XIPropertyEvent;
_XFUNCPROTOBEGIN
extern Bool XIQueryPointer(
Display* display,
int deviceid,
Window win,
Window* root,
Window* child,
double* root_x,
double* root_y,
double* win_x,
double* win_y,
XIButtonState *buttons,
XIModifierState *mods,
XIGroupState *group
);
extern Bool XIWarpPointer(
Display* display,
int deviceid,
Window src_win,
Window dst_win,
int src_x,
int src_y,
unsigned int src_width,
unsigned int src_height,
int dst_x,
int dst_y
);
extern Status XIDefineCursor(
Display* display,
int deviceid,
Window win,
Cursor cursor
);
extern Status XIUndefineCursor(
Display* display,
int deviceid,
Window win
);
extern Status XIChangeHierarchy(
Display* display,
XIAnyHierarchyChangeInfo* changes,
int num_changes
);
extern Status XISetClientPointer(
Display* dpy,
Window win,
int deviceid
);
extern Bool XIGetClientPointer(
Display* dpy,
Window win,
int* deviceid
);
extern int XISelectEvents(
Display* dpy,
Window win,
XIEventMask *masks,
int num_masks
);
extern Status XIQueryVersion(
Display* dpy,
int* major_version_inout,
int* minor_version_inout
);
extern XIDeviceInfo* XIQueryDevice(
Display* dpy,
int deviceid,
int* ndevices_return
);
extern Status XISetFocus(
Display* dpy,
int deviceid,
Window focus,
Time time
);
extern Status XIGetFocus(
Display* dpy,
int deviceid,
Window *focus_return);
extern Status XIGrabDevice(
Display* dpy,
int deviceid,
Window grab_window,
Time time,
Cursor cursor,
int grab_mode,
int paired_device_mode,
Bool owner_events,
XIEventMask *mask
);
extern Status XIUngrabDevice(
Display* dpy,
int deviceid,
Time time
);
extern Status XIAllowEvents(
Display* display,
int deviceid,
int event_mode,
Time time
);
extern int XIGrabButton(
Display* display,
int deviceid,
int button,
Window grab_window,
Cursor cursor,
int grab_mode,
int paired_device_mode,
int owner_events,
XIEventMask *mask,
int num_modifiers,
XIGrabModifiers *modifiers_inout
);
extern int XIGrabKeysym(
Display* display,
int deviceid,
int keysym,
Window grab_window,
int grab_mode,
int paired_device_mode,
int owner_events,
XIEventMask *mask,
int num_modifiers,
XIGrabModifiers *modifiers_inout
);
extern Status XIUngrabButton(
Display* display,
int deviceid,
int button,
Window grab_window,
int num_modifiers,
XIGrabModifiers *modifiers
);
extern Status XIUngrabKeysym(
Display* display,
int deviceid,
int keysym,
Window grab_window,
int num_modifiers,
XIGrabModifiers *modifiers
);
extern Atom *XIListProperties(
Display* display,
int deviceid,
int *num_props_return
);
extern void XIChangeProperty(
Display* display,
int deviceid,
Atom property,
Atom type,
int format,
int mode,
unsigned char *data,
int num_items
);
extern void
XIDeleteProperty(
Display* display,
int deviceid,
Atom property
);
extern Status
XIGetProperty(
Display* display,
int deviceid,
Atom property,
long offset,
long length,
Bool delete_property,
Atom type,
Atom *type_return,
int *format_return,
unsigned long *num_items_return,
unsigned long *bytes_after_return,
unsigned char **data
);
extern void XIFreeDeviceInfo(XIDeviceInfo *info);
extern void XIFreeEventData(XIEvent *ev);
_XFUNCPROTOEND
#endif /* XINPUT2_H */
|