//
//Copyright 1996, 1998  The Open Group
//
//Permission to use, copy, modify, distribute, and sell this software and its
//documentation for any purpose is hereby granted without fee, provided that
//the above copyright notice appear in all copies and that both that
//copyright notice and this permission notice appear in supporting
//documentation.
//
//The above copyright notice and this permission notice shall be
//included in all copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
//EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
//MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
//IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
//OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
//ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
//OTHER DEALINGS IN THE SOFTWARE.
//
//Except as contained in this notice, the name of The Open Group shall
//not be used in advertising or otherwise to promote the sale, use or
//other dealings in this Software without prior written authorization
//from The Open Group.
//
// ---------------------------------------------------------------------------
// Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice (including the next
// paragraph) shall be included in all copies or substantial portions of the
// Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// ---------------------------------------------------------------------------
//

default xkb_keycodes "type4" {

    minimum= 8;
    maximum= 255;

    <ESC>  = 36;
    <AE01> = 37;
    <AE02> = 38;
    <AE03> = 39;
    <AE04> = 40;
    <AE05> = 41;
    <AE06> = 42;
    <AE07> = 43;
    <AE08> = 44;
    <AE09> = 45;
    <AE10> = 46;
    <AE11> = 47;
    <AE12> = 48;
    <TLDE> = 49;
    <BKSP> = 50;

    <TAB>  = 60;
    <AD01> = 61;
    <AD02> = 62;
    <AD03> = 63;
    <AD04> = 64;
    <AD05> = 65;
    <AD06> = 66;
    <AD07> = 67;
    <AD08> = 68;
    <AD09> = 69;
    <AD10> = 70;
    <AD11> = 71;
    <AD12> = 72;
    <DELE> = 73;

    <LCTL> = 83;
    <AC01> = 84;
    <AC02> = 85;
    <AC03> = 86;
    <AC04> = 87;
    <AC05> = 88;
    <AC06> = 89;
    <AC07> = 90;
    <AC08> = 91;
    <AC09> = 92;
    <AC10> = 93;
    <AC11> = 94;
    <BKSL> = 95;
    <RTRN> = 96;

    <LFSH> = 106;
    <AB01> = 107;
    <AB02> = 108;
    <AB03> = 109;
    <AB04> = 110;
    <AB05> = 111;
    <AB06> = 112;
    <AB07> = 113;
    <AB08> = 114;
    <AB09> = 115;
    <AB10> = 116;
    <RTSH> = 117;
    <LNFD> = 118;

    <HELP> = 125;
    <CAPS> = 126;
    <LALT> = 26;
    <LMTA> = 127;
    <SPCE> = 128;
    <RMTA> = 129;
    <COMP> = 74;
    <ALGR> = 20;
    alias <RALT> = <ALGR>;

    <FK01> = 12;
    <FK02> = 13;
    <FK03> = 15;
    <FK04> = 17;
    <FK05> = 19;
    <FK06> = 21;
    <FK07> = 23;
    <FK08> = 24;
    <FK09> = 25;
    <FK10> = 14;
    <FK11> = 16;
    <FK12> = 18;

    <STOP> = 8;
    <AGAI> = 10;
    <PROP> = 32;
    <UNDO> = 33;
    <FRNT> = 56;
    <COPY> = 58;
    <OPEN> = 79;
    <PAST> = 80;
    <FIND> = 102;
    <CUT>  = 104;

    <PRSC> = 29;
    <SCLK> = 30;
    <PAUS> = 28;

    <NMLK> = 105;
    <KPEQ> = 52;
    <KPDV> = 53;
    <KPMU> = 54;
    <KPSU> = 78;

    <KP7>  = 75;
    <KP8>  = 76;
    <KP9>  = 77;
    <KPAD> = 132;

    <KP4>  = 98;
    <KP5>  = 99;
    <KP6>  = 100;

    <KP1>  = 119;
    <KP2>  = 120;
    <KP3>  = 121;
    <KPEN> = 97;

    <KP0>  = 101;
    <KPDL> = 57;
    indicator 4 = "Caps Lock";
    indicator 3 = "Compose";
    indicator 2 = "Scroll Lock";
    indicator 1 = "Num Lock";
};

