aboutsummaryrefslogtreecommitdiff
path: root/X11/extensions/XKB.h
blob: a91531719489ca8fed61c3151da8d5fcf6ab766f (plain)
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
/* $Xorg: XKB.h,v 1.3 2000/08/18 04:05:45 coskrey Exp $ */
/************************************************************
Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.

Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be 
used in advertising or publicity pertaining to distribution 
of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability 
of this software for any purpose. It is provided "as is"
without any express or implied warranty.

SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.

********************************************************/
/* $XFree86: xc/include/extensions/XKB.h,v 1.5tsi Exp $ */

#ifndef _XKB_H_
#define	_XKB_H_

    /*
     * XKB request codes, used in:
     *  -  xkbReqType field of all requests
     *  -  requestMinor field of some events
     */
#define	X_kbUseExtension		 0
#define	X_kbSelectEvents	 	 1
#define	X_kbBell			 3
#define	X_kbGetState			 4
#define	X_kbLatchLockState		 5
#define	X_kbGetControls			 6
#define	X_kbSetControls			 7
#define	X_kbGetMap			 8
#define	X_kbSetMap			 9
#define	X_kbGetCompatMap		10
#define	X_kbSetCompatMap		11
#define	X_kbGetIndicatorState		12
#define	X_kbGetIndicatorMap		13
#define	X_kbSetIndicatorMap		14
#define	X_kbGetNamedIndicator		15
#define	X_kbSetNamedIndicator		16
#define	X_kbGetNames			17
#define	X_kbSetNames			18
#define	X_kbGetGeometry			19
#define	X_kbSetGeometry			20
#define	X_kbPerClientFlags		21
#define	X_kbListComponents		22
#define	X_kbGetKbdByName		23
#define	X_kbGetDeviceInfo		24
#define	X_kbSetDeviceInfo		25
#define	X_kbSetDebuggingFlags		101

    /*
     * In the X sense, XKB reports only one event.
     * The type field of all XKB events is XkbEventCode
     */
#define	XkbEventCode			0
#define	XkbNumberEvents			(XkbEventCode+1)

    /*
     * XKB has a minor event code so it can use one X event code for 
     * multiple purposes.  
     *  - reported in the xkbType field of all XKB events.
     *  - XkbSelectEventDetails: Indicates the event for which event details 
     *    are being changed
     */
#define	XkbNewKeyboardNotify		0
#define XkbMapNotify			1
#define	XkbStateNotify			2
#define XkbControlsNotify		3
#define	XkbIndicatorStateNotify		4
#define	XkbIndicatorMapNotify		5
#define	XkbNamesNotify			6
#define XkbCompatMapNotify		7
#define	XkbBellNotify			8
#define	XkbActionMessage		9
#define	XkbAccessXNotify		10
#define	XkbExtensionDeviceNotify	11

    /*
     * Event Mask:
     *  - XkbSelectEvents:  Specifies event interest.
     */
#define	XkbNewKeyboardNotifyMask	(1L << 0)
#define XkbMapNotifyMask		(1L << 1)
#define	XkbStateNotifyMask		(1L << 2)
#define XkbControlsNotifyMask		(1L << 3)
#define	XkbIndicatorStateNotifyMask	(1L << 4)
#define	XkbIndicatorMapNotifyMask	(1L << 5)
#define	XkbNamesNotifyMask		(1L << 6)
#define XkbCompatMapNotifyMask		(1L << 7)
#define	XkbBellNotifyMask		(1L << 8)
#define	XkbActionMessageMask		(1L << 9)
#define	XkbAccessXNotifyMask		(1L << 10)
#define	XkbExtensionDeviceNotifyMask	(1L << 11)
#define	XkbAllEventsMask		(0xFFF)

    /*
     * NewKeyboardNotify event details:
     */
#define	XkbNKN_KeycodesMask		(1L << 0)
#define	XkbNKN_GeometryMask		(1L << 1)
#define	XkbNKN_DeviceIDMask		(1L << 2)
#define	XkbAllNewKeyboardEventsMask	(0x7)

    /*
     * AccessXNotify event types:
     *  - The 'what' field of AccessXNotify events reports the
     *    reason that the event was generated.
     */
#define	XkbAXN_SKPress			0
#define	XkbAXN_SKAccept			1
#define	XkbAXN_SKReject			2
#define	XkbAXN_SKRelease		3
#define	XkbAXN_BKAccept			4
#define	XkbAXN_BKReject			5
#define	XkbAXN_AXKWarning		6

    /*
     * AccessXNotify details:
     * - Used as an event detail mask to limit the conditions under which
     *   AccessXNotify events are reported
     */
