Git init
[framework/uifw/xorg/proto/x11proto-kb.git] / XKB.h
1 /* $Xorg: XKB.h,v 1.3 2000/08/18 04:05:45 coskrey Exp $ */
2 /************************************************************
3 Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
4
5 Permission to use, copy, modify, and distribute this
6 software and its documentation for any purpose and without
7 fee is hereby granted, provided that the above copyright
8 notice appear in all copies and that both that copyright
9 notice and this permission notice appear in supporting
10 documentation, and that the name of Silicon Graphics not be 
11 used in advertising or publicity pertaining to distribution 
12 of the software without specific prior written permission.
13 Silicon Graphics makes no representation about the suitability 
14 of this software for any purpose. It is provided "as is"
15 without any express or implied warranty.
16
17 SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
18 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
19 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
20 GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
21 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
22 DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
23 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
24 THE USE OR PERFORMANCE OF THIS SOFTWARE.
25
26 ********************************************************/
27 /* $XFree86: xc/include/extensions/XKB.h,v 1.5tsi Exp $ */
28
29 #ifndef _XKB_H_
30 #define _XKB_H_
31
32     /*
33      * XKB request codes, used in:
34      *  -  xkbReqType field of all requests
35      *  -  requestMinor field of some events
36      */
37 #define X_kbUseExtension                 0
38 #define X_kbSelectEvents                 1
39 #define X_kbBell                         3
40 #define X_kbGetState                     4
41 #define X_kbLatchLockState               5
42 #define X_kbGetControls                  6
43 #define X_kbSetControls                  7
44 #define X_kbGetMap                       8
45 #define X_kbSetMap                       9
46 #define X_kbGetCompatMap                10
47 #define X_kbSetCompatMap                11
48 #define X_kbGetIndicatorState           12
49 #define X_kbGetIndicatorMap             13
50 #define X_kbSetIndicatorMap             14
51 #define X_kbGetNamedIndicator           15
52 #define X_kbSetNamedIndicator           16
53 #define X_kbGetNames                    17
54 #define X_kbSetNames                    18
55 #define X_kbGetGeometry                 19
56 #define X_kbSetGeometry                 20
57 #define X_kbPerClientFlags              21
58 #define X_kbListComponents              22
59 #define X_kbGetKbdByName                23
60 #define X_kbGetDeviceInfo               24
61 #define X_kbSetDeviceInfo               25
62 #define X_kbSetDebuggingFlags           101
63
64     /*
65      * In the X sense, XKB reports only one event.
66      * The type field of all XKB events is XkbEventCode
67      */
68 #define XkbEventCode                    0
69 #define XkbNumberEvents                 (XkbEventCode+1)
70
71     /*
72      * XKB has a minor event code so it can use one X event code for 
73      * multiple purposes.  
74      *  - reported in the xkbType field of all XKB events.
75      *  - XkbSelectEventDetails: Indicates the event for which event details 
76      *    are being changed
77      */
78 #define XkbNewKeyboardNotify            0
79 #define XkbMapNotify                    1
80 #define XkbStateNotify                  2
81 #define XkbControlsNotify               3
82 #define XkbIndicatorStateNotify         4
83 #define XkbIndicatorMapNotify           5
84 #define XkbNamesNotify                  6
85 #define XkbCompatMapNotify              7
86 #define XkbBellNotify                   8
87 #define XkbActionMessage                9
88 #define XkbAccessXNotify                10
89 #define XkbExtensionDeviceNotify        11
90
91     /*
92      * Event Mask:
93      *  - XkbSelectEvents:  Specifies event interest.
94      */
95 #define XkbNewKeyboardNotifyMask        (1L << 0)
96 #define XkbMapNotifyMask                (1L << 1)
97 #define XkbStateNotifyMask              (1L << 2)
98 #define XkbControlsNotifyMask           (1L << 3)
99 #define XkbIndicatorStateNotifyMask     (1L << 4)
100 #define XkbIndicatorMapNotifyMask       (1L << 5)
101 #define XkbNamesNotifyMask              (1L << 6)
102 #define XkbCompatMapNotifyMask          (1L << 7)
103 #define XkbBellNotifyMask               (1L << 8)
104 #define XkbActionMessageMask            (1L << 9)
105 #define XkbAccessXNotifyMask            (1L << 10)
106 #define XkbExtensionDeviceNotifyMask    (1L << 11)
107 #define XkbAllEventsMask                (0xFFF)
108
109     /*
110      * NewKeyboardNotify event details:
111      */
112 #define XkbNKN_KeycodesMask             (1L << 0)
113 #define XkbNKN_GeometryMask             (1L << 1)
114 #define XkbNKN_DeviceIDMask             (1L << 2)
115 #define XkbAllNewKeyboardEventsMask     (0x7)
116
117     /*
118      * AccessXNotify event types:
119      *  - The 'what' field of AccessXNotify events reports the
120      *    reason that the event was generated.
121      */
122 #define XkbAXN_SKPress                  0
123 #define XkbAXN_SKAccept                 1
124 #define XkbAXN_SKReject                 2
125 #define XkbAXN_SKRelease                3
126 #define XkbAXN_BKAccept                 4
127 #define XkbAXN_BKReject                 5
128 #define XkbAXN_AXKWarning               6
129
130     /*
131      * AccessXNotify details:
132      * - Used as an event detail mask to limit the conditions under which
133      *   AccessXNotify events are reported
134      */
135 #define XkbAXN_SKPressMask              (1L << 0)
136 #define XkbAXN_SKAcceptMask             (1L << 1)
137 #define XkbAXN_SKRejectMask             (1L << 2)
138 #define XkbAXN_SKReleaseMask            (1L << 3)
139 #define XkbAXN_BKAcceptMask             (1L << 4)
140 #define XkbAXN_BKRejectMask             (1L << 5)
141 #define XkbAXN_AXKWarningMask           (1L << 6)
142 #define XkbAllAccessXEventsMask         (0x7f)
143
144     /*
145      * Miscellaneous event details:
146      * - event detail masks for assorted events that don't reall
147      *   have any details.
148      */
149 #define XkbAllStateEventsMask           XkbAllStateComponentsMask
150 #define XkbAllMapEventsMask             XkbAllMapComponentsMask
151 #define XkbAllControlEventsMask         XkbAllControlsMask
152 #define XkbAllIndicatorEventsMask       XkbAllIndicatorsMask
153 #define XkbAllNameEventsMask            XkbAllNamesMask
154 #define XkbAllCompatMapEventsMask       XkbAllCompatMask
155 #define XkbAllBellEventsMask            (1L << 0)
156 #define XkbAllActionMessagesMask        (1L << 0)
157
158     /*
159      * XKB reports one error:  BadKeyboard
160      * A further reason for the error is encoded into to most significant
161      * byte of the resourceID for the error:
162      *    XkbErr_BadDevice - the device in question was not found
163      *    XkbErr_BadClass  - the device was found but it doesn't belong to 
164      *                       the appropriate class.
165      *    XkbErr_BadId     - the device was found and belongs to the right
166      *                       class, but not feedback with a matching id was
167      *                       found.
168      * The low byte of the resourceID for this error contains the device
169      * id, class specifier or feedback id that failed.
170      */
171 #define XkbKeyboard                     0
172 #define XkbNumberErrors                 1
173
174 #define XkbErr_BadDevice        0xff
175 #define XkbErr_BadClass         0xfe
176 #define XkbErr_BadId            0xfd
177
178     /*
179      * Keyboard Components Mask:
180      * - Specifies the components that follow a GetKeyboardByNameReply
181      */
182 #define XkbClientMapMask                (1L << 0)
183 #define XkbServerMapMask                (1L << 1)
184 #define XkbCompatMapMask                (1L << 2)
185 #define XkbIndicatorMapMask             (1L << 3)
186 #define XkbNamesMask                    (1L << 4)
187 #define XkbGeometryMask                 (1L << 5)
188 #define XkbControlsMask                 (1L << 6)
189 #define XkbAllComponentsMask            (0x7f)
190
191     /*
192      * State detail mask:
193      *  - The 'changed' field of StateNotify events reports which of
194      *    the keyboard state components have changed.
195      *  - Used as an event detail mask to limit the conditions under
196      *    which StateNotify events are reported.
197      */
198 #define XkbModifierStateMask            (1L << 0)
199 #define XkbModifierBaseMask             (1L << 1)
200 #define XkbModifierLatchMask            (1L << 2)
201 #define XkbModifierLockMask             (1L << 3)
202 #define XkbGroupStateMask               (1L << 4)
203 #define XkbGroupBaseMask                (1L << 5)
204 #define XkbGroupLatchMask               (1L << 6)
205 #define XkbGroupLockMask                (1L << 7)
206 #define XkbCompatStateMask              (1L << 8)
207 #define XkbGrabModsMask                 (1L << 9)
208 #define XkbCompatGrabModsMask           (1L << 10)
209 #define XkbLookupModsMask               (1L << 11)
210 #define XkbCompatLookupModsMask         (1L << 12)
211 #define XkbPointerButtonMask            (1L << 13)
212 #define XkbAllStateComponentsMask       (0x3fff)
213
214     /*
215      * Controls detail masks:
216      *  The controls specified in XkbAllControlsMask:
217      *  - The 'changed' field of ControlsNotify events reports which of 
218      *    the keyboard controls have changed.
219      *  - The 'changeControls' field of the SetControls request specifies
220      *    the controls for which values are to be changed.
221      *  - Used as an event detail mask to limit the conditions under 
222      *    which ControlsNotify events are reported.
223      *
224      *  The controls specified in the XkbAllBooleanCtrlsMask:
225      *  - The 'enabledControls' field of ControlsNotify events reports the
226      *    current status of the boolean controls.
227      *  - The 'enabledControlsChanges' field of ControlsNotify events reports
228      *    any boolean controls that have been turned on or off.
229      *  - The 'affectEnabledControls' and 'enabledControls' fields of the
230      *    kbSetControls request change the set of enabled controls.
231      *  - The 'accessXTimeoutMask' and 'accessXTimeoutValues' fields of
232      *    an XkbControlsRec specify the controls to be changed if the keyboard
233      *    times out and the values to which they should be changed.
234      *  - The 'autoCtrls' and 'autoCtrlsValues' fields of the PerClientFlags 
235      *    request specifies the specify the controls to be reset when the
236      *    client exits and the values to which they should be reset.
237      *  - The 'ctrls' field of an indicator map specifies the controls
238      *    that drive the indicator.
239      *  - Specifies the boolean controls affected by the SetControls and
240      *    LockControls key actions.
241      */
242 #define XkbRepeatKeysMask        (1L << 0)
243 #define XkbSlowKeysMask          (1L << 1)
244 #define XkbBounceKeysMask        (1L << 2)
245 #define XkbStickyKeysMask        (1L << 3)
246 #define XkbMouseKeysMask         (1L << 4)
247 #define XkbMouseKeysAccelMask    (1L << 5)
248 #define XkbAccessXKeysMask       (1L << 6)
249 #define XkbAccessXTimeoutMask    (1L << 7)
250 #define XkbAccessXFeedbackMask   (1L << 8)
251 #define XkbAudibleBellMask       (1L << 9)
252 #define XkbOverlay1Mask          (1L << 10)
253 #define XkbOverlay2Mask          (1L << 11)
254 #define XkbIgnoreGroupLockMask   (1L << 12)
255 #define XkbGroupsWrapMask        (1L << 27)
256 #define XkbInternalModsMask      (1L << 28)
257 #define XkbIgnoreLockModsMask    (1L << 29)
258 #define XkbPerKeyRepeatMask      (1L << 30)
259 #define XkbControlsEnabledMask   (1L << 31)
260
261 #define XkbAccessXOptionsMask    (XkbStickyKeysMask|XkbAccessXFeedbackMask)
262
263 #define XkbAllBooleanCtrlsMask   (0x00001FFF)
264 #define XkbAllControlsMask       (0xF8001FFF)
265 #define XkbAllControlEventsMask  XkbAllControlsMask
266
267     /*
268      * AccessX Options Mask
269      *  - The 'accessXOptions' field of an XkbControlsRec specifies the
270      *    AccessX options that are currently in effect.
271      *  - The 'accessXTimeoutOptionsMask' and 'accessXTimeoutOptionsValues'
272      *    fields of an XkbControlsRec specify the Access X options to be 
273      *    changed if the keyboard times out and the values to which they 
274      *    should be changed.
275      */
276 #define XkbAX_SKPressFBMask     (1L << 0)
277 #define XkbAX_SKAcceptFBMask    (1L << 1)
278 #define XkbAX_FeatureFBMask     (1L << 2)
279 #define XkbAX_SlowWarnFBMask    (1L << 3)
280 #define XkbAX_IndicatorFBMask   (1L << 4)
281 #define XkbAX_StickyKeysFBMask  (1L << 5)
282 #define XkbAX_TwoKeysMask       (1L << 6)
283 #define XkbAX_LatchToLockMask   (1L << 7)
284 #define XkbAX_SKReleaseFBMask   (1L << 8)
285 #define XkbAX_SKRejectFBMask    (1L << 9)
286 #define XkbAX_BKRejectFBMask    (1L << 10)
287 #define XkbAX_DumbBellFBMask    (1L << 11)
288 #define XkbAX_FBOptionsMask     (0xF3F)
289 #define XkbAX_SKOptionsMask     (0x0C0)
290 #define XkbAX_AllOptionsMask    (0xFFF)
291
292     /*
293      * XkbUseCoreKbd is used to specify the core keyboard without having
294      *                  to look up its X input extension identifier.
295      * XkbUseCorePtr is used to specify the core pointer without having
296      *                  to look up its X input extension identifier.
297      * XkbDfltXIClass is used to specify "don't care" any place that the
298      *                  XKB protocol is looking for an X Input Extension 
299      *                  device class.
300      * XkbDfltXIId is used to specify "don't care" any place that the
301      *                  XKB protocol is looking for an X Input Extension
302      *                  feedback identifier.
303      * XkbAllXIClasses is used to get information about all device indicators,
304      *                  whether they're part of the indicator feedback class
305      *                  or the keyboard feedback class.
306      * XkbAllXIIds is used to get information about all device indicator
307      *                  feedbacks without having to list them.
308      * XkbXINone is used to indicate that no class or id has been specified.
309      * XkbLegalXILedClass(c)  True if 'c' specifies a legal class with LEDs
310      * XkbLegalXIBellClass(c) True if 'c' specifies a legal class with bells
311      * XkbExplicitXIDevice(d) True if 'd' explicitly specifies a device
312      * XkbExplicitXIClass(c)  True if 'c' explicitly specifies a device class
313      * XkbExplicitXIId(c)     True if 'i' explicitly specifies a device id
314      * XkbSingleXIClass(c)    True if 'c' specifies exactly one device class, 
315      *                        including the default.
316      * XkbSingleXIId(i)       True if 'i' specifies exactly one device 
317      *                        identifier, including the default.
318      */
319 #define XkbUseCoreKbd           0x0100
320 #define XkbUseCorePtr           0x0200
321 #define XkbDfltXIClass          0x0300
322 #define XkbDfltXIId             0x0400
323 #define XkbAllXIClasses         0x0500
324 #define XkbAllXIIds             0x0600
325 #define XkbXINone               0xff00
326
327 #define XkbLegalXILedClass(c)   (((c)==KbdFeedbackClass)||\
328                                         ((c)==LedFeedbackClass)||\
329                                         ((c)==XkbDfltXIClass)||\
330                                         ((c)==XkbAllXIClasses))
331 #define XkbLegalXIBellClass(c)  (((c)==KbdFeedbackClass)||\
332                                         ((c)==BellFeedbackClass)||\
333                                         ((c)==XkbDfltXIClass)||\
334                                         ((c)==XkbAllXIClasses))
335 #define XkbExplicitXIDevice(c)  (((c)&(~0xff))==0)
336 #define XkbExplicitXIClass(c)   (((c)&(~0xff))==0)
337 #define XkbExplicitXIId(c)      (((c)&(~0xff))==0)
338 #define XkbSingleXIClass(c)     ((((c)&(~0xff))==0)||((c)==XkbDfltXIClass))
339 #define XkbSingleXIId(c)        ((((c)&(~0xff))==0)||((c)==XkbDfltXIId))
340
341 #define XkbNoModifier           0xff
342 #define XkbNoShiftLevel         0xff
343 #define XkbNoShape              0xff
344 #define XkbNoIndicator          0xff
345
346 #define XkbNoModifierMask       0
347 #define XkbAllModifiersMask     0xff
348 #define XkbAllVirtualModsMask   0xffff
349
350 #define XkbNumKbdGroups         4
351 #define XkbMaxKbdGroup          (XkbNumKbdGroups-1)
352
353 #define XkbMaxMouseKeysBtn      4
354
355     /*
356      * Group Index and Mask:
357      *  - Indices into the kt_index array of a key type.
358      *  - Mask specifies types to be changed for XkbChangeTypesOfKey
359      */
360 #define XkbGroup1Index          0
361 #define XkbGroup2Index          1
362 #define XkbGroup3Index          2
363 #define XkbGroup4Index          3
364 #define XkbAnyGroup             254
365 #define XkbAllGroups            255
366
367 #define XkbGroup1Mask           (1<<0)
368 #define XkbGroup2Mask           (1<<1)
369 #define XkbGroup3Mask           (1<<2)
370 #define XkbGroup4Mask           (1<<3)
371 #define XkbAnyGroupMask         (1<<7)
372 #define XkbAllGroupsMask        (0xf)
373
374     /*
375      * BuildCoreState: Given a keyboard group and a modifier state,
376      *                 construct the value to be reported an event.
377      * GroupForCoreState:  Given the state reported in an event,
378      *                 determine the keyboard group.
379      * IsLegalGroup:   Returns TRUE if 'g' is a valid group index.
380      */
381 #define XkbBuildCoreState(m,g)  ((((g)&0x3)<<13)|((m)&0xff))
382 #define XkbGroupForCoreState(s) (((s)>>13)&0x3)
383 #define XkbIsLegalGroup(g)      (((g)>=0)&&((g)<XkbNumKbdGroups))
384
385     /*
386      * GroupsWrap values:
387      *  - The 'groupsWrap' field of an XkbControlsRec specifies the
388      *    treatment of out of range groups.
389      *  - Bits 6 and 7 of the group info field of a key symbol map
390      *    specify the interpretation of out of range groups for the
391      *    corresponding key.
392      */
393 #define XkbWrapIntoRange        (0x00)
394 #define XkbClampIntoRange       (0x40)
395 #define XkbRedirectIntoRange    (0x80)
396
397     /*
398      * Action flags:  Reported in the 'flags' field of most key actions.
399      * Interpretation depends on the type of the action; not all actions
400      * accept all flags.
401      *
402      * Option                   Used for Actions
403      * ------                   ----------------
404      * ClearLocks               SetMods, LatchMods, SetGroup, LatchGroup
405      * LatchToLock              SetMods, LatchMods, SetGroup, LatchGroup
406      * LockNoLock               LockMods, ISOLock, LockPtrBtn, LockDeviceBtn
407      * LockNoUnlock             LockMods, ISOLock, LockPtrBtn, LockDeviceBtn
408      * UseModMapMods            SetMods, LatchMods, LockMods, ISOLock
409      * GroupAbsolute            SetGroup, LatchGroup, LockGroup, ISOLock
410      * UseDfltButton            PtrBtn, LockPtrBtn
411      * NoAcceleration           MovePtr
412      * MoveAbsoluteX            MovePtr
413      * MoveAbsoluteY            MovePtr
414      * ISODfltIsGroup           ISOLock
415      * ISONoAffectMods          ISOLock
416      * ISONoAffectGroup         ISOLock
417      * ISONoAffectPtr           ISOLock
418      * ISONoAffectCtrls         ISOLock
419      * MessageOnPress           ActionMessage
420      * MessageOnRelease         ActionMessage
421      * MessageGenKeyEvent       ActionMessage
422      * AffectDfltBtn            SetPtrDflt
423      * DfltBtnAbsolute          SetPtrDflt
424      * SwitchApplication        SwitchScreen
425      * SwitchAbsolute           SwitchScreen
426      */
427
428 #define XkbSA_ClearLocks        (1L << 0)
429 #define XkbSA_LatchToLock       (1L << 1)
430
431 #define XkbSA_LockNoLock        (1L << 0)
432 #define XkbSA_LockNoUnlock      (1L << 1)
433
434 #define XkbSA_UseModMapMods     (1L << 2)
435
436 #define XkbSA_GroupAbsolute     (1L << 2)
437 #define XkbSA_UseDfltButton     0
438
439 #define XkbSA_NoAcceleration    (1L << 0)
440 #define XkbSA_MoveAbsoluteX     (1L << 1)
441 #define XkbSA_MoveAbsoluteY     (1L << 2)
442
443 #define XkbSA_ISODfltIsGroup     (1L << 7)
444 #define XkbSA_ISONoAffectMods    (1L << 6)
445 #define XkbSA_ISONoAffectGroup   (1L << 5)
446 #define XkbSA_ISONoAffectPtr     (1L << 4)
447 #define XkbSA_ISONoAffectCtrls   (1L << 3)
448 #define XkbSA_ISOAffectMask      (0x78)
449
450 #define XkbSA_MessageOnPress     (1L << 0)
451 #define XkbSA_MessageOnRelease   (1L << 1)
452 #define XkbSA_MessageGenKeyEvent (1L << 2)
453
454 #define XkbSA_AffectDfltBtn     1
455 #define XkbSA_DfltBtnAbsolute   (1L << 2)
456
457 #define XkbSA_SwitchApplication (1L << 0)
458 #define XkbSA_SwitchAbsolute    (1L << 2)
459
460     /*
461      * The following values apply to the SA_DeviceValuator 
462      * action only.  Valuator operations specify the action 
463      * to be taken.   Values specified in the action are 
464      * multiplied by 2^scale before they are applied.
465      */
466 #define XkbSA_IgnoreVal         (0x00)
467 #define XkbSA_SetValMin         (0x10)
468 #define XkbSA_SetValCenter      (0x20)
469 #define XkbSA_SetValMax         (0x30)
470 #define XkbSA_SetValRelative    (0x40)
471 #define XkbSA_SetValAbsolute    (0x50)
472 #define XkbSA_ValOpMask         (0x70)
473 #define XkbSA_ValScaleMask      (0x07)
474 #define XkbSA_ValOp(a)          ((a)&XkbSA_ValOpMask)
475 #define XkbSA_ValScale(a)       ((a)&XkbSA_ValScaleMask)
476
477     /*
478      * Action types: specifies the type of a key action.  Reported in the
479      * type field of all key actions.
480      */
481 #define XkbSA_NoAction          0x00
482 #define XkbSA_SetMods           0x01
483 #define XkbSA_LatchMods         0x02
484 #define XkbSA_LockMods          0x03
485 #define XkbSA_SetGroup          0x04
486 #define XkbSA_LatchGroup        0x05
487 #define XkbSA_LockGroup         0x06
488 #define XkbSA_MovePtr           0x07
489 #define XkbSA_PtrBtn            0x08
490 #define XkbSA_LockPtrBtn        0x09
491 #define XkbSA_SetPtrDflt        0x0a
492 #define XkbSA_ISOLock           0x0b
493 #define XkbSA_Terminate         0x0c
494 #define XkbSA_SwitchScreen      0x0d
495 #define XkbSA_SetControls       0x0e
496 #define XkbSA_LockControls      0x0f
497 #define XkbSA_ActionMessage     0x10
498 #define XkbSA_RedirectKey       0x11
499 #define XkbSA_DeviceBtn         0x12
500 #define XkbSA_LockDeviceBtn     0x13
501 #define XkbSA_DeviceValuator    0x14
502 #define XkbSA_LastAction        XkbSA_DeviceValuator
503 #define XkbSA_NumActions        (XkbSA_LastAction+1)
504
505 #define XkbSA_XFree86Private    0x86
506
507     /*
508      * Specifies the key actions that clear latched groups or modifiers.
509      */
510 #define XkbSA_BreakLatch \
511         ((1<<XkbSA_NoAction)|(1<<XkbSA_PtrBtn)|(1<<XkbSA_LockPtrBtn)|\
512         (1<<XkbSA_Terminate)|(1<<XkbSA_SwitchScreen)|(1<<XkbSA_SetControls)|\
513         (1<<XkbSA_LockControls)|(1<<XkbSA_ActionMessage)|\
514         (1<<XkbSA_RedirectKey)|(1<<XkbSA_DeviceBtn)|(1<<XkbSA_LockDeviceBtn))
515          
516     /*
517      * Macros to classify key actions
518      */
519 #define XkbIsModAction(a)       (((a)->type>=Xkb_SASetMods)&&((a)->type<=XkbSA_LockMods))
520 #define XkbIsGroupAction(a)     (((a)->type>=XkbSA_SetGroup)&&((a)->type<=XkbSA_LockGroup))
521 #define XkbIsPtrAction(a)       (((a)->type>=XkbSA_MovePtr)&&((a)->type<=XkbSA_SetPtrDflt))
522
523
524     /*
525      * Key Behavior Qualifier:
526      *    KB_Permanent indicates that the behavior describes an unalterable
527      *    characteristic of the keyboard, not an XKB software-simulation of
528      *    the listed behavior.
529      * Key Behavior Types:  
530      *    Specifies the behavior of the underlying key.
531      */
532 #define XkbKB_Permanent         0x80
533 #define XkbKB_OpMask            0x7f
534
535 #define XkbKB_Default           0x00
536 #define XkbKB_Lock              0x01
537 #define XkbKB_RadioGroup        0x02
538 #define XkbKB_Overlay1          0x03
539 #define XkbKB_Overlay2          0x04
540
541 #define XkbKB_RGAllowNone       0x80
542
543     /*
544      * Various macros which describe the range of legal keycodes.
545      */
546 #define XkbMinLegalKeyCode      8
547 #define XkbMaxLegalKeyCode      255
548 #define XkbMaxKeyCount          (XkbMaxLegalKeyCode-XkbMinLegalKeyCode+1)
549 #define XkbPerKeyBitArraySize   ((XkbMaxLegalKeyCode+1)/8)
550 /* Seems kinda silly to check that an unsigned char is <= 255... */
551 #define XkbIsLegalKeycode(k)    ((k)>=XkbMinLegalKeyCode)
552
553     /*
554      * Assorted constants and limits.
555      */
556 #define XkbNumModifiers         8
557 #define XkbNumVirtualMods       16
558 #define XkbNumIndicators        32
559 #define XkbAllIndicatorsMask    (0xffffffff)
560 #define XkbMaxRadioGroups       32
561 #define XkbAllRadioGroupsMask   (0xffffffff)
562 #define XkbMaxShiftLevel        63
563 #define XkbMaxSymsPerKey        (XkbMaxShiftLevel*XkbNumKbdGroups)
564 #define XkbRGMaxMembers         12
565 #define XkbActionMessageLength  6
566 #define XkbKeyNameLength        4
567 #define XkbMaxRedirectCount     8
568
569 #define XkbGeomPtsPerMM         10
570 #define XkbGeomMaxColors        32
571 #define XkbGeomMaxLabelColors   3
572 #define XkbGeomMaxPriority      255
573
574     /*
575      * Key Type index and mask for the four standard key types.
576      */
577 #define XkbOneLevelIndex        0
578 #define XkbTwoLevelIndex        1
579 #define XkbAlphabeticIndex      2
580 #define XkbKeypadIndex          3
581 #define XkbLastRequiredType     XkbKeypadIndex
582 #define XkbNumRequiredTypes     (XkbLastRequiredType+1)
583 #define XkbMaxKeyTypes          255
584
585 #define XkbOneLevelMask         (1<<0)
586 #define XkbTwoLevelMask         (1<<1)
587 #define XkbAlphabeticMask       (1<<2)
588 #define XkbKeypadMask           (1<<3)
589 #define XkbAllRequiredTypes     (0xf)
590
591 #define XkbShiftLevel(n)        ((n)-1)
592 #define XkbShiftLevelMask(n)    (1<<((n)-1))
593
594     /*
595      * Extension name and version information
596      */
597 #define XkbName "XKEYBOARD"
598 #define XkbMajorVersion 1
599 #define XkbMinorVersion 0
600
601     /*
602      * Explicit map components:
603      *  - Used in the 'explicit' field of an XkbServerMap.  Specifies
604      *    the keyboard components that should _not_ be updated automatically
605      *    in response to core protocol keyboard mapping requests.
606      */
607 #define XkbExplicitKeyTypesMask   (0x0f)
608 #define XkbExplicitKeyType1Mask   (1<<0)
609 #define XkbExplicitKeyType2Mask   (1<<1)
610 #define XkbExplicitKeyType3Mask   (1<<2)
611 #define XkbExplicitKeyType4Mask   (1<<3)
612 #define XkbExplicitInterpretMask  (1<<4)
613 #define XkbExplicitAutoRepeatMask (1<<5)
614 #define XkbExplicitBehaviorMask   (1<<6)
615 #define XkbExplicitVModMapMask    (1<<7)
616 #define XkbAllExplicitMask        (0xff)
617
618     /*
619      * Map components masks:
620      * Those in AllMapComponentsMask:
621      *  - Specifies the individual fields to be loaded or changed for the
622      *    GetMap and SetMap requests.
623      * Those in ClientInfoMask:
624      *  - Specifies the components to be allocated by XkbAllocClientMap.
625      * Those in ServerInfoMask:
626      *  - Specifies the components to be allocated by XkbAllocServerMap.
627      */
628 #define XkbKeyTypesMask         (1<<0)
629 #define XkbKeySymsMask          (1<<1)
630 #define XkbModifierMapMask      (1<<2)
631 #define XkbExplicitComponentsMask (1<<3)
632 #define XkbKeyActionsMask       (1<<4)
633 #define XkbKeyBehaviorsMask     (1<<5)
634 #define XkbVirtualModsMask      (1<<6)
635 #define XkbVirtualModMapMask    (1<<7)
636
637 #define XkbAllClientInfoMask    (XkbKeyTypesMask|XkbKeySymsMask|XkbModifierMapMask)
638 #define XkbAllServerInfoMask    (XkbExplicitComponentsMask|XkbKeyActionsMask|XkbKeyBehaviorsMask|XkbVirtualModsMask|XkbVirtualModMapMask)
639 #define XkbAllMapComponentsMask (XkbAllClientInfoMask|XkbAllServerInfoMask)
640
641     /*
642      * Symbol interpretations flags:
643      *  - Used in the flags field of a symbol interpretation
644      */
645 #define XkbSI_AutoRepeat        (1<<0)
646 #define XkbSI_LockingKey        (1<<1)
647
648     /*
649      * Symbol interpretations match specification:
650      *  - Used in the match field of a symbol interpretation to specify 
651      *    the conditions under which an interpretation is used.
652      */
653 #define XkbSI_LevelOneOnly      (0x80)
654 #define XkbSI_OpMask            (0x7f)
655 #define XkbSI_NoneOf            (0)
656 #define XkbSI_AnyOfOrNone       (1)
657 #define XkbSI_AnyOf             (2)
658 #define XkbSI_AllOf             (3)
659 #define XkbSI_Exactly           (4)
660
661     /*
662      * Indicator map flags:
663      *  - Used in the flags field of an indicator map to indicate the
664      *    conditions under which and indicator can be changed and the
665      *    effects of changing the indicator.
666      */
667 #define XkbIM_NoExplicit        (1L << 7)
668 #define XkbIM_NoAutomatic       (1L << 6)
669 #define XkbIM_LEDDrivesKB       (1L << 5)
670
671     /*
672      * Indicator map component specifications:
673      *  - Used by the 'which_groups' and 'which_mods' fields of an indicator
674      *    map to specify which keyboard components should be used to drive
675      *    the indicator.
676      */
677 #define XkbIM_UseBase           (1L << 0)
678 #define XkbIM_UseLatched        (1L << 1)
679 #define XkbIM_UseLocked         (1L << 2)
680 #define XkbIM_UseEffective      (1L << 3)
681 #define XkbIM_UseCompat         (1L << 4)
682
683 #define XkbIM_UseNone     0
684 #define XkbIM_UseAnyGroup (XkbIM_UseBase|XkbIM_UseLatched|XkbIM_UseLocked\
685                            |XkbIM_UseEffective)
686 #define XkbIM_UseAnyMods  (XkbIM_UseAnyGroup|XkbIM_UseCompat)
687
688     /*
689      * Compatibility Map Compontents:
690      *  - Specifies the components to be allocated in XkbAllocCompatMap.
691      */
692 #define XkbSymInterpMask        (1<<0)
693 #define XkbGroupCompatMask      (1<<1)
694 #define XkbAllCompatMask        (0x3)
695
696     /*
697      * Names component mask:
698      *  - Specifies the names to be loaded or changed for the GetNames and
699      *    SetNames requests.
700      *  - Specifies the names that have changed in a NamesNotify event.
701      *  - Specifies the names components to be allocated by XkbAllocNames.
702      */
703 #define XkbKeycodesNameMask     (1<<0)
704 #define XkbGeometryNameMask     (1<<1)
705 #define XkbSymbolsNameMask      (1<<2)
706 #define XkbPhysSymbolsNameMask  (1<<3)
707 #define XkbTypesNameMask        (1<<4)
708 #define XkbCompatNameMask       (1<<5)
709 #define XkbKeyTypeNamesMask     (1<<6)
710 #define XkbKTLevelNamesMask     (1<<7)
711 #define XkbIndicatorNamesMask   (1<<8)
712 #define XkbKeyNamesMask         (1<<9)
713 #define XkbKeyAliasesMask       (1<<10)
714 #define XkbVirtualModNamesMask  (1<<11)
715 #define XkbGroupNamesMask       (1<<12)
716 #define XkbRGNamesMask          (1<<13)
717 #define XkbComponentNamesMask   (0x3f)
718 #define XkbAllNamesMask         (0x3fff)
719
720     /*
721      * GetByName components:
722      *  - Specifies desired or necessary components to GetKbdByName request.
723      *  - Reports the components that were found in a GetKbdByNameReply
724      */
725 #define XkbGBN_TypesMask                (1L << 0)
726 #define XkbGBN_CompatMapMask            (1L << 1)
727 #define XkbGBN_ClientSymbolsMask        (1L << 2)
728 #define XkbGBN_ServerSymbolsMask        (1L << 3)
729 #define XkbGBN_SymbolsMask (XkbGBN_ClientSymbolsMask|XkbGBN_ServerSymbolsMask)
730 #define XkbGBN_IndicatorMapMask         (1L << 4)
731 #define XkbGBN_KeyNamesMask             (1L << 5)
732 #define XkbGBN_GeometryMask             (1L << 6)
733 #define XkbGBN_OtherNamesMask           (1L << 7)
734 #define XkbGBN_AllComponentsMask        (0xff)
735
736      /*
737       * ListComponents flags
738       */
739 #define XkbLC_Hidden                    (1L <<  0)
740 #define XkbLC_Default                   (1L <<  1)
741 #define XkbLC_Partial                   (1L <<  2)
742
743 #define XkbLC_AlphanumericKeys          (1L <<  8)
744 #define XkbLC_ModifierKeys              (1L <<  9)
745 #define XkbLC_KeypadKeys                (1L << 10)
746 #define XkbLC_FunctionKeys              (1L << 11)
747 #define XkbLC_AlternateGroup            (1L << 12)
748
749     /*
750      * X Input Extension Interactions
751      * - Specifies the possible interactions between XKB and the X input
752      *   extension
753      * - Used to request (XkbGetDeviceInfo) or change (XKbSetDeviceInfo)
754      *   XKB information about an extension device.
755      * - Reports the list of supported optional features in the reply to
756      *   XkbGetDeviceInfo or in an XkbExtensionDeviceNotify event.
757      * XkbXI_UnsupportedFeature is reported in XkbExtensionDeviceNotify
758      * events to indicate an attempt to use an unsupported feature.
759      */
760 #define XkbXI_KeyboardsMask             (1L << 0)
761 #define XkbXI_ButtonActionsMask         (1L << 1)
762 #define XkbXI_IndicatorNamesMask        (1L << 2)
763 #define XkbXI_IndicatorMapsMask         (1L << 3)
764 #define XkbXI_IndicatorStateMask        (1L << 4)
765 #define XkbXI_UnsupportedFeatureMask    (1L << 15)
766 #define XkbXI_AllFeaturesMask           (0x001f)
767 #define XkbXI_AllDeviceFeaturesMask     (0x001e)
768
769 #define XkbXI_IndicatorsMask            (0x001c)
770 #define XkbAllExtensionDeviceEventsMask (0x801f)
771
772     /*
773      * Per-Client Flags:
774      *  - Specifies flags to be changed by the PerClientFlags request.
775      */
776 #define XkbPCF_DetectableAutoRepeatMask (1L << 0)
777 #define XkbPCF_GrabsUseXKBStateMask     (1L << 1)
778 #define XkbPCF_AutoResetControlsMask    (1L << 2)
779 #define XkbPCF_LookupStateWhenGrabbed   (1L << 3)
780 #define XkbPCF_SendEventUsesXKBState    (1L << 4)
781 #define XkbPCF_AllFlagsMask             (0x1F)
782
783     /*
784      * Debugging flags and controls
785      */
786 #define XkbDF_DisableLocks      (1<<0)
787
788 #endif /* _XKB_H_ */