File: xinput.proto

package info (click to toggle)
xtrace 1.4.0-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, trixie
  • size: 900 kB
  • sloc: ansic: 5,808; sh: 1,241; makefile: 65
file content (1398 lines) | stat: -rw-r--r-- 27,003 bytes parent folder | download
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
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
EXTENSION "XInputExtension" XInput
USE core

TYPE FP1616 FIXED
TYPE FP3232 FIXED3232

#define ra(a) { #a , parameterXInput ## a , NULL,NULL,NULL}
#define rb(a) { #a , parameterXInput ## a , returnXInput ## a ,NULL,NULL}
REQUESTS
UNKNOWN /* 0 */
GetExtensionVersion RESPONDS /* 1 */
ListInputDevices RESPONDS /* 2 */
OpenDevice RESPONDS /* 3 */
CloseDevice /* 4 */
SetDeviceMode RESPONDS /* 5 */
SelectExtensionEvent /* 6 */
GetSelectedExtensionEvents RESPONDS /* 7 */
ChangeDeviceDontPropagateList /* 8 */
GetDeviceDontPropagateList RESPONDS /* 9 */
GetDeviceMotionEvents RESPONDS /* 10 */
ChangeKeyboardDevice RESPONDS /* 11 */
ChangePointerDevice RESPONDS /* 12 */
GrabDevice RESPONDS /* 13 */
UngrabDevice /* 14 */
GrabDeviceKey /* 15 */
UngrabDeviceKey /* 16 */
GrabDeviceButton /* 17 */
UngrabDeviceButton /* 18 */
AllowDeviceEvents /* 19 */
GetDeviceFocus RESPONDS /* 20 */
SetDeviceFocus /* 21 */
GetFeedbackControl RESPONDS /* 22 */
ChangeFeedbackControl /* 23 */
GetDeviceKeyMapping RESPONDS /* 24 */
ChangeDeviceKeyMapping /* 25 */
GetDeviceModifierMapping RESPONDS /* 26 */
SetDeviceModifierMapping RESPONDS /* 27 */
GetDeviceButtonMapping RESPONDS /* 28 */
SetDeviceButtonMapping RESPONDS /* 29 */
QueryDeviceState RESPONDS /* 30 */
SendExtensionEvent /* 31 */
DeviceBell /* 32 */
SetDeviceValuators RESPONDS /* 33 */
GetDeviceControl RESPONDS /* 34 */
ChangeDeviceControl RESPONDS /* 35 */
# XI 1.5
ListDeviceProperties RESPONDS /* 36 */
ChangeDeviceProperty /* 37 */
DeleteDeviceProperty /* 38 */
GetDeviceProperty RESPONDS /* 39 */

# XI 2
XIQueryPointer RESPONDS /* 40 */
XIWarpPointer /* 41 */
XIChangeCursor /* 42 */
XIChangeHierarchy /* 43 */
XISetClientPointer /* 44 */
XIGetClientPointer RESPONDS /* 45 */
XISelectEvents /* 46 */
XIQueryVersion RESPONDS /* 47 */
XIQueryDevice RESPONDS /* 48 */
XISetFocus /* 49 */
XIGetFocus RESPONDS /* 50 */
XIGrabDevice /* 51 */
XIUngrabDevice UNSUPPORTED /* 52 */
XIAllowEvents UNSUPPORTED /* 53 */
XIPassiveGrabDevice UNSUPPORTED RESPONDS /* 54 */
XIPassiveUngrabDevice UNSUPPORTED /* 55 */
XIListProperties RESPONDS /* 56 */
XIChangeProperty /* 57 */
XIDeleteProperty /* 58 */
XIGetProperty RESPONDS /* 59 */
XIGetSelectedEvents UNSUPPORTED /* 60 */
END

EVENTS
DeviceValuator
DeviceKeyPress
DeviceKeyRelease
DeviceButtonPress
DeviceButtonRelease
DeviceMotionNotify
DeviceFocusIn
DeviceFocusOut
ProximityIn
ProximityOut
DeviceStateNotify
DeviceMappingNotify
ChangeDeviceNotify
DeviceKeystateNotify
DeviceButtonstateNotify
DevicePresenceNotify
DevicePropertyNotify
END

ERRORS
BadDevice
BadEvent
BadMode
DeviceBusy
BadClass
END

XGEVENTS
UNKNOWN
DeviceChanged		/* 1 */ UNSUPPORTED
KeyPress		/* 2 */
KeyRelease		/* 3 */
ButtonPress		/* 4 */
ButtonRelease		/* 5 */
Motion			/* 6 */
Enter			/* 7 */
Leave			/* 8 */
FocusIn			/* 9 */
FocusOut		/* 10 */
HierarchyChanged	/* 11 */ UNSUPPORTED
PropertyEvent		/* 12 */ UNSUPPORTED
RawKeyPress		/* 13 */ UNSUPPORTED
RawKeyRelease		/* 14 */ UNSUPPORTED
RawButtonPress		/* 15 */ UNSUPPORTED
RawButtonRelease	/* 16 */ UNSUPPORTED
RawMotion		/* 17 */ UNSUPPORTED
TouchBegin              /* 18 */
TouchUpdate             /* 19 */
TouchEnd                /* 20 */
TouchOwnership          /* 21 */ UNSUPPORTED
RawTouchBegin           /* 22 */ UNSUPPORTED
RawTouchUpdate          /* 23 */ UNSUPPORTED
RawTouchEnd             /* 24 */ UNSUPPORTED
BarrierHit              /* 25 */ UNSUPPORTED
BarrierLeave            /* 26 */ UNSUPPORTED
END