xkb_keycodes "type5" {

    minimum= 8;
    maximum= 255;

    <ESC>  = 36;
    <AE01> = 37;
    <AE02> = 38;
    <AE03> = 39;
    <AE04> = 40;
    <AE05> = 41;
    <AE06> = 42;
    <AE07> = 43;
    <AE08> = 44;
    <AE09> = 45;
    <AE10> = 46;
    <AE11> = 47;
    <AE12> = 48;
    <TLDE> = 49;
    <BKSP> = 50;

    <TAB>  = 60;
    <AD01> = 61;
    <AD02> = 62;
    <AD03> = 63;
    <AD04> = 64;
    <AD05> = 65;
    <AD06> = 66;
    <AD07> = 67;
    <AD08> = 68;
    <AD09> = 69;
    <AD10> = 70;
    <AD11> = 71;
    <AD12> = 72;
    <DELE> = 73;
    <COMP> = 74;
    <ALGR> = 20;
    alias <RALT> = <ALGR>;

    <LCTL> = 83;
    <AC01> = 84;
    <AC02> = 85;
    <AC03> = 86;
    <AC04> = 87;
    <AC05> = 88;
    <AC06> = 89;
    <AC07> = 90;
    <AC08> = 91;
    <AC09> = 92;
    <AC10> = 93;
    <AC11> = 94;
    <BKSL> = 95;
    <RTRN> = 96;

    <LFSH> = 106;
    <AB01> = 107;
    <AB02> = 108;
    <AB03> = 109;
    <AB04> = 110;
    <AB05> = 111;
    <AB06> = 112;
    <AB07> = 113;
    <AB08> = 114;
    <AB09> = 115;
    <AB10> = 116;
    <RTSH> = 117;

    <LALT> = 26;
    <CAPS> = 126;
    <LMTA> = 127;
    <SPCE> = 128;
    <RMTA> = 129;

    <FK01> = 12;
    <FK02> = 13;
    <FK03> = 15;
    <FK04> = 17;
    <FK05> = 19;
    <FK06> = 21;
    <FK07> = 23;
    <FK08> = 24;
    <FK09> = 25;
    <FK10> = 14;
    <FK11> = 16;
    <FK12> = 18;
    <STOP> = 8;
    <AGAI> = 10;
    <PROP> = 32;
    <UNDO> = 33;
    <FRNT> = 56;
    <COPY> = 58;
    <OPEN> = 79;
    <PAST> = 80;
    <FIND> = 102;
    <CUT>  = 104;

    <PRSC> = 29;
    <SCLK> = 30;
    <PAUS> = 28;

    <NMLK> = 105;
    <KPDV> = 53;
    <KPMU> = 54;
    <KPSU> = 78;

    <KP7>  = 75;
    <KP8>  = 76;
    <KP9>  = 77;
    <KPAD> = 132;

    <KP4>  = 98;
    <KP5>  = 99;
    <KP6>  = 100;

    <KP1>  = 119;
    <KP2>  = 120;
    <KP3>  = 121;
    <KPEN> = 97;

    <KP0>  = 101;
    <KPDL> = 57;

    <UP>   = 27;
    <LEFT> = 31;
    <DOWN> = 34;
    <RGHT> = 35;

    <INS>  = 51;
    <HOME> = 59;
    <END>  = 81;
    <PGUP> = 103;
    <PGDN> = 130;
    <HELP> = 125;

    <MUTE> = 52;
    <VOL-> = 9;
    <VOL+> = 11;
    <POWR> = 55;
    indicator 4 = "Caps Lock";
    indicator 3 = "Compose";
    indicator 2 = "Scroll Lock";
    indicator 1 = "Num Lock";
};

