SUMMARY: Sun Type 4/Type 5 keyboards

From: lipscomb@vision1.engr.utk.edu
Date: Mon Apr 18 1994 - 12:16:55 CDT


Hi all,

here is a summary of my original posting re: Sun keyboards:

>do you have anything that can generate the keyboard scan
>codes of a type 4 or type 5 Sun keyboard. Or do you have any
>documentation that has a table listing all the keyboard scan codes?

Here are a few of my replies:

--------
From: James Byrne - Capreq Dev <James.Byrne@fw.gs.com>

The leaflet you get with the keyboards should detail the keycodes for
the type4 or 5 keyboards, ask your friendly Sun supplier to send you a copy,
alternatively, if you are only interested in a few keys, use the xev event
display tool bundled with SunOS. Tyop xev <RETURN> and a window with a
white square will appear. Move the pointer into the window. You will now see
the event information being displayed in the invoking window. When you now press
a key, say 'a', you will get output which looks like:

         
KeyPress event, serial 15, synthetic NO, window 0xa00001,
  root 0x8006d, subw 0x0, time 1200800352, (97,118), root:(218,564),
  state 0x0, keycode 84 (keysym 0x61, a), same_screen YES,
  XLookupString gives 1 characters: "a"

The code you will be interested in is the 'keycode' number in the third line.
The keysim entry is the translation made by the keyboard driver or by the
X server if modified using xmodmap.

--------
From: Don.Rowlands@fw.gs.com (Donovan Rowlands - Sys Admin)

I have a copy of quite a useful X based utility I obtained recently called
xkeycaps. It's generally available and somewhat buggy. If you want it, I
can send a tar'd - compressed - uuencoded copy of the source. The reason I
haven't included it here is so as not to overload your mail system ( You may
get a few copies of it anyway ).

--------
From: Janos Bartok-Nagy <janos@ilab.sztaki.hu>

Hi, as far I know (and it's not too much:-(, there is one quite good
method to get the scancodes. Under the Openwindows environment you
can use the xmakemap command (I don't know whether it is available
under the old SunOS); xmakemap generates a full listing of the keycodes
and the corresponding keysyms used in X. The scancode is 7 less than the
keycode given by xmakemap. Another method is the use of the 'dumpkeys'
command, whidcfh gives you a table with the scancodes and the corresponding
chars. It's a bit less legible, but basically the same. It's up to
you which command to use. If you want to reconfigure the keyboard layout
dinamically, I'd suggest you to use the xmodemap command (it accepts the
output of 'xmakemap' as input) - with it you can change the keyboards
on a per user base. We use the latter method to configure the keyboards
for accepting the accented Hungarian characters as well.

See also: xmakemap, xmodmap (-> .xmodmaprc files), dumpkeys, loadkeys,
keytables manual pages

--------
From: UCWH@ACM.ORG

        Concerning "documentation that has a table listing all the keyboard
scan codes?", below is the output (are the outputs?) from xmodmap -pk and
xmodmap -pke. xmodmap is an X windows command. If you have access to a
machine that runs X, try "man xmodmap" or give the commands a try yourself.

xmodmap -pk:

There are 2 KeySyms per KeyCode; KeyCodes range from 8 to 132.

    KeyCode Keysym (Keysym) ...
    Value Value (Name) ...

      8 0xffc8 (F11)
      9
     10 0xffc9 (F12)
     11
     12 0xffbe (F1)
.
.
.
    128 0x0020 (space)
    129 0xffe8 (Meta_R)
    130
    131
    132 0xffab (KP_Add) 0xffab (KP_Add)

xmodmap -pke:

keycode 8 = F11
keycode 9 =
keycode 10 = F12
keycode 11 =
keycode 12 = F1
.
.
.
keycode 126 = Caps_Lock
keycode 127 = Meta_L
keycode 128 = space
keycode 129 = Meta_R
keycode 130 =
keycode 131 =
keycode 132 = KP_Add KP_Add

        Sincerely,

Pete Johnson

--------
From: mike@trdlnk.chi.il.us (Michael Sullivan)

Look in /usr/share/lib/keytables (at least under SunOS 4.1.x, I don't
know about Solaris 2).

--------
From: everling@iis.fhg.de (Dirk Everling/ktz vdg)

Hi, I'm not a SUN Manager, but to find out about scancodes
try xkeycaps (mine is version 2.07) which should be around
ftp.x.org or else.

--------
From: jv@NL.net (Johan Vromans)

There is a program /usr/openwin/demo/xev. It creates a window and
gives a detailed report of every event happening (e.g. keystrokes).
I have used it to find out all/most of the interesting Type5 keys.