CONSTANTS device_change
0	Added
1	Removed
2	Enabled
3	Disabled
4	Unrecoverable
END

CONSTANTS syncmode
0	AsyncThisDevice
1	SyncThisDevice
2	ReplayThisDevice
3	AsyncOtherDevice
4	AsyncAll
5	SyncAll
END

CONSTANTS device_use
0	Pointer
1	Keyboard
2	ExtensionDevice
3	ExtensionKeyboard
4	ExtensionPointer
END

CONSTANTS notify_mode
0	Normal
1	Grab
2	Ungrab
3	WhileGrabbed
4	PassiveGrab
5	PassiveUngrab
END

CONSTANTS notify_detail
0	Ancestor
1	Virtual
2	Inferior
3	Nonlinear
4	NonlinearVirtual
5	Pointer
6	PointerRoot
7	DetailNone
END

CONSTANTS usexkeyboard
0xFF	UseXKeyboard
END

CONSTANTS anykey
0x00	AnyKey
END

CONSTANTS anybutton
0x00	AnyButton
END

# there is only one set of constants in the header files for this,
# so I assume this are the correct values and what is described for most
# other status values in the XIproto.ps is just bogus
CONSTANTS device_status
0	Success
1	AlreadyGrabbed
2	InvalidTime
3	NotViewable
4	Frozen
END

CONSTANTS input_class_id
0	key
1	button
2	valuator
3	feedback
4	proximity
5	focus
6	other
END

CONSTANTS device_mode
0	relative
1	absolute
END

CONSTANTS device_mode_and_prox
0	"relative, in proximity"
1	"absolute, in proximity"
2	"relative, out of proximity"
3	"absolute, out of proximity"
END

BITMASK classes_reported
0x01	"reporting keys"
0x02	"reporting buttons"
0x04	"reporting valuators"
0x40	absolute
0x80	"out of proximity"
END

CONSTANTS feedback_class
0	Kbd
1	Ptr
2	String
3	Integer
4	Led
5	Bell
END

CONSTANTS auto_repeat_mode
0	Off
1	On
2	Default
END

BITMASK dv_pointer
1<<0	AccelNum
1<<1	AccelDenom
1<<2	Threshold
END

BITMASK dv_keyboardbellled
1<<0	KeyClickPercent
1<<1	Percent
1<<2	Pitch
1<<3	Duration
1<<4	Led
1<<5	LedMode
1<<6	Key
1<<7	AutoRepeatMode
END
BITMASK dv_string
1<<0	String
END
BITMASK dv_integer
1<<0	Integer
END

CONSTANTS devicecontroltype
0	Resolution?
1	RESOLUTION
2	ABS_CALIB
3	CORE
4	ENABLE
5	ABS_AREA
END

CONSTANTS changereason
1	SlaveSwitch
2	DeviceChange
END
TYPE CHANGEREASON ENUM8 changereason

REQUEST GetExtensionVersion
 4	len	COUNT16
 8	name	STRING8
END

RESPONSE GetExtensionVersion
 8	major_version	UINT16
10	minor_version	UINT16
12	present	BOOL
END

REQUEST ListInputDevices ALIASES Empty

LIST AXISINFO length 12
0	resolution	UINT32
4	min	UINT32
8	max	UINT32
END

# /* that's what xspecs says it would like:
# LIST INPUTINFO variable length 4
# //	{	0,	"class id",	ft_ENUM8,	c_class_id},
# 	{	0,	"\0",	ft_IF8,	(void*)structpartKEYINFO},
# 	{	0,	"\1",	ft_IF8,	(void*)structpartBUTTONINFO},
# 	{	0,	"\2",	ft_IF8,	(void*)structpartVALUATORINFO},
# 1	len	COUNT8
# 0	unsupported	LISTofCARD8
# END
#
# LIST DEVICEINFO length 8
# 0	type	CARD32
# 4	id	CARD8
# 6	use	ENUM8 device_use
# 5	"#classes"	COUNT8
# 8	classes	LISTofINPUTINFO
# LATER	name	LISTofSTRING8
# END
#
# RESPONSE ListInputDevices
#  8	#devices	COUNT8
# 32	devices	LISTofDEVICEINFO
# END
#
# but the implementation in reality it is totally different:
#
# first come all the device structs, then all the INPUTINFO structs,
# then all the names. To know how many INPUTINFO structs there are,
# one would need to sum the numbers from the devices, which we cannot
# do yet. So we assume that none will have a name with at most 2 characters:

LIST INPUTINFO variable min-length 4
IF 0 CARD8 0
 2	"min keycode"	CARD8
 3	"max keycode"	CARD8
 4	"#keys"	UINT16
 NEXT 8
