1 /* $OpenBSD: ukbdmap.c,v 1.7 2001/05/03 02:20:33 aaron Exp $ */ 2 /* $NetBSD: ukbdmap.c,v 1.6 2001/04/04 05:31:57 toshii Exp $ */ 3 4 /* 5 * Copyright (c) 1999 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation 9 * by Lennart Augustsson (lennart@augustsson.net) at 10 * Carlstedt Research & Technology. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 3. All advertising materials mentioning features or use of this software 21 * must display the following acknowledgement: 22 * This product includes software developed by the NetBSD 23 * Foundation, Inc. and its contributors. 24 * 4. Neither the name of The NetBSD Foundation nor the names of its 25 * contributors may be used to endorse or promote products derived 26 * from this software without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 29 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 31 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 32 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 * POSSIBILITY OF SUCH DAMAGE. 39 */ 40 41 #include <sys/types.h> 42 #include <dev/wscons/wsksymdef.h> 43 #include <dev/wscons/wsksymvar.h> 44 45 #include <dev/usb/usb_port.h> 46 47 #define KC(n) KS_KEYCODE(n) 48 49 Static const keysym_t ukbd_keydesc_us[] = { 50 /* pos command normal shifted */ 51 KC(4), KS_a, 52 KC(5), KS_b, 53 KC(6), KS_c, 54 KC(7), KS_d, 55 KC(8), KS_e, 56 KC(9), KS_f, 57 KC(10), KS_g, 58 KC(11), KS_h, 59 KC(12), KS_i, 60 KC(13), KS_j, 61 KC(14), KS_k, 62 KC(15), KS_l, 63 KC(16), KS_m, 64 KC(17), KS_n, 65 KC(18), KS_o, 66 KC(19), KS_p, 67 KC(20), KS_q, 68 KC(21), KS_r, 69 KC(22), KS_s, 70 KC(23), KS_t, 71 KC(24), KS_u, 72 KC(25), KS_v, 73 KC(26), KS_w, 74 KC(27), KS_x, 75 KC(28), KS_y, 76 KC(29), KS_z, 77 KC(30), KS_1, KS_exclam, 78 KC(31), KS_2, KS_at, 79 KC(32), KS_3, KS_numbersign, 80 KC(33), KS_4, KS_dollar, 81 KC(34), KS_5, KS_percent, 82 KC(35), KS_6, KS_asciicircum, 83 KC(36), KS_7, KS_ampersand, 84 KC(37), KS_8, KS_asterisk, 85 KC(38), KS_9, KS_parenleft, 86 KC(39), KS_0, KS_parenright, 87 KC(40), KS_Return, 88 KC(41), KS_Cmd_Debugger, KS_Escape, 89 KC(42), KS_BackSpace, 90 KC(43), KS_Tab, 91 KC(44), KS_space, 92 KC(45), KS_minus, KS_underscore, 93 KC(46), KS_equal, KS_plus, 94 KC(47), KS_bracketleft, KS_braceleft, 95 KC(48), KS_bracketright,KS_braceright, 96 KC(49), KS_backslash, KS_bar, 97 KC(50), KS_numbersign, KS_asciitilde, 98 KC(51), KS_semicolon, KS_colon, 99 KC(52), KS_apostrophe, KS_quotedbl, 100 KC(53), KS_grave, KS_asciitilde, 101 KC(54), KS_comma, KS_less, 102 KC(55), KS_period, KS_greater, 103 KC(56), KS_slash, KS_question, 104 KC(57), KS_Caps_Lock, 105 KC(58), KS_Cmd_Screen0, KS_f1, 106 KC(59), KS_Cmd_Screen1, KS_f2, 107 KC(60), KS_Cmd_Screen2, KS_f3, 108 KC(61), KS_Cmd_Screen3, KS_f4, 109 KC(62), KS_Cmd_Screen4, KS_f5, 110 KC(63), KS_Cmd_Screen5, KS_f6, 111 KC(64), KS_Cmd_Screen6, KS_f7, 112 KC(65), KS_Cmd_Screen7, KS_f8, 113 KC(66), KS_Cmd_Screen8, KS_f9, 114 KC(67), KS_Cmd_Screen9, KS_f10, 115 KC(68), KS_Cmd_Screen10, KS_f11, 116 KC(69), KS_Cmd_Screen11, KS_f12, 117 KC(70), KS_Print_Screen, 118 KC(71), KS_Hold_Screen, 119 KC(72), KS_Pause, 120 KC(73), KS_Insert, 121 KC(74), KS_Home, 122 KC(75), KS_Cmd_ScrollBack, KS_Prior, 123 KC(76), KS_Delete, 124 KC(77), KS_End, 125 KC(78), KS_Cmd_ScrollFwd, KS_Next, 126 KC(79), KS_Right, 127 KC(80), KS_Left, 128 KC(81), KS_Down, 129 KC(82), KS_Up, 130 KC(83), KS_Num_Lock, 131 KC(84), KS_KP_Divide, 132 KC(85), KS_KP_Multiply, 133 KC(86), KS_KP_Subtract, 134 KC(87), KS_KP_Add, 135 KC(88), KS_KP_Enter, 136 KC(89), KS_KP_End, KS_KP_1, 137 KC(90), KS_KP_Down, KS_KP_2, 138 KC(91), KS_KP_Next, KS_KP_3, 139 KC(92), KS_KP_Left, KS_KP_4, 140 KC(93), KS_KP_Begin, KS_KP_5, 141 KC(94), KS_KP_Right, KS_KP_6, 142 KC(95), KS_KP_Home, KS_KP_7, 143 KC(96), KS_KP_Up, KS_KP_8, 144 KC(97), KS_KP_Prior, KS_KP_9, 145 KC(98), KS_KP_Insert, KS_KP_0, 146 KC(99), KS_Cmd_KbdReset, KS_KP_Delete, KS_KP_Decimal, 147 KC(100), KS_backslash, KS_bar, 148 KC(101), KS_Menu, 149 /* ... many unmapped keys ... */ 150 KC(224), KS_Cmd1, KS_Control_L, 151 KC(225), KS_Shift_L, 152 KC(226), KS_Cmd2, KS_Alt_L, 153 KC(227), KS_Meta_L, 154 KC(228), KS_Control_R, 155 KC(229), KS_Shift_R, 156 KC(230), KS_Alt_R, KS_Multi_key, 157 KC(231), KS_Meta_R, 158 }; 159 160 Static const keysym_t ukbd_keydesc_jp[] = { 161 /* pos command normal shifted */ 162 KC(31), KS_2, KS_quotedbl, 163 KC(35), KS_6, KS_ampersand, 164 KC(36), KS_7, KS_apostrophe, 165 KC(37), KS_8, KS_parenleft, 166 KC(38), KS_9, KS_parenright, 167 KC(39), KS_0, 168 KC(45), KS_minus, KS_equal, 169 KC(46), KS_asciicircum, KS_asciitilde, 170 KC(47), KS_at, KS_grave, 171 KC(48), KS_bracketleft, KS_braceleft, 172 KC(50), KS_bracketright, KS_braceright, 173 KC(51), KS_semicolon, KS_plus, 174 KC(52), KS_colon, KS_asterisk, 175 KC(53), KS_Zenkaku_Hankaku, /* replace grave/tilde */ 176 KC(135), KS_backslash, KS_underscore, 177 KC(136), KS_Hiragana_Katakana, 178 KC(137), KS_backslash, KS_bar, 179 KC(138), KS_Henkan, 180 KC(139), KS_Muhenkan, 181 }; 182 183 Static const keysym_t ukbd_keydesc_swapctrlcaps[] = { 184 /* pos command normal shifted */ 185 KC(57), KS_Control_L, 186 KC(224), KS_Cmd1, KS_Caps_Lock, 187 }; 188 189 Static const keysym_t ukbd_keydesc_de[] = { 190 /* pos normal shifted altgr shift-altgr */ 191 KC(16), KS_m, KS_M, KS_mu, 192 KC(20), KS_q, KS_Q, KS_at, 193 KC(28), KS_z, 194 KC(29), KS_y, 195 KC(31), KS_2, KS_quotedbl, KS_twosuperior, 196 KC(32), KS_3, KS_section, KS_threesuperior, 197 KC(35), KS_6, KS_ampersand, 198 KC(36), KS_7, KS_slash, KS_braceleft, 199 KC(37), KS_8, KS_parenleft, KS_bracketleft, 200 KC(38), KS_9, KS_parenright, KS_bracketright, 201 KC(39), KS_0, KS_equal, KS_braceright, 202 KC(45), KS_ssharp, KS_question, KS_backslash, 203 KC(46), KS_dead_acute, KS_dead_grave, 204 KC(47), KS_udiaeresis, 205 KC(48), KS_plus, KS_asterisk, KS_dead_tilde, 206 KC(50), KS_numbersign, KS_apostrophe, 207 KC(51), KS_odiaeresis, 208 KC(52), KS_adiaeresis, 209 KC(53), KS_dead_circumflex,KS_dead_abovering, 210 KC(54), KS_comma, KS_semicolon, 211 KC(55), KS_period, KS_colon, 212 KC(56), KS_minus, KS_underscore, 213 KC(100), KS_less, KS_greater, KS_bar, KS_brokenbar, 214 KC(230), KS_Mode_switch, KS_Multi_key, 215 }; 216 217 Static const keysym_t ukbd_keydesc_de_nodead[] = { 218 /* pos normal shifted altgr shift-altgr */ 219 KC(46), KS_apostrophe, KS_grave, 220 KC(48), KS_plus, KS_asterisk, KS_asciitilde, 221 KC(53), KS_asciicircum, KS_degree, 222 }; 223 224 Static const keysym_t ukbd_keydesc_dk[] = { 225 /* pos normal shifted altgr shift-altgr */ 226 KC(31), KS_2, KS_quotedbl, KS_at, 227 KC(32), KS_3, KS_numbersign, KS_sterling, 228 KC(33), KS_4, KS_currency, KS_dollar, 229 KC(35), KS_6, KS_ampersand, 230 KC(36), KS_7, KS_slash, KS_braceleft, 231 KC(37), KS_8, KS_parenleft, KS_bracketleft, 232 KC(38), KS_9, KS_parenright, KS_bracketright, 233 KC(39), KS_0, KS_equal, KS_braceright, 234 KC(45), KS_plus, KS_question, 235 KC(46), KS_dead_acute, KS_dead_grave, KS_bar, 236 KC(47), KS_aring, 237 KC(48), KS_dead_diaeresis, KS_dead_circumflex, KS_dead_tilde, 238 KC(50), KS_apostrophe, KS_asterisk, 239 KC(51), KS_ae, 240 KC(52), KS_oslash, 241 KC(53), KS_onehalf, KS_paragraph, 242 KC(54), KS_comma, KS_semicolon, 243 KC(55), KS_period, KS_colon, 244 KC(56), KS_minus, KS_underscore, 245 KC(100), KS_less, KS_greater, KS_backslash, 246 KC(230), KS_Mode_switch, KS_Multi_key, 247 }; 248 249 Static const keysym_t ukbd_keydesc_dk_nodead[] = { 250 /* pos normal shifted altgr shift-altgr */ 251 KC(46), KS_apostrophe, KS_grave, KS_bar, 252 KC(48), KS_diaeresis, KS_asciicircum, KS_asciitilde, 253 }; 254 255 Static const keysym_t ukbd_keydesc_sv[] = { 256 /* pos normal shifted altgr shift-altgr */ 257 KC(45), KS_plus, KS_question, KS_backslash, 258 KC(48), KS_dead_diaeresis, KS_dead_circumflex, KS_dead_tilde, 259 KC(51), KS_odiaeresis, 260 KC(52), KS_adiaeresis, 261 KC(53), KS_paragraph, KS_onehalf, 262 KC(100), KS_less, KS_greater, KS_bar, 263 KC(230), KS_Mode_switch, KS_Multi_key, 264 }; 265 266 Static const keysym_t ukbd_keydesc_sv_nodead[] = { 267 /* pos normal shifted altgr shift-altgr */ 268 KC(46), KS_apostrophe, KS_grave, KS_bar, 269 KC(48), KS_diaeresis, KS_asciicircum, KS_asciitilde, 270 }; 271 272 Static const keysym_t ukbd_keydesc_no[] = { 273 /* pos normal shifted altgr shift-altgr */ 274 KC(46), KS_backslash, KS_dead_grave, KS_dead_acute, 275 KC(48), KS_dead_diaeresis, KS_dead_circumflex, KS_dead_tilde, 276 KC(51), KS_oslash, 277 KC(52), KS_ae, 278 KC(53), KS_bar, KS_paragraph, 279 KC(100), KS_less, KS_greater, 280 }; 281 282 Static const keysym_t ukbd_keydesc_no_nodead[] = { 283 /* pos normal shifted altgr shift-altgr */ 284 KC(46), KS_backslash, KS_grave, KS_acute, 285 KC(48), KS_diaeresis, KS_asciicircum, KS_asciitilde, 286 }; 287 288 Static const keysym_t ukbd_keydesc_fr[] = { 289 /* pos normal shifted altgr shift-altgr */ 290 KC(4), KS_q, 291 KC(16), KS_comma, KS_question, 292 KC(20), KS_a, 293 KC(26), KS_z, 294 KC(29), KS_w, 295 KC(30), KS_ampersand, KS_1, 296 KC(31), KS_eacute, KS_2, KS_asciitilde, 297 KC(32), KS_quotedbl, KS_3, KS_numbersign, 298 KC(33), KS_apostrophe, KS_4, KS_braceleft, 299 KC(34), KS_parenleft, KS_5, KS_bracketleft, 300 KC(35), KS_minus, KS_6, KS_bar, 301 KC(36), KS_egrave, KS_7, KS_grave, 302 KC(37), KS_underscore, KS_8, KS_backslash, 303 KC(38), KS_ccedilla, KS_9, KS_asciicircum, 304 KC(39), KS_agrave, KS_0, KS_at, 305 KC(45), KS_parenright, KS_degree, KS_bracketright, 306 KC(46), KS_equal, KS_plus, KS_braceright, 307 KC(47), KS_dead_circumflex, KS_dead_diaeresis, 308 KC(48), KS_dollar, KS_sterling, KS_currency, 309 KC(50), KS_asterisk, KS_mu, 310 KC(51), KS_m, 311 KC(52), KS_ugrave, KS_percent, 312 KC(53), KS_twosuperior, 313 KC(54), KS_semicolon, KS_period, 314 KC(55), KS_colon, KS_slash, 315 KC(56), KS_exclam, KS_section, 316 KC(100), KS_less, KS_greater, 317 KC(230), KS_Mode_switch, KS_Multi_key, 318 }; 319 320 Static const keysym_t ukbd_keydesc_it[] = { 321 /* pos normal shifted altgr shift-altgr */ 322 KC(31), KS_2, KS_quotedbl, KS_twosuperior, 323 KC(32), KS_3, KS_sterling, KS_threesuperior, 324 KC(33), KS_4, KS_dollar, 325 KC(34), KS_5, KS_percent, 326 KC(35), KS_6, KS_ampersand, 327 KC(36), KS_7, KS_slash, 328 KC(37), KS_8, KS_parenleft, 329 KC(38), KS_9, KS_parenright, 330 KC(39), KS_0, KS_equal, 331 KC(45), KS_apostrophe, KS_question, 332 KC(46), KS_igrave, KS_asciicircum, 333 KC(47), KS_egrave, KS_eacute, KS_braceleft, KS_bracketleft, 334 KC(48), KS_plus, KS_asterisk, KS_braceright, KS_bracketright, 335 KC(49), KS_ugrave, KS_section, 336 KC(51), KS_ograve, KS_Ccedilla, KS_at, 337 KC(52), KS_agrave, KS_degree, KS_numbersign, 338 KC(53), KS_backslash, KS_bar, 339 KC(54), KS_comma, KS_semicolon, 340 KC(55), KS_period, KS_colon, 341 KC(56), KS_minus, KS_underscore, 342 KC(100), KS_less, KS_greater, 343 KC(230), KS_Mode_switch, KS_Multi_key, 344 }; 345 346 Static const keysym_t ukbd_keydesc_uk[] = { 347 /* pos normal shifted altgr shift-altgr */ 348 KC(30), KS_1, KS_exclam, KS_plusminus, KS_exclamdown, 349 KC(31), KS_2, KS_quotedbl, KS_twosuperior, KS_cent, 350 KC(32), KS_3, KS_sterling, KS_threesuperior, 351 KC(33), KS_4, KS_dollar, KS_acute, KS_currency, 352 KC(34), KS_5, KS_percent, KS_mu, KS_yen, 353 KC(35), KS_6, KS_asciicircum, KS_paragraph, 354 KC(36), KS_7, KS_ampersand, KS_periodcentered, KS_brokenbar, 355 KC(37), KS_8, KS_asterisk, KS_cedilla, KS_ordfeminine, 356 KC(38), KS_9, KS_parenleft, KS_onesuperior, KS_diaeresis, 357 KC(39), KS_0, KS_parenright, KS_masculine, KS_copyright, 358 KC(45), KS_minus, KS_underscore, KS_hyphen, KS_ssharp, 359 KC(46), KS_equal, KS_plus, KS_onehalf, KS_guillemotleft, 360 KC(49), KS_numbersign, KS_asciitilde, KS_sterling, KS_thorn, 361 KC(52), KS_apostrophe, KS_at, KS_section, KS_Agrave, 362 KC(53), KS_grave, KS_grave, KS_agrave, KS_agrave, 363 KC(100), KS_backslash, KS_bar, KS_Udiaeresis, 364 }; 365 366 Static const keysym_t ukbd_keydesc_es[] = { 367 /* pos normal shifted altgr shift-altgr */ 368 KC(30), KS_1, KS_exclam, KS_bar, 369 KC(31), KS_2, KS_quotedbl, KS_at, 370 KC(32), KS_3, KS_periodcentered, KS_numbersign, 371 KC(33), KS_4, KS_dollar, KS_asciitilde, 372 KC(35), KS_6, KS_ampersand, 373 KC(36), KS_7, KS_slash, 374 KC(37), KS_8, KS_parenleft, 375 KC(38), KS_9, KS_parenright, 376 KC(39), KS_0, KS_equal, 377 KC(45), KS_grave, KS_question, 378 KC(46), KS_exclamdown, KS_questiondown, 379 KC(47), KS_dead_grave, KS_dead_circumflex, KS_bracketleft, 380 KC(48), KS_plus, KS_asterisk, KS_bracketright, 381 KC(49), KS_ccedilla, KS_Ccedilla, KS_braceright, 382 KC(51), KS_ntilde, 383 KC(52), KS_dead_acute, KS_dead_diaeresis, KS_braceleft, 384 KC(53), KS_degree, KS_ordfeminine, KS_backslash, 385 KC(54), KS_comma, KS_semicolon, 386 KC(55), KS_period, KS_colon, 387 KC(56), KS_minus, KS_underscore, 388 KC(100), KS_less, KS_greater, 389 KC(230), KS_Mode_switch, KS_Multi_key, 390 }; 391 392 #define KBD_MAP(name, base, map) \ 393 { name, base, sizeof(map)/sizeof(keysym_t), map } 394 395 const struct wscons_keydesc ukbd_keydesctab[] = { 396 KBD_MAP(KB_US, 0, ukbd_keydesc_us), 397 KBD_MAP(KB_US | KB_SWAPCTRLCAPS, KB_US, ukbd_keydesc_swapctrlcaps), 398 KBD_MAP(KB_JP, KB_US, ukbd_keydesc_jp), 399 KBD_MAP(KB_JP | KB_SWAPCTRLCAPS,KB_JP, ukbd_keydesc_swapctrlcaps), 400 KBD_MAP(KB_DE, KB_US, ukbd_keydesc_de), 401 KBD_MAP(KB_DE | KB_NODEAD, KB_DE, ukbd_keydesc_de_nodead), 402 KBD_MAP(KB_FR, KB_US, ukbd_keydesc_fr), 403 KBD_MAP(KB_FR | KB_SWAPCTRLCAPS, KB_FR, ukbd_keydesc_swapctrlcaps), 404 KBD_MAP(KB_DK, KB_US, ukbd_keydesc_dk), 405 KBD_MAP(KB_DK | KB_NODEAD, KB_DK, ukbd_keydesc_dk_nodead), 406 KBD_MAP(KB_IT, KB_US, ukbd_keydesc_it), 407 KBD_MAP(KB_UK, KB_US, ukbd_keydesc_uk), 408 KBD_MAP(KB_SV, KB_DK, ukbd_keydesc_sv), 409 KBD_MAP(KB_SV | KB_NODEAD, KB_SV, ukbd_keydesc_sv_nodead), 410 KBD_MAP(KB_NO, KB_DK, ukbd_keydesc_no), 411 KBD_MAP(KB_NO | KB_NODEAD, KB_NO, ukbd_keydesc_no_nodead), 412 KBD_MAP(KB_ES , KB_US, ukbd_keydesc_es), 413 {0, 0, 0, 0} 414 }; 415 416 #undef KBD_MAP 417 #undef KC 418