Home | History | Annotate | Line # | Download | only in dev
      1 /*	$NetBSD: dnkbdmap.c,v 1.3 2011/02/19 05:37:55 tsutsui Exp $	*/
      2 /*	$OpenBSD: dnkbdmap.c,v 1.2 2005/05/06 22:22:53 miod Exp $	*/
      3 /*
      4  * Copyright (c) 2005, Miodrag Vallat
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  *
     15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     18  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
     19  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     21  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     23  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     24  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     25  * POSSIBILITY OF SUCH DAMAGE.
     26  */
     27 
     28 #include "opt_wsdisplay_compat.h"
     29 
     30 #include <sys/types.h>
     31 
     32 #include <dev/wscons/wsksymdef.h>
     33 #include <dev/wscons/wsksymvar.h>
     34 
     35 #include <hp300/dev/dnkbdmap.h>
     36 
     37 #ifdef WSDISPLAY_COMPAT_RAWKBD
     38 
     39 /*
     40  * Translate Domain keycodes to US keyboard XT scancodes, for proper
     41  * X11-over-wsmux operation.
     42  */
     43 const uint8_t dnkbd_raw[0x80] = {
     44     0x00, 0x00, 0x00, 0x00, 0x44, 0x3b, 0x3c, 0x3d,
     45     0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x00, 0x00,
     46     0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x01, 0x01,
     47     0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
     48     0x0a, 0x0b, 0x0c, 0x0d, 0x29, 0x0e, 0x00, 0x00,
     49     0x00, 0x00, 0x00, 0x00, 0x0f, 0x10, 0x11, 0x12,
     50     0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a,
     51     0x1b, 0x00, 0xd3, 0x00, 0x47, 0x48, 0x49, 0x4e,
     52     0x00, 0xc8, 0x00, 0x1d, 0x00, 0x00, 0x1e, 0x1f,
     53     0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
     54     0x28, 0x00, 0x1c, 0x2b, 0x00, 0x4b, 0x4c, 0x4d,
     55     0x4a, 0xcb, 0x00, 0xcd, 0x00, 0x00, 0x2a, 0x00,
     56     0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
     57     0x34, 0x35, 0x36, 0x00, 0x00, 0x00, 0x4f, 0x50,
     58     0x51, 0x00, 0x00, 0xd0, 0x00, 0x38, 0x39, 0xb8,
     59     0x00, 0x52, 0x00, 0x53, 0x9c, 0x00, 0x3a, 0x00
     60 };
     61 #endif
     62 
     63 #define	KC(n)	KS_KEYCODE(n)
     64 
     65 /*
     66  * US English
     67  */
     68 
     69 static const keysym_t dnkbd_keydesc_us[] = {
     70 /*	pos		command		normal		shifted */
     71 	/* 01 Ins Mark */
     72 	/* 02 Line Del */
     73 	/* 03 Char Del */
     74 	KC(0x04),			KS_f10,
     75 	KC(0x05),			KS_f1,
     76 	KC(0x06),			KS_f2,
     77 	KC(0x07),			KS_f3,
     78 	KC(0x08),			KS_f4,
     79 	KC(0x09),			KS_f5,
     80 	KC(0x0a),			KS_f6,
     81 	KC(0x0b),			KS_f7,
     82 	KC(0x0c),			KS_f8,
     83 	KC(0x0d),			KS_f9,
     84 	/* 0e Again */
     85 	/* 0f Read */
     86 	/* 10 Save Edit */
     87 	/* 11 Abort Exit */
     88 	KC(0x12),			KS_Hold_Screen,
     89 	/* 13 Cut Copy */
     90 	/* 14 Undo Paste */
     91 	/* 15 Move Grow */
     92 	KC(0x17),  KS_Cmd_Debugger,	KS_Escape,
     93 	KC(0x18),			KS_1,		KS_exclam,
     94 	KC(0x19),			KS_2,		KS_at,
     95 	KC(0x1a),			KS_3,		KS_numbersign,
     96 	KC(0x1b),			KS_4,		KS_dollar,
     97 	KC(0x1c),			KS_5,		KS_percent,
     98 	KC(0x1d),			KS_6,		KS_asciicircum,
     99 	KC(0x1e),			KS_7,		KS_ampersand,
    100 	KC(0x1f),			KS_8,		KS_asterisk,
    101 	KC(0x20),			KS_9,		KS_parenleft,
    102 	KC(0x21),			KS_0,		KS_parenright,
    103 	KC(0x22),			KS_minus,	KS_underscore,
    104 	KC(0x23),			KS_equal,	KS_plus,
    105 	KC(0x24),			KS_grave,	KS_asciitilde,
    106 	KC(0x25),  KS_Cmd_ResetEmul,	KS_Delete,	/* backspace */
    107 	KC(0x27),			KS_Home,
    108 	/* 28 Shell Cmd */
    109 	KC(0x29),			KS_End,
    110 	KC(0x2c),			KS_Tab,
    111 	KC(0x2d),			KS_q,
    112 	KC(0x2e),			KS_w,
    113 	KC(0x2f),			KS_e,
    114 	KC(0x30),			KS_r,
    115 	KC(0x31),			KS_t,
    116 	KC(0x32),			KS_y,
    117 	KC(0x33),			KS_u,
    118 	KC(0x34),			KS_i,
    119 	KC(0x35),			KS_o,
    120 	KC(0x36),			KS_p,
    121 	KC(0x37),			KS_bracketleft,	KS_braceleft,
    122 	KC(0x38),			KS_bracketright,KS_braceright,
    123 	KC(0x3a),			KS_Delete,
    124 	KC(0x3c),			KS_KP_7,
    125 	KC(0x3d),			KS_KP_8,
    126 	KC(0x3e),			KS_KP_9,
    127 	KC(0x3f),			KS_KP_Add,
    128 	/* 40 Left Box */
    129 	KC(0x41),			KS_Up,
    130 	/* 42 Right Box */
    131 	KC(0x43),  KS_Cmd1,		KS_Control_L,
    132 	KC(0x46),			KS_a,
    133 	KC(0x47),			KS_s,
    134 	KC(0x48),			KS_d,
    135 	KC(0x49),			KS_f,
    136 	KC(0x4a),			KS_g,
    137 	KC(0x4b),			KS_h,
    138 	KC(0x4c),			KS_j,
    139 	KC(0x4d),			KS_k,
    140 	KC(0x4e),			KS_l,
    141 	KC(0x4f),			KS_semicolon,	KS_colon,
    142 	KC(0x50),			KS_apostrophe,	KS_quotedbl,
    143 	KC(0x52),			KS_Return,
    144 	KC(0x53),			KS_backslash,	KS_bar,
    145 	KC(0x55),			KS_KP_4,
    146 	KC(0x56),			KS_KP_5,
    147 	KC(0x57),			KS_KP_6,
    148 	KC(0x58),			KS_KP_Subtract,
    149 	KC(0x59),			KS_Left,
    150 	/* 5a Next Wndw */
    151 	KC(0x5b),			KS_Right,
    152 	/* 5d Rept */
    153 	KC(0x5e),			KS_Shift_L,
    154 	KC(0x60),			KS_z,
    155 	KC(0x61),			KS_x,
    156 	KC(0x62),			KS_c,
    157 	KC(0x63),			KS_v,
    158 	KC(0x64),			KS_b,
    159 	KC(0x65),			KS_n,
    160 	KC(0x66),			KS_m,
    161 	KC(0x67),			KS_comma,	KS_less,
    162 	KC(0x68),			KS_period,	KS_greater,
    163 	KC(0x69),			KS_slash,	KS_question,
    164 	KC(0x6a),			KS_Shift_R,
    165 	/* 6c Pop */
    166 	KC(0x6e),			KS_KP_1,
    167 	KC(0x6f),			KS_KP_2,
    168 	KC(0x70),			KS_KP_3,
    169 	/* 72 Top Box */
    170 	KC(0x73),			KS_Down,
    171 	/* 74 Bottom Box */
    172 	KC(0x75),  KS_Cmd2,		KS_Alt_L,
    173 	KC(0x76),			KS_space,
    174 	KC(0x77),  KS_Cmd2,		KS_Alt_R,	KS_Multi_key,
    175 	KC(0x79),			KS_KP_0,
    176 	KC(0x7b),			KS_KP_Separator,
    177 	KC(0x7c),			KS_KP_Enter,
    178 	KC(0x7e),			KS_Caps_Lock
    179 };
    180 
    181 /*
    182  * German
    183  */
    184 
    185 static const keysym_t dnkbd_keydesc_de[] = {
    186 /*	pos		normal		shifted		altgr */
    187 	KC(0x17),	KS_dead_circumflex, KS_dead_abovering,
    188 	KC(0x19),	KS_2,		KS_quotedbl,
    189 	KC(0x1a),	KS_3,		KS_at,		KS_section,
    190 	KC(0x1d),	KS_6,		KS_ampersand,
    191 	KC(0x1e),	KS_7,		KS_slash,
    192 	KC(0x1f),	KS_8,		KS_parenleft,
    193 	KC(0x20),	KS_9,		KS_parenright,
    194 	KC(0x21),	KS_0,		KS_equal,
    195 	KC(0x22),	KS_dead_tilde,	KS_question,	KS_ssharp,
    196 	KC(0x23),	KS_dead_acute,	KS_dead_grave,
    197 	KC(0x32),	KS_z,
    198 	KC(0x37),	KS_braceright,	KS_bracketright,KS_udiaeresis,
    199 	KC(0x38),	KS_plus,	KS_asterisk,
    200 	KC(0x4f),	KS_bar,		KS_backslash,	KS_odiaeresis,
    201 	KC(0x50),	KS_braceleft,	KS_bracketleft,	KS_adiaeresis,
    202 	KC(0x51),	KS_numbersign,	KS_apostrophe,
    203 	KC(0x5f),	KS_less,	KS_greater,
    204 	KC(0x60),	KS_y,
    205 	KC(0x67),	KS_comma,	KS_semicolon,
    206 	KC(0x68),	KS_period,	KS_colon,
    207 	KC(0x69),	KS_minus,	KS_underscore,
    208 	KC(0x77),	KS_Mode_switch,	KS_Multi_key
    209 };
    210 
    211 static const keysym_t dnkbd_keydesc_de_nodead[] = {
    212 	KC(0x17),	KS_asciicircum, KS_degree,
    213 	KC(0x22),	KS_asciitilde,	KS_question,	KS_ssharp,
    214 	KC(0x23),	KS_apostrophe,	KS_grave
    215 };
    216 
    217 /*
    218  * Norwegian / Danish
    219  */
    220 
    221 static const keysym_t dnkbd_keydesc_dk[] = {
    222 /*	pos		normal		shifted		altgr */
    223 	KC(0x17),	KS_underscore,
    224 	KC(0x19),	KS_2,		KS_quotedbl,
    225 	KC(0x1d),	KS_6,		KS_ampersand,
    226 	KC(0x1e),	KS_7,		KS_slash,
    227 	KC(0x1f),	KS_8,		KS_parenleft,
    228 	KC(0x20),	KS_9,		KS_parenright,
    229 	KC(0x21),	KS_0,		KS_equal,
    230 	KC(0x22),	KS_plus,	KS_question,
    231 	KC(0x23),	KS_dead_grave,	KS_at,
    232 	KC(0x37),	KS_braceright,	KS_bracketright,KS_aring,
    233 	KC(0x38),	KS_dead_tilde,	KS_dead_circumflex,KS_dead_diaeresis,
    234 	KC(0x4f),	KS_bar,		KS_backslash,	KS_oslash,
    235 	KC(0x50),	KS_braceleft,	KS_bracketleft,	KS_ae,
    236 	KC(0x51),	KS_dead_acute,	KS_asterisk,
    237 	KC(0x5f),	KS_less,	KS_greater,
    238 	KC(0x67),	KS_comma,	KS_semicolon,
    239 	KC(0x68),	KS_period,	KS_colon,
    240 	KC(0x69),	KS_minus,	KS_underscore,
    241 	KC(0x77),	KS_Mode_switch,	KS_Multi_key
    242 };
    243 
    244 static const keysym_t dnkbd_keydesc_dk_nodead[] = {
    245 /*	pos		normal		shifted		altgr */
    246 	KC(0x23),	KS_grave,	KS_at,
    247 	KC(0x38),	KS_asciitilde,	KS_asciicircum,	KS_diaeresis,
    248 	KC(0x51),	KS_apostrophe,	KS_asterisk,
    249 };
    250 
    251 /*
    252  * French
    253  */
    254 
    255 static const keysym_t dnkbd_keydesc_fr[] = {
    256 /*	pos		normal		shifted		altgr */
    257 	KC(0x17),	KS_bracketleft,	KS_degree,
    258 	KC(0x18),	KS_ampersand,	KS_1,
    259 	KC(0x19),	KS_braceleft,	KS_2,		KS_eacute,
    260 	KC(0x1a),	KS_quotedbl,	KS_3,
    261 	KC(0x1b),	KS_apostrophe,	KS_4,
    262 	KC(0x1c),	KS_parenleft,	KS_5,
    263 	KC(0x1d),	KS_bracketright,KS_6,		KS_section,
    264 	KC(0x1e),	KS_braceright,	KS_7,		KS_egrave,
    265 	KC(0x1f),	KS_exclam,	KS_8,
    266 	KC(0x20),	KS_backslash,	KS_9,		KS_ccedilla,
    267 	KC(0x21),	KS_at,		KS_0,		KS_agrave,
    268 	KC(0x22),	KS_parenright,	KS_degree,
    269 	KC(0x23),	KS_minus,	KS_underscore,
    270 	KC(0x2d),	KS_a,
    271 	KC(0x2e),	KS_z,
    272 	KC(0x37),	KS_dead_circumflex, KS_asciitilde, KS_dead_diaeresis,
    273 	KC(0x38),	KS_dollar,	KS_asterisk,
    274 	KC(0x46),	KS_q,
    275 	KC(0x4f),	KS_m,
    276 	KC(0x50),	KS_bar,		KS_percent,	KS_ugrave,
    277 	KC(0x51),	KS_grave,	KS_numbersign,
    278 	KC(0x5f),	KS_less,	KS_greater,
    279 	KC(0x60),	KS_w,
    280 	KC(0x66),	KS_comma,	KS_question,
    281 	KC(0x67),	KS_semicolon,	KS_period,
    282 	KC(0x68),	KS_colon,	KS_slash,
    283 	KC(0x69),	KS_equal,	KS_plus,
    284 	KC(0x77),	KS_Mode_switch,	KS_Multi_key
    285 };
    286 
    287 /*
    288  * Japanese (and basis for international layouts)
    289  *
    290  * Apparently this layout lacks all japanese keys (Zenkaku/Hankaku,
    291  * Hiragana/Katakana, Henkan and Muhenkan). Makes one wonder about
    292  * its usefulness.
    293  */
    294 
    295 static const keysym_t dnkbd_keydesc_jp[] = {
    296 /*	pos		cmd		normal		shifted */
    297 	KC(0x16),  KS_Cmd_Debugger,	KS_Escape,
    298 	KC(0x17),	KS_grave,	KS_asciitilde,
    299 	KC(0x24),  KS_Cmd_ResetEmul,	KS_Delete,	/* backspace */
    300 	KC(0x25),			KS_Delete,
    301 	/* 2b Rept */
    302 	KC(0x3b),			KS_KP_Add,
    303 	KC(0x3f),			KS_parenleft,	/* KS_KP_parenleft */
    304 	KC(0x51),			KS_backslash,	KS_bar,
    305 	KC(0x54),			KS_KP_Subtract,
    306 	KC(0x58),			KS_parenright,	/* KS_KP_parenright */
    307 	KC(0x5f),			KS_less,	KS_greater,
    308 	KC(0x6d),			KS_KP_Multiply,
    309 	KC(0x78),			KS_KP_Divide,
    310 };
    311 
    312 /*
    313  * Swiss (relative to the German layout)
    314  */
    315 
    316 static const keysym_t dnkbd_keydesc_sg[] = {
    317 /*	pos		normal		shifted		altgr */
    318 	KC(0x17),	KS_at,		KS_exclam,	KS_section,
    319 	KC(0x18),	KS_1,		KS_plus,
    320 	KC(0x1a),	KS_3,		KS_asterisk,
    321 	KC(0x1b),	KS_4,		KS_backslash,	KS_ccedilla,
    322 	KC(0x22),	KS_apostrophe,	KS_question,
    323 	KC(0x23),	KS_dead_circumflex,KS_dead_grave,
    324 	KC(0x37),	KS_braceright,	KS_dead_tilde,	KS_udiaeresis,	KS_egrave,
    325 	KC(0x38),	KS_dead_diaeresis,KS_dead_acute,
    326 	KC(0x4f),	KS_bar,		KS_bracketleft,	KS_odiaeresis,	KS_eacute,
    327 	KC(0x50),	KS_braceleft,	KS_bracketright,KS_adiaeresis,	KS_agrave,
    328 	KC(0x51),	KS_dollar,	KS_numbersign,	KS_sterling
    329 };
    330 
    331 static const keysym_t dnkbd_keydesc_sg_nodead[] = {
    332 /*	pos		normal		shifted		altgr */
    333 	KC(0x23),	KS_asciicircum,	KS_grave,
    334 	KC(0x37),	KS_braceright,	KS_asciitilde,	KS_udiaeresis,	KS_egrave,
    335 	KC(0x38),	KS_diaeresis,	KS_apostrophe
    336 };
    337 
    338 /*
    339  * Swedish / Finnish (relative to the Norwegian / Danish layout)
    340  */
    341 
    342 static const keysym_t dnkbd_keydesc_sv[] = {
    343 /*	pos		normal		shifted		altgr */
    344 	KC(0x1b),	KS_4,		KS_dollar,	KS_currency,
    345 	KC(0x23),	KS_dead_grave,	KS_at,		KS_eacute,
    346 	KC(0x38),	KS_dead_tilde,	KS_dead_circumflex,KS_udiaeresis,
    347 	KC(0x4f),	KS_bar,		KS_backslash,	KS_odiaeresis,
    348 	KC(0x50),	KS_braceleft,	KS_bracketleft,	KS_adiaeresis
    349 };
    350 
    351 static const keysym_t dnkbd_keydesc_sv_nodead[] = {
    352 /*	pos		normal		shifted		altgr */
    353 	KC(0x23),	KS_grave,	KS_at,		KS_eacute,
    354 	KC(0x38),	KS_asciitilde,	KS_asciicircum,	KS_udiaeresis,
    355 	KC(0x51),	KS_apostrophe,	KS_asterisk,
    356 };
    357 
    358 /*
    359  * UK English
    360  */
    361 
    362 static const keysym_t dnkbd_keydesc_uk[] = {
    363 /*	pos		normal		shifted */
    364 	KC(0x17),	KS_underscore,
    365 	KC(0x19),	KS_2,		KS_quotedbl,
    366 	KC(0x1d),	KS_6,		KS_ampersand,
    367 	KC(0x1e),	KS_7,		KS_apostrophe,
    368 	KC(0x1f),	KS_8,		KS_parenleft,
    369 	KC(0x20),	KS_9,		KS_parenright,
    370 	KC(0x21),	KS_0,		KS_underscore,
    371 	KC(0x22),	KS_minus,	KS_equal,
    372 	KC(0x23),	KS_asciicircum,	KS_asciitilde,
    373 	KC(0x37),	KS_at,		KS_grave,
    374 	KC(0x38),	KS_bracketleft,	KS_braceleft,
    375 	KC(0x4f),	KS_semicolon,	KS_plus,
    376 	KC(0x50),	KS_colon,	KS_asterisk,
    377 	KC(0x51),	KS_bracketright,KS_braceright,
    378 	KC(0x5f),	KS_backslash,	KS_bar
    379 };
    380 
    381 #define	KBD_MAP(name, base, map) \
    382 	{ name, base, sizeof(map) / sizeof(keysym_t), map }
    383 
    384 const struct wscons_keydesc dnkbd_keydesctab[] = {
    385 	KBD_MAP(KB_US,			0,	dnkbd_keydesc_us),
    386 	KBD_MAP(KB_DE,			KB_JP,	dnkbd_keydesc_de),
    387 	KBD_MAP(KB_DE | KB_NODEAD,	KB_DE,	dnkbd_keydesc_de_nodead),
    388 	KBD_MAP(KB_DK,			KB_JP,	dnkbd_keydesc_dk),
    389 	KBD_MAP(KB_DK | KB_NODEAD,	KB_DK,	dnkbd_keydesc_dk_nodead),
    390 	KBD_MAP(KB_FR,			KB_JP,	dnkbd_keydesc_fr),
    391 	KBD_MAP(KB_JP,			KB_US,	dnkbd_keydesc_jp),
    392 	KBD_MAP(KB_SG,			KB_DE,	dnkbd_keydesc_sg),
    393 	KBD_MAP(KB_SG | KB_NODEAD,	KB_SG,	dnkbd_keydesc_sg_nodead),
    394 	KBD_MAP(KB_SV,			KB_DK,	dnkbd_keydesc_sv),
    395 	KBD_MAP(KB_SV | KB_NODEAD,	KB_SV,	dnkbd_keydesc_sv_nodead),
    396 	KBD_MAP(KB_UK,			KB_JP,	dnkbd_keydesc_uk),
    397 	{ 0, 0, 0, 0 }
    398 };
    399