ELSEIF 0 CARD8 1
 2	"#buttons"	CARD16
 NEXT 4
ELSEIF 0 CARD8 2
 2	"#axes"	CARD16
 3	mode	ENUM8 device_mode
 4	"motion buffer size"	UINT32
 2	"#axes"	COUNT16
 8	axes	LISTofAXISINFO
ELSE
# otherwise we assume that it is time for the strings
0	len	COUNT8
1	name	STRING8
END

LIST DEVICEINFO length 8
0	type	CARD32
4	id	CARD8
5	"#classes"	UINT8
6	use	ENUM8 device_use
END

RESPONSE ListInputDevices
 8	"#devices"	COUNT8
32	devices	LISTofDEVICEINFO
RESET_COUNTER
LATER	infos	LISTofINPUTINFO
END

# The rest I had no program to test with. Judging from the problems
# above, that might mean the actual code is totally different, too

templateREQUEST Device
 4	device	CARD8
END
REQUEST OpenDevice ALIASES Device

LIST INPUTCLASSINFO length 2
0	class	ENUM8 input_class_id
1	"event type base"	CARD8
END
RESPONSE OpenDevice
 8	"#classes"	COUNT8
32	classes	LISTofINPUTCLASSINFO
END

REQUEST CloseDevice ALIASES Device

REQUEST SetDeviceMode
 4	device	CARD8
 5	mode	ENUM8 device_mode
END

templateRESPONSE Status
 8	status	CARD8 constants device_status
END
RESPONSE SetDeviceMode ALIASES Status

TYPE LISTofEVENTCLASS LISTofCARD32

REQUEST SelectExtensionEvent
 4	window	WINDOW
 8	count	UINT16
12	"desired events"	LISTofEVENTCLASS
END

REQUEST GetSelectedExtensionEvents
 4	window	WINDOW
END
RESPONSE GetSelectedExtensionEvents
 8	"#this client"	COUNT16
32	"this client"	LISTofEVENTCLASS
10	"#all clients"	COUNT16
LATER	"all clients"	LISTofEVENTCLASS
END

REQUEST ChangeDeviceDontPropagateList
 4	window	WINDOW
 8	count	COUNT16
10	mode	ENUM8 device_mode
12	"desired events"	LISTofEVENTCLASS
END

REQUEST GetDeviceDontPropagateList ALIASES GetSelectedExtensionEvents

RESPONSE GetDeviceDontPropagateList
 8	count	COUNT16
32	list	LISTofEVENTCLASS
END

REQUEST GetDeviceMotionEvents
 4	start-time	TIMESTAMP constants curtime
 8	stop-time	TIMESTAMP constants curtime
10	device	CARD8
END

LIST DEVICETIMECOORD variable min-length 4
 0	time	TIMESTAMP
GET  0
# TODO huch?
 0	valuators	LISTofUINT32
END

RESPONSE GetDeviceMotionEvents
 8	"#events"	UINT32
12	axes	UINT8
12	axes	PUSH8
13	mode	ENUM8 device_mode
32	events	LISTofDEVICETIMECOORD
END

REQUEST ChangeKeyboardDevice ALIASES Device
RESPONSE ChangeKeyboardDevice ALIASES Status

REQUEST ChangePointerDevice
 4	xaxis	CARD8
 5	yaxis	CARD8
 6	device	CARD8
END
RESPONSE ChangePointerDevice ALIASES Status

REQUEST GrabDevice
 4	window	WINDOW
 8	time	TIMESTAMP constants curtime
12	"#event"	COUNT16
14	this-device-mode	ENUM8 synmode
15	other-device-mode	ENUM8 synmode
16	owner-events	BOOL
17	device	CARD8
20	events	LISTofEVENTCLASS
END
RESPONSE GrabDevice ALIASES Status

REQUEST UngrabDevice
 4	time	TIMESTAMP constants curtime
 8	device	CARD8
END

REQUEST GrabDeviceKey
 4	window	WINDOW
 8	"#event"	COUNT16
10	modifiers	SETofKEYMASK
12	modifier_device	CARD8 constants usexkeyboard
13	grabbed_device	CARD8
14	key	CARD8 constants anykey
15	this-device-mode	ENUM8 synmode
16	other-device-mode	ENUM8 synmode
17	owner-events	BOOL
20	events	LISTofEVENTCLASS
END

REQUEST UngrabDeviceKey
 4	window	WINDOW
 8	modifiers	SETofKEYMASK
10	modifier_device	CARD8 constants usexkeyboard
11	key	CARD8 constants anykey
12	grabbed_device	CARD8
END


REQUEST GrabDeviceButton
 4	window	WINDOW
 8	grabbed_device	CARD8
 9	modifier_device	CARD8 constants usexkeyboard
10	"#event"	COUNT16
12	modifiers	SETofKEYMASK
14	this-device-mode	ENUM8 synmode
15	other-device-mode	ENUM8 synmode
16	button	UINT8 constants anybutton
17	owner-events	BOOL
20	events	LISTofEVENTCLASS
END

REQUEST UngrabDeviceButton
 4	window	WINDOW
 8	modifiers	SETofKEYMASK
