Subject:    FYI: How I enabled the extra keys on my MS Natural keyboard
From:       Craig Johnston <Craig.E.Johnston@boeing.com>
Date:       1996/12/06
Message-Id: <32A88D01.41C6@boeing.com>
Newsgroups: comp.sys.sgi.misc, comp.sys.sgi.admin

I know some of you are using a Microsoft Natural keyboard with your
Indy or Indigo2 as I am.  I wanted to make use of the extra "windoze"
keys along the bottom row, but couldn't find any reference as to how to
do it.  So here's how I did it.

The xev utility told me that the scan codes for the 3 keys are 147,148,
and 149 (left to right).  I then copied and patched the US keymap file
(US.xkm) to have a key symbol for those codes (US_msnatural.xkm).  Use
your favorite binary editor to make the change.

% od -x /var/X11/input/US.xkm > USxkm.dmp
% od -x /var/X11/input/US_msnatural.xkm > USxkmnat.dmp
% diff USxkm.dmp USxkmnat.dmp
66a67,70
> 0002040 0000 0000 0000 0000 0000 0000 0000 fed0
> 0002060 0000 0000 0000 fed4 0000 0000 0000 fed2
> 0002100 0000 0000 0000 0000 0000 0000 0000 0000
> *

This adds the keysym value of 0xfed0, 0xfed4, and 0xfed2 for the
keycodes 147, 148, and 149 respectively.  From
/usr/include/X11/keysymdef.h, these values correspond to
XK_First_Virtual_Screen, XK_Last_Virtual_Screen, and
XK_Next_Virtual_Screen.  I chose these more or less arbitrarily.

Now you have to install the new keymap as the default.  As root (the
only way to make the change stick) start the 'keyboards' GUI program.
Select your new keymap file (US_msnatural) and select 'Set System
Default' and 'Apply'.  Don't panic when you see the errors from xmodmap
complaining about the keycode being out of range.  You now have to
restart the xserver (reboot is best) to get it to install the keymap.

The tail end of 'xmodmap -pk' should now look like;

...
    138         
    139         
    140         0xffad (KP_Subtract)    
    141         
    142         
    143         
    144         
    145         
    146         
    147         0xfed0 (First_Virtual_Screen)   
    148         0xfed4 (Last_Virtual_Screen)    
    149         0xfed2 (Next_Virtual_Screen)    
    150         
...

Now you just have to figure out what you want to do with the keys.
I added the following to my .4Dwmrc file,

# SGI added key bindings
  ....
  <key>First_Virtual_Screen root|icon|window      f.switch_desk "Desk 1"
  Shift<key>First_Virtual_Screen root|icon|window f.switch_desk "Desk 2"
  <key>Last_Virtual_Screen root|icon|window       f.switch_desk "Desk 2"
  Shift<key>Last_Virtual_Screen root|icon|window  f.switch_desk "Desk 1"
  <key>Next_Virtual_Screen root|icon|window       f.lower
  Shift<key>Next_Virtual_Screen root|icon|window  f.raise
  ....

Now I can switch desks at the push of a button.  I know I can get the
same effect by binding some other Alt or Ctrl combination, but this is
a little nicer.

As of 6.2 SGI has also included the XKEYBOARD extension stuff that could
have made this a lot easier, but the X server (Xsgi) doesn't appear to
use it.  It builds a X0-defaults.xkm file in the
/usr/lib/X11/xkb/compiled directory, but does not use it.  Also the
format of this and other *.xkm files built by xkbcomp are quite a bit
different from the *.xkm files in /var/X11/input.  Anyone know what is
up here?

Hope this is of use to someone.  Comments and fixes welcome.
