Using a Sun Type 6 USB keyboard under X.org

Oliver M. Haynold

Sun makes a pretty cool USB keyboard, the Type 6. With a dedicated Compose key and an extra block of function keys, the Type 6 makes a good *nix keyboard. It also has the Control and Caps Lock keys reversed compared to normal keyboards. (I'm not very fond of the keys' spongy feel, though. If I don't get used to it I'll go back to my standard-layout Kensington keyboard which had worked splendidly for seven years and still has a very nice feel to it.) Here's a photo of a non-USB version of this keyboard.

Unfortunately, X.org's support for this keyboard out of the box isn't all that great, though with the introduction of xkb it has become pretty easy to make the necessary changes. Here they are:

xkb/keycodes/sun

This is the most important change. My version of X.org (6.8.2-10) from the Hoary distribution had a Type 6 definition in this file, but the definitions for the special keys didn't work. This could be either because Sun shipped two or more different variations of the Type 6 keyboard or because someone messed up with these definitions. These here work for my keyboard. (Replace the corresponding lines in the `type6' section.

    <STOP> = 232;
    <AGAI> = 133;
    <PROP> = 134; // The odd empty key at the top also generates this
    <UNDO> = 135;
    <FRNT> = 140;
    <COPY> = 248;
    <OPEN> = 191;
    <PAST> = 192;
    <FIND> = 122;
    <CUT>  = 188;

    <HELP> = 245;

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

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

xkb/geometry/sun

This is a definition of what the physical keyboard looks like:

default xkb_geometry "type6" {

    description= "Sun Type6 keyboard";

    width= 515;
    height= 170;

    shape "EDGE" { cornerRadius= 2, { [ 515, 170 ] } };
    shape.cornerRadius= 1;
    shape "NORM" { { [ 18,18] }, { [2,1], [16,17] } };
    shape "BKSP" { { [ 37,18] }, { [2,1], [35,17] } };
    shape "TABK" { { [ 27,18] }, { [2,1], [25,17] } };
    shape "BKSL" { { [ 27,18] }, { [2,1], [25,17] } };
    shape "RTRN" { { [ 42,18] }, { [2,1], [40,17] } };
    shape "CAPS" { { [ 32,18] }, { [2,1], [30,17] } };
    shape "LFSH" { { [ 42,18] }, { [2,1], [40,17] } };
    shape "RTSH" { { [ 51,18] }, { [2,1], [49,17] } };
    shape "LCTL" { { [ 32,18] }, { [2,1], [30,17] } };
    shape "MODK" { { [ 28,18] }, { [2,1], [26,17] } };
    shape "SPCE" { { [157,18] }, { [2,1], [155,17] } };
    shape "KP0"  { { [ 37,18] }, { [2,1], [35,17] } };
    shape "KPAD" { { [ 18,37] }, { [2,1], [16,36] } };
    shape "HELP" { { [ 37,18] }, { [2,1], [35,17] } };
    shape "LOGO" { { [ 16,16] } };

    outline "Edges" {
        top= 0;
        left= 0;
        shape= "EDGE";
    };

    section.left= 14;
    row.left= 1;
    key.shape= "NORM";
    key.gap=  1;
    section "Function" {
        top= 24;
        row {
            top= 1;
            keys { { <HELP>, "HELP" }, <PROP>,
                   { <FK01>, 19 }, <FK02>, <FK03>, <FK04>,
                   { <FK05>, 11 }, <FK06>, <FK07>, <FK08>,
                   { <FK09>, 11 }, <FK10>, <FK11>, <FK12>,
                   { <PRSC>,  9 }, <SCLK>, <PAUS>,
                   { <MUTE>,  9 }, <VOL->, <VOL+>, <POWR>
            };
        };
    }; // End of "Function" section

    section "Alpha" {
        top= 61;
        row {
            top= 1;
            keys { <STOP>, <AGAI>,
                 { <TLDE>, 9}, <AE01>, <AE02>, <AE03>, <AE04>,
                   <AE05>, <AE06>, <AE07>, <AE08>, <AE09>,
                   <AE10>, <AE11>, <AE12>,
                   <BKSL>, <TLDE> 
            };
        };
        row {
            top= 20;
            keys { <PROP>, <UNDO>, { <TAB>, 9, shape="TABK" },
                   <AD01>, <AD02>, <AD03>, <AD04>, <AD05>, 
                   <AD06>, <AD07>, <AD08>, <AD09>, <AD10>, 
                   <AD11>, <AD12>,
                 { <BKSP>}
            };
        };
        row {
            top= 39;
            keys { <FRNT>, <COPY>, { <CAPS>, 9, shape="CAPS" },
                   <AC01>, <AC02>, <AC03>, <AC04>, <AC05>, 
                   <AC06>, <AC07>, <AC08>, <AC09>, <AC10>, 
                   <AC11>,
                 { <RTRN>, "RTRN" }
            };
        };
        row {
            top= 58;
            keys { <OPEN>, <PAST>, { <LFSH>, 9 , shape="LFSH" }, 
                   <AB01>, <AB02>, <AB03>, <AB04>, <AB05>, 
                   <AB06>, <AB07>, <AB08>, <AB09>, <AB10>, 
                 { <RTSH>, "RTSH", color="grey20" }
            };
        };
        row {
            top= 77;
            keys { <FIND>, <CUT>, { <LCTL>, 9, shape="LCTL" },
                   <LALT>, <LMTA>,
                 { <SPCE>, "SPCE" },
                   <RMTA>, <COMP>, <ALGR>
            };
        };
    }; // End of "Alpha" section

    section "Editing" {
        top= 61;
        left= 352;
        row {
            top= 1;
            keys { <INS>, <HOME>, <PGUP> };
        };
        row {
            top= 20;
            keys { <DELE>, <END>, <PGDN> };
        };
        row {
            top= 58;
            left= 20;
            keys { <UP> };
        };
        row {
            top= 77;
            keys { <LEFT>, <DOWN>, <RGHT> };
        };
    }; // End of "Editing" section

    section "Keypad" {
        top= 61;
        left= 420;
        row {
            top= 1;
            keys { <NMLK>, <KPDV>, <KPMU>, <KPSU> };
        };
        row {
            top= 20;
            keys { <KP7>, <KP8>, <KP9>, { <KPAD>, "KPAD", color= "grey20" } };
        };
        row {
            top= 39;
            keys { <KP4>, <KP5>, <KP6> };
        };
        row {
            top= 58;
            keys { <KP1>, <KP2>, <KP3>, { <KPEN>, "KPAD", color= "grey20" } };
        };
        row {
            top= 77;
            keys { { <KP0>, "KP0" }, <KPDL> };
        };
    }; // End of "Keypad" section
};