10	modifier_device	CARD8 constants usexkeyboard
11	button	UINT8 constants anybutton
12	grabbed_device	CARD8
END

REQUEST AllowDeviceEvents
 4	time	TIMESTAMP constants curtime
 8	mode	ENUM8 syncmode
 9	device	CARD8
END

REQUEST GetDeviceFocus ALIASES Device
RESPONSE GetDeviceFocus
 8	focus	WINDOW constants revertto
12	time	TIMESTAMP
16	revert-to	ENUM8 revertto
END

REQUEST SetDeviceFocus
 4	focus	WINDOW constants revertto
 8	time	TIMESTAMP
12	revert-to	ENUM8 revertto
13	device	CARD8
END

LIST FEEDBACKSTATE variable min-length 4
# XIproto.ps has strange values here, XI.h looks more reasonable:
 0	"feedback class"	ENUM8 feedback_class
 1	id	CARD8
IF 0 CARD8 $feedback_class:Kbd
 4	pitch	UINT16
 6	duration	UINT16
 8	led_mask	CARD32
12	led_values	CARD32
16	global-auto-repeat	BOOL
17	click	UINT8
18	percent	UINT8
SET_COUNTER 32
20	auto-repeats	LISTofCARD8
ELSEIF 0 CARD8 $feedback_class:Ptr
# PTR
 6	acceleration	FRACTION16_16
10	treshold	UINT16
NEXT	12
ELSEIF 0 CARD8 $feedback_class:String
 4	"max symbols"	UINT16
 6	"#keysyms"	COUNT16
 8	keysyms	LISTofKEYSYM
ELSEIF 0 CARD8 $feedback_class:Integer
 4	resolution	UINT32
 8	min	INT32
12	max	INT32
NEXT 16
ELSEIF 0 CARD8 $feedback_class:Led
 4	mask	CARD32
 8	values	CARD32
NEXT 12
ELSEIF 0 CARD8 $feedback_class:Bell
 4	percent	UINT8
 8	pitch	UINT16
10	duration	UINT16
NEXT 12
ELSE
# fallback in case of unsupported:
 2	length	COUNT16
 0	unsupported	LISTofCARD8
END

REQUEST GetFeedbackControl ALIASES Device
RESPONSE GetFeedbackControl
 8	"#feedbacks"	COUNT16
32	feedbacks	LISTofFEEDBACKSTATE
END

REQUEST ChangeFeedbackControl
 8	device	CARD8
 9	"feedback id"	CARD8
12	"feedback class"	ENUM8 feedback_class
13	"feedback id"	CARD8
IF 12 CARD8 $feedback_class:Kbd
 4	mask	BITMASK32 dv_keyboardbellled
16	key	CARD8
17	auto-repeat	ENUM8 auto_repeat_mode
18	click-percent	UINT8
19	bell-percent	UINT8
20	bell-pitch	UINT16
22	bell-duration	UINT16
24	led_mask	CARD32
28	led_values	CARD32
ELSEIF 12 CARD8 $feedback_class:Ptr
 4	mask	BITMASK32 dv_pointer
18	acceleration	FRACTION16_16
22	treshold	UINT16
ELSEIF 12 CARD8 $feedback_class:String
 4	mask	BITMASK32 dv_string
18	"#keysyms"	COUNT16
20	keysyms	LISTofCARD32
ELSEIF 12 CARD8 $feedback_class:Integer
 4	mask	BITMASK32 dv_integer
16	integer	INT32
ELSEIF 12 CARD8 $feedback_class:Led
 4	mask	BITMASK32 dv_keyboardbellled
16	led_mask	CARD32
20	led_values	CARD32
ELSEIF 12 CARD8 $feedback_class:Bell
 4	mask	BITMASK32 dv_keyboardbellled
16	percent	UINT8
20	pitch	INT16
22	duration	INT16
ELSE
14	length	COUNT16
12	unsupported	LISTofCARD8
END

REQUEST GetDeviceKeyMapping
 4	device	CARD8
 5	firstKeyCode	CARD8
 6	count	UINT8
END
RESPONSE GetDeviceKeyMapping
 8	keysSyms/keyCode	UINT8
32	keysyms	LISTofCARD32
END

REQUEST ChangeDeviceKeyMapping
 4	device	CARD8
 5	firstKeyCode	CARD8
 6	"#keycodes"	UINT8
 7	"#keySyms/keyCode"	UINT8
 8	keysyms	LISTofCARD32
END

REQUEST GetDeviceModifierMapping ALIASES Device
RESPONSE GetDeviceModifierMapping
 8	keycodes/modifier	UINT8
32	keycodes	LISTofCARD8
END

REQUEST SetDeviceModifierMapping
 4	device	CARD8
 5	keycodes/modifier	UINT8
 8	keycodes	LISTofCARD8
END
RESPONSE SetDeviceModifierMapping ALIASES Status

REQUEST GetDeviceButtonMapping ALIASES Device
RESPONSE GetDeviceButtonMapping
 8	l(map)	COUNT8
32	map	LISTofCARD8
END

