2 Copyright 1985, 1987, 1990, 1998 The Open Group
3 Copyright 2008 Dan Nicholson
5 Permission is hereby granted, free of charge, to any person obtaining a
6 copy of this software and associated documentation files (the "Software"),
7 to deal in the Software without restriction, including without limitation
8 the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 and/or sell copies of the Software, and to permit persons to whom the
10 Software is furnished to do so, subject to the following conditions:
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the names of the authors or their
23 institutions shall not be used in advertising or otherwise to promote the
24 sale, use or other dealings in this Software without prior written
25 authorization from the authors.
28 /************************************************************
29 Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
31 Permission to use, copy, modify, and distribute this
32 software and its documentation for any purpose and without
33 fee is hereby granted, provided that the above copyright
34 notice appear in all copies and that both that copyright
35 notice and this permission notice appear in supporting
36 documentation, and that the name of Silicon Graphics not be
37 used in advertising or publicity pertaining to distribution
38 of the software without specific prior written permission.
39 Silicon Graphics makes no representation about the suitability
40 of this software for any purpose. It is provided "as is"
41 without any express or implied warranty.
43 SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
44 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
45 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
46 GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
47 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
48 DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
49 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
50 THE USE OR PERFORMANCE OF THIS SOFTWARE.
52 ********************************************************/
55 * Copyright © 2012 Intel Corporation
57 * Permission is hereby granted, free of charge, to any person obtaining a
58 * copy of this software and associated documentation files (the "Software"),
59 * to deal in the Software without restriction, including without limitation
60 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
61 * and/or sell copies of the Software, and to permit persons to whom the
62 * Software is furnished to do so, subject to the following conditions:
64 * The above copyright notice and this permission notice (including the next
65 * paragraph) shall be included in all copies or substantial portions of the
68 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
69 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
70 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
71 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
72 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
73 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
74 * DEALINGS IN THE SOFTWARE.
76 * Author: Daniel Stone <daniel@fooishbar.org>
79 #ifndef _XKBCOMMONINT_H_
80 #define _XKBCOMMONINT_H_
85 #include "xkbcommon/xkbcommon.h"
95 #define XkmFileVersion 15
97 #define XkmIllegalFile -1
98 #define XkmSemanticsFile 20
99 #define XkmLayoutFile 21
100 #define XkmKeymapFile 22
101 #define XkmGeometryFile 23
102 #define XkmRulesFile 24
104 #define XkmTypesIndex 0
105 #define XkmCompatMapIndex 1
106 #define XkmSymbolsIndex 2
107 #define XkmIndicatorsIndex 3
108 #define XkmKeyNamesIndex 4
109 #define XkmGeometryIndex 5
110 #define XkmVirtualModsIndex 6
111 #define XkmLastIndex XkmVirtualModsIndex
113 #define XkmTypesMask (1<<0)
114 #define XkmCompatMapMask (1<<1)
115 #define XkmSymbolsMask (1<<2)
116 #define XkmIndicatorsMask (1<<3)
117 #define XkmKeyNamesMask (1<<4)
118 #define XkmGeometryMask (1<<5)
119 #define XkmVirtualModsMask (1<<6)
120 #define XkmLegalIndexMask (0x7f)
121 #define XkmAllIndicesMask (0x7f)
123 #define XkmSemanticsRequired (XkmCompatMapMask)
124 #define XkmSemanticsOptional (XkmTypesMask|XkmVirtualModsMask|XkmIndicatorsMask|XkmGeometryMask)
125 #define XkmSemanticsLegal (XkmSemanticsRequired|XkmSemanticsOptional)
126 #define XkmLayoutRequired (XkmKeyNamesMask|XkmSymbolsMask|XkmTypesMask)
127 #define XkmLayoutOptional (XkmVirtualModsMask|XkmGeometryMask)
128 #define XkmLayoutLegal (XkmLayoutRequired|XkmLayoutOptional)
129 #define XkmKeymapRequired (XkmSemanticsRequired|XkmLayoutRequired)
130 #define XkmKeymapOptional ((XkmSemanticsOptional|XkmLayoutOptional)&(~XkmKeymapRequired))
131 #define XkmKeymapLegal (XkmKeymapRequired|XkmKeymapOptional)
133 extern unsigned int xkb_key_get_group(struct xkb_state *state,
135 extern unsigned int xkb_key_get_level(struct xkb_state *state,
139 struct xkb_any_action {
144 struct xkb_mod_action {
152 struct xkb_group_action {
158 struct xkb_iso_action {
168 struct xkb_controls_action {
174 struct xkb_device_button_action {
182 struct xkb_device_valuator_action {
193 struct xkb_pointer_default_action {
200 struct xkb_switch_screen_action {
206 struct xkb_redirect_key_action {
208 xkb_keycode_t new_key;
215 struct xkb_pointer_action {
222 struct xkb_message_action {
228 struct xkb_pointer_button_action {
236 struct xkb_any_action any;
237 struct xkb_mod_action mods;
238 struct xkb_group_action group;
239 struct xkb_iso_action iso;
240 struct xkb_controls_action ctrls;
241 struct xkb_device_button_action devbtn;
242 struct xkb_device_valuator_action devval;
243 struct xkb_pointer_default_action dflt;
244 struct xkb_switch_screen_action screen;
245 struct xkb_redirect_key_action redirect; /* XXX wholly unnecessary? */
246 struct xkb_pointer_action ptr; /* XXX delete for DeviceValuator */
247 struct xkb_pointer_button_action btn; /* XXX delete for DeviceBtn */
248 struct xkb_message_action msg; /* XXX just delete */
253 uint32_t mask; /* effective mods */
258 struct xkb_kt_map_entry {
261 struct xkb_mods mods;
264 struct xkb_key_type {
265 struct xkb_mods mods;
267 unsigned char map_count;
268 struct xkb_kt_map_entry * map;
269 struct xkb_mods * preserve;
271 const char **level_names;
274 struct xkb_sym_interpret {
279 uint32_t virtual_mod;
280 union xkb_action act;
283 struct xkb_compat_map {
284 struct xkb_sym_interpret * sym_interpret;
285 struct xkb_mods groups[XkbNumKbdGroups];
286 unsigned short num_si;
287 unsigned short size_si;
291 unsigned char kt_index[XkbNumKbdGroups];
292 unsigned char group_info;
294 int *sym_index; /* per level/group index into 'syms' */
295 unsigned int *num_syms; /* per level/group */
297 unsigned int size_syms; /* size of 'syms' */
300 #define XkbNumGroups(g) ((g)&0x0f)
301 #define XkbOutOfRangeGroupInfo(g) ((g)&0xf0)
302 #define XkbOutOfRangeGroupAction(g) ((g)&0xc0)
303 #define XkbOutOfRangeGroupNumber(g) (((g)&0x30)>>4)
304 #define XkbSetGroupInfo(g,w,n) (((w)&0xc0)|(((n)&3)<<4)|((g)&0x0f))
305 #define XkbSetNumGroups(g,n) (((g)&0xf0)|((n)&0x0f))
307 struct xkb_client_map {
308 unsigned char size_types;
309 unsigned char num_types;
310 struct xkb_key_type * types;
311 struct xkb_sym_map * key_sym_map;
312 unsigned char *modmap;
315 struct xkb_behavior {
320 struct xkb_server_map {
321 unsigned short num_acts;
322 unsigned short size_acts;
324 #if defined(__cplusplus) || defined(c_plusplus)
325 /* explicit is a C++ reserved word */
326 unsigned char * c_explicit;
328 unsigned char * explicit;
331 union xkb_action *acts;
332 struct xkb_behavior *behaviors;
333 unsigned short *key_acts;
334 unsigned char *explicits;
335 uint32_t vmods[XkbNumVirtualMods]; /* vmod -> mod mapping */
336 uint32_t *vmodmap; /* key -> vmod mapping */
340 struct xkb_indicator_map {
342 unsigned char which_groups;
343 unsigned char groups;
344 unsigned char which_mods;
345 struct xkb_mods mods;
349 struct xkb_indicator {
350 unsigned long phys_indicators;
351 struct xkb_indicator_map maps[XkbNumIndicators];
354 struct xkb_key_name {
355 char name[XkbKeyNameLength];
358 struct xkb_key_alias {
359 char real[XkbKeyNameLength];
360 char alias[XkbKeyNameLength];
364 const char *vmods[XkbNumVirtualMods];
365 const char *indicators[XkbNumIndicators];
366 const char *groups[XkbNumKbdGroups];
367 struct xkb_key_name * keys;
368 struct xkb_key_alias * key_aliases;
370 xkb_keycode_t num_keys;
371 xkb_keycode_t num_key_aliases;
374 struct xkb_controls {
375 unsigned char num_groups;
376 unsigned char groups_wrap;
377 struct xkb_mods internal;
378 struct xkb_mods ignore_lock;
379 unsigned int enabled_ctrls;
380 unsigned short repeat_delay;
381 unsigned short repeat_interval;
382 unsigned short slow_keys_delay;
383 unsigned short debounce_delay;
384 unsigned short ax_options;
385 unsigned short ax_timeout;
386 unsigned short axt_opts_mask;
387 unsigned short axt_opts_values;
388 unsigned int axt_ctrls_mask;
389 unsigned int axt_ctrls_values;
390 unsigned char *per_key_repeat;
393 /* Common keyboard description structure */
395 struct xkb_context *context;
398 unsigned int defined;
399 unsigned short flags;
400 xkb_keycode_t min_key_code;
401 xkb_keycode_t max_key_code;
403 struct xkb_controls * ctrls;
404 struct xkb_server_map * server;
405 struct xkb_client_map * map;
406 struct xkb_indicator * indicators;
407 struct xkb_names * names;
408 struct xkb_compat_map * compat;
411 #define XkbKeyGroupInfo(d,k) ((d)->map->key_sym_map[k].group_info)
412 #define XkbKeyNumGroups(d,k) (XkbNumGroups((d)->map->key_sym_map[k].group_info))
413 #define XkbKeyGroupWidth(d,k,g) (XkbKeyType(d,k,g)->num_levels)
414 #define XkbKeyGroupsWidth(d,k) ((d)->map->key_sym_map[k].width)
415 #define XkbKeyTypeIndex(d,k,g) ((d)->map->key_sym_map[k].kt_index[g&0x3])
416 #define XkbKeyType(d,k,g) (&(d)->map->types[XkbKeyTypeIndex(d,k,g)])
417 #define XkbKeyNumSyms(d,k,g,sl) \
418 ((d)->map->key_sym_map[k].num_syms[(g*XkbKeyGroupsWidth(d,k))+sl])
419 #define XkbKeySym(d,k,n) (&(d)->map->key_sym_map[k].syms[n])
420 #define XkbKeySymOffset(d,k,g,sl) \
421 ((d)->map->key_sym_map[k].sym_index[(g*XkbKeyGroupsWidth(d,k))+sl])
422 #define XkbKeySymEntry(d,k,g,sl) \
423 (XkbKeySym(d,k,XkbKeySymOffset(d,k,g,sl)))
424 #define XkbKeyHasActions(d,k) ((d)->server->key_acts[k]!=0)
425 #define XkbKeyNumActions(d,k) \
426 (XkbKeyHasActions(d,k)?(XkbKeyGroupsWidth(d,k)*XkbKeyNumGroups(d,k)):1)
427 #define XkbKeyActionsPtr(d,k) (&(d)->server->acts[(d)->server->key_acts[k]])
428 #define XkbKeyAction(d,k,n) \
429 (XkbKeyHasActions(d,k)?&XkbKeyActionsPtr(d,k)[n]:NULL)
430 #define XkbKeyActionEntry(d,k,sl,g) \
431 (XkbKeyHasActions(d,k)?\
432 XkbKeyAction(d,k,((XkbKeyGroupsWidth(d,k)*(g))+(sl))):NULL)
434 #define XkbKeycodeInRange(d,k) (((k)>=(d)->min_key_code)&&\
435 ((k)<=(d)->max_key_code))
436 #define XkbNumKeys(d) ((d)->max_key_code-(d)->min_key_code+1)
438 struct xkb_component_name {
439 unsigned short flags;
444 xkb_group_index_t base_group; /**< depressed */
445 xkb_group_index_t latched_group;
446 xkb_group_index_t locked_group;
447 xkb_group_index_t group; /**< effective */
449 xkb_mod_mask_t base_mods; /**< depressed */
450 xkb_mod_mask_t latched_mods;
451 xkb_mod_mask_t locked_mods;
452 xkb_mod_mask_t mods; /**< effective */
459 struct xkb_keymap *xkb;
462 #define XkbStateFieldFromRec(s) XkbBuildCoreState((s)->lookup_mods,(s)->group)
463 #define XkbGrabStateFromRec(s) XkbBuildCoreState((s)->grab_mods,(s)->group)
465 #define XkbNumGroups(g) ((g)&0x0f)
466 #define XkbOutOfRangeGroupInfo(g) ((g)&0xf0)
467 #define XkbOutOfRangeGroupAction(g) ((g)&0xc0)
468 #define XkbOutOfRangeGroupNumber(g) (((g)&0x30)>>4)
469 #define XkbSetNumGroups(g,n) (((g)&0xf0)|((n)&0x0f))
471 #endif /* _XKBCOMMONINT_H_ */