xkb/keymap/sun

We add a keymap entry for this keyboard:

xkb_keymap "type_6"
{
    xkb_keycodes        { include "sun(type6)"          };
    xkb_types           { include "types/complete"              };
    xkb_compatibility   { include "compat/complete"             };
    xkb_symbols         { include "sun/us(sun6)"        };
    xkb_geometry        { include "sun(type6)"  };
};

xkb/rules/sun.xml

This is a definition of the keyboard's capabilities for programs like the GNOME keyboard manager.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xkbConfigRegistry SYSTEM "xkb.dtd">
<xkbConfigRegistry>
  <modelList>
    <model>
      <configItem>
        <name>type4</name>
        <description>Sun Type4</description>
      </configItem>
    </model>
    <model>
      <configItem>
        <name>type5</name>
        <description>Sun Type5</description>
      </configItem>
    </model>
    <model>
      <configItem>
        <name>type5_euro</name>
        <description>Sun Type5 European</description>
      </configItem>
    </model>
    <model>
      <configItem>
        <name>type5_unix</name>
        <description>Sun Type5 Unix</description>
      </configItem>
    </model>
    <model>
      <configItem>
        <name>type6</name>
        <description>Sun Type6</description>
      </configItem>
    </model>
    <model>
      <configItem>
        <name>type6_euro</name>
        <description>Sun Type6 European</description>
      </configItem>
    </model>
</modelList>

<layoutList>
    <layout>
      <configItem>
        <name>us</name>
        <shortDescription>USA</shortDescription>
        <description>U.S. English</description>
      </configItem>
      <variantList>
      </variantList>
    </layout>
</layoutList>

<optionList>
    <group allowMultipleSelection="true">
      <configItem>
        <name>grp</name>
        <description>Group Shift/Lock behavior</description>
      </configItem>
      <option>
        <configItem>
          <name>grp:switch</name>
          <description>Right Alt switches group while pressed</description>
        </configItem>
      </option>
      <option>
        <configItem>
          <name>grp:toggle</name>
          <description>Right Alt key changes group</description>
        </configItem>
      </option>
      <option>
        <configItem>
          <name>grp:caps_toggle</name>
          <description>Caps Lock key changes group</description>
        </configItem>
      </option>
      <option>
        <configItem>
          <name>grp:ctrl_shift_toggle</name>
          <description>Control+Shift changes group</description>
        </configItem>
      </option>
      <option>
        <configItem>
          <name>grp:shift_toggle</name>
          <description>Shift changes group</description>
        </configItem>
      </option>
      <option>
        <configItem>
          <name>grp:ctrl_alt_toggle</name>
          <description>Alt+Control changes group</description>
        </configItem>
      </option>
    </group>
    <group allowMultipleSelection="false">
      <configItem>
        <name>ctrl</name>
        <description>Control Key Position</description>
      </configItem>
      <option>
        <configItem>
          <name>ctrl:nocaps</name>
          <description>Make CapsLock an additional Control</description>
        </configItem>
      </option>
      <option>
        <configItem>
          <name>ctrl:swapcaps</name>
          <description>Swap Control and Caps Lock</description>
        </configItem>
      </option>
      <option>
        <configItem>
          <name>ctrl:ctrl_ac</name>
          <description>Control key at left of 'A'</description>
        </configItem>
      </option>
      <option>
        <configItem>
          <name>ctrl:ctrl_aa</name>
          <description>Control key at bottom left</description>
        </configItem>
      </option>
    </group>
    <group allowMultipleSelection="false">
      <configItem>
        <name>lock</name>
        <description>CapsLock key behavior</description>
      </configItem>
      <option>
        <configItem>
          <name>lock:shift</name>
          <description>Key is Shift lock.</description>
        </configItem>
      </option>
      <option>
        <configItem>
          <name>lock:caps</name>
          <description>Key is capitals lock.</description>
        </configItem>
      </option>
      <option>
        <configItem>
          <name>lock:group</name>
          <description>Key is group lock.</description>
        </configItem>
      </option>
    </group>
  </optionList>
</xkbConfigRegistry>

This information is in the public domain but comes WITHOUT ANY WARRANTIES WHATSOEVER.