Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ scancode(HW) — OpenDesktop 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ioctl(S)

keyboard(HW)

mapkey(M)

screen(HW)

terminfo(M)

tput(C)


 scancode(HW)                  06 January 1993                   scancode(HW)


 Name

    scancode - PC-scancode capable terminal

 Description

    Like any terminal, a PC-scancode capable terminal is used to enter and
    display data.  Unlike other terminals, which send information to the op-
    erating system only in the form of keytop values (the characters that
    appear on the faces of the keys), a PC-scancode capable terminal can also
    send scancodes (unique values associated with the depression and release
    of each key).  The PC-scancode capable terminal sends scancodes to the
    sio driver when the terminal is set to scancode mode.  When the terminal
    is in character mode, it sends keytop values.

    Running a terminal in PC-scancode mode lets a scancode application access
    more distinct keystrokes than character mode would provide.  For example,
    if you set your terminal to character mode and press the key labeled
    ``A'', your terminal sends a single value (the ASCII value of ``a'') to
    your application.  However, if you set your terminal to scancode mode and
    press the key labeled ``A'', your terminal sends one value when you
    depress the key and a second value when you release the key.  A scancode
    application translates these scancode values according to a predetermined
    map.

    For more information on scancodes, including mapping tables, see
    keyboard(HW).

 Line discipline ioctl calls

    The line discipline ioctl calls control scancode settings on the device
    driver side.

    The following ioctl calls and flags are defined in
    /usr/include/sys/termio.h:

    TCSETSC       sets flags for a PC-scancode capable terminal.  The argu-
                  ment values are:

                  KBXSCANCODE      the device driver translates PC-scancodes
                                    to ASCII

                  KBISSCANCODE     the terminal device sends PC-scancodes

    TCGETSC       gets PC-scancode terminal flags.

    The following ioctl calls are defined in /usr/include/sys/scankbd.h:

    KDGKBMAP      gets the keyboard state bitmap (scbitmap).  This bitmap is
                  an array of eight unsigned longs that describe the current
                  state of all keyboard keys.

    AIOCSETSS     sets the start/stop characters that the serial terminal
                  sends.  The argument to the ioctl call is of the type
                  (struct termss *), defined in /usr/include/sys/termio.h.

    The following ioctl calls are available on a terminal device if the
    KBISSCANCODE flag is set on the device:

    GIOSTRMAP    gets mapping table for a function-key string.  See
                  keyboard(HW).

    PIOSTRMAP    puts mapping table for a function-key string.  See
                  keyboard(HW).

    GIOKEYMAP    gets key-mapping table.  See keyboard(HW).

    PIOKEYMAP    puts key-mapping table.  See keyboard(HW).

    KDGKBSTATE    returns the Shifted, Ctrl, or Alt state of the keyboard.
                  Returns a Boolean combination of:

                  1       Shifted
                  2       Ctrl
                  4       Alt

    KDGKBMODE     gets keyboard translation mode (KRAW, KXLATE).  Mode is
                  returned where the arg parameter points.

    KDSKBMODE     sets keyboard translation mode (KRAW, KXLATE).

    ioctl(S) can be used to define or obtain the current definition of a
    function key.  The arg parameter of the ioctl call uses the fkeyarg data
    structure:

       struct fkeyarg {
              unassigned int keynum;
              char keydef [MAXFK];
              /* Comes from ioctl.h via comcrt.h */
              char flen;
       }

    You can use the following ioctl requests to obtain or assign function key
    definitions:

    GETFKEY       gets the current definition of a function key.  The func-
                  tion key number must be passed in keynum.  The string
                  currently assigned to the key is returned in keydef, and
                  the length of the string is returned in flen when the ioctl
                  call is performed.

    SETFKEY       assigns a given string to a function key.  The function key
                  number must be passed in keydef, and the length of the
                  string (number of characters) must be passed in flen.

 terminfo settings

    The following terminfo database strings control scancode settings from
    the terminal side:

    _________________________________________________________________________
    String                             Definition
    _________________________________________________________________________
    smsc                               enters PC-scancode mode (string)
    rmsc                               leaves PC-scancode mode (string)
    xonc                               alternates XON character (int)
    xoffc                              alternates XOFF character (int)
    dispc                              displays a PC character (string)

 Files

    /usr/include/sys/comcrt.h
    /usr/include/sys/ioctl.h
    /usr/include/sys/sc_keys.h
    /usr/include/sys/scancode.h
    /usr/include/sys/scankbd.h
    /usr/include/sys/termio.h

 See also

    ioctl(S), keyboard(HW), mapkey(M), screen(HW), terminfo(M), tput(C)


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026