#define	XkbAXN_SKPressMask		(1L << 0)
#define	XkbAXN_SKAcceptMask		(1L << 1)
#define	XkbAXN_SKRejectMask		(1L << 2)
#define	XkbAXN_SKReleaseMask		(1L << 3)
#define	XkbAXN_BKAcceptMask		(1L << 4)
#define	XkbAXN_BKRejectMask		(1L << 5)
#define	XkbAXN_AXKWarningMask		(1L << 6)
#define	XkbAllAccessXEventsMask		(0xf)

    /*
     * Miscellaneous event details:
     * - event detail masks for assorted events that don't reall
     *   have any details.
     */
#define	XkbAllStateEventsMask		XkbAllStateComponentsMask
#define	XkbAllMapEventsMask		XkbAllMapComponentsMask
#define	XkbAllControlEventsMask		XkbAllControlsMask
#define	XkbAllIndicatorEventsMask	XkbAllIndicatorsMask
#define	XkbAllNameEventsMask		XkbAllNamesMask
#define	XkbAllCompatMapEventsMask	XkbAllCompatMask
#define	XkbAllBellEventsMask		(1L << 0)
#define	XkbAllActionMessagesMask	(1L << 0)

    /*
     * XKB reports one error:  BadKeyboard
     * A further reason for the error is encoded into to most significant
     * byte of the resourceID for the error:
     *    XkbErr_BadDevice - the device in question was not found
     *    XkbErr_BadClass  - the device was found but it doesn't belong to 
     *                       the appropriate class.
     *    XkbErr_BadId     - the device was found and belongs to the right
     *                       class, but not feedback with a matching id was
     *                       found.
     * The low byte of the resourceID for this error contains the device
     * id, class specifier or feedback id that failed.
     */
#define	XkbKeyboard			0
#define	XkbNumberErrors			1

#define	XkbErr_BadDevice	0xff
#define	XkbErr_BadClass		0xfe
#define	XkbErr_BadId		0xfd

    /*
     * Keyboard Components Mask:
     * - Specifies the components that follow a GetKeyboardByNameReply
     */
#define	XkbClientMapMask		(1L << 0)
#define	XkbServerMapMask		(1L << 1)
#define	XkbCompatMapMask		(1L << 2)
#define	XkbIndicatorMapMask		(1L << 3)
#define	XkbNamesMask			(1L << 4)
#define	XkbGeometryMask			(1L << 5)
#define	XkbControlsMask			(1L << 6)
#define	XkbAllComponentsMask		(0x7f)

    /*
     * State detail mask:
     *  - The 'changed' field of StateNotify events reports which of
     *    the keyboard state components have changed.
     *  - Used as an event detail mask to limit the conditions under
     *    which StateNotify events are reported.
     */
#define	XkbModifierStateMask		(1L << 0)
#define	XkbModifierBaseMask		(1L << 1)
#define	XkbModifierLatchMask		(1L << 2)
#define	XkbModifierLockMask		(1L << 3)
#define	XkbGroupStateMask		(1L << 4)
#define	XkbGroupBaseMask		(1L << 5)
#define	XkbGroupLatchMask		(1L << 6)
#define XkbGroupLockMask		(1L << 7)
#define	XkbCompatStateMask		(1L << 8)
#define	XkbGrabModsMask			(1L << 9)
#define	XkbCompatGrabModsMask		(1L << 10)
#define	XkbLookupModsMask		(1L << 11)
#define	XkbCompatLookupModsMask		(1L << 12)
#define	XkbPointerButtonMask		(1L << 13)
#define	XkbAllStateComponentsMask	(0x3fff)

    /*
     * Controls detail masks:
     *  The controls specified in XkbAllControlsMask:
     *  - The 'changed' field of ControlsNotify events reports which of 
     *    the keyboard controls have changed.
     *  - The 'changeControls' field of the SetControls request specifies
     *    the controls for which values are to be changed.
     *  - Used as an event detail mask to limit the conditions under 
     *    which ControlsNotify events are reported.
     *
     *  The controls specified in the XkbAllBooleanCtrlsMask:
     *  - The 'enabledControls' field of ControlsNotify events reports the
     *    current status of the boolean controls.
     *  - The 'enabledControlsChanges' field of ControlsNotify events reports
     *    any boolean controls that have been turned on or off.
     *  - The 'affectEnabledControls' and 'enabledControls' fields of the
     *    kbSetControls request change the set of enabled controls.
     *  - The 'accessXTimeoutMask' and 'accessXTimeoutValues' fields of
     *    an XkbControlsRec specify the controls to be changed if the keyboard
     *    times out and the values to which they should be changed.
     *  - The 'autoCtrls' and 'autoCtrlsValues' fields of the PerClientFlags 
     *    request specifies the specify the controls to be reset when the
     *    client exits and the values to which they should be reset.
     *  - The 'ctrls' field of an indicator map specifies the controls
     *    that drive the indicator.
     *  - Specifies the boolean controls affected by the SetControls and
     *    LockControls key actions.
     */
