1 /* $OpenBSD: wskbdutil.c,v 1.15 2016/08/31 11:05:48 jca Exp $ */ 2 /* $NetBSD: wskbdutil.c,v 1.7 1999/12/21 11:59:13 drochner Exp $ */ 3 4 /*- 5 * Copyright (c) 1997 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation 9 * by Juergen Hannken-Illjes. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #include <sys/param.h> 34 #include <sys/types.h> 35 #include <sys/errno.h> 36 #include <sys/systm.h> 37 #include <sys/malloc.h> 38 #include <dev/wscons/wsksymdef.h> 39 #include <dev/wscons/wsksymvar.h> 40 41 static struct compose_tab_s { 42 keysym_t elem[2]; 43 keysym_t result; 44 } compose_tab[] = { 45 { { KS_plus, KS_plus }, KS_numbersign }, 46 { { KS_a, KS_a }, KS_at }, 47 { { KS_parenleft, KS_parenleft }, KS_bracketleft }, 48 { { KS_slash, KS_slash }, KS_backslash }, 49 { { KS_parenright, KS_parenright }, KS_bracketright }, 50 { { KS_parenleft, KS_minus }, KS_braceleft }, 51 { { KS_slash, KS_minus }, KS_bar }, 52 { { KS_parenright, KS_minus }, KS_braceright }, 53 { { KS_exclam, KS_exclam }, KS_exclamdown }, 54 { { KS_c, KS_slash }, KS_cent }, 55 { { KS_l, KS_minus }, KS_sterling }, 56 { { KS_y, KS_minus }, KS_yen }, 57 { { KS_s, KS_o }, KS_section }, 58 { { KS_x, KS_o }, KS_currency }, 59 { { KS_c, KS_o }, KS_copyright }, 60 { { KS_less, KS_less }, KS_guillemotleft }, 61 { { KS_greater, KS_greater }, KS_guillemotright }, 62 { { KS_question, KS_question }, KS_questiondown }, 63 { { KS_dead_acute, KS_space }, KS_apostrophe }, 64 { { KS_dead_grave, KS_space }, KS_grave }, 65 { { KS_dead_tilde, KS_space }, KS_asciitilde }, 66 { { KS_dead_circumflex, KS_space }, KS_asciicircum }, 67 { { KS_dead_diaeresis, KS_space }, KS_quotedbl }, 68 { { KS_dead_cedilla, KS_space }, KS_comma }, 69 { { KS_dead_circumflex, KS_A }, KS_Acircumflex }, 70 { { KS_dead_diaeresis, KS_A }, KS_Adiaeresis }, 71 { { KS_dead_grave, KS_A }, KS_Agrave }, 72 { { KS_dead_abovering, KS_A }, KS_Aring }, 73 { { KS_dead_tilde, KS_A }, KS_Atilde }, 74 { { KS_dead_cedilla, KS_C }, KS_Ccedilla }, 75 { { KS_dead_acute, KS_E }, KS_Eacute }, 76 { { KS_dead_circumflex, KS_E }, KS_Ecircumflex }, 77 { { KS_dead_diaeresis, KS_E }, KS_Ediaeresis }, 78 { { KS_dead_grave, KS_E }, KS_Egrave }, 79 { { KS_dead_acute, KS_I }, KS_Iacute }, 80 { { KS_dead_circumflex, KS_I }, KS_Icircumflex }, 81 { { KS_dead_diaeresis, KS_I }, KS_Idiaeresis }, 82 { { KS_dead_grave, KS_I }, KS_Igrave }, 83 { { KS_dead_tilde, KS_N }, KS_Ntilde }, 84 { { KS_dead_acute, KS_O }, KS_Oacute }, 85 { { KS_dead_circumflex, KS_O }, KS_Ocircumflex }, 86 { { KS_dead_diaeresis, KS_O }, KS_Odiaeresis }, 87 { { KS_dead_grave, KS_O }, KS_Ograve }, 88 { { KS_dead_tilde, KS_O }, KS_Otilde }, 89 { { KS_dead_acute, KS_U }, KS_Uacute }, 90 { { KS_dead_circumflex, KS_U }, KS_Ucircumflex }, 91 { { KS_dead_diaeresis, KS_U }, KS_Udiaeresis }, 92 { { KS_dead_grave, KS_U }, KS_Ugrave }, 93 { { KS_dead_acute, KS_Y }, KS_Yacute }, 94 { { KS_dead_acute, KS_a }, KS_aacute }, 95 { { KS_dead_circumflex, KS_a }, KS_acircumflex }, 96 { { KS_dead_diaeresis, KS_a }, KS_adiaeresis }, 97 { { KS_dead_grave, KS_a }, KS_agrave }, 98 { { KS_dead_abovering, KS_a }, KS_aring }, 99 { { KS_dead_tilde, KS_a }, KS_atilde }, 100 { { KS_dead_cedilla, KS_c }, KS_ccedilla }, 101 { { KS_dead_acute, KS_e }, KS_eacute }, 102 { { KS_dead_circumflex, KS_e }, KS_ecircumflex }, 103 { { KS_dead_diaeresis, KS_e }, KS_ediaeresis }, 104 { { KS_dead_grave, KS_e }, KS_egrave }, 105 { { KS_dead_acute, KS_i }, KS_iacute }, 106 { { KS_dead_circumflex, KS_i }, KS_icircumflex }, 107 { { KS_dead_diaeresis, KS_i }, KS_idiaeresis }, 108 { { KS_dead_grave, KS_i }, KS_igrave }, 109 { { KS_dead_tilde, KS_n }, KS_ntilde }, 110 { { KS_dead_acute, KS_o }, KS_oacute }, 111 { { KS_dead_circumflex, KS_o }, KS_ocircumflex }, 112 { { KS_dead_diaeresis, KS_o }, KS_odiaeresis }, 113 { { KS_dead_grave, KS_o }, KS_ograve }, 114 { { KS_dead_tilde, KS_o }, KS_otilde }, 115 { { KS_dead_acute, KS_u }, KS_uacute }, 116 { { KS_dead_circumflex, KS_u }, KS_ucircumflex }, 117 { { KS_dead_diaeresis, KS_u }, KS_udiaeresis }, 118 { { KS_dead_grave, KS_u }, KS_ugrave }, 119 { { KS_dead_acute, KS_y }, KS_yacute }, 120 { { KS_dead_diaeresis, KS_y }, KS_ydiaeresis }, 121 { { KS_quotedbl, KS_A }, KS_Adiaeresis }, 122 { { KS_quotedbl, KS_E }, KS_Ediaeresis }, 123 { { KS_quotedbl, KS_I }, KS_Idiaeresis }, 124 { { KS_quotedbl, KS_O }, KS_Odiaeresis }, 125 { { KS_quotedbl, KS_U }, KS_Udiaeresis }, 126 { { KS_quotedbl, KS_a }, KS_adiaeresis }, 127 { { KS_quotedbl, KS_e }, KS_ediaeresis }, 128 { { KS_quotedbl, KS_i }, KS_idiaeresis }, 129 { { KS_quotedbl, KS_o }, KS_odiaeresis }, 130 { { KS_quotedbl, KS_u }, KS_udiaeresis }, 131 { { KS_quotedbl, KS_y }, KS_ydiaeresis }, 132 { { KS_acute, KS_A }, KS_Aacute }, 133 { { KS_asciicircum, KS_A }, KS_Acircumflex }, 134 { { KS_grave, KS_A }, KS_Agrave }, 135 { { KS_asterisk, KS_A }, KS_Aring }, 136 { { KS_asciitilde, KS_A }, KS_Atilde }, 137 { { KS_cedilla, KS_C }, KS_Ccedilla }, 138 { { KS_acute, KS_E }, KS_Eacute }, 139 { { KS_asciicircum, KS_E }, KS_Ecircumflex }, 140 { { KS_grave, KS_E }, KS_Egrave }, 141 { { KS_acute, KS_I }, KS_Iacute }, 142 { { KS_asciicircum, KS_I }, KS_Icircumflex }, 143 { { KS_grave, KS_I }, KS_Igrave }, 144 { { KS_asciitilde, KS_N }, KS_Ntilde }, 145 { { KS_acute, KS_O }, KS_Oacute }, 146 { { KS_asciicircum, KS_O }, KS_Ocircumflex }, 147 { { KS_grave, KS_O }, KS_Ograve }, 148 { { KS_asciitilde, KS_O }, KS_Otilde }, 149 { { KS_acute, KS_U }, KS_Uacute }, 150 { { KS_asciicircum, KS_U }, KS_Ucircumflex }, 151 { { KS_grave, KS_U }, KS_Ugrave }, 152 { { KS_acute, KS_Y }, KS_Yacute }, 153 { { KS_acute, KS_a }, KS_aacute }, 154 { { KS_asciicircum, KS_a }, KS_acircumflex }, 155 { { KS_grave, KS_a }, KS_agrave }, 156 { { KS_asterisk, KS_a }, KS_aring }, 157 { { KS_asciitilde, KS_a }, KS_atilde }, 158 { { KS_cedilla, KS_c }, KS_ccedilla }, 159 { { KS_acute, KS_e }, KS_eacute }, 160 { { KS_asciicircum, KS_e }, KS_ecircumflex }, 161 { { KS_grave, KS_e }, KS_egrave }, 162 { { KS_acute, KS_i }, KS_iacute }, 163 { { KS_asciicircum, KS_i }, KS_icircumflex }, 164 { { KS_grave, KS_i }, KS_igrave }, 165 { { KS_asciitilde, KS_n }, KS_ntilde }, 166 { { KS_acute, KS_o }, KS_oacute }, 167 { { KS_asciicircum, KS_o }, KS_ocircumflex }, 168 { { KS_grave, KS_o }, KS_ograve }, 169 { { KS_asciitilde, KS_o }, KS_otilde }, 170 { { KS_acute, KS_u }, KS_uacute }, 171 { { KS_asciicircum, KS_u }, KS_ucircumflex }, 172 { { KS_grave, KS_u }, KS_ugrave }, 173 { { KS_acute, KS_y }, KS_yacute }, 174 { { KS_dead_caron, KS_space }, KS_L2_caron }, 175 { { KS_dead_caron, KS_S }, KS_L2_Scaron }, 176 { { KS_dead_caron, KS_Z }, KS_L2_Zcaron }, 177 { { KS_dead_caron, KS_s }, KS_L2_scaron }, 178 { { KS_dead_caron, KS_z }, KS_L2_zcaron } 179 }; 180 181 #define COMPOSE_SIZE nitems(compose_tab) 182 183 static int compose_tab_inorder = 0; 184 185 inline int compose_tab_cmp(struct compose_tab_s *, struct compose_tab_s *); 186 keysym_t ksym_upcase(keysym_t); 187 void fillmapentry(const keysym_t *, int, struct wscons_keymap *); 188 189 inline int 190 compose_tab_cmp(struct compose_tab_s *i, struct compose_tab_s *j) 191 { 192 if (i->elem[0] == j->elem[0]) 193 return(i->elem[1] - j->elem[1]); 194 else 195 return(i->elem[0] - j->elem[0]); 196 } 197 198 keysym_t 199 wskbd_compose_value(keysym_t *compose_buf) 200 { 201 int i, j, r; 202 struct compose_tab_s v; 203 204 if (!compose_tab_inorder) { 205 /* Insertion sort. */ 206 for (i = 1; i < COMPOSE_SIZE; i++) { 207 v = compose_tab[i]; 208 /* find correct slot, moving others up */ 209 for (j = i; --j >= 0 && 210 compose_tab_cmp(&v, &compose_tab[j]) < 0;) 211 compose_tab[j + 1] = compose_tab[j]; 212 compose_tab[j + 1] = v; 213 } 214 compose_tab_inorder = 1; 215 } 216 217 for (j = 0, i = COMPOSE_SIZE; i != 0; i /= 2) { 218 if (compose_tab[j + i/2].elem[0] == compose_buf[0]) { 219 if (compose_tab[j + i/2].elem[1] == compose_buf[1]) 220 return(compose_tab[j + i/2].result); 221 r = compose_tab[j + i/2].elem[1] < compose_buf[1]; 222 } else 223 r = compose_tab[j + i/2].elem[0] < compose_buf[0]; 224 if (r) { 225 j += i/2 + 1; 226 i--; 227 } 228 } 229 230 return(KS_voidSymbol); 231 } 232 233 static const u_char latin1_to_upper[256] = { 234 /* 0 8 1 9 2 a 3 b 4 c 5 d 6 e 7 f */ 235 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */ 236 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */ 237 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1 */ 238 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1 */ 239 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 2 */ 240 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 2 */ 241 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 3 */ 242 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 3 */ 243 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 4 */ 244 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 4 */ 245 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 5 */ 246 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 5 */ 247 0x00, 'A', 'B', 'C', 'D', 'E', 'F', 'G', /* 6 */ 248 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', /* 6 */ 249 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', /* 7 */ 250 'X', 'Y', 'Z', 0x00, 0x00, 0x00, 0x00, 0x00, /* 7 */ 251 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8 */ 252 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8 */ 253 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9 */ 254 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9 */ 255 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 256 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ 257 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ 258 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ 259 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c */ 260 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c */ 261 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d */ 262 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d */ 263 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* e */ 264 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* e */ 265 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0x00, /* f */ 266 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0x00, /* f */ 267 }; 268 269 keysym_t 270 ksym_upcase(keysym_t ksym) 271 { 272 if (ksym >= KS_f1 && ksym <= KS_f20) 273 return(KS_F1 - KS_f1 + ksym); 274 275 if (KS_GROUP(ksym) == KS_GROUP_Ascii && ksym <= 0xff && 276 latin1_to_upper[ksym] != 0x00) 277 return(latin1_to_upper[ksym]); 278 279 return(ksym); 280 } 281 282 void 283 fillmapentry(const keysym_t *kp, int len, struct wscons_keymap *mapentry) 284 { 285 switch (len) { 286 case 0: 287 mapentry->group1[0] = KS_voidSymbol; 288 mapentry->group1[1] = KS_voidSymbol; 289 mapentry->group2[0] = KS_voidSymbol; 290 mapentry->group2[1] = KS_voidSymbol; 291 break; 292 293 case 1: 294 mapentry->group1[0] = kp[0]; 295 mapentry->group1[1] = ksym_upcase(kp[0]); 296 mapentry->group2[0] = mapentry->group1[0]; 297 mapentry->group2[1] = mapentry->group1[1]; 298 break; 299 300 case 2: 301 mapentry->group1[0] = kp[0]; 302 mapentry->group1[1] = kp[1]; 303 mapentry->group2[0] = mapentry->group1[0]; 304 mapentry->group2[1] = mapentry->group1[1]; 305 break; 306 307 case 3: 308 mapentry->group1[0] = kp[0]; 309 mapentry->group1[1] = kp[1]; 310 mapentry->group2[0] = kp[2]; 311 mapentry->group2[1] = ksym_upcase(kp[2]); 312 break; 313 314 case 4: 315 mapentry->group1[0] = kp[0]; 316 mapentry->group1[1] = kp[1]; 317 mapentry->group2[0] = kp[2]; 318 mapentry->group2[1] = kp[3]; 319 break; 320 321 } 322 } 323 324 void 325 wskbd_get_mapentry(const struct wskbd_mapdata *mapdata, int kc, 326 struct wscons_keymap *mapentry) 327 { 328 kbd_t cur; 329 const keysym_t *kp; 330 const struct wscons_keydesc *mp; 331 int l; 332 keysym_t ksg; 333 334 mapentry->command = KS_voidSymbol; 335 mapentry->group1[0] = KS_voidSymbol; 336 mapentry->group1[1] = KS_voidSymbol; 337 mapentry->group2[0] = KS_voidSymbol; 338 mapentry->group2[1] = KS_voidSymbol; 339 340 for (cur = mapdata->layout & ~KB_HANDLEDBYWSKBD; cur != 0; ) { 341 mp = mapdata->keydesc; 342 while (mp->map_size > 0) { 343 if (mp->name == cur) 344 break; 345 mp++; 346 } 347 348 /* If map not found, return */ 349 if (mp->map_size <= 0) 350 return; 351 352 for (kp = mp->map; kp < mp->map + mp->map_size; kp++) { 353 ksg = KS_GROUP(*kp); 354 if (ksg == KS_GROUP_Keycode && 355 KS_VALUE(*kp) == kc) { 356 /* First skip keycode and possible command */ 357 kp++; 358 if (KS_GROUP(*kp) == KS_GROUP_Command || 359 *kp == KS_Cmd || *kp == KS_Cmd1 || *kp == KS_Cmd2) 360 mapentry->command = *kp++; 361 362 for (l = 0; kp + l < mp->map + mp->map_size; 363 l++) { 364 ksg = KS_GROUP(kp[l]); 365 if (ksg == KS_GROUP_Keycode) 366 break; 367 } 368 if (l > 4) 369 panic("wskbd_get_mapentry: %d(%d): bad entry", 370 mp->name, *kp); 371 fillmapentry(kp, l, mapentry); 372 return; 373 } 374 } 375 376 cur = mp->base; 377 } 378 } 379 380 void 381 wskbd_init_keymap(int newlen, struct wscons_keymap **map, int *maplen) 382 { 383 int i; 384 385 if (newlen != *maplen) { 386 if (*maplen > 0) 387 free(*map, M_DEVBUF, 0); 388 *maplen = newlen; 389 *map = mallocarray(newlen, sizeof(struct wscons_keymap), 390 M_DEVBUF, M_WAITOK); 391 } 392 393 for (i = 0; i < *maplen; i++) { 394 (*map)[i].command = KS_voidSymbol; 395 (*map)[i].group1[0] = KS_voidSymbol; 396 (*map)[i].group1[1] = KS_voidSymbol; 397 (*map)[i].group2[0] = KS_voidSymbol; 398 (*map)[i].group2[1] = KS_voidSymbol; 399 } 400 } 401 402 int 403 wskbd_load_keymap(const struct wskbd_mapdata *mapdata, kbd_t layout, 404 struct wscons_keymap **map, int *maplen) 405 { 406 int i, s, kc, stack_ptr; 407 const keysym_t *kp; 408 const struct wscons_keydesc *mp, *stack[10]; 409 kbd_t cur; 410 keysym_t ksg; 411 412 for (cur = layout & ~KB_HANDLEDBYWSKBD, stack_ptr = 0; 413 cur != 0; stack_ptr++) { 414 mp = mapdata->keydesc; 415 while (mp->map_size > 0) { 416 if (cur == 0 || mp->name == cur) { 417 break; 418 } 419 mp++; 420 } 421 422 if (stack_ptr == nitems(stack)) 423 panic("wskbd_load_keymap: %d: recursion too deep", 424 mapdata->layout); 425 if (mp->map_size <= 0) 426 return(EINVAL); 427 428 stack[stack_ptr] = mp; 429 cur = mp->base; 430 } 431 432 for (i = 0, s = stack_ptr - 1; s >= 0; s--) { 433 mp = stack[s]; 434 for (kp = mp->map; kp < mp->map + mp->map_size; kp++) { 435 ksg = KS_GROUP(*kp); 436 if (ksg == KS_GROUP_Keycode && KS_VALUE(*kp) > i) 437 i = KS_VALUE(*kp); 438 } 439 } 440 441 wskbd_init_keymap(i + 1, map, maplen); 442 443 for (s = stack_ptr - 1; s >= 0; s--) { 444 mp = stack[s]; 445 for (kp = mp->map; kp < mp->map + mp->map_size; ) { 446 ksg = KS_GROUP(*kp); 447 if (ksg != KS_GROUP_Keycode) 448 panic("wskbd_load_keymap: %d(%d): bad entry", 449 mp->name, *kp); 450 451 kc = KS_VALUE(*kp); 452 kp++; 453 454 if (KS_GROUP(*kp) == KS_GROUP_Command || 455 *kp == KS_Cmd || *kp == KS_Cmd1 || *kp == KS_Cmd2) { 456 (*map)[kc].command = *kp; 457 kp++; 458 } 459 460 for (i = 0; kp + i < mp->map + mp->map_size; i++) { 461 ksg = KS_GROUP(kp[i]); 462 if (ksg == KS_GROUP_Keycode) 463 break; 464 } 465 466 if (i > 4) 467 panic("wskbd_load_keymap: %d(%d): bad entry", 468 mp->name, *kp); 469 470 fillmapentry(kp, i, &(*map)[kc]); 471 kp += i; 472 } 473 } 474 475 return(0); 476 } 477