1 /************************************************************
2 Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
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.
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.
25 ********************************************************/
30 static struct xkb_kt_map_entry map2Level[]= {
34 .mods = {.mask = 1, .vmods = ShiftMask, .real_mods = 0 }
38 static struct xkb_kt_map_entry mapAlpha[]= {
42 .mods = { .mask = 1, .vmods = ShiftMask, .real_mods = 0 }
47 .mods = { .mask = 0, .vmods = LockMask, .real_mods = 0 }
51 static struct xkb_mods preAlpha[]= {
52 { .mask = 0, .vmods = 0, .real_mods = 0 },
53 { .mask = LockMask, .vmods = LockMask, .real_mods = 0 }
56 #define NL_VMOD_MASK 0
57 static struct xkb_kt_map_entry mapKeypad[]= {
61 .mods = { .mask = 1, .vmods = ShiftMask, .real_mods = 0 }
66 .mods = { .mask = 1, .vmods = 0, .real_mods = NL_VMOD_MASK }
70 static const struct xkb_key_type canonicalTypes[XkbNumRequiredTypes] = {
72 .mods = { .mask = 0, .vmods = 0, .real_mods = 0 },
79 .mods = { .mask = ShiftMask, .vmods = ShiftMask, .real_mods = 0 },
81 .map = darray_lit(map2Level),
87 .mods = { .mask = ShiftMask|LockMask, .vmods = ShiftMask|LockMask, .real_mods = 0 },
89 .map = darray_lit(mapAlpha),
95 .mods = { .mask = ShiftMask, .vmods = ShiftMask, .real_mods = NL_VMOD_MASK },
97 .map = darray_lit(mapKeypad),
105 XkbcInitCanonicalKeyTypes(struct xkb_keymap *keymap, unsigned which,
108 struct xkb_client_map * map;
109 const struct xkb_key_type *from;
115 rtrn = XkbcAllocClientMap(keymap, XkbKeyTypesMask, XkbNumRequiredTypes);
120 if ((which & XkbAllRequiredTypes) == 0)
124 from = canonicalTypes;
126 if (which & XkbOneLevelMask)
127 rtrn = XkbcCopyKeyType(&from[XkbOneLevelIndex],
128 &darray_item(map->types, XkbOneLevelIndex));
130 if ((which & XkbTwoLevelMask) && (rtrn == Success))
131 rtrn = XkbcCopyKeyType(&from[XkbTwoLevelIndex],
132 &darray_item(map->types, XkbTwoLevelIndex));
134 if ((which & XkbAlphabeticMask) && (rtrn == Success))
135 rtrn = XkbcCopyKeyType(&from[XkbAlphabeticIndex],
136 &darray_item(map->types, XkbAlphabeticIndex));
138 if ((which & XkbKeypadMask) && (rtrn == Success)) {
139 struct xkb_key_type * type;
141 rtrn = XkbcCopyKeyType(&from[XkbKeypadIndex],
142 &darray_item(map->types, XkbKeypadIndex));
143 type = &darray_item(map->types, XkbKeypadIndex);
145 if ((keypadVMod >= 0) && (keypadVMod < XkbNumVirtualMods) &&
147 struct xkb_kt_map_entry *entry;
148 type->mods.vmods = (1 << keypadVMod);
150 entry = &darray_item(type->map, 0);
151 entry->active = true;
152 entry->mods.mask = ShiftMask;
153 entry->mods.real_mods = ShiftMask;
154 entry->mods.vmods = 0;
157 entry = &darray_item(type->map, 1);
158 entry->active = false;
159 entry->mods.mask = 0;
160 entry->mods.real_mods = 0;
161 entry->mods.vmods = (1 << keypadVMod);
170 _XkbcKSCheckCase(xkb_keysym_t ks)
172 unsigned set = (ks & (~0xff)) >> 8;
176 case 0: /* latin 1 */
177 if ((ks >= XKB_KEY_A && ks <= XKB_KEY_Z) ||
178 (ks >= XKB_KEY_Agrave && ks <= XKB_KEY_THORN && ks != XKB_KEY_multiply))
180 if ((ks >= XKB_KEY_a && ks <= XKB_KEY_z) ||
181 (ks >= XKB_KEY_agrave && ks <= XKB_KEY_ydiaeresis))
184 case 1: /* latin 2 */
185 if ((ks >= XKB_KEY_Aogonek && ks <= XKB_KEY_Zabovedot && ks != XKB_KEY_breve) ||
186 (ks >= XKB_KEY_Racute && ks<=XKB_KEY_Tcedilla))
188 if ((ks >= XKB_KEY_aogonek && ks <= XKB_KEY_zabovedot && ks != XKB_KEY_caron) ||
189 (ks >= XKB_KEY_racute && ks <= XKB_KEY_tcedilla))
192 case 2: /* latin 3 */
193 if ((ks >= XKB_KEY_Hstroke && ks <= XKB_KEY_Jcircumflex) ||
194 (ks >= XKB_KEY_Cabovedot && ks <= XKB_KEY_Scircumflex))
196 if ((ks >= XKB_KEY_hstroke && ks <= XKB_KEY_jcircumflex) ||
197 (ks >= XKB_KEY_cabovedot && ks <= XKB_KEY_scircumflex))
200 case 3: /* latin 4 */
201 if ((ks >= XKB_KEY_Rcedilla && ks <= XKB_KEY_Tslash) ||
202 (ks == XKB_KEY_ENG) ||
203 (ks >= XKB_KEY_Amacron && ks <= XKB_KEY_Umacron))
205 if ((ks >= XKB_KEY_rcedilla && ks <= XKB_KEY_tslash) ||
206 (ks == XKB_KEY_eng) ||
207 (ks >= XKB_KEY_amacron && ks <= XKB_KEY_umacron))
210 case 18: /* latin 8 */
211 if ((ks == XKB_KEY_Wcircumflex) ||
212 (ks == XKB_KEY_Ycircumflex) ||
213 (ks == XKB_KEY_Babovedot) ||
214 (ks == XKB_KEY_Dabovedot) ||
215 (ks == XKB_KEY_Fabovedot) ||
216 (ks == XKB_KEY_Mabovedot) ||
217 (ks == XKB_KEY_Pabovedot) ||
218 (ks == XKB_KEY_Sabovedot) ||
219 (ks == XKB_KEY_Tabovedot) ||
220 (ks == XKB_KEY_Wdiaeresis) ||
221 (ks == XKB_KEY_Ygrave))
223 if ((ks == XKB_KEY_wcircumflex) ||
224 (ks == XKB_KEY_ycircumflex) ||
225 (ks == XKB_KEY_babovedot) ||
226 (ks == XKB_KEY_dabovedot) ||
227 (ks == XKB_KEY_fabovedot) ||
228 (ks == XKB_KEY_mabovedot) ||
229 (ks == XKB_KEY_pabovedot) ||
230 (ks == XKB_KEY_sabovedot) ||
231 (ks == XKB_KEY_tabovedot) ||
232 (ks == XKB_KEY_wdiaeresis) ||
233 (ks == XKB_KEY_ygrave))
236 case 19: /* latin 9 */
237 if (ks == XKB_KEY_OE || ks == XKB_KEY_Ydiaeresis)
239 if (ks == XKB_KEY_oe)
248 XkbcFindKeycodeByName(struct xkb_keymap *keymap, const char *name,
251 struct xkb_key_alias *alias;
254 for (i = keymap->min_key_code; i <= keymap->max_key_code; i++) {
255 if (strncmp(darray_item(keymap->names->keys, i).name, name,
256 XkbKeyNameLength) == 0)
264 for (i = 0; i < darray_size(keymap->names->key_aliases); i++) {
265 alias = &darray_item(keymap->names->key_aliases, i);
266 if (strncmp(name, alias->alias, XkbKeyNameLength) == 0)
267 return XkbcFindKeycodeByName(keymap, alias->real, false);