#define	XkbRepeatKeysMask	 (1L << 0)
#define	XkbSlowKeysMask		 (1L << 1)
#define	XkbBounceKeysMask	 (1L << 2)
#define	XkbStickyKeysMask	 (1L << 3)
#define	XkbMouseKeysMask	 (1L << 4)
#define	XkbMouseKeysAccelMask	 (1L << 5)
#define	XkbAccessXKeysMask	 (1L << 6)
#define	XkbAccessXTimeoutMask	 (1L << 7)
#define	XkbAccessXFeedbackMask	 (1L << 8)
#define	XkbAudibleBellMask	 (1L << 9)
#define	XkbOverlay1Mask		 (1L << 10)
#define	XkbOverlay2Mask		 (1L << 11)
#define	XkbIgnoreGroupLockMask	 (1L << 12)
#define	XkbGroupsWrapMask	 (1L << 27)
#define	XkbInternalModsMask	 (1L << 28)
#define	XkbIgnoreLockModsMask	 (1L << 29)
#define	XkbPerKeyRepeatMask	 (1L << 30)
#define	XkbControlsEnabledMask	 (1L << 31)

#define	XkbAccessXOptionsMask    (XkbStickyKeysMask|XkbAccessXFeedbackMask)

#define	XkbAllBooleanCtrlsMask	 (0x00001FFF)
#define	XkbAllControlsMask	 (0xF8001FFF)
#define	XkbAllControlEventsMask	 XkbAllControlsMask

    /*
     * AccessX Options Mask
     *  - The 'accessXOptions' field of an XkbControlsRec specifies the
     *    AccessX options that are currently in effect.
     *  - The 'accessXTimeoutOptionsMask' and 'accessXTimeoutOptionsValues'
     *    fields of an XkbControlsRec specify the Access X options to be 
     *    changed if the keyboard times out and the values to which they 
     *    should be changed.
     */
#define	XkbAX_SKPressFBMask	(1L << 0)
#define	XkbAX_SKAcceptFBMask	(1L << 1)
#define	XkbAX_FeatureFBMask	(1L << 2)
#define	XkbAX_SlowWarnFBMask	(1L << 3)
#define	XkbAX_IndicatorFBMask	(1L << 4)
#define	XkbAX_StickyKeysFBMask	(1L << 5)
#define	XkbAX_TwoKeysMask	(1L << 6)
#define	XkbAX_LatchToLockMask	(1L << 7)
#define	XkbAX_SKReleaseFBMask	(1L << 8)
#define	XkbAX_SKRejectFBMask	(1L << 9)
#define	XkbAX_BKRejectFBMask	(1L << 10)
#define	XkbAX_DumbBellFBMask	(1L << 11)
#define	XkbAX_FBOptionsMask	(0xF3F)
#define	XkbAX_SKOptionsMask	(0x0C0)
#define	XkbAX_AllOptionsMask	(0xFFF)

    /*
     * XkbUseCoreKbd is used to specify the core keyboard without having
     * 			to look up its X input extension identifier.
     * XkbUseCorePtr is used to specify the core pointer without having
     *			to look up its X input extension identifier.
     * XkbDfltXIClass is used to specify "don't care" any place that the
     *			XKB protocol is looking for an X Input Extension 
     *			device class.
     * XkbDfltXIId is used to specify "don't care" any place that the
     *			XKB protocol is looking for an X Input Extension
     *			feedback identifier.
     * XkbAllXIClasses is used to get information about all device indicators,
     *			whether they're part of the indicator feedback class
     *			or the keyboard feedback class.
     * XkbAllXIIds is used to get information about all device indicator
     *			feedbacks without having to list them.
     * XkbXINone is used to indicate that no class or id has been specified.
     * XkbLegalXILedClass(c)  True if 'c' specifies a legal class with LEDs
     * XkbLegalXIBellClass(c) True if 'c' specifies a legal class with bells
     * XkbExplicitXIDevice(d) True if 'd' explicitly specifies a device
     * XkbExplicitXIClass(c)  True if 'c' explicitly specifies a device class
     * XkbExplicitXIId(c)     True if 'i' explicitly specifies a device id
     * XkbSingleXIClass(c)    True if 'c' specifies exactly one device class, 
     *                        including the default.
     * XkbSingleXIId(i)       True if 'i' specifies exactly one device 
     *	                      identifier, including the default.
     */