xkb_keycodes "type4tuv" {
    include "sun(type4)"
    <LSGT> = 131;
    <BRCR> = 22;
};

xkb_keycodes "type4_ca" {
    include "sun(type4)"
    <LSGT> = 131;
};

xkb_keycodes "type4_jp" {
    include "sun(type4)"
    <EXEC> = 122;
    <KANJ> = 123;
    <HENK> = 124;
    <BRCR> = 22;
    alias <UNDR> = <LNFD>;
};

xkb_keycodes "type4_euro" {
    include "sun(type4)"
    <LSGT> = 131;
};

xkb_keycodes "type5tuv" {
    include "sun(type5)"
    <LSGT> = 131;
};

xkb_keycodes "type5_jp" {
    include "sun(type5)"
    <EXEC> = 122;
    <KANJ> = 123;
    <HENK> = 124;
    <UNDR> = 118;
};

xkb_keycodes "type5_euro" {
    include "sun(type5)"
    <LSGT> = 131;
};

xkb_keycodes "type5hobo" {

    minimum= 8;
    maximum= 255;

    <ESC>  = 36;
    <AE01> = 37;
    <AE02> = 38;
    <AE03> = 39;
    <AE04> = 40;
    <AE05> = 41;
    <AE06> = 42;
    <AE07> = 43;
    <AE08> = 44;
    <AE09> = 45;
    <AE10> = 46;
    <AE11> = 47;
    <AE12> = 48;
    <TLDE> = 49;
    <BKSP> = 50;

    <TAB>  = 60;
    <AD01> = 61;
    <AD02> = 62;
    <AD03> = 63;
    <AD04> = 64;
    <AD05> = 65;
    <AD06> = 66;
    <AD07> = 67;
    <AD08> = 68;
    <AD09> = 69;
    <AD10> = 70;
    <AD11> = 71;
    <AD12> = 72;
    <DELE> = 73;
    <COMP> = 74;
    <ALGR> = 20;
    alias <RALT> = <ALGR>;

    <LCTL> = 83;
    <AC01> = 84;
    <AC02> = 85;
    <AC03> = 86;
    <AC04> = 87;
    <AC05> = 88;
    <AC06> = 89;
    <AC07> = 90;
    <AC08> = 91;
    <AC09> = 92;
    <AC10> = 93;
    <AC11> = 94;
    <BKSL> = 95;
    <RTRN> = 96;

    <LFSH> = 106;
    <AB01> = 107;
    <AB02> = 108;
    <AB03> = 109;
    <AB04> = 110;
    <AB05> = 111;
    <AB06> = 112;
    <AB07> = 113;
    <AB08> = 114;
    <AB09> = 115;
    <AB10> = 116;
    <RTSH> = 117;

    <LALT> = 26;
    <CAPS> = 126;
    <LMTA> = 127;
    <SPCE> = 128;
    <RMTA> = 129;

    <FK01> = 12;
    <FK02> = 13;
    <FK03> = 15;
    <FK04> = 17;
    <FK05> = 19;
    <FK06> = 21;
    <FK07> = 23;
    <FK08> = 24;
    <FK09> = 25;
    <FK10> = 14;
    <FK11> = 16;
    <FK12> = 18;
    <STOP> = 8;
    <AGAI> = 10;
    <PROP> = 32;
    <UNDO> = 33;
    <FRNT> = 56;
    <COPY> = 58;
    <OPEN> = 79;
    <PAST> = 80;
    <FIND> = 102;
    <CUT>  = 104;

    <PRSC> = 29;
    <SCLK> = 30;
    <PAUS> = 28;

    <NMLK> = 105;
//     <KPDV> = 53;
//     <KPMU> = 54;
//     <KPSU> = 78;

//     <KP7>  = 75;
//     <KP8>  = 76;
//     <KP9>  = 77;
//     <KPAD> = 132;

//     <KP4>  = 98;
//     <KP5>  = 99;
//     <KP6>  = 100;

//     <KP1>  = 119;
//     <KP2>  = 120;
//     <KP3>  = 121;
//     <KPEN> = 97;

//     <KP0>  = 101;
//     <KPDL> = 57;

    <UP>   = 27;
    <LEFT> = 31;
    <DOWN> = 34;
    <RGHT> = 35;

    <INS>  = 51;
    <HOME> = 59;
    <END>  = 81;
    <PGUP> = 103;
    <PGDN> = 130;
    <HELP> = 125;

    <MUTE> = 52;
    <VOL-> = 9;
    <VOL+> = 11;
    <POWR> = 55;
    indicator 4 = "Caps Lock";
    indicator 3 = "Compose";
    indicator 2 = "Scroll Lock";
    indicator 1 = "Num Lock";
};