REQUEST SetDeviceButtonMapping
 4	device	CARD8
 5	l(map)	COUNT8
 8	map	LISTofCARD8
END
RESPONSE SetDeviceButtonMapping ALIASES Status


LIST INPUTSTATE variable min-length 2
 0	class	ENUM8 input_class_id
IF 0 CARD8 $input_class_id:key
 2	"#keys"	UINT8
SET_COUNTER	32
 4	"key states"	LISTofCARD8
ELSEIF 0 CARD8 $input_class_id:button
 2	"#buttons"	UINT8
SET_COUNTER	32
 4	"button states"	LISTofCARD8
ELSEIF 0 CARD8 $input_class_id:valuator
 2	"#valuators"	COUNT8
 3	mode	ENUM8 device_mode_and_prox
 4	"valuator states"	LISTofCARD32
ELSE
 1	length	COUNT8
 0	unsupported	LISTofCARD8
END

REQUEST QueryDeviceState ALIASES Device
RESPONSE QueryDeviceState
 8	"#classes"	COUNT8
32	classes	LISTofINPUTSTATE
END

LIST XiEVENT length 32
 0	event	EVENT
END
REQUEST SendExtensionEvent
 4	destinatione	WINDOW
 8	device	CARD8
 9	propagate	BOOL
12	"#events"	COUNT8
16	events	LISTofXiEVENT
10	"#event classes"	COUNT16
LATER	"desired events"	LISTofEVENTCLASS
END

REQUEST DeviceBell
 4	device	CARD8
 5	"feedback id"	CARD8
 6	"feedback class"	ENUM8 feedback_class
 7	percent	INT8
END

REQUEST SetDeviceValuators
 4	device	CARD8
 5	"first valuator"	UINT8
 6	"#valuators"	COUNT8
 8	valuators	LISTofUINT32
END
RESPONSE SetDeviceValuators ALIASES Status

LIST DEVICESTATE variable min-length 4
# this is supposed to be the length, but at least in
# lenny the xserver is still buggy and returns bogus values:
 2	"length (often faulty)"	UINT16
# Xspecs says 0, DEVICE_RESOLUTION is 1...
IF 0 CARD16 0
# RESOLUTIONSTATE
 4	"#valuators"	COUNT32
 8	values	LISTofUINT32
 4	"#valuators"	COUNT32
LATER	min_values	LISTofUINT32
 4	"#valuators"	COUNT32
LATER	max_values	LISTofUINT32
ELSEIF 0 CARD16 1
# RESOLUTIONSTATE
 4	"#valuators"	COUNT32
 8	values	LISTofUINT32
 4	"#valuators"	COUNT32
LATER	min_values	LISTofUINT32
 4	"#valuators"	COUNT32
LATER	max_values	LISTofUINT32
ELSEIF 0 CARD16 2
# ABSCALIBSTATE
 4	min_x	UINT32
 8	max_x	UINT32
12	min_y	UINT32
16	max_y	UINT32
20	flip_x	UINT32
24	flip_y	UINT32
28	rotation	UINT32
32	button_threshold	UINT32
NEXT	36
ELSEIF 0 CARD16 3
# CORESTATE
 4	status	CARD8
 5	iscore	BOOL
NEXT 8
ELSEIF 0 CARD16 4
# ENABLESTATE
 4	enable	CARD8
NEXT 8
ELSEIF 0 CARD16 5
# ABSAREASTATE
 4	offset_x	UINT32
 8	offset_y	UINT32
12	width	UINT32
16	height	UINT32
20	screen	CARD32
24	following	CARD32
NEXT	28
ELSE
 2	length	COUNT16
 0	unsupported	LISTofCARD8
END
REQUEST GetDeviceControl
 6	device	CARD8
 4	"device control type"	ENUM16 devicecontroltype
END
RESPONSE GetDeviceControl
 8	status	CARD8 constants device_status
32	states	LISTofDEVICESTATE
END

LIST DEVICECONTROL variable min-length 4
 2	length	UINT16
# Xspecs says 0, DEVICE_RESOLUTION is 1...
IF 0 CARD16 0
# RESOLUTIONCONTOL
 4	"first valuator"	UINT8
 5	"#valuators"	COUNT8
 8	values	LISTofUINT32
ELSEIF 0 CARD16 1
# RESOLUTIONCONTOL
 4	"first valuator"	UINT8
 5	"#valuators"	COUNT8
 8	values	LISTofUINT32
ELSEIF 0 CARD16 2
# ABSCALIBCONTOL
 4	min_x	UINT32
 8	max_x	UINT32
12	min_y	UINT32
16	max_y	UINT32
20	flip_x	UINT32
24	flip_y	UINT32
28	rotation	UINT32
32	button_threshold	UINT32
NEXT	36
ELSEIF 0 CARD16 3
# CORECONTOL
 4	status	CARD8
NEXT	8
ELSEIF 0 CARD16 4
# ENABLECONTOL
 4	enable	CARD8
NEXT	8
ELSEIF 0 CARD16 5
# ABSAREACONTOL
 4	offset_x	UINT32
 8	offset_y	UINT32