#define	XkbUseCoreKbd		0x0100
#define	XkbUseCorePtr		0x0200
#define	XkbDfltXIClass		0x0300
#define	XkbDfltXIId		0x0400
#define	XkbAllXIClasses		0x0500
#define	XkbAllXIIds		0x0600
#define	XkbXINone		0xff00

#define	XkbLegalXILedClass(c)	(((c)==KbdFeedbackClass)||\
					((c)==LedFeedbackClass)||\
					((c)==XkbDfltXIClass)||\
					((c)==XkbAllXIClasses))
#define	XkbLegalXIBellClass(c)	(((c)==KbdFeedbackClass)||\
					((c)==BellFeedbackClass)||\
					((c)==XkbDfltXIClass)||\
					((c)==XkbAllXIClasses))
#define	XkbExplicitXIDevice(c)	(((c)&(~0xff))==0)
#define	XkbExplicitXIClass(c)	(((c)&(~0xff))==0)
#define	XkbExplicitXIId(c)	(((c)&(~0xff))==0)
#define	XkbSingleXIClass(c)	((((c)&(~0xff))==0)||((c)==XkbDfltXIClass))
#define	XkbSingleXIId(c)	((((c)&(~0xff))==0)||((c)==XkbDfltXIId))

#define	XkbNoModifier		0xff
#define	XkbNoShiftLevel		0xff
#define	XkbNoShape		0xff
#define	XkbNoIndicator		0xff

#define	XkbNoModifierMask	0
#define	XkbAllModifiersMask	0xff
#define	XkbAllVirtualModsMask	0xffff

#define	XkbNumKbdGroups		4
#define	XkbMaxKbdGroup		(XkbNumKbdGroups-1)

#define	XkbMaxMouseKeysBtn	4

    /*
     * Group Index and Mask:
     *  - Indices into the kt_index array of a key type.
     *  - Mask specifies types to be changed for XkbChangeTypesOfKey
     */
#define	XkbGroup1Index		0
#define	XkbGroup2Index		1
#define	XkbGroup3Index		2
#define	XkbGroup4Index		3
#define	XkbAnyGroup		254
#define	XkbAllGroups		255

#define	XkbGroup1Mask		(1<<0)
#define	XkbGroup2Mask		(1<<1)
#define	XkbGroup3Mask		(1<<2)
#define	XkbGroup4Mask		(1<<3)
#define	XkbAnyGroupMask		(1<<7)
#define	XkbAllGroupsMask	(0xf)

    /*
     * BuildCoreState: Given a keyboard group and a modifier state,
     *                 construct the value to be reported an event.
     * GroupForCoreState:  Given the state reported in an event,
     *                 determine the keyboard group.
     * IsLegalGroup:   Returns TRUE if 'g' is a valid group index.
     */
#define	XkbBuildCoreState(m,g)	((((g)&0x3)<<13)|((m)&0xff))
#define XkbGroupForCoreState(s)	(((s)>>13)&0x3)
#define	XkbIsLegalGroup(g)	(((g)>=0)&&((g)<XkbNumKbdGroups))

    /*
     * GroupsWrap values:
     *  - The 'groupsWrap' field of an XkbControlsRec specifies the
     *    treatment of out of range groups.
     *  - Bits 6 and 7 of the group info field of a key symbol map
     *    specify the interpretation of out of range groups for the
     *    corresponding key.
     */
