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 ********************************************************/
27 #include <X11/keysym.h>
32 #define mapSize(m) (sizeof(m) / sizeof(struct xkb_kt_map_entry))
33 static struct xkb_kt_map_entry map2Level[]= {
34 { true, ShiftMask, {1, ShiftMask, 0} }
37 static struct xkb_kt_map_entry mapAlpha[]= {
38 { true, ShiftMask, { 1, ShiftMask, 0 } },
39 { true, LockMask, { 0, LockMask, 0 } }
42 static struct xkb_mods preAlpha[]= {
44 { LockMask, LockMask, 0 }
47 #define NL_VMOD_MASK 0
48 static struct xkb_kt_map_entry mapKeypad[]= {
49 { true, ShiftMask, { 1, ShiftMask, 0 } },
50 { false, 0, { 1, 0, NL_VMOD_MASK } }
53 static struct xkb_key_type canonicalTypes[XkbNumRequiredTypes] = {
60 { { ShiftMask, ShiftMask, 0 },
62 mapSize(map2Level), /* map_count */
66 { { ShiftMask|LockMask, ShiftMask|LockMask, 0 },
68 mapSize(mapAlpha), /* map_count */
72 { { ShiftMask, ShiftMask, NL_VMOD_MASK },
74 mapSize(mapKeypad), /* map_count */
81 XkbcInitCanonicalKeyTypes(struct xkb_keymap * xkb, unsigned which, int keypadVMod)
83 struct xkb_client_map * map;
84 struct xkb_key_type *from, *to;
90 rtrn= XkbcAllocClientMap(xkb, XkbKeyTypesMask, XkbNumRequiredTypes);
95 if ((which & XkbAllRequiredTypes) == 0)
99 from = canonicalTypes;
102 if (which & XkbOneLevelMask)
103 rtrn = XkbcCopyKeyType(&from[XkbOneLevelIndex], &to[XkbOneLevelIndex]);
105 if ((which & XkbTwoLevelMask) && (rtrn == Success))
106 rtrn = XkbcCopyKeyType(&from[XkbTwoLevelIndex], &to[XkbTwoLevelIndex]);
108 if ((which & XkbAlphabeticMask) && (rtrn == Success))
109 rtrn = XkbcCopyKeyType(&from[XkbAlphabeticIndex],
110 &to[XkbAlphabeticIndex]);
112 if ((which & XkbKeypadMask) && (rtrn == Success)) {
113 struct xkb_key_type * type;
115 rtrn = XkbcCopyKeyType(&from[XkbKeypadIndex], &to[XkbKeypadIndex]);
116 type = &to[XkbKeypadIndex];
118 if ((keypadVMod >= 0) && (keypadVMod < XkbNumVirtualMods) &&
120 type->mods.vmods = (1 << keypadVMod);
121 type->map[0].active = true;
122 type->map[0].mods.mask = ShiftMask;
123 type->map[0].mods.real_mods = ShiftMask;
124 type->map[0].mods.vmods = 0;
125 type->map[0].level = 1;
126 type->map[1].active = false;
127 type->map[1].mods.mask = 0;
128 type->map[1].mods.real_mods = 0;
129 type->map[1].mods.vmods = (1 << keypadVMod);
130 type->map[1].level = 1;
138 _XkbcKSCheckCase(xkb_keysym_t ks)
140 unsigned set = (ks & (~0xff)) >> 8;
144 case 0: /* latin 1 */
145 if ((ks >= XK_A && ks <= XK_Z) ||
146 (ks >= XK_Agrave && ks <= XK_THORN && ks != XK_multiply))
148 if ((ks >= XK_a && ks <= XK_z) ||
149 (ks >= XK_agrave && ks <= XK_ydiaeresis))
152 case 1: /* latin 2 */
153 if ((ks >= XK_Aogonek && ks <= XK_Zabovedot && ks != XK_breve) ||
154 (ks >= XK_Racute && ks<=XK_Tcedilla))
156 if ((ks >= XK_aogonek && ks <= XK_zabovedot && ks != XK_caron) ||
157 (ks >= XK_racute && ks <= XK_tcedilla))
160 case 2: /* latin 3 */
161 if ((ks >= XK_Hstroke && ks <= XK_Jcircumflex) ||
162 (ks >= XK_Cabovedot && ks <= XK_Scircumflex))
164 if ((ks >= XK_hstroke && ks <= XK_jcircumflex) ||
165 (ks >= XK_cabovedot && ks <= XK_scircumflex))
168 case 3: /* latin 4 */
169 if ((ks >= XK_Rcedilla && ks <= XK_Tslash) ||
171 (ks >= XK_Amacron && ks <= XK_Umacron))
173 if ((ks >= XK_rcedilla && ks <= XK_tslash) ||
175 (ks >= XK_amacron && ks <= XK_umacron))
178 case 18: /* latin 8 */
179 if ((ks == XK_Wcircumflex) ||
180 (ks == XK_Ycircumflex) ||
181 (ks == XK_Babovedot) ||
182 (ks == XK_Dabovedot) ||
183 (ks == XK_Fabovedot) ||
184 (ks == XK_Mabovedot) ||
185 (ks == XK_Pabovedot) ||
186 (ks == XK_Sabovedot) ||
187 (ks == XK_Tabovedot) ||
188 (ks == XK_Wdiaeresis) ||
191 if ((ks == XK_wcircumflex) ||
192 (ks == XK_ycircumflex) ||
193 (ks == XK_babovedot) ||
194 (ks == XK_dabovedot) ||
195 (ks == XK_fabovedot) ||
196 (ks == XK_mabovedot) ||
197 (ks == XK_pabovedot) ||
198 (ks == XK_sabovedot) ||
199 (ks == XK_tabovedot) ||
200 (ks == XK_wdiaeresis) ||
204 case 19: /* latin 9 */
205 if (ks == XK_OE || ks == XK_Ydiaeresis)