1*2b949d04SAndroid Build Coastguard Worker /*
2*2b949d04SAndroid Build Coastguard Worker * Copyright 1985, 1987, 1990, 1998 The Open Group
3*2b949d04SAndroid Build Coastguard Worker *
4*2b949d04SAndroid Build Coastguard Worker * Permission is hereby granted, free of charge, to any person obtaining a
5*2b949d04SAndroid Build Coastguard Worker * copy of this software and associated documentation files (the "Software"),
6*2b949d04SAndroid Build Coastguard Worker * to deal in the Software without restriction, including without limitation
7*2b949d04SAndroid Build Coastguard Worker * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*2b949d04SAndroid Build Coastguard Worker * and/or sell copies of the Software, and to permit persons to whom the
9*2b949d04SAndroid Build Coastguard Worker * Software is furnished to do so, subject to the following conditions:
10*2b949d04SAndroid Build Coastguard Worker *
11*2b949d04SAndroid Build Coastguard Worker * The above copyright notice and this permission notice shall be included in
12*2b949d04SAndroid Build Coastguard Worker * all copies or substantial portions of the Software.
13*2b949d04SAndroid Build Coastguard Worker *
14*2b949d04SAndroid Build Coastguard Worker * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*2b949d04SAndroid Build Coastguard Worker * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*2b949d04SAndroid Build Coastguard Worker * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17*2b949d04SAndroid Build Coastguard Worker * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18*2b949d04SAndroid Build Coastguard Worker * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19*2b949d04SAndroid Build Coastguard Worker * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20*2b949d04SAndroid Build Coastguard Worker *
21*2b949d04SAndroid Build Coastguard Worker * Except as contained in this notice, the names of the authors or their
22*2b949d04SAndroid Build Coastguard Worker * institutions shall not be used in advertising or otherwise to promote the
23*2b949d04SAndroid Build Coastguard Worker * sale, use or other dealings in this Software without prior written
24*2b949d04SAndroid Build Coastguard Worker * authorization from the authors.
25*2b949d04SAndroid Build Coastguard Worker */
26*2b949d04SAndroid Build Coastguard Worker
27*2b949d04SAndroid Build Coastguard Worker /************************************************************
28*2b949d04SAndroid Build Coastguard Worker * Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
29*2b949d04SAndroid Build Coastguard Worker *
30*2b949d04SAndroid Build Coastguard Worker * Permission to use, copy, modify, and distribute this
31*2b949d04SAndroid Build Coastguard Worker * software and its documentation for any purpose and without
32*2b949d04SAndroid Build Coastguard Worker * fee is hereby granted, provided that the above copyright
33*2b949d04SAndroid Build Coastguard Worker * notice appear in all copies and that both that copyright
34*2b949d04SAndroid Build Coastguard Worker * notice and this permission notice appear in supporting
35*2b949d04SAndroid Build Coastguard Worker * documentation, and that the name of Silicon Graphics not be
36*2b949d04SAndroid Build Coastguard Worker * used in advertising or publicity pertaining to distribution
37*2b949d04SAndroid Build Coastguard Worker * of the software without specific prior written permission.
38*2b949d04SAndroid Build Coastguard Worker * Silicon Graphics makes no representation about the suitability
39*2b949d04SAndroid Build Coastguard Worker * of this software for any purpose. It is provided "as is"
40*2b949d04SAndroid Build Coastguard Worker * without any express or implied warranty.
41*2b949d04SAndroid Build Coastguard Worker *
42*2b949d04SAndroid Build Coastguard Worker * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
43*2b949d04SAndroid Build Coastguard Worker * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
44*2b949d04SAndroid Build Coastguard Worker * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
45*2b949d04SAndroid Build Coastguard Worker * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
46*2b949d04SAndroid Build Coastguard Worker * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
47*2b949d04SAndroid Build Coastguard Worker * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
48*2b949d04SAndroid Build Coastguard Worker * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
49*2b949d04SAndroid Build Coastguard Worker * THE USE OR PERFORMANCE OF THIS SOFTWARE.
50*2b949d04SAndroid Build Coastguard Worker *
51*2b949d04SAndroid Build Coastguard Worker ********************************************************/
52*2b949d04SAndroid Build Coastguard Worker
53*2b949d04SAndroid Build Coastguard Worker /*
54*2b949d04SAndroid Build Coastguard Worker * Copyright © 2009 Dan Nicholson
55*2b949d04SAndroid Build Coastguard Worker * Copyright © 2012 Intel Corporation
56*2b949d04SAndroid Build Coastguard Worker * Copyright © 2012 Ran Benita
57*2b949d04SAndroid Build Coastguard Worker *
58*2b949d04SAndroid Build Coastguard Worker * Permission is hereby granted, free of charge, to any person obtaining a
59*2b949d04SAndroid Build Coastguard Worker * copy of this software and associated documentation files (the "Software"),
60*2b949d04SAndroid Build Coastguard Worker * to deal in the Software without restriction, including without limitation
61*2b949d04SAndroid Build Coastguard Worker * the rights to use, copy, modify, merge, publish, distribute, sublicense,
62*2b949d04SAndroid Build Coastguard Worker * and/or sell copies of the Software, and to permit persons to whom the
63*2b949d04SAndroid Build Coastguard Worker * Software is furnished to do so, subject to the following conditions:
64*2b949d04SAndroid Build Coastguard Worker *
65*2b949d04SAndroid Build Coastguard Worker * The above copyright notice and this permission notice (including the next
66*2b949d04SAndroid Build Coastguard Worker * paragraph) shall be included in all copies or substantial portions of the
67*2b949d04SAndroid Build Coastguard Worker * Software.
68*2b949d04SAndroid Build Coastguard Worker *
69*2b949d04SAndroid Build Coastguard Worker * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
70*2b949d04SAndroid Build Coastguard Worker * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
71*2b949d04SAndroid Build Coastguard Worker * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
72*2b949d04SAndroid Build Coastguard Worker * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
73*2b949d04SAndroid Build Coastguard Worker * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
74*2b949d04SAndroid Build Coastguard Worker * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
75*2b949d04SAndroid Build Coastguard Worker * DEALINGS IN THE SOFTWARE.
76*2b949d04SAndroid Build Coastguard Worker *
77*2b949d04SAndroid Build Coastguard Worker * Author: Daniel Stone <[email protected]>
78*2b949d04SAndroid Build Coastguard Worker * Dan Nicholson <[email protected]>
79*2b949d04SAndroid Build Coastguard Worker */
80*2b949d04SAndroid Build Coastguard Worker
81*2b949d04SAndroid Build Coastguard Worker #ifndef KEYMAP_H
82*2b949d04SAndroid Build Coastguard Worker #define KEYMAP_H
83*2b949d04SAndroid Build Coastguard Worker
84*2b949d04SAndroid Build Coastguard Worker /* Don't use compat names in internal code. */
85*2b949d04SAndroid Build Coastguard Worker #define _XKBCOMMON_COMPAT_H
86*2b949d04SAndroid Build Coastguard Worker #include "xkbcommon/xkbcommon.h"
87*2b949d04SAndroid Build Coastguard Worker
88*2b949d04SAndroid Build Coastguard Worker #include "utils.h"
89*2b949d04SAndroid Build Coastguard Worker #include "context.h"
90*2b949d04SAndroid Build Coastguard Worker
91*2b949d04SAndroid Build Coastguard Worker /* This limit is artificially enforced, we do not depend on it any where.
92*2b949d04SAndroid Build Coastguard Worker * The reason it's still here is that the rules file format does not
93*2b949d04SAndroid Build Coastguard Worker * support multiple groups very well, and the rules shipped with
94*2b949d04SAndroid Build Coastguard Worker * xkeyboard-config (see rules/evdev) depend on this limit extensively.
95*2b949d04SAndroid Build Coastguard Worker * So just lifting this limit would cause problems for people who will use
96*2b949d04SAndroid Build Coastguard Worker * more than 4 layouts.
97*2b949d04SAndroid Build Coastguard Worker * TODO: Fix the group index syntax in the rules format, preferably in a
98*2b949d04SAndroid Build Coastguard Worker * backwards compatible way.
99*2b949d04SAndroid Build Coastguard Worker * See e.g. https://bugs.freedesktop.org/show_bug.cgi?id=14372
100*2b949d04SAndroid Build Coastguard Worker * Note: A limit on the number of groups we *do* depend on is imposed by
101*2b949d04SAndroid Build Coastguard Worker * the size of the xkb_layout_mask_t type (32). This is more than enough
102*2b949d04SAndroid Build Coastguard Worker * though.
103*2b949d04SAndroid Build Coastguard Worker */
104*2b949d04SAndroid Build Coastguard Worker #define XKB_MAX_GROUPS 4
105*2b949d04SAndroid Build Coastguard Worker
106*2b949d04SAndroid Build Coastguard Worker /* Don't allow more modifiers than we can hold in xkb_mod_mask_t. */
107*2b949d04SAndroid Build Coastguard Worker #define XKB_MAX_MODS ((xkb_mod_index_t) (sizeof(xkb_mod_mask_t) * 8))
108*2b949d04SAndroid Build Coastguard Worker
109*2b949d04SAndroid Build Coastguard Worker /* Don't allow more leds than we can hold in xkb_led_mask_t. */
110*2b949d04SAndroid Build Coastguard Worker #define XKB_MAX_LEDS ((xkb_led_index_t) (sizeof(xkb_led_mask_t) * 8))
111*2b949d04SAndroid Build Coastguard Worker
112*2b949d04SAndroid Build Coastguard Worker /* These should all go away. */
113*2b949d04SAndroid Build Coastguard Worker enum mod_type {
114*2b949d04SAndroid Build Coastguard Worker MOD_REAL = (1 << 0),
115*2b949d04SAndroid Build Coastguard Worker MOD_VIRT = (1 << 1),
116*2b949d04SAndroid Build Coastguard Worker MOD_BOTH = (MOD_REAL | MOD_VIRT),
117*2b949d04SAndroid Build Coastguard Worker };
118*2b949d04SAndroid Build Coastguard Worker #define MOD_REAL_MASK_ALL ((xkb_mod_mask_t) 0x000000ff)
119*2b949d04SAndroid Build Coastguard Worker
120*2b949d04SAndroid Build Coastguard Worker enum xkb_action_type {
121*2b949d04SAndroid Build Coastguard Worker ACTION_TYPE_NONE = 0,
122*2b949d04SAndroid Build Coastguard Worker ACTION_TYPE_MOD_SET,
123*2b949d04SAndroid Build Coastguard Worker ACTION_TYPE_MOD_LATCH,
124*2b949d04SAndroid Build Coastguard Worker ACTION_TYPE_MOD_LOCK,
125*2b949d04SAndroid Build Coastguard Worker ACTION_TYPE_GROUP_SET,
126*2b949d04SAndroid Build Coastguard Worker ACTION_TYPE_GROUP_LATCH,
127*2b949d04SAndroid Build Coastguard Worker ACTION_TYPE_GROUP_LOCK,
128*2b949d04SAndroid Build Coastguard Worker ACTION_TYPE_PTR_MOVE,
129*2b949d04SAndroid Build Coastguard Worker ACTION_TYPE_PTR_BUTTON,
130*2b949d04SAndroid Build Coastguard Worker ACTION_TYPE_PTR_LOCK,
131*2b949d04SAndroid Build Coastguard Worker ACTION_TYPE_PTR_DEFAULT,
132*2b949d04SAndroid Build Coastguard Worker ACTION_TYPE_TERMINATE,
133*2b949d04SAndroid Build Coastguard Worker ACTION_TYPE_SWITCH_VT,
134*2b949d04SAndroid Build Coastguard Worker ACTION_TYPE_CTRL_SET,
135*2b949d04SAndroid Build Coastguard Worker ACTION_TYPE_CTRL_LOCK,
136*2b949d04SAndroid Build Coastguard Worker ACTION_TYPE_PRIVATE,
137*2b949d04SAndroid Build Coastguard Worker _ACTION_TYPE_NUM_ENTRIES
138*2b949d04SAndroid Build Coastguard Worker };
139*2b949d04SAndroid Build Coastguard Worker
140*2b949d04SAndroid Build Coastguard Worker enum xkb_action_flags {
141*2b949d04SAndroid Build Coastguard Worker ACTION_LOCK_CLEAR = (1 << 0),
142*2b949d04SAndroid Build Coastguard Worker ACTION_LATCH_TO_LOCK = (1 << 1),
143*2b949d04SAndroid Build Coastguard Worker ACTION_LOCK_NO_LOCK = (1 << 2),
144*2b949d04SAndroid Build Coastguard Worker ACTION_LOCK_NO_UNLOCK = (1 << 3),
145*2b949d04SAndroid Build Coastguard Worker ACTION_MODS_LOOKUP_MODMAP = (1 << 4),
146*2b949d04SAndroid Build Coastguard Worker ACTION_ABSOLUTE_SWITCH = (1 << 5),
147*2b949d04SAndroid Build Coastguard Worker ACTION_ABSOLUTE_X = (1 << 6),
148*2b949d04SAndroid Build Coastguard Worker ACTION_ABSOLUTE_Y = (1 << 7),
149*2b949d04SAndroid Build Coastguard Worker ACTION_ACCEL = (1 << 8),
150*2b949d04SAndroid Build Coastguard Worker ACTION_SAME_SCREEN = (1 << 9),
151*2b949d04SAndroid Build Coastguard Worker };
152*2b949d04SAndroid Build Coastguard Worker
153*2b949d04SAndroid Build Coastguard Worker enum xkb_action_controls {
154*2b949d04SAndroid Build Coastguard Worker CONTROL_REPEAT = (1 << 0),
155*2b949d04SAndroid Build Coastguard Worker CONTROL_SLOW = (1 << 1),
156*2b949d04SAndroid Build Coastguard Worker CONTROL_DEBOUNCE = (1 << 2),
157*2b949d04SAndroid Build Coastguard Worker CONTROL_STICKY = (1 << 3),
158*2b949d04SAndroid Build Coastguard Worker CONTROL_MOUSEKEYS = (1 << 4),
159*2b949d04SAndroid Build Coastguard Worker CONTROL_MOUSEKEYS_ACCEL = (1 << 5),
160*2b949d04SAndroid Build Coastguard Worker CONTROL_AX = (1 << 6),
161*2b949d04SAndroid Build Coastguard Worker CONTROL_AX_TIMEOUT = (1 << 7),
162*2b949d04SAndroid Build Coastguard Worker CONTROL_AX_FEEDBACK = (1 << 8),
163*2b949d04SAndroid Build Coastguard Worker CONTROL_BELL = (1 << 9),
164*2b949d04SAndroid Build Coastguard Worker CONTROL_IGNORE_GROUP_LOCK = (1 << 10),
165*2b949d04SAndroid Build Coastguard Worker CONTROL_ALL = \
166*2b949d04SAndroid Build Coastguard Worker (CONTROL_REPEAT | CONTROL_SLOW | CONTROL_DEBOUNCE | CONTROL_STICKY | \
167*2b949d04SAndroid Build Coastguard Worker CONTROL_MOUSEKEYS | CONTROL_MOUSEKEYS_ACCEL | CONTROL_AX | \
168*2b949d04SAndroid Build Coastguard Worker CONTROL_AX_TIMEOUT | CONTROL_AX_FEEDBACK | CONTROL_BELL | \
169*2b949d04SAndroid Build Coastguard Worker CONTROL_IGNORE_GROUP_LOCK)
170*2b949d04SAndroid Build Coastguard Worker };
171*2b949d04SAndroid Build Coastguard Worker
172*2b949d04SAndroid Build Coastguard Worker enum xkb_match_operation {
173*2b949d04SAndroid Build Coastguard Worker MATCH_NONE,
174*2b949d04SAndroid Build Coastguard Worker MATCH_ANY_OR_NONE,
175*2b949d04SAndroid Build Coastguard Worker MATCH_ANY,
176*2b949d04SAndroid Build Coastguard Worker MATCH_ALL,
177*2b949d04SAndroid Build Coastguard Worker MATCH_EXACTLY,
178*2b949d04SAndroid Build Coastguard Worker };
179*2b949d04SAndroid Build Coastguard Worker
180*2b949d04SAndroid Build Coastguard Worker struct xkb_mods {
181*2b949d04SAndroid Build Coastguard Worker xkb_mod_mask_t mods; /* original real+virtual mods in definition */
182*2b949d04SAndroid Build Coastguard Worker xkb_mod_mask_t mask; /* computed effective mask */
183*2b949d04SAndroid Build Coastguard Worker };
184*2b949d04SAndroid Build Coastguard Worker
185*2b949d04SAndroid Build Coastguard Worker struct xkb_mod_action {
186*2b949d04SAndroid Build Coastguard Worker enum xkb_action_type type;
187*2b949d04SAndroid Build Coastguard Worker enum xkb_action_flags flags;
188*2b949d04SAndroid Build Coastguard Worker struct xkb_mods mods;
189*2b949d04SAndroid Build Coastguard Worker };
190*2b949d04SAndroid Build Coastguard Worker
191*2b949d04SAndroid Build Coastguard Worker struct xkb_group_action {
192*2b949d04SAndroid Build Coastguard Worker enum xkb_action_type type;
193*2b949d04SAndroid Build Coastguard Worker enum xkb_action_flags flags;
194*2b949d04SAndroid Build Coastguard Worker int32_t group;
195*2b949d04SAndroid Build Coastguard Worker };
196*2b949d04SAndroid Build Coastguard Worker
197*2b949d04SAndroid Build Coastguard Worker struct xkb_controls_action {
198*2b949d04SAndroid Build Coastguard Worker enum xkb_action_type type;
199*2b949d04SAndroid Build Coastguard Worker enum xkb_action_flags flags;
200*2b949d04SAndroid Build Coastguard Worker enum xkb_action_controls ctrls;
201*2b949d04SAndroid Build Coastguard Worker };
202*2b949d04SAndroid Build Coastguard Worker
203*2b949d04SAndroid Build Coastguard Worker struct xkb_pointer_default_action {
204*2b949d04SAndroid Build Coastguard Worker enum xkb_action_type type;
205*2b949d04SAndroid Build Coastguard Worker enum xkb_action_flags flags;
206*2b949d04SAndroid Build Coastguard Worker int8_t value;
207*2b949d04SAndroid Build Coastguard Worker };
208*2b949d04SAndroid Build Coastguard Worker
209*2b949d04SAndroid Build Coastguard Worker struct xkb_switch_screen_action {
210*2b949d04SAndroid Build Coastguard Worker enum xkb_action_type type;
211*2b949d04SAndroid Build Coastguard Worker enum xkb_action_flags flags;
212*2b949d04SAndroid Build Coastguard Worker int8_t screen;
213*2b949d04SAndroid Build Coastguard Worker };
214*2b949d04SAndroid Build Coastguard Worker
215*2b949d04SAndroid Build Coastguard Worker struct xkb_pointer_action {
216*2b949d04SAndroid Build Coastguard Worker enum xkb_action_type type;
217*2b949d04SAndroid Build Coastguard Worker enum xkb_action_flags flags;
218*2b949d04SAndroid Build Coastguard Worker int16_t x;
219*2b949d04SAndroid Build Coastguard Worker int16_t y;
220*2b949d04SAndroid Build Coastguard Worker };
221*2b949d04SAndroid Build Coastguard Worker
222*2b949d04SAndroid Build Coastguard Worker struct xkb_pointer_button_action {
223*2b949d04SAndroid Build Coastguard Worker enum xkb_action_type type;
224*2b949d04SAndroid Build Coastguard Worker enum xkb_action_flags flags;
225*2b949d04SAndroid Build Coastguard Worker uint8_t count;
226*2b949d04SAndroid Build Coastguard Worker uint8_t button;
227*2b949d04SAndroid Build Coastguard Worker };
228*2b949d04SAndroid Build Coastguard Worker
229*2b949d04SAndroid Build Coastguard Worker struct xkb_private_action {
230*2b949d04SAndroid Build Coastguard Worker enum xkb_action_type type;
231*2b949d04SAndroid Build Coastguard Worker uint8_t data[7];
232*2b949d04SAndroid Build Coastguard Worker };
233*2b949d04SAndroid Build Coastguard Worker
234*2b949d04SAndroid Build Coastguard Worker union xkb_action {
235*2b949d04SAndroid Build Coastguard Worker enum xkb_action_type type;
236*2b949d04SAndroid Build Coastguard Worker struct xkb_mod_action mods;
237*2b949d04SAndroid Build Coastguard Worker struct xkb_group_action group;
238*2b949d04SAndroid Build Coastguard Worker struct xkb_controls_action ctrls;
239*2b949d04SAndroid Build Coastguard Worker struct xkb_pointer_default_action dflt;
240*2b949d04SAndroid Build Coastguard Worker struct xkb_switch_screen_action screen;
241*2b949d04SAndroid Build Coastguard Worker struct xkb_pointer_action ptr;
242*2b949d04SAndroid Build Coastguard Worker struct xkb_pointer_button_action btn;
243*2b949d04SAndroid Build Coastguard Worker struct xkb_private_action priv;
244*2b949d04SAndroid Build Coastguard Worker };
245*2b949d04SAndroid Build Coastguard Worker
246*2b949d04SAndroid Build Coastguard Worker struct xkb_key_type_entry {
247*2b949d04SAndroid Build Coastguard Worker xkb_level_index_t level;
248*2b949d04SAndroid Build Coastguard Worker struct xkb_mods mods;
249*2b949d04SAndroid Build Coastguard Worker struct xkb_mods preserve;
250*2b949d04SAndroid Build Coastguard Worker };
251*2b949d04SAndroid Build Coastguard Worker
252*2b949d04SAndroid Build Coastguard Worker struct xkb_key_type {
253*2b949d04SAndroid Build Coastguard Worker xkb_atom_t name;
254*2b949d04SAndroid Build Coastguard Worker struct xkb_mods mods;
255*2b949d04SAndroid Build Coastguard Worker xkb_level_index_t num_levels;
256*2b949d04SAndroid Build Coastguard Worker unsigned int num_level_names;
257*2b949d04SAndroid Build Coastguard Worker xkb_atom_t *level_names;
258*2b949d04SAndroid Build Coastguard Worker unsigned int num_entries;
259*2b949d04SAndroid Build Coastguard Worker struct xkb_key_type_entry *entries;
260*2b949d04SAndroid Build Coastguard Worker };
261*2b949d04SAndroid Build Coastguard Worker
262*2b949d04SAndroid Build Coastguard Worker struct xkb_sym_interpret {
263*2b949d04SAndroid Build Coastguard Worker xkb_keysym_t sym;
264*2b949d04SAndroid Build Coastguard Worker enum xkb_match_operation match;
265*2b949d04SAndroid Build Coastguard Worker xkb_mod_mask_t mods;
266*2b949d04SAndroid Build Coastguard Worker xkb_mod_index_t virtual_mod;
267*2b949d04SAndroid Build Coastguard Worker union xkb_action action;
268*2b949d04SAndroid Build Coastguard Worker bool level_one_only;
269*2b949d04SAndroid Build Coastguard Worker bool repeat;
270*2b949d04SAndroid Build Coastguard Worker };
271*2b949d04SAndroid Build Coastguard Worker
272*2b949d04SAndroid Build Coastguard Worker struct xkb_led {
273*2b949d04SAndroid Build Coastguard Worker xkb_atom_t name;
274*2b949d04SAndroid Build Coastguard Worker enum xkb_state_component which_groups;
275*2b949d04SAndroid Build Coastguard Worker xkb_layout_mask_t groups;
276*2b949d04SAndroid Build Coastguard Worker enum xkb_state_component which_mods;
277*2b949d04SAndroid Build Coastguard Worker struct xkb_mods mods;
278*2b949d04SAndroid Build Coastguard Worker enum xkb_action_controls ctrls;
279*2b949d04SAndroid Build Coastguard Worker };
280*2b949d04SAndroid Build Coastguard Worker
281*2b949d04SAndroid Build Coastguard Worker struct xkb_key_alias {
282*2b949d04SAndroid Build Coastguard Worker xkb_atom_t real;
283*2b949d04SAndroid Build Coastguard Worker xkb_atom_t alias;
284*2b949d04SAndroid Build Coastguard Worker };
285*2b949d04SAndroid Build Coastguard Worker
286*2b949d04SAndroid Build Coastguard Worker struct xkb_controls {
287*2b949d04SAndroid Build Coastguard Worker unsigned char groups_wrap;
288*2b949d04SAndroid Build Coastguard Worker struct xkb_mods internal;
289*2b949d04SAndroid Build Coastguard Worker struct xkb_mods ignore_lock;
290*2b949d04SAndroid Build Coastguard Worker unsigned short repeat_delay;
291*2b949d04SAndroid Build Coastguard Worker unsigned short repeat_interval;
292*2b949d04SAndroid Build Coastguard Worker unsigned short slow_keys_delay;
293*2b949d04SAndroid Build Coastguard Worker unsigned short debounce_delay;
294*2b949d04SAndroid Build Coastguard Worker unsigned short ax_options;
295*2b949d04SAndroid Build Coastguard Worker unsigned short ax_timeout;
296*2b949d04SAndroid Build Coastguard Worker unsigned short axt_opts_mask;
297*2b949d04SAndroid Build Coastguard Worker unsigned short axt_opts_values;
298*2b949d04SAndroid Build Coastguard Worker unsigned int axt_ctrls_mask;
299*2b949d04SAndroid Build Coastguard Worker unsigned int axt_ctrls_values;
300*2b949d04SAndroid Build Coastguard Worker };
301*2b949d04SAndroid Build Coastguard Worker
302*2b949d04SAndroid Build Coastguard Worker /* Such an awkward name. Oh well. */
303*2b949d04SAndroid Build Coastguard Worker enum xkb_range_exceed_type {
304*2b949d04SAndroid Build Coastguard Worker RANGE_WRAP = 0,
305*2b949d04SAndroid Build Coastguard Worker RANGE_SATURATE,
306*2b949d04SAndroid Build Coastguard Worker RANGE_REDIRECT,
307*2b949d04SAndroid Build Coastguard Worker };
308*2b949d04SAndroid Build Coastguard Worker
309*2b949d04SAndroid Build Coastguard Worker enum xkb_explicit_components {
310*2b949d04SAndroid Build Coastguard Worker EXPLICIT_INTERP = (1 << 0),
311*2b949d04SAndroid Build Coastguard Worker EXPLICIT_VMODMAP = (1 << 1),
312*2b949d04SAndroid Build Coastguard Worker EXPLICIT_REPEAT = (1 << 2),
313*2b949d04SAndroid Build Coastguard Worker };
314*2b949d04SAndroid Build Coastguard Worker
315*2b949d04SAndroid Build Coastguard Worker struct xkb_level {
316*2b949d04SAndroid Build Coastguard Worker union xkb_action action;
317*2b949d04SAndroid Build Coastguard Worker unsigned int num_syms;
318*2b949d04SAndroid Build Coastguard Worker union {
319*2b949d04SAndroid Build Coastguard Worker xkb_keysym_t sym; /* num_syms == 1 */
320*2b949d04SAndroid Build Coastguard Worker xkb_keysym_t *syms; /* num_syms > 1 */
321*2b949d04SAndroid Build Coastguard Worker } u;
322*2b949d04SAndroid Build Coastguard Worker };
323*2b949d04SAndroid Build Coastguard Worker
324*2b949d04SAndroid Build Coastguard Worker struct xkb_group {
325*2b949d04SAndroid Build Coastguard Worker bool explicit_type;
326*2b949d04SAndroid Build Coastguard Worker /* Points to a type in keymap->types. */
327*2b949d04SAndroid Build Coastguard Worker const struct xkb_key_type *type;
328*2b949d04SAndroid Build Coastguard Worker /* Use XkbKeyNumLevels for the number of levels. */
329*2b949d04SAndroid Build Coastguard Worker struct xkb_level *levels;
330*2b949d04SAndroid Build Coastguard Worker };
331*2b949d04SAndroid Build Coastguard Worker
332*2b949d04SAndroid Build Coastguard Worker struct xkb_key {
333*2b949d04SAndroid Build Coastguard Worker xkb_keycode_t keycode;
334*2b949d04SAndroid Build Coastguard Worker xkb_atom_t name;
335*2b949d04SAndroid Build Coastguard Worker
336*2b949d04SAndroid Build Coastguard Worker enum xkb_explicit_components explicit;
337*2b949d04SAndroid Build Coastguard Worker
338*2b949d04SAndroid Build Coastguard Worker xkb_mod_mask_t modmap;
339*2b949d04SAndroid Build Coastguard Worker xkb_mod_mask_t vmodmap;
340*2b949d04SAndroid Build Coastguard Worker
341*2b949d04SAndroid Build Coastguard Worker bool repeats;
342*2b949d04SAndroid Build Coastguard Worker
343*2b949d04SAndroid Build Coastguard Worker enum xkb_range_exceed_type out_of_range_group_action;
344*2b949d04SAndroid Build Coastguard Worker xkb_layout_index_t out_of_range_group_number;
345*2b949d04SAndroid Build Coastguard Worker
346*2b949d04SAndroid Build Coastguard Worker xkb_layout_index_t num_groups;
347*2b949d04SAndroid Build Coastguard Worker struct xkb_group *groups;
348*2b949d04SAndroid Build Coastguard Worker };
349*2b949d04SAndroid Build Coastguard Worker
350*2b949d04SAndroid Build Coastguard Worker struct xkb_mod {
351*2b949d04SAndroid Build Coastguard Worker xkb_atom_t name;
352*2b949d04SAndroid Build Coastguard Worker enum mod_type type;
353*2b949d04SAndroid Build Coastguard Worker xkb_mod_mask_t mapping; /* vmod -> real mod mapping */
354*2b949d04SAndroid Build Coastguard Worker };
355*2b949d04SAndroid Build Coastguard Worker
356*2b949d04SAndroid Build Coastguard Worker struct xkb_mod_set {
357*2b949d04SAndroid Build Coastguard Worker struct xkb_mod mods[XKB_MAX_MODS];
358*2b949d04SAndroid Build Coastguard Worker unsigned int num_mods;
359*2b949d04SAndroid Build Coastguard Worker };
360*2b949d04SAndroid Build Coastguard Worker
361*2b949d04SAndroid Build Coastguard Worker /* Common keyboard description structure */
362*2b949d04SAndroid Build Coastguard Worker struct xkb_keymap {
363*2b949d04SAndroid Build Coastguard Worker struct xkb_context *ctx;
364*2b949d04SAndroid Build Coastguard Worker
365*2b949d04SAndroid Build Coastguard Worker int refcnt;
366*2b949d04SAndroid Build Coastguard Worker enum xkb_keymap_compile_flags flags;
367*2b949d04SAndroid Build Coastguard Worker enum xkb_keymap_format format;
368*2b949d04SAndroid Build Coastguard Worker
369*2b949d04SAndroid Build Coastguard Worker enum xkb_action_controls enabled_ctrls;
370*2b949d04SAndroid Build Coastguard Worker
371*2b949d04SAndroid Build Coastguard Worker xkb_keycode_t min_key_code;
372*2b949d04SAndroid Build Coastguard Worker xkb_keycode_t max_key_code;
373*2b949d04SAndroid Build Coastguard Worker struct xkb_key *keys;
374*2b949d04SAndroid Build Coastguard Worker
375*2b949d04SAndroid Build Coastguard Worker /* aliases in no particular order */
376*2b949d04SAndroid Build Coastguard Worker unsigned int num_key_aliases;
377*2b949d04SAndroid Build Coastguard Worker struct xkb_key_alias *key_aliases;
378*2b949d04SAndroid Build Coastguard Worker
379*2b949d04SAndroid Build Coastguard Worker struct xkb_key_type *types;
380*2b949d04SAndroid Build Coastguard Worker unsigned int num_types;
381*2b949d04SAndroid Build Coastguard Worker
382*2b949d04SAndroid Build Coastguard Worker unsigned int num_sym_interprets;
383*2b949d04SAndroid Build Coastguard Worker struct xkb_sym_interpret *sym_interprets;
384*2b949d04SAndroid Build Coastguard Worker
385*2b949d04SAndroid Build Coastguard Worker struct xkb_mod_set mods;
386*2b949d04SAndroid Build Coastguard Worker
387*2b949d04SAndroid Build Coastguard Worker /* Number of groups in the key with the most groups. */
388*2b949d04SAndroid Build Coastguard Worker xkb_layout_index_t num_groups;
389*2b949d04SAndroid Build Coastguard Worker /* Not all groups must have names. */
390*2b949d04SAndroid Build Coastguard Worker xkb_layout_index_t num_group_names;
391*2b949d04SAndroid Build Coastguard Worker xkb_atom_t *group_names;
392*2b949d04SAndroid Build Coastguard Worker
393*2b949d04SAndroid Build Coastguard Worker struct xkb_led leds[XKB_MAX_LEDS];
394*2b949d04SAndroid Build Coastguard Worker unsigned int num_leds;
395*2b949d04SAndroid Build Coastguard Worker
396*2b949d04SAndroid Build Coastguard Worker char *keycodes_section_name;
397*2b949d04SAndroid Build Coastguard Worker char *symbols_section_name;
398*2b949d04SAndroid Build Coastguard Worker char *types_section_name;
399*2b949d04SAndroid Build Coastguard Worker char *compat_section_name;
400*2b949d04SAndroid Build Coastguard Worker };
401*2b949d04SAndroid Build Coastguard Worker
402*2b949d04SAndroid Build Coastguard Worker #define xkb_keys_foreach(iter, keymap) \
403*2b949d04SAndroid Build Coastguard Worker for ((iter) = (keymap)->keys + (keymap)->min_key_code; \
404*2b949d04SAndroid Build Coastguard Worker (iter) <= (keymap)->keys + (keymap)->max_key_code; \
405*2b949d04SAndroid Build Coastguard Worker (iter)++)
406*2b949d04SAndroid Build Coastguard Worker
407*2b949d04SAndroid Build Coastguard Worker #define xkb_mods_foreach(iter, mods_) \
408*2b949d04SAndroid Build Coastguard Worker for ((iter) = (mods_)->mods; \
409*2b949d04SAndroid Build Coastguard Worker (iter) < (mods_)->mods + (mods_)->num_mods; \
410*2b949d04SAndroid Build Coastguard Worker (iter)++)
411*2b949d04SAndroid Build Coastguard Worker
412*2b949d04SAndroid Build Coastguard Worker #define xkb_mods_enumerate(idx, iter, mods_) \
413*2b949d04SAndroid Build Coastguard Worker for ((idx) = 0, (iter) = (mods_)->mods; \
414*2b949d04SAndroid Build Coastguard Worker (idx) < (mods_)->num_mods; \
415*2b949d04SAndroid Build Coastguard Worker (idx)++, (iter)++)
416*2b949d04SAndroid Build Coastguard Worker
417*2b949d04SAndroid Build Coastguard Worker #define xkb_leds_foreach(iter, keymap) \
418*2b949d04SAndroid Build Coastguard Worker for ((iter) = (keymap)->leds; \
419*2b949d04SAndroid Build Coastguard Worker (iter) < (keymap)->leds + (keymap)->num_leds; \
420*2b949d04SAndroid Build Coastguard Worker (iter)++)
421*2b949d04SAndroid Build Coastguard Worker
422*2b949d04SAndroid Build Coastguard Worker #define xkb_leds_enumerate(idx, iter, keymap) \
423*2b949d04SAndroid Build Coastguard Worker for ((idx) = 0, (iter) = (keymap)->leds; \
424*2b949d04SAndroid Build Coastguard Worker (idx) < (keymap)->num_leds; \
425*2b949d04SAndroid Build Coastguard Worker (idx)++, (iter)++)
426*2b949d04SAndroid Build Coastguard Worker
427*2b949d04SAndroid Build Coastguard Worker static inline const struct xkb_key *
XkbKey(struct xkb_keymap * keymap,xkb_keycode_t kc)428*2b949d04SAndroid Build Coastguard Worker XkbKey(struct xkb_keymap *keymap, xkb_keycode_t kc)
429*2b949d04SAndroid Build Coastguard Worker {
430*2b949d04SAndroid Build Coastguard Worker if (kc < keymap->min_key_code || kc > keymap->max_key_code)
431*2b949d04SAndroid Build Coastguard Worker return NULL;
432*2b949d04SAndroid Build Coastguard Worker return &keymap->keys[kc];
433*2b949d04SAndroid Build Coastguard Worker }
434*2b949d04SAndroid Build Coastguard Worker
435*2b949d04SAndroid Build Coastguard Worker static inline xkb_level_index_t
XkbKeyNumLevels(const struct xkb_key * key,xkb_layout_index_t layout)436*2b949d04SAndroid Build Coastguard Worker XkbKeyNumLevels(const struct xkb_key *key, xkb_layout_index_t layout)
437*2b949d04SAndroid Build Coastguard Worker {
438*2b949d04SAndroid Build Coastguard Worker return key->groups[layout].type->num_levels;
439*2b949d04SAndroid Build Coastguard Worker }
440*2b949d04SAndroid Build Coastguard Worker
441*2b949d04SAndroid Build Coastguard Worker /*
442*2b949d04SAndroid Build Coastguard Worker * If the virtual modifiers are not bound to anything, the entry
443*2b949d04SAndroid Build Coastguard Worker * is not active and should be skipped. xserver does this with
444*2b949d04SAndroid Build Coastguard Worker * cached entry->active field.
445*2b949d04SAndroid Build Coastguard Worker */
446*2b949d04SAndroid Build Coastguard Worker static inline bool
entry_is_active(const struct xkb_key_type_entry * entry)447*2b949d04SAndroid Build Coastguard Worker entry_is_active(const struct xkb_key_type_entry *entry)
448*2b949d04SAndroid Build Coastguard Worker {
449*2b949d04SAndroid Build Coastguard Worker return entry->mods.mods == 0 || entry->mods.mask != 0;
450*2b949d04SAndroid Build Coastguard Worker }
451*2b949d04SAndroid Build Coastguard Worker
452*2b949d04SAndroid Build Coastguard Worker struct xkb_keymap *
453*2b949d04SAndroid Build Coastguard Worker xkb_keymap_new(struct xkb_context *ctx,
454*2b949d04SAndroid Build Coastguard Worker enum xkb_keymap_format format,
455*2b949d04SAndroid Build Coastguard Worker enum xkb_keymap_compile_flags flags);
456*2b949d04SAndroid Build Coastguard Worker
457*2b949d04SAndroid Build Coastguard Worker struct xkb_key *
458*2b949d04SAndroid Build Coastguard Worker XkbKeyByName(struct xkb_keymap *keymap, xkb_atom_t name, bool use_aliases);
459*2b949d04SAndroid Build Coastguard Worker
460*2b949d04SAndroid Build Coastguard Worker xkb_atom_t
461*2b949d04SAndroid Build Coastguard Worker XkbResolveKeyAlias(const struct xkb_keymap *keymap, xkb_atom_t name);
462*2b949d04SAndroid Build Coastguard Worker
463*2b949d04SAndroid Build Coastguard Worker void
464*2b949d04SAndroid Build Coastguard Worker XkbEscapeMapName(char *name);
465*2b949d04SAndroid Build Coastguard Worker
466*2b949d04SAndroid Build Coastguard Worker xkb_mod_index_t
467*2b949d04SAndroid Build Coastguard Worker XkbModNameToIndex(const struct xkb_mod_set *mods, xkb_atom_t name,
468*2b949d04SAndroid Build Coastguard Worker enum mod_type type);
469*2b949d04SAndroid Build Coastguard Worker
470*2b949d04SAndroid Build Coastguard Worker bool
471*2b949d04SAndroid Build Coastguard Worker XkbLevelsSameSyms(const struct xkb_level *a, const struct xkb_level *b);
472*2b949d04SAndroid Build Coastguard Worker
473*2b949d04SAndroid Build Coastguard Worker xkb_layout_index_t
474*2b949d04SAndroid Build Coastguard Worker XkbWrapGroupIntoRange(int32_t group,
475*2b949d04SAndroid Build Coastguard Worker xkb_layout_index_t num_groups,
476*2b949d04SAndroid Build Coastguard Worker enum xkb_range_exceed_type out_of_range_group_action,
477*2b949d04SAndroid Build Coastguard Worker xkb_layout_index_t out_of_range_group_number);
478*2b949d04SAndroid Build Coastguard Worker
479*2b949d04SAndroid Build Coastguard Worker xkb_mod_mask_t
480*2b949d04SAndroid Build Coastguard Worker mod_mask_get_effective(struct xkb_keymap *keymap, xkb_mod_mask_t mods);
481*2b949d04SAndroid Build Coastguard Worker
482*2b949d04SAndroid Build Coastguard Worker struct xkb_keymap_format_ops {
483*2b949d04SAndroid Build Coastguard Worker bool (*keymap_new_from_names)(struct xkb_keymap *keymap,
484*2b949d04SAndroid Build Coastguard Worker const struct xkb_rule_names *names);
485*2b949d04SAndroid Build Coastguard Worker bool (*keymap_new_from_string)(struct xkb_keymap *keymap,
486*2b949d04SAndroid Build Coastguard Worker const char *string, size_t length);
487*2b949d04SAndroid Build Coastguard Worker bool (*keymap_new_from_file)(struct xkb_keymap *keymap, FILE *file);
488*2b949d04SAndroid Build Coastguard Worker char *(*keymap_get_as_string)(struct xkb_keymap *keymap);
489*2b949d04SAndroid Build Coastguard Worker };
490*2b949d04SAndroid Build Coastguard Worker
491*2b949d04SAndroid Build Coastguard Worker extern const struct xkb_keymap_format_ops text_v1_keymap_format_ops;
492*2b949d04SAndroid Build Coastguard Worker
493*2b949d04SAndroid Build Coastguard Worker #endif
494