#define	XkbWrapIntoRange	(0x00)
#define	XkbClampIntoRange	(0x40)
#define	XkbRedirectIntoRange	(0x80)

    /*
     * Action flags:  Reported in the 'flags' field of most key actions.
     * Interpretation depends on the type of the action; not all actions
     * accept all flags.
     *
     * Option			Used for Actions
     * ------			----------------
     * ClearLocks		SetMods, LatchMods, SetGroup, LatchGroup
     * LatchToLock		SetMods, LatchMods, SetGroup, LatchGroup
     * LockNoLock		LockMods, ISOLock, LockPtrBtn, LockDeviceBtn
     * LockNoUnlock		LockMods, ISOLock, LockPtrBtn, LockDeviceBtn
     * UseModMapMods		SetMods, LatchMods, LockMods, ISOLock
     * GroupAbsolute		SetGroup, LatchGroup, LockGroup, ISOLock
     * UseDfltButton		PtrBtn, LockPtrBtn
     * NoAcceleration		MovePtr
     * MoveAbsoluteX		MovePtr
     * MoveAbsoluteY		MovePtr
     * ISODfltIsGroup		ISOLock
     * ISONoAffectMods		ISOLock
     * ISONoAffectGroup		ISOLock
     * ISONoAffectPtr		ISOLock
     * ISONoAffectCtrls		ISOLock
     * MessageOnPress		ActionMessage
     * MessageOnRelease		ActionMessage
     * MessageGenKeyEvent	ActionMessage
     * AffectDfltBtn		SetPtrDflt
     * DfltBtnAbsolute		SetPtrDflt
     * SwitchApplication	SwitchScreen
     * SwitchAbsolute		SwitchScreen
     */

#define	XkbSA_ClearLocks	(1L << 0)
#define	XkbSA_LatchToLock	(1L << 1)

#define	XkbSA_LockNoLock	(1L << 0)
#define	XkbSA_LockNoUnlock	(1L << 1)

#define	XkbSA_UseModMapMods	(1L << 2)

#define	XkbSA_GroupAbsolute	(1L << 2)
#define	XkbSA_UseDfltButton	0

#define	XkbSA_NoAcceleration	(1L << 0)
#define	XkbSA_MoveAbsoluteX	(1L << 1)
#define	XkbSA_MoveAbsoluteY	(1L << 2)

#define	XkbSA_ISODfltIsGroup 	 (1L << 7)
#define	XkbSA_ISONoAffectMods	 (1L << 6)
#define	XkbSA_ISONoAffectGroup	 (1L << 5)
#define	XkbSA_ISONoAffectPtr	 (1L << 4)
#define	XkbSA_ISONoAffectCtrls	 (1L << 3)
#define	XkbSA_ISOAffectMask	 (0x78)

#define	XkbSA_MessageOnPress	 (1L << 0)
#define	XkbSA_MessageOnRelease	 (1L << 1)
#define	XkbSA_MessageGenKeyEvent (1L << 2)

#define	XkbSA_AffectDfltBtn	1
#define	XkbSA_DfltBtnAbsolute	(1L << 2)

#define	XkbSA_SwitchApplication	(1L << 0)
#define	XkbSA_SwitchAbsolute	(1L << 2)

    /*
     * The following values apply to the SA_DeviceValuator 
     * action only.  Valuator operations specify the action 
     * to be taken.   Values specified in the action are 
     * multiplied by 2^scale before they are applied.
     */
#define	XkbSA_IgnoreVal		(0x00)
#define	XkbSA_SetValMin		(0x10)
#define	XkbSA_SetValCenter	(0x20)
#define	XkbSA_SetValMax		(0x30)
#define	XkbSA_SetValRelative	(0x40)
#define	XkbSA_SetValAbsolute	(0x50)
#define	XkbSA_ValOpMask		(0x70)
#define	XkbSA_ValScaleMask	(0x07)
#define	XkbSA_ValOp(a)		((a)&XkbSA_ValOpMask)
#define	XkbSA_ValScale(a)	((a)&XkbSA_ValScaleMask)

    /*
     * Action types: specifies the type of a key action.  Reported in the
     * type field of all key actions.
     */
#define	XkbSA_NoAction		0x00
#define	XkbSA_SetMods		0x01
#define	XkbSA_LatchMods		0x02
#define	XkbSA_LockMods		0x03
#define	XkbSA_SetGroup		0x04
#define	XkbSA_LatchGroup	0x05
#define	XkbSA_LockGroup		0x06
#define	XkbSA_MovePtr		0x07
#define	XkbSA_PtrBtn		0x08
#define	XkbSA_LockPtrBtn	0x09
#define	XkbSA_SetPtrDflt	0x0a
#define	XkbSA_ISOLock		0x0b
#define	XkbSA_Terminate		0x0c
#define	XkbSA_SwitchScreen	0x0d
#define	XkbSA_SetControls	0x0e
#define	XkbSA_LockControls	0x0f
#define	XkbSA_ActionMessage	0x10
#define	XkbSA_RedirectKey	0x11
#define	XkbSA_DeviceBtn		0x12
#define	XkbSA_LockDeviceBtn	0x13
#define	XkbSA_DeviceValuator	0x14
#define	XkbSA_LastAction	XkbSA_DeviceValuator
#define	XkbSA_NumActions	(XkbSA_LastAction+1)