xkb_keycodes "type5tuvhobo" {
    include "sun(type5hobo)"
    <LSGT> = 131;

};

xkb_keycodes "type5_jphobo" {
    include "sun(type5hobo)"
    <EXEC> = 122;
    <KANJ> = 123;
    <HENK> = 124;
    <UNDR> = 118;
};

xkb_keycodes "type6" {
    include "sun(type5)"
};

xkb_keycodes "type6tuv" {
    include "sun(type5tuv)"
};

xkb_keycodes "type6unix" {
    include "sun(type5)"
};

xkb_keycodes "type6_jp" {
    include "sun(type5_jp)"
};

xkb_keycodes "type6_euro" {
    include "sun(type5_euro)"
};

// Even though this is labeled as _usb, I verified these keycodes as accurate
// on my type5 serial and type6 serial keyboards as well on linux-2.6 boxes.
// I'm not sure where the "type5" keycodes above are coming from...
xkb_keycodes "type6_usb" {
    include "xfree86"

    <STOP> = 232;
    <AGAI> = 133;
    <PROP> = 134;
    <UNDO> = 135;
    <FRNT> = 140;
    <COPY> = 248;
    <OPEN> = 191;
    <PAST> = 192;
    <FIND> = 122;
    <CUT>  = 188;

    <HELP> = 245;

    // The blank has keycode 239 on my type6 serial kb, but 134 on
    // my type6 usb keyboard (same as <PROP>)
    <BLNK> = 239;

    // AltGr + PrScr actually sends a different keycode
    <SYRQ> = 92;

    <MUTE> = 160;
    <VOL-> = 174;
    <VOL+> = 176;
    <POWR> = 222;

    indicator 4 = "Compose";
};

xkb_keycodes "type6tuv_usb" {
    include "sun(type6_usb)"
    <LSGT> = 94;
//    <BKSL> = 51;
};

xkb_keycodes "type6_jp_usb" {
    include "sun(type6_usb)"
    alias <UNDR> = <KPDC>;  // 123
    alias <EXEC> = <I0B>;   // 139 
    alias <KANJ> = <I0A>;   // 138
    alias <HENK> = <XFER>;  // 129
    indicator 5 = "Kana";
};

