Home | History | Annotate | Line # | Download | only in sun
      1 /*	$NetBSD: wskbdmap_sun.c,v 1.17 2010/01/14 02:18:59 macallan Exp $	*/
      2 /*	$OpenBSD: sunkbd.c,v 1.9 2002/09/08 23:22:00 miod Exp $	*/
      3 
      4 /*
      5  * Copyright (c) 2002 Jason L. Wright (jason (at) thought.net)
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. All advertising materials mentioning features or use of this software
     17  *    must display the following acknowledgement:
     18  *	This product includes software developed by Jason L. Wright
     19  * 4. The name of the author may not be used to endorse or promote products
     20  *    derived from this software without specific prior written permission.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     24  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     25  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
     26  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     27  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     30  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     32  * POSSIBILITY OF SUCH DAMAGE.
     33  *
     34  * Effort sponsored in part by the Defense Advanced Research Projects
     35  * Agency (DARPA) and Air Force Research Laboratory, Air Force
     36  * Materiel Command, USAF, under agreement number F30602-01-2-0537.
     37  *
     38  */
     39 
     40 #include <sys/cdefs.h>
     41 __KERNEL_RCSID(0, "$NetBSD: wskbdmap_sun.c,v 1.17 2010/01/14 02:18:59 macallan Exp $");
     42 
     43 #include <sys/types.h>
     44 #include <dev/wscons/wsksymdef.h>
     45 #include <dev/wscons/wsksymvar.h>
     46 
     47 #include "opt_sunkbd.h"
     48 
     49 #define KC(n) KS_KEYCODE(n)
     50 
     51 static const keysym_t wssun_keydesctab_us [] = {
     52 /*  pos      command			normal		shifted */
     53     KC(0x01), KS_Cmd,
     54     KC(0x02), KS_Cmd_VolumeDown,
     55     KC(0x03),				KS_Again,
     56     KC(0x04), KS_Cmd_VolumeUp,
     57     KC(0x05), KS_Cmd_Screen0,				KS_f1,
     58     KC(0x06), KS_Cmd_Screen1,				KS_f2,
     59     KC(0x07), KS_Cmd_Screen9,				KS_f10,
     60     KC(0x08), KS_Cmd_Screen2,				KS_f3,
     61     KC(0x09),				KS_f11,
     62     KC(0x0a), KS_Cmd_Screen3,				KS_f4,
     63     KC(0x0b),				KS_f12,
     64     KC(0x0c), KS_Cmd_Screen4,				KS_f5,
     65     KC(0x0d),				KS_Alt_R,
     66     KC(0x0e), KS_Cmd_Screen5,				KS_f6,
     67     KC(0x10), KS_Cmd_Screen6,				KS_f7,
     68     KC(0x11), KS_Cmd_Screen7,				KS_f8,
     69     KC(0x12), KS_Cmd_Screen8,				KS_f9,
     70 #ifdef SPARCBOOK_CMD
     71     KC(0x13), KS_Cmd,			KS_Alt_L,
     72 #else
     73     KC(0x13),				KS_Alt_L,
     74 #endif
     75     KC(0x14), KS_Cmd_ScrollSlowUp,	KS_Up,
     76     KC(0x15),				KS_Pause,
     77     KC(0x16),				KS_Print_Screen,
     78     KC(0x17),				KS_Hold_Screen,
     79     KC(0x18),				KS_Left,
     80     KC(0x19),				KS_Props,
     81     KC(0x1a),				KS_Undo,
     82     KC(0x1b), KS_Cmd_ScrollSlowDown,	KS_Down,
     83     KC(0x1c),				KS_Right,
     84     KC(0x1d),				KS_Escape,
     85     KC(0x1e),				KS_1,		KS_exclam,
     86     KC(0x1f),				KS_2,		KS_at,
     87     KC(0x20),				KS_3,		KS_numbersign,
     88     KC(0x21),				KS_4,		KS_dollar,
     89     KC(0x22),				KS_5,		KS_percent,
     90     KC(0x23),				KS_6,		KS_asciicircum,
     91     KC(0x24),				KS_7,		KS_ampersand,
     92     KC(0x25),				KS_8,		KS_asterisk,
     93     KC(0x26),				KS_9,		KS_parenleft,
     94     KC(0x27),				KS_0,		KS_parenright,
     95     KC(0x28),				KS_minus,	KS_underscore,
     96     KC(0x29),				KS_equal,	KS_plus,
     97     KC(0x2a),				KS_grave,	KS_asciitilde,
     98     KC(0x2b),				KS_Delete,
     99     KC(0x2c),				KS_Insert,
    100     KC(0x2d),				KS_KP_Equal,
    101     KC(0x2e),				KS_KP_Divide,
    102     KC(0x2f),				KS_KP_Multiply,
    103     KC(0x30),				KS_Power,
    104     KC(0x31),				KS_Front,
    105     KC(0x32),				KS_KP_Delete,	KS_KP_Decimal,
    106     KC(0x33),				KS_Copy,
    107     KC(0x34),				KS_Home,
    108     KC(0x35),				KS_Tab,
    109     KC(0x36),				KS_q,
    110     KC(0x37),				KS_w,
    111     KC(0x38),				KS_e,
    112     KC(0x39),				KS_r,
    113     KC(0x3a),				KS_t,
    114     KC(0x3b),				KS_y,
    115     KC(0x3c),				KS_u,
    116     KC(0x3d),				KS_i,
    117     KC(0x3e),				KS_o,
    118     KC(0x3f),				KS_p,
    119     KC(0x40),				KS_bracketleft,	KS_braceleft,
    120     KC(0x41),				KS_bracketright,KS_braceright,
    121     KC(0x42),				KS_Delete,
    122     KC(0x43),				KS_Multi_key,
    123     KC(0x44),				KS_KP_Home,	KS_KP_7,
    124     KC(0x45), KS_Cmd_ScrollSlowUp,	KS_KP_Up,	KS_KP_8,
    125     KC(0x46), KS_Cmd_ScrollFastUp,	KS_KP_Prior,	KS_KP_9,
    126     KC(0x47),				KS_KP_Subtract,
    127     KC(0x48),				KS_Open,
    128     KC(0x49),				KS_Paste,
    129     KC(0x4a),				KS_End,
    130     KC(0x4c),				KS_Control_L,
    131     KC(0x4d), KS_Cmd_Debugger,		KS_a,
    132     KC(0x4e),				KS_s,
    133     KC(0x4f),				KS_d,
    134     KC(0x50),				KS_f,
    135     KC(0x51),				KS_g,
    136     KC(0x52),				KS_h,
    137     KC(0x53),				KS_j,
    138     KC(0x54),				KS_k,
    139     KC(0x55),				KS_l,
    140     KC(0x56),				KS_semicolon,	KS_colon,
    141     KC(0x57),				KS_apostrophe,	KS_quotedbl,
    142     KC(0x58),				KS_backslash,	KS_bar,
    143     KC(0x59),				KS_Return,
    144     KC(0x5a),				KS_KP_Enter,
    145     KC(0x5b),				KS_KP_Left,	KS_KP_4,
    146     KC(0x5c),				KS_KP_Begin,	KS_KP_5,
    147     KC(0x5d),				KS_KP_Right,	KS_KP_6,
    148     KC(0x5e),				KS_KP_Insert,	KS_KP_0,
    149     KC(0x5f),				KS_Find,
    150     KC(0x60), KS_Cmd_ScrollFastUp,	KS_Prior,
    151     KC(0x61),				KS_Cut,
    152     KC(0x62),				KS_Num_Lock,
    153     KC(0x63),				KS_Shift_L,
    154     KC(0x64),				KS_z,
    155     KC(0x65),				KS_x,
    156     KC(0x66),				KS_c,
    157     KC(0x67),				KS_v,
    158     KC(0x68),				KS_b,
    159     KC(0x69),				KS_n,
    160     KC(0x6a),				KS_m,
    161     KC(0x6b),				KS_comma,	KS_less,
    162     KC(0x6c),				KS_period,	KS_greater,
    163     KC(0x6d),				KS_slash,	KS_question,
    164     KC(0x6e),				KS_Shift_R,
    165     KC(0x6f),				KS_Linefeed,
    166     KC(0x70),				KS_KP_End,	KS_KP_1,
    167     KC(0x71), KS_Cmd_ScrollSlowDown,	KS_KP_Down,	KS_KP_2,
    168     KC(0x72), KS_Cmd_ScrollFastDown,	KS_KP_Next,	KS_KP_3,
    169     KC(0x76),				KS_Help,
    170     KC(0x77),				KS_Caps_Lock,
    171     KC(0x78),				KS_Meta_L,
    172     KC(0x79),				KS_space,
    173     KC(0x7a),				KS_Meta_R,
    174     KC(0x7b), KS_Cmd_ScrollFastDown,	KS_Next,
    175     KC(0x7d),				KS_KP_Add,
    176 };
    177 
    178 const keysym_t wssun_keydesctab_sv[] = {
    179     KC(0x0d),		KS_Multi_key,
    180     KC(0x0f),		KS_asciitilde,	KS_asciicircum,
    181     KC(0x1f),		KS_2,		KS_quotedbl,	KS_at,
    182     KC(0x20),		KS_3,		KS_numbersign,	KS_sterling,
    183     KC(0x21),		KS_4,		KS_currency,	KS_dollar,
    184     KC(0x23),		KS_6,		KS_ampersand,
    185     KC(0x24),		KS_7,		KS_slash,	KS_braceleft,
    186     KC(0x25),		KS_8,		KS_parenleft,	KS_bracketleft,
    187     KC(0x26),		KS_9,		KS_parenright,	KS_bracketright,
    188     KC(0x27),		KS_0,		KS_equal,	KS_braceright,
    189     KC(0x28),		KS_plus,	KS_question,	KS_backslash,
    190     KC(0x29),		KS_dead_acute,	KS_dead_grave,
    191     KC(0x2a),		KS_apostrophe,	KS_asterisk,	KS_grave,
    192     KC(0x40),		KS_aring,
    193     KC(0x41),		KS_dead_diaeresis,KS_dead_circumflex,KS_dead_tilde,
    194     KC(0x43),		KS_Mode_switch,
    195     KC(0x4c),		KS_Caps_Lock,
    196     KC(0x56),		KS_odiaeresis,
    197     KC(0x57),		KS_adiaeresis,
    198     KC(0x58),		KS_paragraph,	KS_onehalf,
    199     KC(0x6b),		KS_comma,	KS_semicolon,
    200     KC(0x6c),		KS_period,	KS_colon,
    201     KC(0x6d),		KS_minus,	KS_underscore,
    202     KC(0x77),		KS_Control_L,
    203     KC(0x7c),		KS_less,	KS_greater,	KS_bar,
    204 };
    205 
    206 const keysym_t wssun_keydesctab_sv_nodead[] = {
    207     KC(0x29),		KS_apostrophe,	KS_grave,
    208     KC(0x41),		KS_diaeresis,	KS_asciicircum,	KS_asciitilde,
    209 };
    210 
    211 const keysym_t wssun_keydesctab_de[] = {
    212     KC(0x0d),		KS_Mode_switch,	/* Alt Graph (Alt R code) */
    213     KC(0x1f),		KS_2,		KS_quotedbl,	KS_twosuperior,
    214     KC(0x20),		KS_3,		KS_paragraph,	KS_threesuperior,
    215     KC(0x21),		KS_4,		KS_dollar,
    216     KC(0x22),		KS_5,		KS_percent,
    217     KC(0x23),		KS_6,		KS_ampersand,
    218     KC(0x24),		KS_7,		KS_slash,	KS_braceleft,
    219     KC(0x25),		KS_8,		KS_parenleft,	KS_bracketleft,
    220     KC(0x26),		KS_9,		KS_parenright,	KS_bracketright,
    221     KC(0x27),		KS_0,		KS_equal,	KS_braceright,
    222     KC(0x28),		KS_ssharp,	KS_question,	KS_backslash,
    223     KC(0x29),		KS_dead_acute,	KS_dead_grave,
    224     KC(0x2a),		KS_dead_circumflex, KS_dead_abovering,
    225     KC(0x36),		KS_q,		KS_Q,		KS_at,
    226     KC(0x3b),		KS_z,
    227     KC(0x40),		KS_udiaeresis,
    228     /* KC(0x43) - Compose - could be used for mode switch too */
    229     KC(0x41),		KS_plus,	KS_asterisk,	KS_dead_tilde,
    230     KC(0x56),		KS_odiaeresis,
    231     KC(0x57),		KS_adiaeresis,
    232     KC(0x58),		KS_numbersign,	KS_apostrophe,	KS_acute,
    233     KC(0x64),		KS_y,
    234     KC(0x6a),		KS_m,		KS_M,		KS_mu,
    235     KC(0x6b),		KS_comma,	KS_semicolon,
    236     KC(0x6c),		KS_period,	KS_colon,
    237     KC(0x6d),		KS_minus,	KS_underscore,
    238     KC(0x7c),		KS_less,	KS_greater,	KS_bar,
    239 };
    240 
    241 const keysym_t wssun_keydesctab_de_nodead[] = {
    242     KC(0x29),		KS_apostrophe,	KS_grave,
    243     KC(0x2a),		KS_asciicircum,	KS_degree,
    244     KC(0x41),		KS_plus,	KS_asterisk,	KS_asciitilde,
    245 };
    246 
    247 const keysym_t wssun_keydesctab_uk[] = {
    248     KC(0x1f),		KS_2,		KS_quotedbl,
    249     KC(0x20),		KS_3,		KS_sterling,
    250     KC(0x21),		KS_4,		KS_dollar,	KS_currency,
    251     KC(0x2a),		KS_grave,	KS_notsign,
    252     KC(0x57),		KS_apostrophe,	KS_at,
    253     KC(0x58),		KS_numbersign,	KS_asciitilde,
    254     KC(0x7c),		KS_backslash,	KS_bar,
    255 };
    256 
    257 static const keysym_t wssun_keydesctab_us_dvorak[] = {
    258 /*  pos      command			normal		shifted */
    259     KC(0x28),				KS_bracketleft,	KS_braceleft,
    260     KC(0x29),				KS_bracketright,KS_braceright,
    261     KC(0x36),				KS_apostrophe,	KS_quotedbl,
    262     KC(0x37),				KS_comma,	KS_less,
    263     KC(0x38),				KS_period,	KS_greater,
    264     KC(0x39),				KS_p,
    265     KC(0x3a),				KS_y,
    266     KC(0x3b),				KS_f,
    267     KC(0x3c),				KS_g,
    268     KC(0x3d),				KS_c,
    269     KC(0x3e),				KS_r,
    270     KC(0x3f),				KS_l,
    271     KC(0x40),				KS_slash,	KS_question,
    272     KC(0x41),				KS_equal,	KS_plus,
    273     KC(0x4d), KS_Cmd_Debugger,		KS_a,
    274     KC(0x4e),				KS_o,
    275     KC(0x4f),				KS_e,
    276     KC(0x50),				KS_u,
    277     KC(0x51),				KS_i,
    278     KC(0x52),				KS_d,
    279     KC(0x53),				KS_h,
    280     KC(0x54),				KS_t,
    281     KC(0x55),				KS_n,
    282     KC(0x56),				KS_s,
    283     KC(0x57),				KS_minus,	KS_underscore,
    284     KC(0x64),				KS_semicolon,	KS_colon,
    285     KC(0x65),				KS_q,
    286     KC(0x66),				KS_j,
    287     KC(0x67),				KS_k,
    288     KC(0x68),				KS_x,
    289     KC(0x69),				KS_b,
    290     KC(0x6a),				KS_m,
    291     KC(0x6b),				KS_w,
    292     KC(0x6c),				KS_v,
    293     KC(0x6d),				KS_z,
    294 };
    295 
    296 static const keysym_t wssun_keydesctab_us_colemak [] = {
    297 /*  pos      command			normal		shifted */
    298     KC(0x36),				KS_q,
    299     KC(0x37),				KS_w,
    300     KC(0x38),				KS_f,
    301     KC(0x39),				KS_p,
    302     KC(0x3a),				KS_g,
    303     KC(0x3b),				KS_j,
    304     KC(0x3c),				KS_l,
    305     KC(0x3d),				KS_u,
    306     KC(0x3e),				KS_y,
    307     KC(0x3f),				KS_semicolon,	KS_colon,
    308     KC(0x4d), KS_Cmd_Debugger,		KS_a,
    309     KC(0x4e),				KS_r,
    310     KC(0x4f),				KS_s,
    311     KC(0x50),				KS_t,
    312     KC(0x51),				KS_d,
    313     KC(0x52),				KS_h,
    314     KC(0x53),				KS_n,
    315     KC(0x54),				KS_e,
    316     KC(0x55),				KS_i,
    317     KC(0x56),				KS_o,
    318     KC(0x64),				KS_z,
    319     KC(0x65),				KS_x,
    320     KC(0x66),				KS_c,
    321     KC(0x67),				KS_v,
    322     KC(0x68),				KS_b,
    323     KC(0x69),				KS_k,
    324     KC(0x6a),				KS_m,
    325     KC(0x77),				KS_Delete,
    326 };
    327 
    328 #define KBD_MAP(name, base, map) \
    329 			{ name, base, sizeof(map)/sizeof(keysym_t), map }
    330 /* KBD_NULLMAP generates a entry for machine native variant.
    331    the entry will be modified by machine dependent keyboard driver. */
    332 #define KBD_NULLMAP(name, base) { name, base, 0, 0 }
    333 
    334 const struct wscons_keydesc wssun_keydesctab[] = {
    335 	KBD_MAP(KB_US,			0,	wssun_keydesctab_us),
    336 	KBD_MAP(KB_SV,			KB_US,	wssun_keydesctab_sv),
    337 	KBD_MAP(KB_SV | KB_NODEAD,	KB_SV,	wssun_keydesctab_sv_nodead),
    338 	KBD_MAP(KB_DE,			KB_US,	wssun_keydesctab_de),
    339 	KBD_MAP(KB_DE | KB_NODEAD,	KB_DE,	wssun_keydesctab_de_nodead),
    340 	KBD_MAP(KB_UK,			KB_US,	wssun_keydesctab_uk),
    341 	KBD_MAP(KB_US | KB_DVORAK,	KB_US,	wssun_keydesctab_us_dvorak),
    342 	KBD_MAP(KB_US | KB_COLEMAK,	KB_US,	wssun_keydesctab_us_colemak),
    343 	{ 0, 0, 0, 0 }
    344 };
    345