#define	XkbSA_XFree86Private	0x86

    /*
     * Specifies the key actions that clear latched groups or modifiers.
     */
#define	XkbSA_BreakLatch \
	((1<<XkbSA_NoAction)|(1<<XkbSA_PtrBtn)|(1<<XkbSA_LockPtrBtn)|\
	(1<<XkbSA_Terminate)|(1<<XkbSA_SwitchScreen)|(1<<XkbSA_SetControls)|\
	(1<<XkbSA_LockControls)|(1<<XkbSA_ActionMessage)|\
	(1<<XkbSA_RedirectKey)|(1<<XkbSA_DeviceBtn)|(1<<XkbSA_LockDeviceBtn))
	 
    /*
     * Macros to classify key actions
     */
#define	XkbIsModAction(a)	(((a)->type>=Xkb_SASetMods)&&((a)->type<=XkbSA_LockMods))
#define	XkbIsGroupAction(a)	(((a)->type>=XkbSA_SetGroup)&&((a)->type<=XkbSA_LockGroup))
#define	XkbIsPtrAction(a)	(((a)->type>=XkbSA_MovePtr)&&((a)->type<=XkbSA_SetPtrDflt))


    /*
     * Key Behavior Qualifier:
     *    KB_Permanent indicates that the behavior describes an unalterable
     *    characteristic of the keyboard, not an XKB software-simulation of
     *    the listed behavior.
     * Key Behavior Types:  
     *    Specifies the behavior of the underlying key.
     */
#define	XkbKB_Permanent		0x80
#define	XkbKB_OpMask		0x7f

#define	XkbKB_Default		0x00
#define	XkbKB_Lock		0x01
#define	XkbKB_RadioGroup	0x02
#define	XkbKB_Overlay1		0x03
#define	XkbKB_Overlay2		0x04

#define	XkbKB_RGAllowNone	0x80

    /*
     * Various macros which describe the range of legal keycodes.
     */
#define	XkbMinLegalKeyCode	8
#define	XkbMaxLegalKeyCode	255
#define	XkbMaxKeyCount		(XkbMaxLegalKeyCode-XkbMinLegalKeyCode+1)
#define	XkbPerKeyBitArraySize	((XkbMaxLegalKeyCode+1)/8)
/* Seems kinda silly to check that an unsigned char is <= 255... */
#define	XkbIsLegalKeycode(k)	((k)>=XkbMinLegalKeyCode)

    /*
     * Assorted constants and limits.
     */
#define	XkbNumModifiers		8
#define	XkbNumVirtualMods	16
#define	XkbNumIndicators	32
#define	XkbAllIndicatorsMask	(0xffffffff)
#define	XkbMaxRadioGroups	32
#define	XkbAllRadioGroupsMask	(0xffffffff)
#define	XkbMaxShiftLevel	63
#define	XkbMaxSymsPerKey	(XkbMaxShiftLevel*XkbNumKbdGroups)
#define	XkbRGMaxMembers		12
#define	XkbActionMessageLength	6
#define	XkbKeyNameLength	4
#define	XkbMaxRedirectCount	8

#define	XkbGeomPtsPerMM		10
#define	XkbGeomMaxColors	32
#define	XkbGeomMaxLabelColors	3
#define	XkbGeomMaxPriority	255

    /*
     * Key Type index and mask for the four standard key types.
     */
#define	XkbOneLevelIndex	0
#define	XkbTwoLevelIndex	1
#define	XkbAlphabeticIndex	2
#define	XkbKeypadIndex		3
#define	XkbLastRequiredType	XkbKeypadIndex
#define	XkbNumRequiredTypes	(XkbLastRequiredType+1)
#define	XkbMaxKeyTypes		255

#define	XkbOneLevelMask		(1<<0)
#define	XkbTwoLevelMask		(1<<1)
#define	XkbAlphabeticMask	(1<<2)
#define	XkbKeypadMask		(1<<3)
#define	XkbAllRequiredTypes	(0xf)

#define	XkbShiftLevel(n)	((n)-1)
#define	XkbShiftLevelMask(n)	(1<<((n)-1))

    /*
     * Extension name and version information
     */
