1706f2543Smrg/************************************************************ 2706f2543SmrgCopyright (c) 1993 by Silicon Graphics Computer Systems, Inc. 3706f2543Smrg 4706f2543SmrgPermission to use, copy, modify, and distribute this 5706f2543Smrgsoftware and its documentation for any purpose and without 6706f2543Smrgfee is hereby granted, provided that the above copyright 7706f2543Smrgnotice appear in all copies and that both that copyright 8706f2543Smrgnotice and this permission notice appear in supporting 9706f2543Smrgdocumentation, and that the name of Silicon Graphics not be 10706f2543Smrgused in advertising or publicity pertaining to distribution 11706f2543Smrgof the software without specific prior written permission. 12706f2543SmrgSilicon Graphics makes no representation about the suitability 13706f2543Smrgof this software for any purpose. It is provided "as is" 14706f2543Smrgwithout any express or implied warranty. 15706f2543Smrg 16706f2543SmrgSILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 17706f2543SmrgSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 18706f2543SmrgAND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON 19706f2543SmrgGRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 20706f2543SmrgDAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 21706f2543SmrgDATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 22706f2543SmrgOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH 23706f2543SmrgTHE USE OR PERFORMANCE OF THIS SOFTWARE. 24706f2543Smrg 25706f2543Smrg********************************************************/ 26706f2543Smrg 27706f2543Smrg#ifndef _XKBSTR_H_ 28706f2543Smrg#define _XKBSTR_H_ 29706f2543Smrg 30706f2543Smrg#include <X11/extensions/XKB.h> 31706f2543Smrg 32706f2543Smrg#define XkbCharToInt(v) ((int) ((v) & 0x80 ? ((v) | (~0xff)) : ((v) & 0x7f))) 33706f2543Smrg#define XkbIntTo2Chars(i, h, l) ((h) = (i >> 8) & 0xff, (l) = (i) & 0xff) 34706f2543Smrg 35706f2543Smrg#if defined(WORD64) && defined(UNSIGNEDBITFIELDS) 36706f2543Smrg#define Xkb2CharsToInt(h, l) ((int) ((h) & 0x80 ? \ 37706f2543Smrg (((h) << 8) | (l) | (~0xffff)) : \ 38706f2543Smrg (((h) << 8) | (l) & 0x7fff)) 39706f2543Smrg#else 40706f2543Smrg#define Xkb2CharsToInt(h,l) ((short)(((h)<<8)|(l))) 41706f2543Smrg#endif 42706f2543Smrg 43706f2543Smrg /* 44706f2543Smrg * Common data structures and access macros 45706f2543Smrg */ 46706f2543Smrg 47706f2543Smrgtypedef struct _XkbStateRec { 48706f2543Smrg unsigned char group; /* base + latched + locked */ 49706f2543Smrg /* FIXME: Why are base + latched short and not char?? */ 50706f2543Smrg unsigned short base_group; /* physically ... down? */ 51706f2543Smrg unsigned short latched_group; 52706f2543Smrg unsigned char locked_group; 53706f2543Smrg 54706f2543Smrg unsigned char mods; /* base + latched + locked */ 55706f2543Smrg unsigned char base_mods; /* physically down */ 56706f2543Smrg unsigned char latched_mods; 57706f2543Smrg unsigned char locked_mods; 58706f2543Smrg 59706f2543Smrg unsigned char compat_state; /* mods + group for core state */ 60706f2543Smrg 61706f2543Smrg /* grab mods = all depressed and latched mods, _not_ locked mods */ 62706f2543Smrg unsigned char grab_mods; /* grab mods minus internal mods */ 63706f2543Smrg unsigned char compat_grab_mods; /* grab mods + group for core state, 64706f2543Smrg but not locked groups if 65706f2543Smrg IgnoreGroupLocks set */ 66706f2543Smrg 67706f2543Smrg /* effective mods = all mods (depressed, latched, locked) */ 68706f2543Smrg unsigned char lookup_mods; /* effective mods minus internal mods */ 69706f2543Smrg unsigned char compat_lookup_mods; /* effective mods + group */ 70706f2543Smrg 71706f2543Smrg unsigned short ptr_buttons; /* core pointer buttons */ 72706f2543Smrg} XkbStateRec,*XkbStatePtr; 73706f2543Smrg#define XkbStateFieldFromRec(s) XkbBuildCoreState((s)->lookup_mods,(s)->group) 74706f2543Smrg#define XkbGrabStateFromRec(s) XkbBuildCoreState((s)->grab_mods,(s)->group) 75706f2543Smrg 76706f2543Smrgtypedef struct _XkbMods { 77706f2543Smrg unsigned char mask; /* effective mods */ 78706f2543Smrg unsigned char real_mods; 79706f2543Smrg unsigned short vmods; 80706f2543Smrg} XkbModsRec,*XkbModsPtr; 81706f2543Smrg 82706f2543Smrgtypedef struct _XkbKTMapEntry { 83706f2543Smrg Bool active; 84706f2543Smrg unsigned char level; 85706f2543Smrg XkbModsRec mods; 86706f2543Smrg} XkbKTMapEntryRec,*XkbKTMapEntryPtr; 87706f2543Smrg 88706f2543Smrgtypedef struct _XkbKeyType { 89706f2543Smrg XkbModsRec mods; 90706f2543Smrg unsigned char num_levels; 91706f2543Smrg unsigned char map_count; 92706f2543Smrg XkbKTMapEntryPtr map; 93706f2543Smrg XkbModsPtr preserve; 94706f2543Smrg Atom name; 95706f2543Smrg Atom * level_names; 96706f2543Smrg} XkbKeyTypeRec, *XkbKeyTypePtr; 97706f2543Smrg 98706f2543Smrg#define XkbNumGroups(g) ((g)&0x0f) 99706f2543Smrg#define XkbOutOfRangeGroupInfo(g) ((g)&0xf0) 100706f2543Smrg#define XkbOutOfRangeGroupAction(g) ((g)&0xc0) 101706f2543Smrg#define XkbOutOfRangeGroupNumber(g) (((g)&0x30)>>4) 102706f2543Smrg#define XkbSetGroupInfo(g, w, n) (((w) & 0xc0) | (((n) & 3) << 4) | \ 103706f2543Smrg ((g) & 0x0f)) 104706f2543Smrg#define XkbSetNumGroups(g,n) (((g)&0xf0)|((n)&0x0f)) 105706f2543Smrg 106706f2543Smrg /* 107706f2543Smrg * Structures and access macros used primarily by the server 108706f2543Smrg */ 109706f2543Smrg 110706f2543Smrgtypedef struct _XkbBehavior { 111706f2543Smrg unsigned char type; 112706f2543Smrg unsigned char data; 113706f2543Smrg} XkbBehavior; 114706f2543Smrg 115706f2543Smrg#define XkbAnyActionDataSize 7 116706f2543Smrgtypedef struct _XkbAnyAction { 117706f2543Smrg unsigned char type; 118706f2543Smrg unsigned char data[XkbAnyActionDataSize]; 119706f2543Smrg} XkbAnyAction; 120706f2543Smrg 121706f2543Smrgtypedef struct _XkbModAction { 122706f2543Smrg unsigned char type; 123706f2543Smrg unsigned char flags; 124706f2543Smrg unsigned char mask; 125706f2543Smrg unsigned char real_mods; 126706f2543Smrg /* FIXME: Make this an int. */ 127706f2543Smrg unsigned char vmods1; 128706f2543Smrg unsigned char vmods2; 129706f2543Smrg} XkbModAction; 130706f2543Smrg#define XkbModActionVMods(a) ((short) (((a)->vmods1 << 8) | (a)->vmods2)) 131706f2543Smrg#define XkbSetModActionVMods(a,v) \ 132706f2543Smrg ((a)->vmods1 = (((v) >> 8) & 0xff), \ 133706f2543Smrg (a)->vmods2 = (v) & 0xff) 134706f2543Smrg 135706f2543Smrgtypedef struct _XkbGroupAction { 136706f2543Smrg unsigned char type; 137706f2543Smrg unsigned char flags; 138706f2543Smrg /* FIXME: Make this an int. */ 139706f2543Smrg char group_XXX; 140706f2543Smrg} XkbGroupAction; 141706f2543Smrg#define XkbSAGroup(a) (XkbCharToInt((a)->group_XXX)) 142706f2543Smrg#define XkbSASetGroup(a,g) ((a)->group_XXX=(g)) 143706f2543Smrg 144706f2543Smrgtypedef struct _XkbISOAction { 145706f2543Smrg unsigned char type; 146706f2543Smrg unsigned char flags; 147706f2543Smrg unsigned char mask; 148706f2543Smrg unsigned char real_mods; 149706f2543Smrg /* FIXME: Make this an int. */ 150706f2543Smrg char group_XXX; 151706f2543Smrg unsigned char affect; 152706f2543Smrg unsigned char vmods1; 153706f2543Smrg unsigned char vmods2; 154706f2543Smrg} XkbISOAction; 155706f2543Smrg 156706f2543Smrgtypedef struct _XkbPtrAction { 157706f2543Smrg unsigned char type; 158706f2543Smrg unsigned char flags; 159706f2543Smrg /* FIXME: Make this an int. */ 160706f2543Smrg unsigned char high_XXX; 161706f2543Smrg unsigned char low_XXX; 162706f2543Smrg unsigned char high_YYY; 163706f2543Smrg unsigned char low_YYY; 164706f2543Smrg} XkbPtrAction; 165706f2543Smrg#define XkbPtrActionX(a) (Xkb2CharsToInt((a)->high_XXX,(a)->low_XXX)) 166706f2543Smrg#define XkbPtrActionY(a) (Xkb2CharsToInt((a)->high_YYY,(a)->low_YYY)) 167706f2543Smrg#define XkbSetPtrActionX(a,x) (XkbIntTo2Chars(x,(a)->high_XXX,(a)->low_XXX)) 168706f2543Smrg#define XkbSetPtrActionY(a,y) (XkbIntTo2Chars(y,(a)->high_YYY,(a)->low_YYY)) 169706f2543Smrg 170706f2543Smrgtypedef struct _XkbPtrBtnAction { 171706f2543Smrg unsigned char type; 172706f2543Smrg unsigned char flags; 173706f2543Smrg unsigned char count; 174706f2543Smrg unsigned char button; 175706f2543Smrg} XkbPtrBtnAction; 176706f2543Smrg 177706f2543Smrgtypedef struct _XkbPtrDfltAction { 178706f2543Smrg unsigned char type; 179706f2543Smrg unsigned char flags; 180706f2543Smrg unsigned char affect; 181706f2543Smrg char valueXXX; 182706f2543Smrg} XkbPtrDfltAction; 183706f2543Smrg#define XkbSAPtrDfltValue(a) (XkbCharToInt((a)->valueXXX)) 184706f2543Smrg#define XkbSASetPtrDfltValue(a, c) ((a)->valueXXX = (c) & 0xff) 185706f2543Smrg 186706f2543Smrgtypedef struct _XkbSwitchScreenAction { 187706f2543Smrg unsigned char type; 188706f2543Smrg unsigned char flags; 189706f2543Smrg char screenXXX; 190706f2543Smrg} XkbSwitchScreenAction; 191706f2543Smrg#define XkbSAScreen(a) (XkbCharToInt((a)->screenXXX)) 192706f2543Smrg#define XkbSASetScreen(a, s) ((a)->screenXXX = (s) & 0xff) 193706f2543Smrg 194706f2543Smrgtypedef struct _XkbCtrlsAction { 195706f2543Smrg unsigned char type; 196706f2543Smrg unsigned char flags; 197706f2543Smrg /* FIXME: Make this an int. */ 198706f2543Smrg unsigned char ctrls3; 199706f2543Smrg unsigned char ctrls2; 200706f2543Smrg unsigned char ctrls1; 201706f2543Smrg unsigned char ctrls0; 202706f2543Smrg} XkbCtrlsAction; 203706f2543Smrg#define XkbActionSetCtrls(a, c) ((a)->ctrls3 = ((c) >> 24) & 0xff, \ 204706f2543Smrg (a)->ctrls2 = ((c) >> 16) & 0xff, \ 205706f2543Smrg (a)->ctrls1 = ((c) >> 8) & 0xff, \ 206706f2543Smrg (a)->ctrls0 = (c) & 0xff) 207706f2543Smrg#define XkbActionCtrls(a) ((((unsigned int)(a)->ctrls3)<<24)|\ 208706f2543Smrg (((unsigned int)(a)->ctrls2)<<16)|\ 209706f2543Smrg (((unsigned int)(a)->ctrls1)<<8)|\ 210706f2543Smrg ((unsigned int) (a)->ctrls0)) 211706f2543Smrg 212706f2543Smrgtypedef struct _XkbMessageAction { 213706f2543Smrg unsigned char type; 214706f2543Smrg unsigned char flags; 215706f2543Smrg unsigned char message[6]; 216706f2543Smrg} XkbMessageAction; 217706f2543Smrg 218706f2543Smrgtypedef struct _XkbRedirectKeyAction { 219706f2543Smrg unsigned char type; 220706f2543Smrg unsigned char new_key; 221706f2543Smrg unsigned char mods_mask; 222706f2543Smrg unsigned char mods; 223706f2543Smrg /* FIXME: Make this an int. */ 224706f2543Smrg unsigned char vmods_mask0; 225706f2543Smrg unsigned char vmods_mask1; 226706f2543Smrg unsigned char vmods0; 227706f2543Smrg unsigned char vmods1; 228706f2543Smrg} XkbRedirectKeyAction; 229706f2543Smrg 230706f2543Smrg#define XkbSARedirectVMods(a) ((((unsigned int)(a)->vmods1)<<8)|\ 231706f2543Smrg ((unsigned int)(a)->vmods0)) 232706f2543Smrg/* FIXME: This is blatantly not setting vmods. Yeesh. */ 233706f2543Smrg#define XkbSARedirectSetVMods(a,m) (((a)->vmods_mask1=(((m)>>8)&0xff)),\ 234706f2543Smrg ((a)->vmods_mask0=((m)&0xff))) 235706f2543Smrg#define XkbSARedirectVModsMask(a) ((((unsigned int)(a)->vmods_mask1)<<8)|\ 236706f2543Smrg ((unsigned int)(a)->vmods_mask0)) 237706f2543Smrg#define XkbSARedirectSetVModsMask(a,m) (((a)->vmods_mask1=(((m)>>8)&0xff)),\ 238706f2543Smrg ((a)->vmods_mask0=((m)&0xff))) 239706f2543Smrg 240706f2543Smrgtypedef struct _XkbDeviceBtnAction { 241706f2543Smrg unsigned char type; 242706f2543Smrg unsigned char flags; 243706f2543Smrg unsigned char count; 244706f2543Smrg unsigned char button; 245706f2543Smrg unsigned char device; 246706f2543Smrg} XkbDeviceBtnAction; 247706f2543Smrg 248706f2543Smrgtypedef struct _XkbDeviceValuatorAction { 249706f2543Smrg unsigned char type; 250706f2543Smrg unsigned char device; 251706f2543Smrg unsigned char v1_what; 252706f2543Smrg unsigned char v1_ndx; 253706f2543Smrg unsigned char v1_value; 254706f2543Smrg unsigned char v2_what; 255706f2543Smrg unsigned char v2_ndx; 256706f2543Smrg unsigned char v2_value; 257706f2543Smrg} XkbDeviceValuatorAction; 258706f2543Smrg 259706f2543Smrgtypedef union _XkbAction { 260706f2543Smrg XkbAnyAction any; 261706f2543Smrg XkbModAction mods; 262706f2543Smrg XkbGroupAction group; 263706f2543Smrg XkbISOAction iso; 264706f2543Smrg XkbPtrAction ptr; 265706f2543Smrg XkbPtrBtnAction btn; 266706f2543Smrg XkbPtrDfltAction dflt; 267706f2543Smrg XkbSwitchScreenAction screen; 268706f2543Smrg XkbCtrlsAction ctrls; 269706f2543Smrg XkbMessageAction msg; 270706f2543Smrg XkbRedirectKeyAction redirect; 271706f2543Smrg XkbDeviceBtnAction devbtn; 272706f2543Smrg XkbDeviceValuatorAction devval; 273706f2543Smrg unsigned char type; 274706f2543Smrg} XkbAction; 275706f2543Smrg 276706f2543Smrgtypedef struct _XkbControls { 277706f2543Smrg unsigned char mk_dflt_btn; 278706f2543Smrg unsigned char num_groups; 279706f2543Smrg unsigned char groups_wrap; 280706f2543Smrg XkbModsRec internal; 281706f2543Smrg XkbModsRec ignore_lock; 282706f2543Smrg unsigned int enabled_ctrls; 283706f2543Smrg unsigned short repeat_delay; 284706f2543Smrg unsigned short repeat_interval; 285706f2543Smrg unsigned short slow_keys_delay; 286706f2543Smrg unsigned short debounce_delay; 287706f2543Smrg unsigned short mk_delay; 288706f2543Smrg unsigned short mk_interval; 289706f2543Smrg unsigned short mk_time_to_max; 290706f2543Smrg unsigned short mk_max_speed; 291706f2543Smrg short mk_curve; 292706f2543Smrg unsigned short ax_options; 293706f2543Smrg unsigned short ax_timeout; 294706f2543Smrg unsigned short axt_opts_mask; 295706f2543Smrg unsigned short axt_opts_values; 296706f2543Smrg unsigned int axt_ctrls_mask; 297706f2543Smrg unsigned int axt_ctrls_values; 298706f2543Smrg unsigned char per_key_repeat[XkbPerKeyBitArraySize]; 299706f2543Smrg} XkbControlsRec, *XkbControlsPtr; 300706f2543Smrg 301706f2543Smrg#define XkbAX_AnyFeedback(c) ((c)->enabled_ctrls&XkbAccessXFeedbackMask) 302706f2543Smrg#define XkbAX_NeedOption(c,w) ((c)->ax_options&(w)) 303706f2543Smrg#define XkbAX_NeedFeedback(c, w) (XkbAX_AnyFeedback((c)) && \ 304706f2543Smrg XkbAX_NeedOption((c), (w))) 305706f2543Smrg 306706f2543Smrgtypedef struct _XkbServerMapRec { 307706f2543Smrg unsigned short num_acts; 308706f2543Smrg unsigned short size_acts; 309706f2543Smrg XkbAction *acts; 310706f2543Smrg 311706f2543Smrg XkbBehavior *behaviors; 312706f2543Smrg unsigned short *key_acts; 313706f2543Smrg#if defined(__cplusplus) || defined(c_plusplus) 314706f2543Smrg /* explicit is a C++ reserved word */ 315706f2543Smrg unsigned char *c_explicit; 316706f2543Smrg#else 317706f2543Smrg unsigned char *explicit; 318706f2543Smrg#endif 319706f2543Smrg unsigned char vmods[XkbNumVirtualMods]; 320706f2543Smrg unsigned short *vmodmap; 321706f2543Smrg} XkbServerMapRec, *XkbServerMapPtr; 322706f2543Smrg 323706f2543Smrg#define XkbSMKeyActionsPtr(m, k) (&(m)->acts[(m)->key_acts[(k)]]) 324706f2543Smrg 325706f2543Smrg /* 326706f2543Smrg * Structures and access macros used primarily by clients 327706f2543Smrg */ 328706f2543Smrg 329706f2543Smrgtypedef struct _XkbSymMapRec { 330706f2543Smrg unsigned char kt_index[XkbNumKbdGroups]; 331706f2543Smrg unsigned char group_info; 332706f2543Smrg unsigned char width; 333706f2543Smrg unsigned short offset; 334706f2543Smrg} XkbSymMapRec, *XkbSymMapPtr; 335706f2543Smrg 336706f2543Smrgtypedef struct _XkbClientMapRec { 337706f2543Smrg unsigned char size_types; 338706f2543Smrg unsigned char num_types; 339706f2543Smrg XkbKeyTypePtr types; 340706f2543Smrg 341706f2543Smrg unsigned short size_syms; 342706f2543Smrg unsigned short num_syms; 343706f2543Smrg KeySym *syms; 344706f2543Smrg XkbSymMapPtr key_sym_map; 345706f2543Smrg 346706f2543Smrg unsigned char *modmap; 347706f2543Smrg} XkbClientMapRec, *XkbClientMapPtr; 348706f2543Smrg 349706f2543Smrg#define XkbCMKeyGroupInfo(m, k) ((m)->key_sym_map[(k)].group_info) 350706f2543Smrg#define XkbCMKeyNumGroups(m, k) (XkbNumGroups((m)->key_sym_map[(k)].group_info)) 351706f2543Smrg#define XkbCMKeyGroupWidth(m, k, g) (XkbCMKeyType((m), (k), (g))->num_levels) 352706f2543Smrg#define XkbCMKeyGroupsWidth(m, k) ((m)->key_sym_map[(k)].width) 353706f2543Smrg#define XkbCMKeyTypeIndex(m, k, g) ((m)->key_sym_map[(k)].kt_index[(g) & 0x3]) 354706f2543Smrg#define XkbCMKeyType(m, k, g) (&(m)->types[XkbCMKeyTypeIndex((m), (k), (g))]) 355706f2543Smrg#define XkbCMKeyNumSyms(m, k) (XkbCMKeyGroupsWidth((m), (k)) * \ 356706f2543Smrg XkbCMKeyNumGroups((m), (k))) 357706f2543Smrg#define XkbCMKeySymsOffset(m, k) ((m)->key_sym_map[(k)].offset) 358706f2543Smrg#define XkbCMKeySymsPtr(m, k) (&(m)->syms[XkbCMKeySymsOffset((m), (k))]) 359706f2543Smrg 360706f2543Smrg /* 361706f2543Smrg * Compatibility structures and access macros 362706f2543Smrg */ 363706f2543Smrg 364706f2543Smrgtypedef struct _XkbSymInterpretRec { 365706f2543Smrg KeySym sym; 366706f2543Smrg unsigned char flags; 367706f2543Smrg unsigned char match; 368706f2543Smrg unsigned char mods; 369706f2543Smrg unsigned char virtual_mod; 370706f2543Smrg XkbAnyAction act; 371706f2543Smrg} XkbSymInterpretRec,*XkbSymInterpretPtr; 372706f2543Smrg 373706f2543Smrgtypedef struct _XkbCompatMapRec { 374706f2543Smrg XkbSymInterpretPtr sym_interpret; 375706f2543Smrg XkbModsRec groups[XkbNumKbdGroups]; 376706f2543Smrg unsigned short num_si; 377706f2543Smrg unsigned short size_si; 378706f2543Smrg} XkbCompatMapRec, *XkbCompatMapPtr; 379706f2543Smrg 380706f2543Smrgtypedef struct _XkbIndicatorMapRec { 381706f2543Smrg unsigned char flags; 382706f2543Smrg /* FIXME: For some reason, interepretation of groups is wildly 383706f2543Smrg * different between which being base/latched/locked. */ 384706f2543Smrg unsigned char which_groups; 385706f2543Smrg unsigned char groups; 386706f2543Smrg unsigned char which_mods; 387706f2543Smrg XkbModsRec mods; 388706f2543Smrg unsigned int ctrls; 389706f2543Smrg} XkbIndicatorMapRec, *XkbIndicatorMapPtr; 390706f2543Smrg 391706f2543Smrg#define XkbIM_IsAuto(i) (!((i)->flags & XkbIM_NoAutomatic) && \ 392706f2543Smrg (((i)->which_groups&&(i)->groups)||\ 393706f2543Smrg ((i)->which_mods&&(i)->mods.mask)||\ 394706f2543Smrg (i)->ctrls)) 395706f2543Smrg#define XkbIM_InUse(i) ((i)->flags || (i)->which_groups || (i)->which_mods || \ 396706f2543Smrg (i)->ctrls) 397706f2543Smrg 398706f2543Smrg 399706f2543Smrgtypedef struct _XkbIndicatorRec { 400706f2543Smrg unsigned long phys_indicators; 401706f2543Smrg XkbIndicatorMapRec maps[XkbNumIndicators]; 402706f2543Smrg} XkbIndicatorRec,*XkbIndicatorPtr; 403706f2543Smrg 404706f2543Smrgtypedef struct _XkbKeyNameRec { 405706f2543Smrg char name[XkbKeyNameLength]; 406706f2543Smrg} XkbKeyNameRec,*XkbKeyNamePtr; 407706f2543Smrg 408706f2543Smrgtypedef struct _XkbKeyAliasRec { 409706f2543Smrg char real[XkbKeyNameLength]; 410706f2543Smrg char alias[XkbKeyNameLength]; 411706f2543Smrg} XkbKeyAliasRec,*XkbKeyAliasPtr; 412706f2543Smrg 413706f2543Smrg /* 414706f2543Smrg * Names for everything 415706f2543Smrg */ 416706f2543Smrgtypedef struct _XkbNamesRec { 417706f2543Smrg Atom keycodes; 418706f2543Smrg Atom geometry; 419706f2543Smrg Atom symbols; 420706f2543Smrg Atom types; 421706f2543Smrg Atom compat; 422706f2543Smrg Atom vmods[XkbNumVirtualMods]; 423706f2543Smrg Atom indicators[XkbNumIndicators]; 424706f2543Smrg Atom groups[XkbNumKbdGroups]; 425706f2543Smrg XkbKeyNamePtr keys; 426706f2543Smrg XkbKeyAliasPtr key_aliases; 427706f2543Smrg Atom *radio_groups; 428706f2543Smrg Atom phys_symbols; 429706f2543Smrg 430706f2543Smrg unsigned char num_keys; 431706f2543Smrg unsigned char num_key_aliases; 432706f2543Smrg unsigned short num_rg; 433706f2543Smrg} XkbNamesRec,*XkbNamesPtr; 434706f2543Smrg 435706f2543Smrgtypedef struct _XkbGeometry *XkbGeometryPtr; 436706f2543Smrg /* 437706f2543Smrg * Tie it all together into one big keyboard description 438706f2543Smrg */ 439706f2543Smrgtypedef struct _XkbDesc { 440706f2543Smrg unsigned int defined; 441706f2543Smrg unsigned short flags; 442706f2543Smrg unsigned short device_spec; 443706f2543Smrg KeyCode min_key_code; 444706f2543Smrg KeyCode max_key_code; 445706f2543Smrg 446706f2543Smrg XkbControlsPtr ctrls; 447706f2543Smrg XkbServerMapPtr server; 448706f2543Smrg XkbClientMapPtr map; 449706f2543Smrg XkbIndicatorPtr indicators; 450706f2543Smrg XkbNamesPtr names; 451706f2543Smrg XkbCompatMapPtr compat; 452706f2543Smrg XkbGeometryPtr geom; 453706f2543Smrg} XkbDescRec, *XkbDescPtr; 454706f2543Smrg#define XkbKeyKeyTypeIndex(d, k, g) (XkbCMKeyTypeIndex((d)->map, (k), (g))) 455706f2543Smrg#define XkbKeyKeyType(d, k, g) (XkbCMKeyType((d)->map, (k), (g))) 456706f2543Smrg#define XkbKeyGroupWidth(d, k, g) (XkbCMKeyGroupWidth((d)->map, (k), (g))) 457706f2543Smrg#define XkbKeyGroupsWidth(d, k) (XkbCMKeyGroupsWidth((d)->map, (k))) 458706f2543Smrg#define XkbKeyGroupInfo(d,k) (XkbCMKeyGroupInfo((d)->map,(k))) 459706f2543Smrg#define XkbKeyNumGroups(d,k) (XkbCMKeyNumGroups((d)->map,(k))) 460706f2543Smrg#define XkbKeyNumSyms(d,k) (XkbCMKeyNumSyms((d)->map,(k))) 461706f2543Smrg#define XkbKeySymsPtr(d,k) (XkbCMKeySymsPtr((d)->map,(k))) 462706f2543Smrg#define XkbKeySym(d, k, n) (XkbKeySymsPtr((d), (k))[(n)]) 463706f2543Smrg#define XkbKeySymEntry(d,k,sl,g) \ 464706f2543Smrg (XkbKeySym((d), (k), (XkbKeyGroupsWidth((d), (k)) * (g)) + (sl))) 465706f2543Smrg#define XkbKeyAction(d,k,n) \ 466706f2543Smrg (XkbKeyHasActions((d), (k)) ? & XkbKeyActionsPtr((d), (k))[(n)] : NULL) 467706f2543Smrg#define XkbKeyActionEntry(d,k,sl,g) \ 468706f2543Smrg (XkbKeyHasActions((d), (k)) ? \ 469706f2543Smrg XkbKeyAction((d), (k), ((XkbKeyGroupsWidth((d), (k)) * (g)) + (sl))) : \ 470706f2543Smrg NULL) 471706f2543Smrg 472706f2543Smrg#define XkbKeyHasActions(d, k) (!!(d)->server->key_acts[(k)]) 473706f2543Smrg#define XkbKeyNumActions(d, k) (XkbKeyHasActions((d), (k)) ? \ 474706f2543Smrg XkbKeyNumSyms((d), (k)) : 1) 475706f2543Smrg#define XkbKeyActionsPtr(d, k) (XkbSMKeyActionsPtr((d)->server, (k))) 476706f2543Smrg#define XkbKeycodeInRange(d, k) ((k) >= (d)->min_key_code && \ 477706f2543Smrg (k) <= (d)->max_key_code) 478706f2543Smrg#define XkbNumKeys(d) ((d)->max_key_code-(d)->min_key_code+1) 479706f2543Smrg 480706f2543Smrg 481706f2543Smrg /* 482706f2543Smrg * The following structures can be used to track changes 483706f2543Smrg * to a keyboard device 484706f2543Smrg */ 485706f2543Smrgtypedef struct _XkbMapChanges { 486706f2543Smrg unsigned short changed; 487706f2543Smrg KeyCode min_key_code; 488706f2543Smrg KeyCode max_key_code; 489706f2543Smrg unsigned char first_type; 490706f2543Smrg unsigned char num_types; 491706f2543Smrg KeyCode first_key_sym; 492706f2543Smrg unsigned char num_key_syms; 493706f2543Smrg KeyCode first_key_act; 494706f2543Smrg unsigned char num_key_acts; 495706f2543Smrg KeyCode first_key_behavior; 496706f2543Smrg unsigned char num_key_behaviors; 497706f2543Smrg KeyCode first_key_explicit; 498706f2543Smrg unsigned char num_key_explicit; 499706f2543Smrg KeyCode first_modmap_key; 500706f2543Smrg unsigned char num_modmap_keys; 501706f2543Smrg KeyCode first_vmodmap_key; 502706f2543Smrg unsigned char num_vmodmap_keys; 503706f2543Smrg unsigned char pad; 504706f2543Smrg unsigned short vmods; 505706f2543Smrg} XkbMapChangesRec,*XkbMapChangesPtr; 506706f2543Smrg 507706f2543Smrgtypedef struct _XkbControlsChanges { 508706f2543Smrg unsigned int changed_ctrls; 509706f2543Smrg unsigned int enabled_ctrls_changes; 510706f2543Smrg Bool num_groups_changed; 511706f2543Smrg} XkbControlsChangesRec,*XkbControlsChangesPtr; 512706f2543Smrg 513706f2543Smrgtypedef struct _XkbIndicatorChanges { 514706f2543Smrg unsigned int state_changes; 515706f2543Smrg unsigned int map_changes; 516706f2543Smrg} XkbIndicatorChangesRec,*XkbIndicatorChangesPtr; 517706f2543Smrg 518706f2543Smrgtypedef struct _XkbNameChanges { 519706f2543Smrg unsigned int changed; 520706f2543Smrg unsigned char first_type; 521706f2543Smrg unsigned char num_types; 522706f2543Smrg unsigned char first_lvl; 523706f2543Smrg unsigned char num_lvls; 524706f2543Smrg unsigned char num_aliases; 525706f2543Smrg unsigned char num_rg; 526706f2543Smrg unsigned char first_key; 527706f2543Smrg unsigned char num_keys; 528706f2543Smrg unsigned short changed_vmods; 529706f2543Smrg unsigned long changed_indicators; 530706f2543Smrg unsigned char changed_groups; 531706f2543Smrg} XkbNameChangesRec,*XkbNameChangesPtr; 532706f2543Smrg 533706f2543Smrgtypedef struct _XkbCompatChanges { 534706f2543Smrg unsigned char changed_groups; 535706f2543Smrg unsigned short first_si; 536706f2543Smrg unsigned short num_si; 537706f2543Smrg} XkbCompatChangesRec,*XkbCompatChangesPtr; 538706f2543Smrg 539706f2543Smrgtypedef struct _XkbChanges { 540706f2543Smrg unsigned short device_spec; 541706f2543Smrg unsigned short state_changes; 542706f2543Smrg XkbMapChangesRec map; 543706f2543Smrg XkbControlsChangesRec ctrls; 544706f2543Smrg XkbIndicatorChangesRec indicators; 545706f2543Smrg XkbNameChangesRec names; 546706f2543Smrg XkbCompatChangesRec compat; 547706f2543Smrg} XkbChangesRec, *XkbChangesPtr; 548706f2543Smrg 549706f2543Smrg /* 550706f2543Smrg * These data structures are used to construct a keymap from 551706f2543Smrg * a set of components or to list components in the server 552706f2543Smrg * database. 553706f2543Smrg */ 554706f2543Smrgtypedef struct _XkbComponentNames { 555706f2543Smrg char * keycodes; 556706f2543Smrg char * types; 557706f2543Smrg char * compat; 558706f2543Smrg char * symbols; 559706f2543Smrg char * geometry; 560706f2543Smrg} XkbComponentNamesRec, *XkbComponentNamesPtr; 561706f2543Smrg 562706f2543Smrgtypedef struct _XkbComponentName { 563706f2543Smrg unsigned short flags; 564706f2543Smrg char * name; 565706f2543Smrg} XkbComponentNameRec,*XkbComponentNamePtr; 566706f2543Smrg 567706f2543Smrgtypedef struct _XkbComponentList { 568706f2543Smrg int num_keymaps; 569706f2543Smrg int num_keycodes; 570706f2543Smrg int num_types; 571706f2543Smrg int num_compat; 572706f2543Smrg int num_symbols; 573706f2543Smrg int num_geometry; 574706f2543Smrg XkbComponentNamePtr keymaps; 575706f2543Smrg XkbComponentNamePtr keycodes; 576706f2543Smrg XkbComponentNamePtr types; 577706f2543Smrg XkbComponentNamePtr compat; 578706f2543Smrg XkbComponentNamePtr symbols; 579706f2543Smrg XkbComponentNamePtr geometry; 580706f2543Smrg} XkbComponentListRec, *XkbComponentListPtr; 581706f2543Smrg 582706f2543Smrg /* 583706f2543Smrg * The following data structures describe and track changes to a 584706f2543Smrg * non-keyboard extension device 585706f2543Smrg */ 586706f2543Smrgtypedef struct _XkbDeviceLedInfo { 587706f2543Smrg unsigned short led_class; 588706f2543Smrg unsigned short led_id; 589706f2543Smrg unsigned int phys_indicators; 590706f2543Smrg unsigned int maps_present; 591706f2543Smrg unsigned int names_present; 592706f2543Smrg unsigned int state; 593706f2543Smrg Atom names[XkbNumIndicators]; 594706f2543Smrg XkbIndicatorMapRec maps[XkbNumIndicators]; 595706f2543Smrg} XkbDeviceLedInfoRec,*XkbDeviceLedInfoPtr; 596706f2543Smrg 597706f2543Smrgtypedef struct _XkbDeviceInfo { 598706f2543Smrg char * name; 599706f2543Smrg Atom type; 600706f2543Smrg unsigned short device_spec; 601706f2543Smrg Bool has_own_state; 602706f2543Smrg unsigned short supported; 603706f2543Smrg unsigned short unsupported; 604706f2543Smrg 605706f2543Smrg unsigned short num_btns; 606706f2543Smrg XkbAction * btn_acts; 607706f2543Smrg 608706f2543Smrg unsigned short sz_leds; 609706f2543Smrg unsigned short num_leds; 610706f2543Smrg unsigned short dflt_kbd_fb; 611706f2543Smrg unsigned short dflt_led_fb; 612706f2543Smrg XkbDeviceLedInfoPtr leds; 613706f2543Smrg} XkbDeviceInfoRec,*XkbDeviceInfoPtr; 614706f2543Smrg 615706f2543Smrg#define XkbXI_DevHasBtnActs(d) ((d)->num_btns > 0 && (d)->btn_acts) 616706f2543Smrg#define XkbXI_LegalDevBtn(d,b) (XkbXI_DevHasBtnActs(d) && (b) < (d)->num_btns) 617706f2543Smrg#define XkbXI_DevHasLeds(d) ((d)->num_leds > 0 && (d)->leds) 618706f2543Smrg 619706f2543Smrgtypedef struct _XkbDeviceLedChanges { 620706f2543Smrg unsigned short led_class; 621706f2543Smrg unsigned short led_id; 622706f2543Smrg unsigned int defined; /* names or maps changed */ 623706f2543Smrg struct _XkbDeviceLedChanges *next; 624706f2543Smrg} XkbDeviceLedChangesRec,*XkbDeviceLedChangesPtr; 625706f2543Smrg 626706f2543Smrgtypedef struct _XkbDeviceChanges { 627706f2543Smrg unsigned int changed; 628706f2543Smrg unsigned short first_btn; 629706f2543Smrg unsigned short num_btns; 630706f2543Smrg XkbDeviceLedChangesRec leds; 631706f2543Smrg} XkbDeviceChangesRec,*XkbDeviceChangesPtr; 632706f2543Smrg 633706f2543Smrg#endif /* _XKBSTR_H_ */ 634