12	width	UINT32
16	height	UINT32
20	screen	CARD32
24	following	CARD32
NEXT	28
ELSE
 2	length	COUNT16
 0	unsupported	LISTofCARD8
END

REQUEST ChangeDeviceControl
 6	device	CARD8
 4	"device control type"	ENUM16 devicecontroltype
 8	data	LISTofDEVICECONTROL
END
RESPONSE ChangeDeviceControl ALIASES Status

REQUEST ListDeviceProperties
 4	device	UINT8
END
RESPONSE ListDeviceProperties
 8	nAtoms	COUNT16
32	Atoms	LISTofATOM
END

REQUEST ChangeDeviceProperty
 4	property	ATOM
 8	type	ATOM
12	device	UINT8
13	format	FORMAT8
14	mode	ENUM8 change_mode
16	nUnits	COUNT32
IF 8 ATOM "ATOM"
20	value	LISTofATOM
ELSEIF 8 ATOM "FLOAT"
20	value	LISTofFLOAT32
ELSE
20	value	LISTofFormat
END

REQUEST DeleteDeviceProperty
 4	property	ATOM
 8	device	UINT8
END

REQUEST GetDeviceProperty
 4	property	ATOM
 8	type	ATOM
12	longOffset	UINT32
16	longLength	UINT32
20	device	UINT8
21	delete	BOOL
END
RESPONSE GetDeviceProperty
 8	type	ATOM
12	bytesAfter	UINT32
16	nItems	COUNT32
20	format	FORMAT8
21	device	UINT8
IF 8 ATOM "ATOM"
32	value	LISTofATOM
ELSEIF 8 ATOM "FLOAT"
32	value	LISTofFLOAT32
ELSE
32	value	LISTofFormat
END

STRUCT MODIFIERINFO length 16
 0	base_mods	CARD32
 4	latched_mods	CARD32
 8	locked_mods	CARD32
12	effective_mods	CARD32
END

STRUCT GROUPINFO length 4
0	base_group	CARD8
1	latched_group	CARD8
2	locked_group	CARD8
3	effective_group	CARD8
END

REQUEST XIQueryPointer
 4	window	WINDOW
 8	device	UINT16
END
RESPONSE XIQueryPointer
 8	root	WINDOW
12	child	WINDOW
16	root_x	FIXED
20	root_y	FIXED
24	win_x	FIXED
28	win_y	FIXED
32	same_screen	BOOL
34	buttons_len	COUNT16
36	mods	MODIFIERINFO
52	groups	GROUPINFO
56	buttons	LISTofCARD8
END

REQUEST XIWarpPointer
 4	src_win	WINDOW
 8	dst_win	WINDOW
12	src_x	FIXED
16	src_y	FIXED
20	src_width	UINT16
22	src_height	UINT16
24	dst_x	FIXED
28	dst_y	FIXED
32	device	CARD16
END

REQUEST XIChangeCursor
 4	win	WINDOW
 8	cursor	CURSOR
12	device	CARD16
END

CONSTANTS hierarchy_change
1	AddMaster
2	RemoveMaster
3	AttachSlave
4	DetachSlave
END

CONSTANTS change_mode
1	Attach
2	Float
END

LIST HIERARCHYCHANGE variable min-length 8
 0	type	ENUM16 hierarchy_change
 2	length	COUNT16
IF 0 CARD16 $hierarchy_change:AddMaster
 4	name_len	COUNT16
 6	send_core	BOOL
 7	enable	BOOL
 8	name	STRING8
ELSEIF 0 CARD16 $hierarchy_change:RemoveMaster
 4	device	UINT16
 6	return_mode	ENUM8 change_mode
 8	return_pointer	UINT16
10	return_keyboard	UINT16
 NEXT	12
ELSEIF 0 CARD16 $hierarchy_change:AttachSlave
 4	device	UINT16
 6	new_master	UINT16
 NEXT	8
ELSEIF 0 CARD16 $hierarchy_change:DetachSlave
 4	device	UINT16
 NEXT	8
ELSE
 0	pad	LISTofCARD32
END

REQUEST XIChangeHierarchy
 4	num_changes	COUNT8
 8	changes	LISTofHIERARCHYCHANGE
END

REQUEST XISetClientPointer
 4	win	WINDOW
 8	device	UINT16
END

REQUEST XIGetClientPointer
 4	win	WINDOW
END
RESPONSE XIGetClientPointer
 8	set	BOOL
10	device	UINT16
END

LIST EVENTMASK variable min-length 4
0	device	UINT16
2	mask_len	COUNT16
4	mask	LISTofCARD32
END

REQUEST XISelectEvents
 4	win	WINDOW
 8	num_masks	COUNT16
12	masks	LISTofEVENTMASK
END

REQUEST XIQueryVersion
 4	major	UINT16
 6	minor	UINT16
END
RESPONSE XIQueryVersion
 8	major	UINT16
10	minor	UINT16
END

# TODO: could be > 32bits if the device has more than 2^32 buttons
TYPE SETofBUTTONMASK CARD32

CONSTANTS class
0	KeyClass
1	ButtonClass
2	ValuatorClass
3	ScrollClass
8	TouchClass
END