#define	XkbName "XKEYBOARD"
#define	XkbMajorVersion	1
#define	XkbMinorVersion	0

    /*
     * Explicit map components:
     *  - Used in the 'explicit' field of an XkbServerMap.  Specifies
     *    the keyboard components that should _not_ be updated automatically
     *    in response to core protocol keyboard mapping requests.
     */
#define	XkbExplicitKeyTypesMask	  (0x0f)
#define	XkbExplicitKeyType1Mask	  (1<<0)
#define	XkbExplicitKeyType2Mask	  (1<<1)
#define	XkbExplicitKeyType3Mask	  (1<<2)
#define	XkbExplicitKeyType4Mask	  (1<<3)
#define	XkbExplicitInterpretMask  (1<<4)
#define	XkbExplicitAutoRepeatMask (1<<5)
#define	XkbExplicitBehaviorMask	  (1<<6)
#define	XkbExplicitVModMapMask	  (1<<7)
#define	XkbAllExplicitMask	  (0xff)

    /*
     * Map components masks:
     * Those in AllMapComponentsMask:
     *  - Specifies the individual fields to be loaded or changed for the
     *    GetMap and SetMap requests.
     * Those in ClientInfoMask:
     *  - Specifies the components to be allocated by XkbAllocClientMap.
     * Those in ServerInfoMask:
     *  - Specifies the components to be allocated by XkbAllocServerMap.
     */
#define	XkbKeyTypesMask		(1<<0)
#define	XkbKeySymsMask		(1<<1)
#define	XkbModifierMapMask	(1<<2)
#define	XkbExplicitComponentsMask (1<<3)
#define XkbKeyActionsMask	(1<<4)
#define	XkbKeyBehaviorsMask	(1<<5)
#define	XkbVirtualModsMask	(1<<6)
#define	XkbVirtualModMapMask	(1<<7)

#define	XkbAllClientInfoMask	(XkbKeyTypesMask|XkbKeySymsMask|XkbModifierMapMask)
#define	XkbAllServerInfoMask	(XkbExplicitComponentsMask|XkbKeyActionsMask|XkbKeyBehaviorsMask|XkbVirtualModsMask|XkbVirtualModMapMask)
#define	XkbAllMapComponentsMask	(XkbAllClientInfoMask|XkbAllServerInfoMask)

    /*
     * Symbol interpretations flags:
     *  - Used in the flags field of a symbol interpretation
     */
#define	XkbSI_AutoRepeat	(1<<0)
#define	XkbSI_LockingKey	(1<<1)

    /*
     * Symbol interpretations match specification:
     *  - Used in the match field of a symbol interpretation to specify 
     *    the conditions under which an interpretation is used.
     */
#define	XkbSI_LevelOneOnly	(0x80)
#define	XkbSI_OpMask		(0x7f)
#define	XkbSI_NoneOf		(0)
#define	XkbSI_AnyOfOrNone	(1)
#define	XkbSI_AnyOf		(2)
#define	XkbSI_AllOf		(3)
#define	XkbSI_Exactly		(4)

    /*
     * Indicator map flags:
     *  - Used in the flags field of an indicator map to indicate the
     *    conditions under which and indicator can be changed and the
     *    effects of changing the indicator.
     */
#define	XkbIM_NoExplicit	(1L << 7)
#define	XkbIM_NoAutomatic	(1L << 6)
#define	XkbIM_LEDDrivesKB	(1L << 5)

    /*
     * Indicator map component specifications:
     *  - Used by the 'which_groups' and 'which_mods' fields of an indicator
     *    map to specify which keyboard components should be used to drive
     *    the indicator.
     */
#define	XkbIM_UseBase		(1L << 0)
#define	XkbIM_UseLatched	(1L << 1)
#define	XkbIM_UseLocked		(1L << 2)
#define	XkbIM_UseEffective	(1L << 3)
#define	XkbIM_UseCompat		(1L << 4)

#define	XkbIM_UseNone	  0
#define	XkbIM_UseAnyGroup (XkbIM_UseBase|XkbIM_UseLatched|XkbIM_UseLocked\
                           |XkbIM_UseEffective)
#define	XkbIM_UseAnyMods  (XkbIM_UseAnyGroup|XkbIM_UseCompat)

    /*
     * Compatibility Map Compontents:
     *  - Specifies the components to be allocated in XkbAllocCompatMap.
     */
#define	XkbSymInterpMask	(1<<0)
#define	XkbGroupCompatMask	(1<<1)
#define	XkbAllCompatMask	(0x3)

    /*
     * Names component mask:
     *  - Specifies the names to be loaded or changed for the GetNames and
     *    SetNames requests.
     *  - Specifies the names that have changed in a NamesNotify event.
     *  - Specifies the names components to be allocated by XkbAllocNames.
     */
