DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

scancode(HW)


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 operating 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 argument values are:

KB_XSCANCODE
the device driver translates PC-scancodes to ASCII

KB_ISSCANCODE
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 (sc_bitmap). 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 ioctl 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 KB_ISSCANCODE flag is set on the device:

GIO_STRMAP
gets mapping table for a function-key string. See the keyboard(HW) manual page.

PIO_STRMAP
puts mapping table for a function-key string. See the keyboard(HW) manual page.

GIO_KEYMAP
gets key-mapping table. See the keyboard(HW) manual page.

PIO_KEYMAP
puts key-mapping table. See the keyboard(HW) manual page.

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 (K_RAW, K_XLATE). Mode is returned where the arg parameter points.

KDSKBMODE
sets keyboard translation mode (K_RAW, K_XLATE).
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 {
          unsigned short   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 function 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)

 +-------+---------------------------------------+
 |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/scancode.h
/usr/include/sys/scankbd.h
/usr/include/sys/termio.h

See also

ioctl(S), keyboard(HW), screen(HW), terminfo(M), tput(C)
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003