CONSTANTS scrolltype
1 vertical
2 horizontal
END
TYPE ScrollType ENUM32 scrolltype
BITMASK scrollflag
1<<0	NoEmulation
1<<1	Preferred
END
TYPE ScrollFlag BITMASK32 scrollflag
CONSTANTS touchmode
1 DirectTouch
2 DependentTouch
END
TYPE TouchMode ENUM8 touchmode

LIST CLASS variable min-length 8
0	type	ENUM16	class
2	length	COUNT16
4	sourceid	UINT16
IF 0 CARD16 $class:KeyClass
6	num_keys	COUNT16
8	keys	LISTofCARD32
ELSEIF 0 CARD16 $class:ButtonClass
6	num_buttons	COUNT16
8	state	SETofBUTTONMASK
12	labels	LISTofATOM
ELSEIF 0 CARD16 $class:ValuatorClass
6	number	UINT16
8	label	ATOM
12	min	FP3232
20	max	FP3232
28	value	FP3232
36	resolution	UINT32
40	mode	CARD8
NEXT	44
ELSEIF 0 CARD16 $class:ScrollClass
6	number	UINT16
8	type	ScrollType
12	flags	ScrollFlag
16	increment	FP3232
NEXT	24
ELSEIF 0 CARD16 $class:TouchClass
6	mode	TouchMode
7	touch_max	UINT8
NEXT	8
ELSE
0	pad	LISTofCARD32
END

CONSTANTS xi_device_use
1	MasterPointer
2	MasterKeyboard
3	SlavePointer
4	SlaveKeyboard
5	FloatingSlave
END

LIST XIDEVICEINFO variable min-length 12
 0	device	UINT16
 2	use	ENUM16 xi_device_use
 4	attachment	CARD16
10	enabled	BOOL
 8	name_len	COUNT16
12	name	STRING8
ROUND
 6	num_classes	COUNT16
LATER	classes	LISTofCLASS
END

CONSTANTS xidevice
0	AllDevices
1	AllMasterDevices
END

REQUEST XIQueryDevice
 4	device	ENUM16 xidevice
END
RESPONSE XIQueryDevice
 8	num_devices	COUNT16
32	deviceinfo	LISTofXIDEVICEINFO
END

REQUEST XISetFocus
 4	focus	WINDOW
 8	time	TIMESTAMP
10	device	UINT16
END

REQUEST XIGetFocus
 4	device	UINT16
END
RESPONSE XIGetFocus
 8	focus	WINDOW
END

REQUEST XIGrabDevice
 4	grab_window	WINDOW
 8	time	TIMESTAMP
12	cursor	CURSOR
16	device	UINT16
18	grab_mode	ENUM8	synmode
19	paired_device_mode	ENUM8	synmode
20	owner_events	BOOL
22	mask_len	COUNT16
24	masks	LISTofCARD32
END

REQUEST XIListProperties
 4	device	UINT16
END
RESPONSE XIListProperties
 8	"#properties"	COUNT16
32	properties	LISTofATOM
END

REQUEST XIChangeProperty
 4	device	UINT16
 6	mode	ENUM8	device_mode
 7	format	FORMAT8
 8	property	ATOM
12	type	ATOM
16	num_items	COUNT32
IF 12 ATOM "ATOM"
20	value	LISTofATOM
ELSEIF 12 ATOM "FLOAT"
20	value	LISTofFLOAT32
ELSE
20	value	LISTofFormat
END

REQUEST XIDeleteProperty
 4	device	UINT16
 8	property	ATOM
END

REQUEST XIGetProperty
 4	device	UINT16
 6	delete	BOOL
 8	property	ATOM
12	type	ATOM
16	offset	UINT32
20	len	UINT32
END
RESPONSE XIGetProperty
 8	type	ATOM
12	bytes_after	UINT32
16	num_items	COUNT32
20	format	FORMAT8
IF 8 ATOM "ATOM"
32	value	LISTofATOM
ELSEIF 8 ATOM "FLOAT"
32	value	LISTofFLOAT32
ELSE
32	value	LISTofFormat
END

# Events

# the top-most bit of the device-id (0x80) always means more events to follow.
# TODO: how to express that?

EVENT DeviceValuator
 1	device	CARD8
 4	state	SETofKEYBUTMASK
 6	"#valuators"	COUNT8
 7	"first axis"	CARD8
# should be LISTofINT32?
 8	valuators	LISTofUINT32
END

templateEVENT KeyButtonPointer
# keycode, button, ... depending on actual even
 1	detail	CARD8
 4	"timestamp"	TIMESTAMP
 8	"root window"	WINDOW
12	"event window"	WINDOW
16	"child window"	WINDOW constants none
20	root-x	INT16
22	root-y	INT16
24	event-x	INT16
26	event-y	INT16
28	state	SETofKEYBUTMASK
30	same-screen	BOOL
31	device	CARD8
END
EVENT DeviceKeyPress ALIASES KeyButtonPointer
EVENT DeviceKeyRelease ALIASES KeyButtonPointer
EVENT DeviceButtonPress ALIASES KeyButtonPointer
EVENT DeviceButtonRelease ALIASES KeyButtonPointer