xkb_keycodes "type5_se" {

    minimum= 8;
    maximum= 255;

    // Row G
    <HELP> = 125;
    //
    <ESC>  = 36;
    //
    <FK01> = 12;
    <FK02> = 13;
    <FK03> = 15;
    <FK04> = 17;
    //
    <FK05> = 19;
    <FK06> = 21;
    <FK07> = 23;
    <FK08> = 24;
    //
    <FK09> = 25;
    <FK10> = 14;
    <FK11> = 16;
    <FK12> = 18;
    //
    <PRSC> = 29;
    <SCLK> = 30;
    <PAUS> = 28;
    //
    <MUTE> = 52;
    <VOL-> = 9;
    <VOL+> = 11;
    <POWR> = 55;
    // End Row G

    // Row F
    //
    // End Row F

    // Row E
    <STOP> = 8;
    <AGAI> = 10;
    //
    <AE00> = 49;
    alias <TLDE> = <AE00>;
    <AE01> = 37;
    <AE02> = 38;
    <AE03> = 39;
    <AE04> = 40;
    <AE05> = 41;
    <AE06> = 42;
    <AE07> = 43;
    <AE08> = 44;
    <AE09> = 45;
    <AE10> = 46;
    <AE11> = 47;
    <AE12> = 48;
    <BKSP> = 50;
    //
    <INS>  = 51;
    <HOME> = 59;
    <PGUP> = 103;
    //
    <NMLK> = 105;
    <KPDV> = 53;
    <KPMU> = 54;
    <KPSU> = 78;
    //End Row E

    // Row D
    <PROP> = 32;
    <UNDO> = 33;
    //
    <AD00> = 60;
    alias <TAB> = <AD00>;
    <AD01> = 61;
    <AD02> = 62;
    <AD03> = 63;
    <AD04> = 64;
    <AD05> = 65;
    <AD06> = 66;
    <AD07> = 67;
    <AD08> = 68;
    <AD09> = 69;
    <AD10> = 70;
    <AD11> = 71;
    <AD12> = 72;
    //
    <DELE> = 73;
    <END>  = 81;
    <PGDN> = 130;
    //
    <KP7>  = 75;
    <KP8>  = 76;
    <KP9>  = 77;
    <KPAD> = 132;
    // End Row D

    // Row C
    <FRNT> = 56;
    <COPY> = 58;
    //
    <AC00> = 126;
    alias <CAPS> = <AC00>;
    <AC01> = 84;
    <AC02> = 85;
    <AC03> = 86;
    <AC04> = 87;
    <AC05> = 88;
    <AC06> = 89;
    <AC07> = 90;
    <AC08> = 91;
    <AC09> = 92;
    <AC10> = 93;
    <AC11> = 94;
    <AC12> = 95;
    alias <BKSL> = <AC12>;
    <RTRN> = 96;
    //
    <KP4>  = 98;
    <KP5>  = 99;
    <KP6>  = 100;
    // End Row C

    // Row B
    <OPEN> = 79;
    <PAST> = 80;
    //
    <LFSH> = 106;
    <AB00> = 131;
    alias <LSGT> = <AB00>;
    <AB01> = 107;
    <AB02> = 108;
    <AB03> = 109;
    <AB04> = 110;
    <AB05> = 111;
    <AB06> = 112;
    <AB07> = 113;
    <AB08> = 114;
    <AB09> = 115;
    <AB10> = 116;
    <RTSH> = 117;
    //
    <UP>   = 27;
    //
    <KP1>  = 119;
    <KP2>  = 120;
    <KP3>  = 121;
    <KPEN> = 97;
    // End Row B

    // Row A
    <FIND> = 102;
    <CUT>  = 104;
    //
    <LCTL> = 83;
    <LALT> = 26;
    <LMTA> = 127;
    <SPCE> = 128;
    <RMTA> = 129;
    <COMP> = 74;
    <ALGR> = 20;
    alias <RALT> = <ALGR>;
    //
    <LEFT> = 31;
    <DOWN> = 34;
    <RGHT> = 35;
    //
    <KP0>  = 101;
    <KPDL> = 57;
    // End Row A

    indicator 4 = "Caps Lock";
    indicator 3 = "Compose";
    indicator 2 = "Scroll Lock";
    indicator 1 = "Num Lock";
};

xkb_keycodes "type5c_se" {
    include "sun(type5_se)"
};