#define	XkbKeycodesNameMask	(1<<0)
#define	XkbGeometryNameMask	(1<<1)
#define	XkbSymbolsNameMask	(1<<2)
#define	XkbPhysSymbolsNameMask	(1<<3)
#define	XkbTypesNameMask	(1<<4)
#define	XkbCompatNameMask 	(1<<5)
#define	XkbKeyTypeNamesMask	(1<<6)
#define	XkbKTLevelNamesMask	(1<<7)
#define	XkbIndicatorNamesMask	(1<<8)
#define	XkbKeyNamesMask		(1<<9)
#define	XkbKeyAliasesMask	(1<<10)
#define	XkbVirtualModNamesMask	(1<<11)
#define	XkbGroupNamesMask	(1<<12)
#define	XkbRGNamesMask		(1<<13)
#define	XkbComponentNamesMask	(0x3f)
#define	XkbAllNamesMask		(0x3fff)

    /*
     * GetByName components:
     *  - Specifies desired or necessary components to GetKbdByName request.
     *  - Reports the components that were found in a GetKbdByNameReply
     */
#define	XkbGBN_TypesMask		(1L << 0)
#define	XkbGBN_CompatMapMask		(1L << 1)
#define	XkbGBN_ClientSymbolsMask	(1L << 2)
#define	XkbGBN_ServerSymbolsMask	(1L << 3)
#define	XkbGBN_SymbolsMask (XkbGBN_ClientSymbolsMask|XkbGBN_ServerSymbolsMask)
#define	XkbGBN_IndicatorMapMask		(1L << 4)
#define	XkbGBN_KeyNamesMask		(1L << 5)
#define	XkbGBN_GeometryMask		(1L << 6)
#define	XkbGBN_OtherNamesMask		(1L << 7)
#define	XkbGBN_AllComponentsMask	(0xff)

     /*
      * ListComponents flags
      */
#define	XkbLC_Hidden			(1L <<  0)
#define	XkbLC_Default			(1L <<  1)
#define	XkbLC_Partial			(1L <<  2)

#define	XkbLC_AlphanumericKeys		(1L <<  8)
#define	XkbLC_ModifierKeys		(1L <<  9)
#define	XkbLC_KeypadKeys		(1L << 10)
#define	XkbLC_FunctionKeys		(1L << 11)
#define	XkbLC_AlternateGroup		(1L << 12)

    /*
     * X Input Extension Interactions
     * - Specifies the possible interactions between XKB and the X input
     *   extension
     * - Used to request (XkbGetDeviceInfo) or change (XKbSetDeviceInfo)
     *   XKB information about an extension device.
     * - Reports the list of supported optional features in the reply to
     *   XkbGetDeviceInfo or in an XkbExtensionDeviceNotify event.
     * XkbXI_UnsupportedFeature is reported in XkbExtensionDeviceNotify
     * events to indicate an attempt to use an unsupported feature.
     */
#define	XkbXI_KeyboardsMask		(1L << 0)
#define	XkbXI_ButtonActionsMask		(1L << 1)
#define	XkbXI_IndicatorNamesMask	(1L << 2)
#define	XkbXI_IndicatorMapsMask		(1L << 3)
#define	XkbXI_IndicatorStateMask	(1L << 4)
#define	XkbXI_UnsupportedFeatureMask	(1L << 15)
#define	XkbXI_AllFeaturesMask		(0x001f)
#define	XkbXI_AllDeviceFeaturesMask	(0x001e)

#define	XkbXI_IndicatorsMask		(0x001c)
#define	XkbAllExtensionDeviceEventsMask (0x801f)

    /*
     * Per-Client Flags:
     *  - Specifies flags to be changed by the PerClientFlags request.
     */
#define	XkbPCF_DetectableAutoRepeatMask	(1L << 0)
#define	XkbPCF_GrabsUseXKBStateMask	(1L << 1)
#define	XkbPCF_AutoResetControlsMask	(1L << 2)
#define	XkbPCF_LookupStateWhenGrabbed	(1L << 3)
#define	XkbPCF_SendEventUsesXKBState	(1L << 4)
#define	XkbPCF_AllFlagsMask		(0x1F)

    /*
     * Debugging flags and controls
     */
#define	XkbDF_DisableLocks	(1<<0)

#endif /* _XKB_H_ */