kb - keyboard STREAMS module
#include <sys/types.h>
#include <sys/stream.h>
#include <sys/stropts.h>
#include <sys/vuid_event.h>
#include <sys/kbio.h>
#include <sys/kbd.h>
ioctl(fd, I_PUSH, "kb");
The kb STREAMS module processes byte streams generated by a keyboard attached to a CPU serial port. Definitions for altering keyboard translation and reading events from the keyboard are contained in <sys/kbio.h> and <sys/kbd.h>.
The kb STREAMS module utilizes a set of keyboard tables to recognize which keys have been typed. Each translation table is an array of 128 16-bit words (unsigned shorts). If a table entry is less than 0x100, the entry is treated as an ISO 8859/1 character. Higher values indicate special characters that invoke more complicated actions.
The keyboard can be in one of the following translation modes:
TR_NONE
TR_ASCII
TR_EVENT
TR_UNTRANS_EVENT
All instances of the kb module share seven translation tables that convert raw keystation codes to event values. The tables are:
Unshifted
Shifted
Caps Lock
Alt Graph
Num Lock
Controlled
Key Up
Each key on the keyboard has a key station code that represents a number from 0 to 127. The number is used as an index into the translation table that is currently in effect. If the corresponding entry in the translation table is a value from 0 to 255, the value is treated as an ISO 8859/1 character, and the character is the result of the translation.
If the entry in the translation table is higher than 255, it is a special entry. Special entry values are classified according to the value of the high-order bits. The high-order value for each class is defined as a constant, as shown below. When added to the constant, the value of the low-order bits distinguish between keys within each class:
SHIFTKEYS 0x100
CAPSLOCK 0
SHIFTLOCK 1
LEFTSHIFT 2
RIGHTSHIFT 3
LEFTCTRL 4
RIGHTCTRL 5
ALTGRAPH 9
ALT 10
NUMLOCK 11
BUCKYBITS 0x200
METABIT 0
SYSTEMBIT 1
FUNNY 0x300
NOP 0x300
OOPS 0x301
HOLE 0x302
RESET 0x306
ERROR 0x307
IDLE 0x308
COMPOSE 0x309
NONL 0x30A
0x30B --- 0x30F
FA_CLASS 0x400
FA_UMLAUT 0x400
FA_CFLEX 0x401
FA_TILDE 0x402
FA_CEDILLA 0x403
FA_ACUTE 0x404
FA_GRAVE 0x405
STRING 0x500
KTAB_STRLEN
Individual string numbers are defined as:
HOMEARROW
UPARROW
DOWNARROW
LEFTARROW
RIGHTARROW
String numbers 0x05 --- 0x0F are available for custom entries.
FUNCKEYS 0x600
The next-to-lowest 4 bits indicate the group of function keys:
LEFTFUNC
RIGHTFUNC
TOPFUNC 0x610
BOTTOMFUNC
The low 4 bits indicate the function key number within the group:
LF(n)
RF(n)
TF(n)
BF(n)
PADKEYS 0x700
PADEQUAL 0x700
PADSLASH 0x701
PADSTAR 0x702
PADMINUS 0x703
PADSEP 0x704
PAD7 0x705
PAD8 0x706
PAD9 0x707
PADPLUS 0x708
PAD4 0x709
PAD5 0x70A
PAD6 0x70B
PAD1 0x70C
PAD2 0x70D
PAD3 0x70E
PAD0 0x70F
PADDOT 0x710
PADENTER 0x711
When a function key is pressed in TR_ASCII mode, the following escape sequence is sent:
ESC[0....9z
where ESC is a single escape character and "0...9" indicates the decimal representation of the function-key value. For example, function key R1 sends the sequence:
ESC[208z
because the decimal value of RF(1) is 208. In TR_EVENT mode, if there is a VUID event code for the function key in question, an event with that event code is generated; otherwise, individual events for the characters of the escape sequence are generated.
When started, the kb STREAMS module is in the compatibility mode. When the keyboard is in the TR_EVENT translation mode, ISO 8859/1 characters from the upper half of the character set (that is, characters with the eighth bit set) , are presented as events with codes in the ISO_FIRST range (as defined in <<sys/vuid_event.h>>). For backwards compatibility with older versions of the keyboard driver, the event code is ISO_FIRST plus the character value. When compatibility mode is turned off, ISO 8859/1 characters are presented as events with codes equal to the character code.
The following ioctl() requests set and retrieve the current translation mode of a keyboard:
KIOCTRANS
KIOCGTRANS
ioctl() requests for changing and retrieving entries from the keyboard translation table use the kiockeymap structure:
struct kiockeymap { int kio_tablemask; /* Translation table (one of: 0, CAPSMASK, * SHIFTMASK, CTRLMASK, UPMASK, * ALTGRAPHMASK, NUMLOCKMASK) */ #define KIOCABORT1 -1 /* Special "mask": abort1 keystation */ #define KIOCABORT2 -2 /* Special "mask": abort2 keystation */ uchar_t kio_station; /* Physical keyboard key station (0-127) */ ushort_t kio_entry; /* Translation table station's entry */ char kio_string[10]; /* Value for STRING entries-null terminated */ };
KIOCSKEY
UPMASK 0x0080
NUMLOCKMASK 0x0800
CTRLMASK 0x0030
ALTGRAPHMASK 0x0200
SHIFTMASK 0x000E
CAPSMASK 0x0001
(No shift keys pressed or locked)
The kio_station request specifies the keystation code for the entry to be modified. The value of kio_entry is stored in the entry in question. If kio_entry is between STRING and STRING+15, the string contained in kio_string is copied to the appropriate string table entry. This call may return EINVAL if there are invalid arguments.
Special values of kio_tablemask can affect the two step "break to the PROM monitor" sequence. The usual sequence is L1-a or Stop-. If kio_tablemask is KIOCABORT1, then the value of kio_station is set to be the first keystation in the sequence. If kio_tablemask, is KIOCABORT2 then the value of kio_station is set to be the second keystation in the sequence. An attempt to change the "break to the PROM monitor" sequence without having superuser permission results in an EPERM error.
KIOCGKEY
KIOCTYPE
KB_SUN3
KB_SUN4
KB_USB
KB_ASCII
KB_PC
KB_DEFAULT
KIOCLAYOUT
KIOCCMD
Commands to the Sun Type 3 and Sun Type 4 keyboards:
KBD_CMD_RESET
KBD_CMD_BELL
KBD_CMD_NOBELL
KBD_CMD_CLICK
KBD_CMD_NOCLICK
Commands to the Sun Type 4 keyboard:
KBD_CMD_SETLED
KBD_CMD_GETLAYOUT
Inappropriate commands for particular keyboard types are ignored. Since there is no reliable way to get the state of the bell or click (because the keyboard cannot be queried and a process could do writes to the appropriate serial driver --- circumventing this ioctl() request) an equivalent ioctl() to query its state is not provided.
KIOCSLED
LED_CAPS_LOCK
LED_COMPOSE
LED_SCROLL_LOCK
LED_NUM_LOCK
On some Japanese layouts, the value for the fifth LED is:
LED_KANA
KIOCGLED
KIOCSCOMPAT
KIOCGCOMPAT
The following ioctl() request allows the default effect of the keyboard abort sequence to be changed.
KIOCSKABORTEN
Due to a risk of incorrect sequence interpretation, SLIP and certain other binary protocols should not be run over the serial console port when Alternate Break sequence is in effect. Although PPP is a binary protocol, it is able to avoid these sequences using the ACCM feature in RFC 1662. For Solaris PPP 4.0, you do this by adding the following line to the /etc/ppp/options file (or other configuration files used for the connection; see pppd(1M) for details):
asyncmap 0x00002000
SLIP has no comparable capability, and must not be used if the Alternate Break sequence is in use.
This ioctl() will be active and retain state even if there is no physical keyboard in the system. The default effect (enable) causes the operating system to suspend and enter the kernel debugger (if present) or the system prom (on most systems with OpenBoot proms). The default effect is enabled on most systems, but may be different on server systems with key switches in the 'secure' position. On these systems, the effect is always disabled when the key switch is in the 'secure' position. This ioctl()returns EPERM if the caller is not the superuser.
These ioctl() requests are supported for compatibility with the system keyboard device /dev/kbd.
KIOCSDIRECT
KIOCGDIRECT
The following ioctl() requests are used to set and get the keyboard autorepeat delay and rate.
KIOCSRPTDELAY
KIOCGRPTDELAY
KIOCSRPTRATE
KIOCGRPTRATE
See attributes(5) for descriptions of the following attributes:
|
kbd(1), loadkeys(1), kadb(1M), pppd(1M), keytables(4), attributes(5), zs(7D), se(7D), asy(7D), virtualkm(7D), termio(7I), usbkbm(7M)
Many keyboards released after Sun Type 4 keyboard also report themselves as Sun Type 4 keyboards.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |