| 1 | /************************************************************ |
| 2 | Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. |
| 3 | |
| 4 | Permission to use, copy, modify, and distribute this |
| 5 | software and its documentation for any purpose and without |
| 6 | fee is hereby granted, provided that the above copyright |
| 7 | notice appear in all copies and that both that copyright |
| 8 | notice and this permission notice appear in supporting |
| 9 | documentation, and that the name of Silicon Graphics not be |
| 10 | used in advertising or publicity pertaining to distribution |
| 11 | of the software without specific prior written permission. |
| 12 | Silicon Graphics makes no representation about the suitability |
| 13 | of this software for any purpose. It is provided "as is" |
| 14 | without any express or implied warranty. |
| 15 | |
| 16 | SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS |
| 17 | SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
| 18 | AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON |
| 19 | GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
| 20 | DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, |
| 21 | DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE |
| 22 | OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
| 23 | THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 24 | |
| 25 | ********************************************************/ |
| 26 | |
| 27 | #ifndef _XKBSTR_H_ |
| 28 | #define _XKBSTR_H_ |
| 29 | |
| 30 | #include <X11/extensions/XKB.h> |
| 31 | |
| 32 | #define XkbCharToInt(v) ((int) ((v) & 0x80 ? ((v) | (~0xff)) : ((v) & 0x7f))) |
| 33 | #define XkbIntTo2Chars(i, h, l) ((h) = (i >> 8) & 0xff, (l) = (i) & 0xff) |
| 34 | |
| 35 | #if defined(WORD64) && defined(UNSIGNEDBITFIELDS) |
| 36 | #define Xkb2CharsToInt(h, l) ((int) ((h) & 0x80 ? \ |
| 37 | (((h) << 8) | (l) | (~0xffff)) : \ |
| 38 | (((h) << 8) | (l) & 0x7fff)) |
| 39 | #else |
| 40 | #define Xkb2CharsToInt(h,l) ((short)(((h)<<8)|(l))) |
| 41 | #endif |
| 42 | |
| 43 | /* |
| 44 | * Common data structures and access macros |
| 45 | */ |
| 46 | |
| 47 | typedef struct _XkbStateRec { |
| 48 | unsigned char group; /* base + latched + locked */ |
| 49 | /* FIXME: Why are base + latched short and not char?? */ |
| 50 | unsigned short base_group; /* physically ... down? */ |
| 51 | unsigned short latched_group; |
| 52 | unsigned char locked_group; |
| 53 | |
| 54 | unsigned char mods; /* base + latched + locked */ |
| 55 | unsigned char base_mods; /* physically down */ |
| 56 | unsigned char latched_mods; |
| 57 | unsigned char locked_mods; |
| 58 | |
| 59 | unsigned char compat_state; /* mods + group for core state */ |
| 60 | |
| 61 | /* grab mods = all depressed and latched mods, _not_ locked mods */ |
| 62 | unsigned char grab_mods; /* grab mods minus internal mods */ |
| 63 | unsigned char compat_grab_mods; /* grab mods + group for core state, |
| 64 | but not locked groups if |
| 65 | IgnoreGroupLocks set */ |
| 66 | |
| 67 | /* effective mods = all mods (depressed, latched, locked) */ |
| 68 | unsigned char lookup_mods; /* effective mods minus internal mods */ |
| 69 | unsigned char compat_lookup_mods; /* effective mods + group */ |
| 70 | |
| 71 | unsigned short ptr_buttons; /* core pointer buttons */ |
| 72 | } XkbStateRec, *XkbStatePtr; |
| 73 | |
| 74 | #define XkbStateFieldFromRec(s) XkbBuildCoreState((s)->lookup_mods,(s)->group) |
| 75 | #define XkbGrabStateFromRec(s) XkbBuildCoreState((s)->grab_mods,(s)->group) |
| 76 | |
| 77 | typedef struct _XkbMods { |
| 78 | unsigned char mask; /* effective mods */ |
| 79 | unsigned char real_mods; |
| 80 | unsigned short vmods; |
| 81 | } XkbModsRec, *XkbModsPtr; |
| 82 | |
| 83 | typedef struct _XkbKTMapEntry { |
| 84 | Bool active; |
| 85 | unsigned char level; |
| 86 | XkbModsRec mods; |
| 87 | } XkbKTMapEntryRec, *XkbKTMapEntryPtr; |
| 88 | |
| 89 | typedef struct _XkbKeyType { |
| 90 | XkbModsRec mods; |
| 91 | unsigned char num_levels; |
| 92 | unsigned char map_count; |
| 93 | XkbKTMapEntryPtr map; |
| 94 | XkbModsPtr preserve; |
| 95 | Atom name; |
| 96 | Atom *level_names; |
| 97 | } XkbKeyTypeRec, *XkbKeyTypePtr; |
| 98 | |
| 99 | #define XkbNumGroups(g) ((g)&0x0f) |
| 100 | #define XkbOutOfRangeGroupInfo(g) ((g)&0xf0) |
| 101 | #define XkbOutOfRangeGroupAction(g) ((g)&0xc0) |
| 102 | #define XkbOutOfRangeGroupNumber(g) (((g)&0x30)>>4) |
| 103 | #define XkbSetGroupInfo(g, w, n) (((w) & 0xc0) | (((n) & 3) << 4) | \ |
| 104 | ((g) & 0x0f)) |
| 105 | #define XkbSetNumGroups(g,n) (((g)&0xf0)|((n)&0x0f)) |
| 106 | |
| 107 | /* |
| 108 | * Structures and access macros used primarily by the server |
| 109 | */ |
| 110 | |
| 111 | typedef struct _XkbBehavior { |
| 112 | unsigned char type; |
| 113 | unsigned char data; |
| 114 | } XkbBehavior; |
| 115 | |
| 116 | #define XkbAnyActionDataSize 7 |
| 117 | typedef struct _XkbAnyAction { |
| 118 | unsigned char type; |
| 119 | unsigned char data[XkbAnyActionDataSize]; |
| 120 | } XkbAnyAction; |
| 121 | |
| 122 | typedef struct _XkbModAction { |
| 123 | unsigned char type; |
| 124 | unsigned char flags; |
| 125 | unsigned char mask; |
| 126 | unsigned char real_mods; |
| 127 | /* FIXME: Make this an int. */ |
| 128 | unsigned char vmods1; |
| 129 | unsigned char vmods2; |
| 130 | } XkbModAction; |
| 131 | |
| 132 | #define XkbModActionVMods(a) ((short) (((a)->vmods1 << 8) | (a)->vmods2)) |
| 133 | #define XkbSetModActionVMods(a,v) \ |
| 134 | ((a)->vmods1 = (((v) >> 8) & 0xff), \ |
| 135 | (a)->vmods2 = (v) & 0xff) |
| 136 | |
| 137 | typedef struct _XkbGroupAction { |
| 138 | unsigned char type; |
| 139 | unsigned char flags; |
| 140 | /* FIXME: Make this an int. */ |
| 141 | char group_XXX; |
| 142 | } XkbGroupAction; |
| 143 | |
| 144 | #define XkbSAGroup(a) (XkbCharToInt((a)->group_XXX)) |
| 145 | #define XkbSASetGroup(a,g) ((a)->group_XXX=(g)) |
| 146 | |
| 147 | typedef struct _XkbISOAction { |
| 148 | unsigned char type; |
| 149 | unsigned char flags; |
| 150 | unsigned char mask; |
| 151 | unsigned char real_mods; |
| 152 | /* FIXME: Make this an int. */ |
| 153 | char group_XXX; |
| 154 | unsigned char affect; |
| 155 | unsigned char vmods1; |
| 156 | unsigned char vmods2; |
| 157 | } XkbISOAction; |
| 158 | |
| 159 | typedef struct _XkbPtrAction { |
| 160 | unsigned char type; |
| 161 | unsigned char flags; |
| 162 | /* FIXME: Make this an int. */ |
| 163 | unsigned char high_XXX; |
| 164 | unsigned char low_XXX; |
| 165 | unsigned char high_YYY; |
| 166 | unsigned char low_YYY; |
| 167 | } XkbPtrAction; |
| 168 | |
| 169 | #define XkbPtrActionX(a) (Xkb2CharsToInt((a)->high_XXX,(a)->low_XXX)) |
| 170 | #define XkbPtrActionY(a) (Xkb2CharsToInt((a)->high_YYY,(a)->low_YYY)) |
| 171 | #define XkbSetPtrActionX(a,x) (XkbIntTo2Chars(x,(a)->high_XXX,(a)->low_XXX)) |
| 172 | #define XkbSetPtrActionY(a,y) (XkbIntTo2Chars(y,(a)->high_YYY,(a)->low_YYY)) |
| 173 | |
| 174 | typedef struct _XkbPtrBtnAction { |
| 175 | unsigned char type; |
| 176 | unsigned char flags; |
| 177 | unsigned char count; |
| 178 | unsigned char button; |
| 179 | } XkbPtrBtnAction; |
| 180 | |
| 181 | typedef struct _XkbPtrDfltAction { |
| 182 | unsigned char type; |
| 183 | unsigned char flags; |
| 184 | unsigned char affect; |
| 185 | char valueXXX; |
| 186 | } XkbPtrDfltAction; |
| 187 | |
| 188 | #define XkbSAPtrDfltValue(a) (XkbCharToInt((a)->valueXXX)) |
| 189 | #define XkbSASetPtrDfltValue(a, c) ((a)->valueXXX = (c) & 0xff) |
| 190 | |
| 191 | typedef struct _XkbSwitchScreenAction { |
| 192 | unsigned char type; |
| 193 | unsigned char flags; |
| 194 | char screenXXX; |
| 195 | } XkbSwitchScreenAction; |
| 196 | |
| 197 | #define XkbSAScreen(a) (XkbCharToInt((a)->screenXXX)) |
| 198 | #define XkbSASetScreen(a, s) ((a)->screenXXX = (s) & 0xff) |
| 199 | |
| 200 | typedef struct _XkbCtrlsAction { |
| 201 | unsigned char type; |
| 202 | unsigned char flags; |
| 203 | /* FIXME: Make this an int. */ |
| 204 | unsigned char ctrls3; |
| 205 | unsigned char ctrls2; |
| 206 | unsigned char ctrls1; |
| 207 | unsigned char ctrls0; |
| 208 | } XkbCtrlsAction; |
| 209 | |
| 210 | #define XkbActionSetCtrls(a, c) ((a)->ctrls3 = ((c) >> 24) & 0xff, \ |
| 211 | (a)->ctrls2 = ((c) >> 16) & 0xff, \ |
| 212 | (a)->ctrls1 = ((c) >> 8) & 0xff, \ |
| 213 | (a)->ctrls0 = (c) & 0xff) |
| 214 | #define XkbActionCtrls(a) ((((unsigned int)(a)->ctrls3)<<24)|\ |
| 215 | (((unsigned int)(a)->ctrls2)<<16)|\ |
| 216 | (((unsigned int)(a)->ctrls1)<<8)|\ |
| 217 | ((unsigned int) (a)->ctrls0)) |
| 218 | |
| 219 | typedef struct _XkbMessageAction { |
| 220 | unsigned char type; |
| 221 | unsigned char flags; |
| 222 | unsigned char message[6]; |
| 223 | } XkbMessageAction; |
| 224 | |
| 225 | typedef struct _XkbRedirectKeyAction { |
| 226 | unsigned char type; |
| 227 | unsigned char new_key; |
| 228 | unsigned char mods_mask; |
| 229 | unsigned char mods; |
| 230 | /* FIXME: Make this an int. */ |
| 231 | unsigned char vmods_mask0; |
| 232 | unsigned char vmods_mask1; |
| 233 | unsigned char vmods0; |
| 234 | unsigned char vmods1; |
| 235 | } XkbRedirectKeyAction; |
| 236 | |
| 237 | #define XkbSARedirectVMods(a) ((((unsigned int)(a)->vmods1)<<8)|\ |
| 238 | ((unsigned int)(a)->vmods0)) |
| 239 | /* FIXME: This is blatantly not setting vmods. Yeesh. */ |
| 240 | #define XkbSARedirectSetVMods(a,m) (((a)->vmods_mask1=(((m)>>8)&0xff)),\ |
| 241 | ((a)->vmods_mask0=((m)&0xff))) |
| 242 | #define XkbSARedirectVModsMask(a) ((((unsigned int)(a)->vmods_mask1)<<8)|\ |
| 243 | ((unsigned int)(a)->vmods_mask0)) |
| 244 | #define XkbSARedirectSetVModsMask(a,m) (((a)->vmods_mask1=(((m)>>8)&0xff)),\ |
| 245 | ((a)->vmods_mask0=((m)&0xff))) |
| 246 | |
| 247 | typedef struct _XkbDeviceBtnAction { |
| 248 | unsigned char type; |
| 249 | unsigned char flags; |
| 250 | unsigned char count; |
| 251 | unsigned char button; |
| 252 | unsigned char device; |
| 253 | } XkbDeviceBtnAction; |
| 254 | |
| 255 | typedef struct _XkbDeviceValuatorAction { |
| 256 | unsigned char type; |
| 257 | unsigned char device; |
| 258 | unsigned char v1_what; |
| 259 | unsigned char v1_ndx; |
| 260 | unsigned char v1_value; |
| 261 | unsigned char v2_what; |
| 262 | unsigned char v2_ndx; |
| 263 | unsigned char v2_value; |
| 264 | } XkbDeviceValuatorAction; |
| 265 | |
| 266 | typedef union _XkbAction { |
| 267 | XkbAnyAction any; |
| 268 | XkbModAction mods; |
| 269 | XkbGroupAction group; |
| 270 | XkbISOAction iso; |
| 271 | XkbPtrAction ptr; |
| 272 | XkbPtrBtnAction btn; |
| 273 | XkbPtrDfltAction dflt; |
| 274 | XkbSwitchScreenAction screen; |
| 275 | XkbCtrlsAction ctrls; |
| 276 | XkbMessageAction msg; |
| 277 | XkbRedirectKeyAction redirect; |
| 278 | XkbDeviceBtnAction devbtn; |
| 279 | XkbDeviceValuatorAction devval; |
| 280 | unsigned char type; |
| 281 | } XkbAction; |
| 282 | |
| 283 | typedef struct _XkbControls { |
| 284 | unsigned char mk_dflt_btn; |
| 285 | unsigned char num_groups; |
| 286 | unsigned char groups_wrap; |
| 287 | XkbModsRec internal; |
| 288 | XkbModsRec ignore_lock; |
| 289 | unsigned int enabled_ctrls; |
| 290 | unsigned short repeat_delay; |
| 291 | unsigned short repeat_interval; |
| 292 | unsigned short slow_keys_delay; |
| 293 | unsigned short debounce_delay; |
| 294 | unsigned short mk_delay; |
| 295 | unsigned short mk_interval; |
| 296 | unsigned short mk_time_to_max; |
| 297 | unsigned short mk_max_speed; |
| 298 | short mk_curve; |
| 299 | unsigned short ax_options; |
| 300 | unsigned short ax_timeout; |
| 301 | unsigned short axt_opts_mask; |
| 302 | unsigned short axt_opts_values; |
| 303 | unsigned int axt_ctrls_mask; |
| 304 | unsigned int axt_ctrls_values; |
| 305 | unsigned char per_key_repeat[XkbPerKeyBitArraySize]; |
| 306 | } XkbControlsRec, *XkbControlsPtr; |
| 307 | |
| 308 | #define XkbAX_AnyFeedback(c) ((c)->enabled_ctrls&XkbAccessXFeedbackMask) |
| 309 | #define XkbAX_NeedOption(c,w) ((c)->ax_options&(w)) |
| 310 | #define XkbAX_NeedFeedback(c, w) (XkbAX_AnyFeedback((c)) && \ |
| 311 | XkbAX_NeedOption((c), (w))) |
| 312 | |
| 313 | typedef struct _XkbServerMapRec { |
| 314 | unsigned short num_acts; |
| 315 | unsigned short size_acts; |
| 316 | XkbAction *acts; |
| 317 | |
| 318 | XkbBehavior *behaviors; |
| 319 | unsigned short *key_acts; |
| 320 | #if defined(__cplusplus) || defined(c_plusplus) |
| 321 | /* explicit is a C++ reserved word */ |
| 322 | unsigned char *c_explicit; |
| 323 | #else |
| 324 | unsigned char *explicit; |
| 325 | #endif |
| 326 | unsigned char vmods[XkbNumVirtualMods]; |
| 327 | unsigned short *vmodmap; |
| 328 | } XkbServerMapRec, *XkbServerMapPtr; |
| 329 | |
| 330 | #define XkbSMKeyActionsPtr(m, k) (&(m)->acts[(m)->key_acts[(k)]]) |
| 331 | |
| 332 | /* |
| 333 | * Structures and access macros used primarily by clients |
| 334 | */ |
| 335 | |
| 336 | typedef struct _XkbSymMapRec { |
| 337 | unsigned char kt_index[XkbNumKbdGroups]; |
| 338 | unsigned char group_info; |
| 339 | unsigned char width; |
| 340 | unsigned short offset; |
| 341 | } XkbSymMapRec, *XkbSymMapPtr; |
| 342 | |
| 343 | typedef struct _XkbClientMapRec { |
| 344 | unsigned char size_types; |
| 345 | unsigned char num_types; |
| 346 | XkbKeyTypePtr types; |
| 347 | |
| 348 | unsigned short size_syms; |
| 349 | unsigned short num_syms; |
| 350 | KeySym *syms; |
| 351 | XkbSymMapPtr key_sym_map; |
| 352 | |
| 353 | unsigned char *modmap; |
| 354 | } XkbClientMapRec, *XkbClientMapPtr; |
| 355 | |
| 356 | #define XkbCMKeyGroupInfo(m, k) ((m)->key_sym_map[(k)].group_info) |
| 357 | #define XkbCMKeyNumGroups(m, k) (XkbNumGroups((m)->key_sym_map[(k)].group_info)) |
| 358 | #define XkbCMKeyGroupWidth(m, k, g) (XkbCMKeyType((m), (k), (g))->num_levels) |
| 359 | #define XkbCMKeyGroupsWidth(m, k) ((m)->key_sym_map[(k)].width) |
| 360 | #define XkbCMKeyTypeIndex(m, k, g) ((m)->key_sym_map[(k)].kt_index[(g) & 0x3]) |
| 361 | #define XkbCMKeyType(m, k, g) (&(m)->types[XkbCMKeyTypeIndex((m), (k), (g))]) |
| 362 | #define XkbCMKeyNumSyms(m, k) (XkbCMKeyGroupsWidth((m), (k)) * \ |
| 363 | XkbCMKeyNumGroups((m), (k))) |
| 364 | #define XkbCMKeySymsOffset(m, k) ((m)->key_sym_map[(k)].offset) |
| 365 | #define XkbCMKeySymsPtr(m, k) (&(m)->syms[XkbCMKeySymsOffset((m), (k))]) |
| 366 | |
| 367 | /* |
| 368 | * Compatibility structures and access macros |
| 369 | */ |
| 370 | |
| 371 | typedef struct _XkbSymInterpretRec { |
| 372 | KeySym sym; |
| 373 | unsigned char flags; |
| 374 | unsigned char match; |
| 375 | unsigned char mods; |
| 376 | unsigned char virtual_mod; |
| 377 | XkbAnyAction act; |
| 378 | } XkbSymInterpretRec, *XkbSymInterpretPtr; |
| 379 | |
| 380 | typedef struct _XkbCompatMapRec { |
| 381 | XkbSymInterpretPtr sym_interpret; |
| 382 | XkbModsRec groups[XkbNumKbdGroups]; |
| 383 | unsigned short num_si; |
| 384 | unsigned short size_si; |
| 385 | } XkbCompatMapRec, *XkbCompatMapPtr; |
| 386 | |
| 387 | typedef struct _XkbIndicatorMapRec { |
| 388 | unsigned char flags; |
| 389 | /* FIXME: For some reason, interepretation of groups is wildly |
| 390 | * different between which being base/latched/locked. */ |
| 391 | unsigned char which_groups; |
| 392 | unsigned char groups; |
| 393 | unsigned char which_mods; |
| 394 | XkbModsRec mods; |
| 395 | unsigned int ctrls; |
| 396 | } XkbIndicatorMapRec, *XkbIndicatorMapPtr; |
| 397 | |
| 398 | #define XkbIM_IsAuto(i) (!((i)->flags & XkbIM_NoAutomatic) && \ |
| 399 | (((i)->which_groups&&(i)->groups)||\ |
| 400 | ((i)->which_mods&&(i)->mods.mask)||\ |
| 401 | (i)->ctrls)) |
| 402 | #define XkbIM_InUse(i) ((i)->flags || (i)->which_groups || (i)->which_mods || \ |
| 403 | (i)->ctrls) |
| 404 | |
| 405 | typedef struct _XkbIndicatorRec { |
| 406 | unsigned long phys_indicators; |
| 407 | XkbIndicatorMapRec maps[XkbNumIndicators]; |
| 408 | } XkbIndicatorRec, *XkbIndicatorPtr; |
| 409 | |
| 410 | typedef struct _XkbKeyNameRec { |
| 411 | char name[XkbKeyNameLength]; |
| 412 | } XkbKeyNameRec, *XkbKeyNamePtr; |
| 413 | |
| 414 | typedef struct _XkbKeyAliasRec { |
| 415 | char real[XkbKeyNameLength]; |
| 416 | char alias[XkbKeyNameLength]; |
| 417 | } XkbKeyAliasRec, *XkbKeyAliasPtr; |
| 418 | |
| 419 | /* |
| 420 | * Names for everything |
| 421 | */ |
| 422 | typedef struct _XkbNamesRec { |
| 423 | Atom keycodes; |
| 424 | Atom geometry; |
| 425 | Atom symbols; |
| 426 | Atom types; |
| 427 | Atom compat; |
| 428 | Atom vmods[XkbNumVirtualMods]; |
| 429 | Atom indicators[XkbNumIndicators]; |
| 430 | Atom groups[XkbNumKbdGroups]; |
| 431 | XkbKeyNamePtr keys; |
| 432 | XkbKeyAliasPtr key_aliases; |
| 433 | Atom *radio_groups; |
| 434 | Atom phys_symbols; |
| 435 | |
| 436 | unsigned char num_keys; |
| 437 | unsigned char num_key_aliases; |
| 438 | unsigned short num_rg; |
| 439 | } XkbNamesRec, *XkbNamesPtr; |
| 440 | |
| 441 | typedef struct _XkbGeometry *XkbGeometryPtr; |
| 442 | |
| 443 | /* |
| 444 | * Tie it all together into one big keyboard description |
| 445 | */ |
| 446 | typedef struct _XkbDesc { |
| 447 | unsigned int defined; |
| 448 | unsigned short flags; |
| 449 | unsigned short device_spec; |
| 450 | KeyCode min_key_code; |
| 451 | KeyCode max_key_code; |
| 452 | |
| 453 | XkbControlsPtr ctrls; |
| 454 | XkbServerMapPtr server; |
| 455 | XkbClientMapPtr map; |
| 456 | XkbIndicatorPtr indicators; |
| 457 | XkbNamesPtr names; |
| 458 | XkbCompatMapPtr compat; |
| 459 | XkbGeometryPtr geom; |
| 460 | } XkbDescRec, *XkbDescPtr; |
| 461 | |
| 462 | #define XkbKeyKeyTypeIndex(d, k, g) (XkbCMKeyTypeIndex((d)->map, (k), (g))) |
| 463 | #define XkbKeyKeyType(d, k, g) (XkbCMKeyType((d)->map, (k), (g))) |
| 464 | #define XkbKeyGroupWidth(d, k, g) (XkbCMKeyGroupWidth((d)->map, (k), (g))) |
| 465 | #define XkbKeyGroupsWidth(d, k) (XkbCMKeyGroupsWidth((d)->map, (k))) |
| 466 | #define XkbKeyGroupInfo(d,k) (XkbCMKeyGroupInfo((d)->map,(k))) |
| 467 | #define XkbKeyNumGroups(d,k) (XkbCMKeyNumGroups((d)->map,(k))) |
| 468 | #define XkbKeyNumSyms(d,k) (XkbCMKeyNumSyms((d)->map,(k))) |
| 469 | #define XkbKeySymsPtr(d,k) (XkbCMKeySymsPtr((d)->map,(k))) |
| 470 | #define XkbKeySym(d, k, n) (XkbKeySymsPtr((d), (k))[(n)]) |
| 471 | #define XkbKeySymEntry(d,k,sl,g) \ |
| 472 | (XkbKeySym((d), (k), (XkbKeyGroupsWidth((d), (k)) * (g)) + (sl))) |
| 473 | #define XkbKeyAction(d,k,n) \ |
| 474 | (XkbKeyHasActions((d), (k)) ? & XkbKeyActionsPtr((d), (k))[(n)] : NULL) |
| 475 | #define XkbKeyActionEntry(d,k,sl,g) \ |
| 476 | (XkbKeyHasActions((d), (k)) ? \ |
| 477 | XkbKeyAction((d), (k), ((XkbKeyGroupsWidth((d), (k)) * (g)) + (sl))) : \ |
| 478 | NULL) |
| 479 | |
| 480 | #define XkbKeyHasActions(d, k) (!!(d)->server->key_acts[(k)]) |
| 481 | #define XkbKeyNumActions(d, k) (XkbKeyHasActions((d), (k)) ? \ |
| 482 | XkbKeyNumSyms((d), (k)) : 1) |
| 483 | #define XkbKeyActionsPtr(d, k) (XkbSMKeyActionsPtr((d)->server, (k))) |
| 484 | #define XkbKeycodeInRange(d, k) ((k) >= (d)->min_key_code && \ |
| 485 | (k) <= (d)->max_key_code) |
| 486 | #define XkbNumKeys(d) ((d)->max_key_code-(d)->min_key_code+1) |
| 487 | |
| 488 | /* |
| 489 | * The following structures can be used to track changes |
| 490 | * to a keyboard device |
| 491 | */ |
| 492 | typedef struct _XkbMapChanges { |
| 493 | unsigned short changed; |
| 494 | KeyCode min_key_code; |
| 495 | KeyCode max_key_code; |
| 496 | unsigned char first_type; |
| 497 | unsigned char num_types; |
| 498 | KeyCode first_key_sym; |
| 499 | unsigned char num_key_syms; |
| 500 | KeyCode first_key_act; |
| 501 | unsigned char num_key_acts; |
| 502 | KeyCode first_key_behavior; |
| 503 | unsigned char num_key_behaviors; |
| 504 | KeyCode first_key_explicit; |
| 505 | unsigned char num_key_explicit; |
| 506 | KeyCode first_modmap_key; |
| 507 | unsigned char num_modmap_keys; |
| 508 | KeyCode first_vmodmap_key; |
| 509 | unsigned char num_vmodmap_keys; |
| 510 | unsigned char pad; |
| 511 | unsigned short vmods; |
| 512 | } XkbMapChangesRec, *XkbMapChangesPtr; |
| 513 | |
| 514 | typedef struct _XkbControlsChanges { |
| 515 | unsigned int changed_ctrls; |
| 516 | unsigned int enabled_ctrls_changes; |
| 517 | Bool num_groups_changed; |
| 518 | } XkbControlsChangesRec, *XkbControlsChangesPtr; |
| 519 | |
| 520 | typedef struct _XkbIndicatorChanges { |
| 521 | unsigned int state_changes; |
| 522 | unsigned int map_changes; |
| 523 | } XkbIndicatorChangesRec, *XkbIndicatorChangesPtr; |
| 524 | |
| 525 | typedef struct _XkbNameChanges { |
| 526 | unsigned int changed; |
| 527 | unsigned char first_type; |
| 528 | unsigned char num_types; |
| 529 | unsigned char first_lvl; |
| 530 | unsigned char num_lvls; |
| 531 | unsigned char num_aliases; |
| 532 | unsigned char num_rg; |
| 533 | unsigned char first_key; |
| 534 | unsigned char num_keys; |
| 535 | unsigned short changed_vmods; |
| 536 | unsigned long changed_indicators; |
| 537 | unsigned char changed_groups; |
| 538 | } XkbNameChangesRec, *XkbNameChangesPtr; |
| 539 | |
| 540 | typedef struct _XkbCompatChanges { |
| 541 | unsigned char changed_groups; |
| 542 | unsigned short first_si; |
| 543 | unsigned short num_si; |
| 544 | } XkbCompatChangesRec, *XkbCompatChangesPtr; |
| 545 | |
| 546 | typedef struct _XkbChanges { |
| 547 | unsigned short device_spec; |
| 548 | unsigned short state_changes; |
| 549 | XkbMapChangesRec map; |
| 550 | XkbControlsChangesRec ctrls; |
| 551 | XkbIndicatorChangesRec indicators; |
| 552 | XkbNameChangesRec names; |
| 553 | XkbCompatChangesRec compat; |
| 554 | } XkbChangesRec, *XkbChangesPtr; |
| 555 | |
| 556 | /* |
| 557 | * These data structures are used to construct a keymap from |
| 558 | * a set of components or to list components in the server |
| 559 | * database. |
| 560 | */ |
| 561 | typedef struct _XkbComponentNames { |
| 562 | char *keycodes; |
| 563 | char *types; |
| 564 | char *compat; |
| 565 | char *symbols; |
| 566 | char *geometry; |
| 567 | } XkbComponentNamesRec, *XkbComponentNamesPtr; |
| 568 | |
| 569 | typedef struct _XkbComponentName { |
| 570 | unsigned short flags; |
| 571 | char *name; |
| 572 | } XkbComponentNameRec, *XkbComponentNamePtr; |
| 573 | |
| 574 | typedef struct _XkbComponentList { |
| 575 | int num_keymaps; |
| 576 | int num_keycodes; |
| 577 | int num_types; |
| 578 | int num_compat; |
| 579 | int num_symbols; |
| 580 | int num_geometry; |
| 581 | XkbComponentNamePtr keymaps; |
| 582 | XkbComponentNamePtr keycodes; |
| 583 | XkbComponentNamePtr types; |
| 584 | XkbComponentNamePtr compat; |
| 585 | XkbComponentNamePtr symbols; |
| 586 | XkbComponentNamePtr geometry; |
| 587 | } XkbComponentListRec, *XkbComponentListPtr; |
| 588 | |
| 589 | /* |
| 590 | * The following data structures describe and track changes to a |
| 591 | * non-keyboard extension device |
| 592 | */ |
| 593 | typedef struct _XkbDeviceLedInfo { |
| 594 | unsigned short led_class; |
| 595 | unsigned short led_id; |
| 596 | unsigned int phys_indicators; |
| 597 | unsigned int maps_present; |
| 598 | unsigned int names_present; |
| 599 | unsigned int state; |
| 600 | Atom names[XkbNumIndicators]; |
| 601 | XkbIndicatorMapRec maps[XkbNumIndicators]; |
| 602 | } XkbDeviceLedInfoRec, *XkbDeviceLedInfoPtr; |
| 603 | |
| 604 | typedef struct _XkbDeviceInfo { |
| 605 | char *name; |
| 606 | Atom type; |
| 607 | unsigned short device_spec; |
| 608 | Bool has_own_state; |
| 609 | unsigned short supported; |
| 610 | unsigned short unsupported; |
| 611 | |
| 612 | unsigned short num_btns; |
| 613 | XkbAction *btn_acts; |
| 614 | |
| 615 | unsigned short sz_leds; |
| 616 | unsigned short num_leds; |
| 617 | unsigned short dflt_kbd_fb; |
| 618 | unsigned short dflt_led_fb; |
| 619 | XkbDeviceLedInfoPtr leds; |
| 620 | } XkbDeviceInfoRec, *XkbDeviceInfoPtr; |
| 621 | |
| 622 | #define XkbXI_DevHasBtnActs(d) ((d)->num_btns > 0 && (d)->btn_acts) |
| 623 | #define XkbXI_LegalDevBtn(d,b) (XkbXI_DevHasBtnActs(d) && (b) < (d)->num_btns) |
| 624 | #define XkbXI_DevHasLeds(d) ((d)->num_leds > 0 && (d)->leds) |
| 625 | |
| 626 | typedef struct _XkbDeviceLedChanges { |
| 627 | unsigned short led_class; |
| 628 | unsigned short led_id; |
| 629 | unsigned int defined; /* names or maps changed */ |
| 630 | struct _XkbDeviceLedChanges *next; |
| 631 | } XkbDeviceLedChangesRec, *XkbDeviceLedChangesPtr; |
| 632 | |
| 633 | typedef struct _XkbDeviceChanges { |
| 634 | unsigned int changed; |
| 635 | unsigned short first_btn; |
| 636 | unsigned short num_btns; |
| 637 | XkbDeviceLedChangesRec leds; |
| 638 | } XkbDeviceChangesRec, *XkbDeviceChangesPtr; |
| 639 | |
| 640 | #endif /* _XKBSTR_H_ */ |