--------
From: lrjackson@sunesc.East.Sun.COM (Lynn Reilly Jackson)

                 Keyboard Frequently Asked Questions
                -------------------------------------

 1. How do I set the Function Key escape sequences in shelltool ?
 2. How do I set the Function Key escape sequences in cmdtool & textedit ?
 3. How do I set the Function Key escape sequences in xterm ?
 4. How do I prevent the F1 Function Key from bringing up Help ?
 5. How do I use the F11 & F12 Function Keys ?
 6. What is a keyboard modifier ?
 7. Why aren't the Meta, Control and NumLock keys used consistantly among X
    applications ?
 8. What is the recommended way to emulate a VT100 keyboard ?
 9. Does the SunView compatibility mode affect X Keyboard settings ?
10. Why don't loadkeys and dumpkeys work in Open Windows ?
11. The 3rd party application can't use the Function Keys after moving from
    the SunView environment to Open Windows. Why ?
12. What are the commands to manipulate the Keyboard in Open Windows ?
13. How do I customize the Keyboard layout for all X applications ?
14. What Keyboard resources can be set in .Xdefaults ?
15. How do I modify the repeat key and delay rate times ?
16. How do I set the Delete Char, Delete Word & Delete Line characters ?
17. How do I get my Xlib application to receive Keyboard input ?
18. Open Windows doesn't start and complains about the Keyboard ?
19. How do I turn on the Keyboard Accelerators ?

                             ------------

 1. How do I set the Function Key escape sequences in shelltool ?

        Open Windows 2.0:
        Open Windows 3.0:
        
        This is done by modifying the .ttyswrc file in your home
        directory. The file allows you to attach text, including escape
        codes to Function Keys. The format of the .ttyswrc file is:
        
                # Starts a comment line.
                mapi [key] [text] Inputs [text] when [key] is pressed
                mapo [key] [text] Outputs [text] when [key] is pressed
        
        The [key] may be F2-F10, R1-R7, R9, R11, R13, R15. There are no
        provisions for shifted and unshifted function keys. The shift state
        is ignored.

        The [text] may contain escape strings such as \E for escape, \n for
        newline, and ^X for Control-X.

        mapi will send the [text] out to the application as if the text
        were sent via the keyboard. This is what you would want to use
        if you wanted to map an escape sequence to a Function Key.

        mapo will send the [text] to the tty as if it were sent out from the
        application. This is useful when you want to set things on the
        tty line such as the cursor position. It is not as common as mapi.

        A sample .ttyswrc file is in $OPENWINHOME/lib/.ttyswrc. It allows
        the shelltool to emulate the keyboard behavior of a SunView shelltool.

        Example
                To map F5 key to send out <ESC>[228z the following line
                would be in .ttysrc

                        mapi F5 \E[228z

        References
                Section 4.6, SunView User's Guide
        

 2. How do I set the Function Key escape sequences in cmdtool & textedit ?

        Open Windows 2.0:
        Open Windows 3.0:

        This is done by modifying the .textswrc file in your home directory.
        The file allows you to attach filters to Function Keys. Filters are
        really just programs that are run, so you can use /usr/5bin/echo to
        send out the escape code. The format of the .textswrc file is:

                [key-name] FILTER
                [command-line]
        
        The [key-name] is a string signifying the area on the keyboard where
        the Function Key resides. It is either KEY_TOP(xx) for the Fxx keys,
        KEY_LEFT(xx) for the Lxx keys, or KEY_RIGHT(xx) for the Rxx keys.

        The F2-F10, R1-R7, R9, R11, R13, R15 may be used in the .textswrc
        file. There are no provisions for shifted and unshifted function keys.
        The shift state is ignored.

        The [command-line] is the command you would type to send out
        the escape code. /usr/5bin/echo would be good for this purpose.

        A sample .textswrc file is located in /usr/lib/textswrc.

        Example
                To map the F5 key to send out <ESC>[228z, you would put
                the following two lines in .textswrc

                        KEY_TOP(5) FILTER
                        /usr/5bin/echo "\033[228z\c"

        References
                Section 4.6, SunView User's Guide
                man echo

        
 3. How do I set the Function Key escape sequences in xterm ?
        
        Open Windows 2.0:
        Open Windows 3.0:

        This is done by adding some lines to the .Xdefaults file in
        your home directory. The lines should have the following format:
        
                XTerm*VT100.Translations: #override \
                [ShiftStates]<key>[KeySym]: string([text]) \n\
                ...
                [ShiftStates]<key>[KeySym]: string([text])

        The [ShiftStates] are the states of key keyboard modifiers that
        need to be in effect when they key is pressed. The values can be
        any combination of Shift, Ctrl, Meta, mod1, mod2, mod3, mod4 & mod5.
        Placing a tilde (~) in front of a modifier specifies that the modifier
        is Up or Not Pressed rather than Down or Pressed. Being able to
        specifies shift states allows the Shifted and Unshifted keys to
        be unique.

        The [KeySym] is the symbol that the key generates when it is pressed.
        This value can be retrieved by running $OPENWINHOME/demo/xev, moving
        the pointer into the window that xev creates, and pressing the desired
        keys. This will generate text in the window you started xev from. If
        you look at the text that is displayed, you will see in the some text
        like (keysym nnnn, kkkk). It is the kkkk field that is the [KeySym].
        
        The [text] field is the string that you actually want to be sent.
        it had been typed. Quotation is necessary if the string contains
        whitespace or non-alphanumeric characters. If the string argument
        begins with the characters ``0x'', it is interpreted as a hex
        character constant.

        Note that every line except the first and the last lines must have
        the "\n\" string appended to it. The first line needs only a "\", and
        the last line should have nothing.

        Example
                To map the F5 key to send out <ESC>[228z, you would put
                the following two lines in .XDefaults

        
                XTerm*VT100.Translations: #override \
                <key>F5: string(0x1b); string("[228z")

        References
                man xterm

 4. How do I prevent the F1 Function Key from bringing up Help ?
        
        OpenWindow 2.0:

        This is done by modifying the .xinitrc file in your home directory.

        If you have no .xinitrc in your home directory, then you first
        need to copy the default one from $OPENWINHOME/lib/Xinitrc to
        $HOME/.xinitrc
        
        Edit the .xinitrc file and look for a line that reads
        
                xmodmap -e 'keysym F1 = Help'

        and add a pound sign (#) at the beginning of the line so it reads

                #xmodmap -e 'keysym F1 = Help'

        Save the file, then exit and restart Open Windows. The F1 key should
        no longer bring up help.

 5. How do I use the F11 & F12 Function Keys ?
        
        Open Windows 2.0:
        Open Windows 3.0:
        
        The F11 and F12 keys are mapped to keysyms SunXK_F36 and SunXK_F37
        respectively, which are Sun defined keysyms.

        This was done for a couple of reasons. First, Standard MIT X11 only
        defines 35 Function Key keysyms. Since Sun's Type-4 keyboard contains
        37 Function Keys, it was necessary for Sun to define 2 keysyms.

        The reason F11 and F12 were selected to use the new keysyms is
        for compatibility with Sun's older Type-3 keyboards which have
        Function Keys F1-F10, L1-L10 and R1-R15. The L keys were defined
        as F11-F20 and the R keys were defined as F21-F35. Modifying this
        layout for Type-4 keyboards would have meant conditional programming
        for Type-3 and Type-4 keyboards.

 6. What is a keyboard modifier ?
        Shift/CapsLock and AltGraph (Mode_switch) are the two modifiers
        supported by Xlib. Client applications are in charge of the other
        modifiers.

        Suppose you type xmodmap -e 'keysym q = a b c d'
        q will give a
        shift+q b
        AltGraph+q c
        Shift+Alt+Graph+q d

        OR type xmodmap -e 'keycode 16 = 0x0c9 b c d'
        F11 will give E acute
        Shift+F11 b
        AltGraph+F11 c
        Shift+AltGraph+F11 d

 7. Why aren't the Meta, Control and NumLock keys used consistantly among X
    applications ?
        It the responsibility of the client or toolkits
        to to handle these modifiers.
        Xlib knows nothing about these modifiers and simply passes on the
        keysym along with the modifier map. A Xlib application that uses
        XLookupString directly must handle these modifiers itself. This may
        be done by looking at the modifier map.
                

 8. What is the recommended way to emulate a VT100 keyboard ?
        
        xterm emulates vt100 terminal emulation. Here are couple of
        methods which make the keypad behave like a vt100 keypad.

There are two methods:
        1) Modifying xterm* stuff in .Xdefaults
        2) Using xmodmap

Method 1:

Add the following to your .Xdefaults. When you press the "L1" key the keypad
will emulate a vt100 keypad. When you press "L1" again, it will go back to it
orginal settings. I hope this helps.

xterm*sunFunctionKeys: true
xterm*VT100.Translations: \
#override <Key>L1: keymap(VT100)
!
!! Define keymapping for VT100
!!
!! SUN Key VT100 Key
!! R1 PF1
!! R2 PF2
!! R3 PF3
!! F7 PF4
!! R13 KP0
!! R10(Left) KP1
!! R11 KP2
!! R12(Right) KP3
!! R7 KP4
!! R8(Up) KP5
!! R9 KP6
!! R4 KP7
!! R5 KP8
!! R6 KP9
!! R15 ENTER
!! F8 KP -
!! F9 KP ,
!! R14(Down) KP .
!! F3 Up Arrow
!! F4 Down Arrow
!! F5 Left Arrow
!! F6 Right Arrow
!
xterm*VT100.VT100Keymap.translations: \
<Key>L1: keymap(None) \n\
<Key>R1: string("0x01b") string("OP") \n\
<Key>R2: string("0x01b") string("OQ") \n\
<Key>R3: string("0x01b") string("OR") \n\
<Key>F7: string("0x01b") string("OS") \n\
<Key>R13: string("0x01b") string("Op") \n\
<Key>Left: string("0x01b") string("Oq") \n\
<Key>R11: string("0x01b") string("Or") \n\
<Key>Right: string("0x01b") string("Os") \n\
<Key>R7: string("0x01b") string("Ot") \n\
<Key>Up: string("0x01b") string("Ou") \n\
<Key>R9: string("0x01b") string("Ov") \n\
<Key>R4: string("0x01b") string("Ow") \n\
<Key>R5: string("0x01b") string("Ox") \n\
<Key>R6: string("0x01b") string("Oy") \n\
<Key>R15: string("0x01b") string("OM") \n\
<Key>F8: string("0x01b") string("Om") \n\
<Key>F9: string("0x01b") string("Ol") \n\
<Key>Down: string("0x01b") string("On") \n\
<Key>F3: string("0x01b") string("OA") \n\
<Key>F4: string("0x01b") string("OB") \n\
<Key>F5: string("0x01b") string("OD") \n\
<Key>F6: string("0x01b") string("OC")

Method 2
Feed this file to xmodmap:
===cut here==
! Last modified: 9-Sep-1990
!
! Input file for xmodmap. This file is used to re-map a Sun4 right keypad
! into a VT100 style right keypad.
!
! See 'man xmodmap' for more details.
!
! Usage: xmodmap this_file
!
! +-------+-------+-------+-------+
! Keycode| 28 | 29 | 30 | 105 |
! | | | | |
! VT100 | <- | -> | , |Nm_Lock|
! +-------+-------+-------+-------+
! | 52 | 53 | 54 | 78 |
! | | | | |
! | PF1 | PF2 | PF3 | PF4 |
! +-------+-------+-------+-------+
! | 75 | 76 | 77 | 132 |
! | | | | |
! | 7 | 8 | 9 | - | Shift 8 is Up
! +-------+-------+-------+ | Shift 4 is Left
! | 98 | 99 | 100 | | Shift 6 is Right
! | | | | , | Shift 2 is Down
! | 4 | 5 | 6 | |
! +-------+-------+-------+-------+ To get the Sun4 keys as labelled
! | 119 | 120 | 121 | 97 | on the keypad be sure that
! | | | | | Num_Lock is engaged (except for
! | 1 | 2 | 3 | E | the + key.
! +-------+-------+-------+ n |
! | 101 | 57 | t |
! | | | e |
! | 0 | . | r |
! +---------------+-------+-------+
!
keycode 28 = Left
keycode 29 = Right
keycode 30 = KP_Separator comma
keycode 52 = KP_F1 KP_Equal
keycode 53 = KP_F2 KP_Divide
keycode 54 = KP_F3 KP_Multiply
keycode 78 = KP_F4 KP_Subtract
!
! The Sun4 + key is really 2 VT100 keys: , and - so use the Shift modifier
! to mimic this. This means the loss of the normal Sun4 function
!
keycode 132 = KP_Separator KP_Subtract KP_Add
keycode 75 = KP_7
keycode 76 = KP_8 Up
keycode 77 = KP_9
keycode 98 = KP_4 Left
keycode 99 = KP_5
keycode 100 = KP_6 Right
keycode 119 = KP_1
keycode 120 = KP_2 Down
keycode 121 = KP_3
keycode 101 = KP_0
keycode 57 = KP_Decimal
keycode 97 = KP_Enter

 9. Does the SunView compatibility mode affect X Keyboard settings ?
        No.

10. Why don't loadkeys and dumpkeys work in Open Windows ?
        loadkeys and dumpkeys modifies the keyboard streams module's
        translation tables. Openwindows requires untranslated keyboard events
        tables. Openwindows requires untranslated keyboard events
        (keycodes). As such, loadkeys will have no effect in open-
        windows.

11. The 3rd party application can't use the Function Keys after moving from
    the SunView environment to Open Windows. Why ?

        They are expecting a escape sequence. Copy $OPENWINHOME/lib/ttyswrc
        to home directory as .ttyswrc.

12. What are the commands to manipulate the Keyboard in Open Windows ?
        xmodmap - Utility for modifying keymaps in X
        xset - User preference utility for X.
                        Option to look for is "r".
        Example: "xset r 84" should change the 'a' key
                   so it does repeat.
                  "xset -r 84" should change the 'a' key
                   so it does not repeat.

        kbd_mode - Change the keyboard translation mode

13. How do I customize the Keyboard layout for all X applications ?
        Same as 12

14. What Keyboard resources can be set in .Xdefaults ?
        Place the following resource in .Xdefaults file:
        OpenWindows.KeyboardCommands: Full
        Rest of the Keyboard resources can be found in the Xview reference
        manual. See page#216-229.

15. How do I modify the repeat key and delay rate times ?
         The command `xset r' is used to turn autorepeat ON or
                     OFF (this is from the xset manpage):
 
                     The r option controls the autorepeat. If a preced-
                     ing dash or the 'off' flag is used, autorepeat will
                     be disabled. If no parameters or the 'on' flag is
                     used, autorepeat will be enabled.
 
                     Here is what users can add/modify in their .startup.ps
                     file in their home directory under OpenWindows to change
                     the repeat key parameters:
 
        UserProfile begin
 
 
        %% cause the server to wait 1/2 second before repeating keys
            /KeyRepeatThresh 1 60 div 2 div def
 
        %% cause keys to repeat 10 times per second
            /KeyRepeatTime 1 60 div 10 div def
 
        %% cursor focus follows mouse
            /FocusStyle /CursorFocus def
 
        %% time to wait for next key in multi-key-click
        operations /MultiClickThresh 0.0001 def
 
        end
 
                     You can also set the `multiclick' resource for XView
                     applications with the following:
 
        Resource: mouse.multiclick.space
        Values: N (4)
        Description: Where N is an integer between 2 and 500.

17. How do I get my Xlib application to receive Keyboard input ?
        Keyboard input is set to a window with XSetInputFocus. The focus
        window must be viewable. For window to be viewable , it must be
        mapped and all its ancestors must be mapped, but it may be obscured.
        
        
        
18. Open Windows doesn't start and complains about the Keyboard ?
        Check the Dip Switches under your keyboard, they should all be turned
        off.

19. How do I turn on the Keyboard Accelerators ?
        Place the following resource in .Xdefaults file:
        OpenWindows.KeyboardCommands: Full

--------
From: rogers@cogs.susx.ac.uk (Roger Sinnhuber)

You might find this information I got from Sun useful:
>>>>>>>>>>>>>>>

******************************************************
* *
* DISCLAIMER *
* *
******************************************************

The contents of this file are intended to be read as
an example. This is not a supported product of Sun
Microsystems and no hotline calls will be accepted
which directly relate to this information.

NO LIABILITY WILL BE ACCEPTED BY SUN MICROSYSTEMS FOR
ANY LOSS (DIRECT OR CONSEQUENTIAL) INCURRED IN ANY WAY
BY ANY PARTY THROUGH THE USE OF THIS INFORMATION.

NO WARRANTY OF ANY SORT IS IMPLIED OR GIVEN FOR ANY
CODE DERIVED FROM THIS INFORMATION.

A short program to determine which type of keyboard is fitted to your system.
============================================================================

#include <sys/types.h>
#include <sys/time.h>
#include <sys/stream.h>
#include <sys/stropts.h>
#include <sundev/vuid_event.h>
#include <sundev/kbio.h>
#include <sundev/kbd.h>

main()
{ int t,d;
  int fd = open("/dev/kbd",01, 0145);

  ioctl(fd,KIOCTYPE,&t);
  ioctl (3, KIOCLAYOUT,&d);

  printf("results = %x %x\n",t,d);
}

Example results:

results = 4 22

Ignore the "4" the interesting bit is the "22"

Country: Type 4: Type 5:

US 0 21
US/UNIX N/A 22
BELGIUM/FRANCE 02 23
FRENCH CANADIAN 03 N/A
DANISH 04 24
GERMAN 05 25
ITALIAN 06 26
DUTCH 07 27
NORWEGIAN 08 28
PORTUGUESE 09 29
SPANISH 0A 2A
SWEDISH/FINISH 0B 2B
SWISS/FRENCH 0C 2C
SWISS/GERMAN 0D 2D
UK 0E 2E
KOREAN N/A 2F
TAIWANESE N/A 30
NIHON-GO N/A 31

<<<<<<<<<<<<<<<<<<<<

--------



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:08:59 CDT