EVENT DeviceMotionNotify
 1	detail	ENUM8 normalhint
        4	"timestamp"	TIMESTAMP
 8	"root window"	WINDOW
12	"event window"	WINDOW
16	"child window"	WINDOW constants none
20	root-x	INT16
22	root-y	INT16
24	event-x	INT16
26	event-y	INT16
28	state	SETofKEYBUTMASK
30	same-screen	BOOL
31	device	CARD8
END

templateEVENT Proximity
        4	"timestamp"	TIMESTAMP
 8	"root window"	WINDOW
12	"event window"	WINDOW
16	"child window"	WINDOW constants none
20	root-x	INT16
22	root-y	INT16
24	event-x	INT16
26	event-y	INT16
28	state	SETofKEYBUTMASK
30	same-screen	BOOL
31	device	CARD8
END
EVENT ProximityIn ALIASES Proximity
EVENT ProximityOut ALIASES Proximity

templateEVENT DeviceFocus
 1	detail	ENUM8 enterdetail
        4	"timestamp"	TIMESTAMP
 8	"event window"	WINDOW
12	mode	ENUM8 grabmode
13	device	CARD8
END
EVENT DeviceFocusOut ALIASES DeviceFocus
EVENT DeviceFocusIn ALIASES DeviceFocus

EVENT DeviceStateNotify
 1	device	CARD8
        4	"timestamp"	TIMESTAMP
11	reported	BITMASK8 classes_reported
 8	"#keys"	COUNT8
12	keys	LISTofCARD8
 9	"#buttons"	COUNT8
LATER	buttons	LISTofCARD8
10	"#valuators"	COUNT8
LATER	valuators	LISTofCARD32
END

EVENT DeviceKeystateNotify
 1	device	CARD8
 4	keys	LISTofCARD8
END

EVENT DeviceButtonstateNotify
 1	device	CARD8
 4	buttons	LISTofCARD8
END

EVENT DeviceMappingNotify
 1	device	CARD8
 4	request	CARD8
 5	"first key code"	KEYCODE
 6	count	UINT8
 8	"timestamp"	TIMESTAMP
END

EVENT ChangeDeviceNotify
 1	device	CARD8
 4	"timestamp"	TIMESTAMP
 8	request	CARD8
END

EVENT DevicePresenceNotify
 4	timestamp	TIMESTAMP
 8	change	ENUM8 device_change
 9	device	CARD8
10	control	CARD16
END

EVENT DevicePropertyNotify
 1	state	ENUM8	newdeleted
 4	timestamp	TIMESTAMP
 8	atom	ATOM
31	device	CARD8
END

STRUCT ModifierInfo length 16
 0	base_mods	CARD32
 4	latched_mods	CARD32
 8	locked_mods	CARD32
12	effective_mods	CARD32
END

STRUCT GroupInfo length 4
0	base_group	CARD8
1	latched_group	CARD8
2	locked_group	CARD8
3	effective_group	CARD8
END

# This does not work. I do not know if XIDEVICEINFO
# is broken or if the event encodes it differently...
# XGEVENT DeviceChanged
# 10	deviceid	CARD8
# 12	time		TIMESTAMP
# 16	"#classes"	COUNT16
# 18	sourceid	CARD8
# 20	reason		CHANGEREASON
# 32	classes		LISTofXIDEVICEINFO
# END

templateEVENT Device
10	deviceid	CARD8
12	time		TIMESTAMP
16	detail		CARD32
20	root		WINDOW
24	event		WINDOW
28	child		WINDOW
32	root_x		FP1616
36	root_y		FP1616
40	event_x		FP1616
44	event_y		FP1616
52	sourceid	CARD16
# TODO: meaning of flags...
56	flags		CARD32
60	mods		ModifierInfo
76	group		GroupInfo
48	buttons_len	COUNT16
80	buttons		LISTofCARD32
50	valuators_len	COUNT16
LATER	valuators	LISTofCARD32
RESET_COUNTER
LATER	axisvalues	LISTofFIXED3232
END

XGEVENT KeyPress ALIASES Device
XGEVENT KeyRelease ALIASES Device
XGEVENT ButtonPress ALIASES Device
XGEVENT ButtonRelease ALIASES Device
XGEVENT Motion ALIASES Device
XGEVENT TouchBegin ALIASES Device
XGEVENT TouchUpdate ALIASES Device
XGEVENT TouchEnd ALIASES Device

templateEVENT Notify
10	deviceid	CARD8
12	time		TIMESTAMP
16	sourceid	CARD8
18	mode		ENUM8 notify_mode
19	detail		ENUM8 notify_detail
20	root		WINDOW
24	event		WINDOW
28	child		WINDOW
32	root_x		FP1616
36	root_y		FP1616
40	event_x		FP1616
44	event_y		FP1616
48	same_screen	BOOL
49	focus		BOOL
52	mods		ModifierInfo
68	group		GroupInfo
50	buttons_len	COUNT16
72	masks		LISTofCARD32
END

XGEVENT Enter ALIASES Notify
XGEVENT Leave ALIASES Notify
XGEVENT FocusIn ALIASES Notify
XGEVENT FocusOut ALIASES Notify

EOF