xkb_keycodes "type4__se" {

    minimum= 8;
    maximum= 255;

    // Row F
    <STOP> = 8;
    <AGAI> = 10;
    //
    <FK01> = 12;
    <FK02> = 13;
    <FK03> = 15;
    <FK04> = 17;
    <FK05> = 19;
    <FK06> = 21;
    <FK07> = 23;
    <FK08> = 24;
    <FK09> = 25;
    <FK10> = 14;
    <FK11> = 16;
    <FK12> = 18;
    <AF13> = 95;
    alias <TLDE> = <AF13>;
    <AF14> = 22;
    <DELE> = 73;
    //
    <PAUS> = 28;
    <PRSC> = 29;
    <SCLK> = 30;
    <NMLK> = 105;
    // End Row F

    // Row E
    <PROP> = 32;
    <UNDO> = 33;
    //
    <AE00> = 36;
    alias <ESC> = <AE00>;
    <AE01> = 37;
    <AE02> = 38;
    <AE03> = 39;
    <AE04> = 40;
    <AE05> = 41;
    <AE06> = 42;
    <AE07> = 43;
    <AE08> = 44;
    <AE09> = 45;
    <AE10> = 46;
    <AE11> = 47;
    <AE12> = 48;
    <BKSP> = 50;
    //
    <KPEQ> = 52;
    <KPDV> = 53;
    <KPMU> = 54;
    <KPSU> = 78;
    // End Row E

    // Row D
    <FRNT> = 56;
    <COPY> = 58;
    //
    <AD00> = 60;
    alias <TAB> = <AD00>;
    <AD01> = 61;
    <AD02> = 62;
    <AD03> = 63;
    <AD04> = 64;
    <AD05> = 65;
    <AD06> = 66;
    <AD07> = 67;
    <AD08> = 68;
    <AD09> = 69;
    <AD10> = 70;
    <AD11> = 71;
    <AD12> = 72;
    //
    <KP7>  = 75;
    <KP8>  = 76;
    <KP9>  = 77;
    <KPAD> = 132;
    // End Row D

    // Row C
    <OPEN> = 79;
    <PAST> = 80;
    //
    <AC00> = 83;
    //    alias <CAPS> = <AC00>;
    <AC01> = 84;
    <AC02> = 85;
    <AC03> = 86;
    <AC04> = 87;
    <AC05> = 88;
    <AC06> = 89;
    <AC07> = 90;
    <AC08> = 91;
    <AC09> = 92;
    <AC10> = 93;
    <AC11> = 94;
    <AC12> = 49;
    alias <BKSL> = <AC12>;
    <RTRN> = 96;
    //
    <KP4>  = 98;
    <KP5>  = 99;
    <KP6>  = 100;
    // End Row C

    // Row B
    <FIND> = 102;
    <CUT>  = 104;
    //
    <LFSH> = 106;
    <AB00> = 131;
    alias <LSGT> = <AB00>;
    <AB01> = 107;
    <AB02> = 108;
    <AB03> = 109;
    <AB04> = 110;
    <AB05> = 111;
    <AB06> = 112;
    <AB07> = 113;
    <AB08> = 114;
    <AB09> = 115;
    <AB10> = 116;
    <RTSH> = 117;
    <LNFD> = 118;
    //
    <KP1>  = 119;
    <KP2>  = 120;
    <KP3>  = 121;
    <KPEN> = 97;
    // End Row B

    // Row A
    <HELP> = 125;
    //
    <AA00> = 126;
    //    alias <LCTL> = <AA00>;
    <LALT> = 26;
    <LMTA> = 127;
    <SPCE> = 128;
    <RMTA> = 129;
    <COMP> = 74;
    <ALGR> = 20;
    alias <RALT> = <ALGR>;
    //
    <KP0>  = 101;
    <KPDL> = 57;
    // End Row A

    indicator 4 = "Caps Lock";
    indicator 3 = "Compose";
    indicator 2 = "Scroll Lock";
    indicator 1 = "Num Lock";
};

xkb_keycodes "type4_se" {

    include "sun(type4__se)"

    alias <LCTL> = <AA00>;
    alias <CAPS> = <AC00>;
};

xkb_keycodes "type4_se_swapctl" {

    include "sun(type4__se)"

    alias <LCTL> = <AC00>;
    alias <CAPS> = <AA00>;
};