Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ kbd(5) — SunOS 1.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cons(4S)

KBD(5)  —  FILE FORMATS

NAME

kbd − keyboard translation table format and default table

SYNOPSIS

#include <sundev/kbd.h>

DESCRIPTION

Keyboard translation is done in the UNIX kernel via a set of tables.  A translation table is 128 bytes of ‘entries’, which are bytes (unsigned chars).  The top 4 bits of each entry are decoded by a case statement in the keyboard translator.  If the entry is less than 0x80, it is sent out as an ASCII character (possibly with the META bit OR-ed in).  ‘Special’ entries are 0x80 or greater, and invoke more complicated actions. 

struct keymap {
unsigned charkeymap[128];/∗ maps keycodes to actions ∗/
};

A keyboard is defined by its keymaps. 

struct keyboard {
struct keymap∗k_normal;/∗ Unshifted ∗/
struct keymap∗k_shifted;/∗ Shifted ∗/
struct keymap∗k_caps;/∗ Caps locked ∗/
struct keymap∗k_control;/∗ Controlled ∗/
struct keymap∗k_up;/∗ Key went up ∗/
intk_idleshifts;/∗ Shifts ∗/
intk_idlebuckys;/∗ Bucky bits ∗/
unsigned chark_abort1;/∗ 1st key of abort sequence ∗/
unsigned chark_abort2;/∗ 2nd key of abort sequence ∗/
};

The following defines the bit positions used within k_idleshifts to indicate the ‘pressed’ (1) or ‘released’ (0) state of shift keys.  The bit numbers and the aggregate masks are defined. 

Since it is possible to have more than one bit in the shift mask on at once, there is an implied priority given to each shift state when determining which translation table to use.  The order is (from highest priority to lowest) UPMASK, CTRLMASK, SHIFTMASK, and lastly CAPSMASK. 

#defineCAPSLOCK0/∗ Caps Lock key ∗/
#defineSHIFTLOCK1/∗ Shift Lock key ∗/
#defineLEFTSHIFT2/∗ Left-hand shift key ∗/
#defineRIGHTSHIFT3/∗ Right-hand shift key ∗/
#defineLEFTCTRL4/∗ Left-hand (or only) control key ∗/
#defineRIGHTCTRL5/∗ Right-hand control key ∗/
#defineCAPSMASK0x0001/∗ Caplock translation table ∗/
#defineSHIFTMASK0x000E/∗ Shifted translation table ∗/
#defineCTRLMASK0x0030/∗ Ctrl shift translation table ∗/
#defineUPMASK0x0080/∗ Key up translation table ∗/

Special Entry Keys

The ‘special’ entries’ top 4 bits are defined below.  Generally they are used with a 4-bit parameter (such as a bit number) in the low 4 bits.  The bytes whose top 4 bits are 0x0 thru 0x7 happen to be ASCII characters.  They are not special cased, but just normal cased. 

#defineSHIFTKEYS0x80

thru 0x8F.  This key helps to determine the translation table used.  The bit position of its bit in ‘shiftmask’ is added to the entry, for example, SHIFTKEYS+LEFTCTRL.  When this entry is invoked, the bit in ‘shiftmask’ is toggled.  Depending which tables you put it in, this works well for hold-down keys or press-on, press-off keys. 

#defineBUCKYBITS0x90

thru 0x9F.  This key determines the state of one of the ‘bucky’ bits above the returned ASCII character.  This is basically a way to pass mode-key-up/down information back to the caller with each ‘real’ key depressed.  The concept, and name ‘bucky’ (derivation unknown) comes from the MIT/SAIL ‘TV’ system — they had TOP, META, CTRL, and a few other bucky bits.  The bit position of its bit in ‘buckybits’, minus 7, is added to the entry; for example, bit 0x00000400 is BUCKYBITS +3.  The ‘-7’ prevents us from messing up the ASCII char, and gives us 16 useful bucky bits.  When this entry is invoked, the designated bit in ‘buckybits’ is toggled.  Depending which tables you put it in, this works well for hold-down keys or press-on, press-off keys. 

#defineMETABIT0

Meta key depressed with key.  This is the only user accessible bucky bit.  This value is added to BUCKYBITS in the translation table. 

#defineSYSTEMBIT1

‘System’ key was down w/key.  This is a kernel-accessible bucky bit.  This value is added to BUCKYBITS in the translation table.  The system key is currently not used except as a place holder to indicate the key used as the k_abort1 key (as defined above). 

#defineFUNNY0xA0/∗ thru 0xAF.  This key does one of 16 funny
   things based on the low 4 bits: ∗/
#defineNOP0xA0/∗ This key does nothing. ∗/
#defineOOPS0xA1/∗ This key exists but is undefined. ∗/
#defineHOLE0xA2/∗ This key does not exist on the keyboard.
   Its position code should never be
   generated.  This indicates a software/
   hardware mismatch, or bugs. ∗/
#defineNOSCROLL0xA3/∗ This key alternately sends ^S or ^Q ∗/
#defineCTRLS0xA4/∗ This sends ^S and lets NOSCROLL know ∗/
#defineCTRLQ0xA5/∗ This sends ^Q and lets NOSCROLL know ∗/
#defineRESET0xA6/∗ Kbd was just reset ∗/
#defineERROR0xA7/∗ Kbd just detected an internal error ∗/
#defineIDLE0xA8/∗ Kbd is idle (no keys down) ∗/

Combinations 0xA9 to 0xAF are reserved for non-parameterized functions. 

#defineSTRING0xB0

thru 0xBF.  The low-order 4 bits index a table select a string to be returned, char by char.  Each entry in the table is null terminated. 

#defineKTAB_STRLEN10/∗ Maximum string length (including null) ∗/

Definitions for the individual string numbers:

#defineHOMEARROW0x00
#defineUPARROW0x01
#defineDOWNARROW0x02
#defineLEFTARROW0x03
#defineRIGHTARROW0x04

String numbers 5 thru F are available to users making custom entries. 

Function Key Groupings

In the following function key groupings, the low-order 4 bits indicate the function key number within the group:

#defineLEFTFUNC0xC0/∗ thru 0xCF.  The ‘left’ group. ∗/
#defineRIGHTFUNC0xD0/∗ thru 0xDF.  The ‘right’ group. ∗/
#defineTOPFUNC0xE0/∗ thru 0xEF.  The ‘top’ group. ∗/
#defineBOTTOMFUNC0xF0/∗ thru 0xFF.  The ‘bottom’ group. ∗/
#define LF(n)(LEFTFUNC+(n)-1)
#define RF(n)(RIGHTFUNC+(n)-1)
#define TF(n)(TOPFUNC+(n)-1)
#define BF(n)(BOTTOMFUNC+(n)-1)

The actual keyboard positions may not be on the left/right/top/bottom of the physical keyboard (although they usually are).  What is important is that we have reserved 64 keys for function keys. 

Normally, when a function key is pressed, the following escape sequence is sent through the character stream:

ESC[0..9z
where ESC is a single escape character and 0..9 indicate some number of digits needed to encode the function key as a decimal number. 

DEFAULT TABLES

The kernel has 3 sets of initial translation tables, one set for each type of keyboard supported. 

#ifndef lint
staticchar sccsid[] = "@(#)keytables.c 1.3 83/10/25 Copyr 1983 Sun Micro";
#endif
 /∗
 ∗ Copyright (C) 1983 by Sun Microsystems, Inc.
 ∗/
 /∗
 ∗ keytables.c
 ∗
 ∗ This module contains the translation tables for the up-down encoded
 ∗ Sun keyboards.
 ∗/
#include "../sun/kbd.h"
 /∗ handy way to define control characters in the tables ∗/
#definec(char)(char&0x1F)
#define ESC 0x1B
  /∗ Unshifted keyboard table for Micro Switch 103SD32-2 ∗/
 static struct keymap keytab_ms_lc = {
/∗  0 ∗/HOLE,BUCKYBITS+SYSTEMBIT,
LF(2),LF(3),HOLE,TF(1),TF(2),TF(3),
/∗  8 ∗/TF(4), TF(5), TF(6),TF(7),TF(8),TF(9),TF(10),TF(11),
/∗ 16 ∗/TF(12), TF(13), TF(14),c(’[’),HOLE,RF(1),’+’,’-’,
/∗ 24 ∗/HOLE, LF(4), ’\f’,LF(6),HOLE,SHIFTKEYS+CAPSLOCK,
’1’,’2’,
/∗ 32 ∗/’3’,’4’,’5’,’6’,’7’,’8’,’9’,’0’,
/∗ 40 ∗/’-’,’~’,’‘’,’\b’,HOLE,’7’,’8’,’9’,
/∗ 48 ∗/HOLE,LF(7),STRING+UPARROW,
LF(9),HOLE,’\t’,’q’,’w’,
/∗ 56 ∗/’e’,’r’,’t’,’y’,’u’,’i’,’o’,’p’,
/∗ 64 ∗/’{’,’}’,’_’,HOLE,’4’,’5’,’6’,HOLE,
/∗ 72 ∗/STRING+LEFTARROW,
STRING+HOMEARROW,
STRING+RIGHTARROW,
HOLE,SHIFTKEYS+SHIFTLOCK,
’a’, ’s’,’d’,
/∗ 80 ∗/’f’,’g’,’h’,’j’,’k’,’l’,’;’,’:’,
/∗ 88 ∗/’|’,’\r’,HOLE,’1’,’2’,’3’,HOLE,NOSCROLL,
/∗ 96 ∗/STRING+DOWNARROW,
LF(97),HOLE,HOLE,SHIFTKEYS+LEFTSHIFT,
’z’,’x’,’c’,
/∗104 ∗/’v’,’b’,’n’,’m’,’,’,’.’,’/’,SHIFTKEYS+RIGHTSHIFT,
/∗112 ∗/NOP,0x7F,’0’,NOP,’.’,HOLE,HOLE,HOLE,
/∗120 ∗/HOLE,HOLE,SHIFTKEYS+LEFTCTRL,
’ ’,SHIFTKEYS+RIGHTCTRL,
HOLE,HOLE,IDLE,
};
 /∗ Shifted keyboard table for Micro Switch 103SD32-2 ∗/
 static struct keymap keytab_ms_uc = {
/∗  0 ∗/HOLE,BUCKYBITS+SYSTEMBIT,
LF(2),LF(3),HOLE,TF(1),TF(2),TF(3),
/∗  8 ∗/TF(4), TF(5), TF(6),TF(7),TF(8),TF(9),TF(10),TF(11),
/∗ 16 ∗/TF(12), TF(13), TF(14),c(’[’),HOLE,RF(1),’+’,’-’,
/∗ 24 ∗/HOLE, LF(4), ’\f’,LF(6),HOLE,SHIFTKEYS+CAPSLOCK,
’!’,’"’,
/∗ 32 ∗/’#’,’$’,’%’,’&’,’\”,’(’,’)’,’0’,
/∗ 40 ∗/’=’,’^’,’@’,’\b’,HOLE,’7’,’8’,’9’,
/∗ 48 ∗/HOLE,LF(7),STRING+UPARROW,
LF(9),HOLE,’\t’,’Q’,’W’,
/∗ 56 ∗/’E’,’R’,’T’,’Y’,’U’,’I’,’O’,’P’,
/∗ 64 ∗/’[’,’]’,’_’,HOLE,’4’,’5’,’6’,HOLE,
/∗ 72 ∗/STRING+LEFTARROW,
STRING+HOMEARROW,
STRING+RIGHTARROW,
HOLE,SHIFTKEYS+SHIFTLOCK,
’A’, ’S’,’D’,
/∗ 80 ∗/’F’,’G’,’H’,’J’,’K’,’L’,’+’,’∗’,
/∗ 88 ∗/’\\’,’\r’,HOLE,’1’,’2’,’3’,HOLE,NOSCROLL,
/∗ 96 ∗/STRING+DOWNARROW,
LF(97),HOLE,HOLE,SHIFTKEYS+LEFTSHIFT,
’Z’,’X’,’C’,
/∗104 ∗/’V’,’B’,’N’,’M’,’<’,’>’,’?’,SHIFTKEYS+RIGHTSHIFT,
/∗112 ∗/NOP,0x7F,’0’,NOP,’.’,HOLE,HOLE,HOLE,
/∗120 ∗/HOLE,HOLE,SHIFTKEYS+LEFTCTRL,
’ ’,SHIFTKEYS+RIGHTCTRL,
HOLE,HOLE,IDLE,
};
  /∗ Caps Locked keyboard table for Micro Switch 103SD32-2 ∗/
 static struct keymap keytab_ms_cl = {
/∗  0 ∗/HOLE,BUCKYBITS+SYSTEMBIT,
LF(2),LF(3),HOLE,TF(1),TF(2),TF(3),
/∗  8 ∗/TF(4), TF(5), TF(6),TF(7),TF(8),TF(9),TF(10),TF(11),
/∗ 16 ∗/TF(12), TF(13), TF(14),c(’[’),HOLE,RF(1),’+’,’-’,
/∗ 24 ∗/HOLE, LF(4), ’\f’,LF(6),HOLE,SHIFTKEYS+CAPSLOCK,
’1’,’2’,
/∗ 32 ∗/’3’,’4’,’5’,’6’,’7’,’8’,’9’,’0’,
/∗ 40 ∗/’-’,’~’,’‘’,’\b’,HOLE,’7’,’8’,’9’,
/∗ 48 ∗/HOLE,LF(7),STRING+UPARROW,
LF(9),HOLE,’\t’,’Q’,’W’,
/∗ 56 ∗/’E’,’R’,’T’,’Y’,’U’,’I’,’O’,’P’,
/∗ 64 ∗/’{’,’}’,’_’,HOLE,’4’,’5’,’6’,HOLE,
/∗ 72 ∗/STRING+LEFTARROW,
STRING+HOMEARROW,
STRING+RIGHTARROW,
HOLE,SHIFTKEYS+SHIFTLOCK,
’A’, ’S’,’D’,
/∗ 80 ∗/’F’,’G’,’H’,’J’,’K’,’L’,’;’,’:’,
/∗ 88 ∗/’|’,’\r’,HOLE,’1’,’2’,’3’,HOLE,NOSCROLL,
/∗ 96 ∗/STRING+DOWNARROW,
LF(97),HOLE,HOLE,SHIFTKEYS+LEFTSHIFT,
’Z’,’X’,’C’,
/∗104 ∗/’V’,’B’,’N’,’M’,’,’,’.’,’/’,SHIFTKEYS+RIGHTSHIFT,
/∗112 ∗/NOP,0x7F,’0’,NOP,’.’,HOLE,HOLE,HOLE,
/∗120 ∗/HOLE,HOLE,SHIFTKEYS+LEFTCTRL,
’ ’,SHIFTKEYS+RIGHTCTRL,
HOLE,HOLE,IDLE,
};
 /∗ Controlled keyboard table for Micro Switch 103SD32-2 ∗/
 static struct keymap keytab_ms_ct = {
/∗  0 ∗/HOLE,BUCKYBITS+SYSTEMBIT,
LF(2),LF(3),HOLE,TF(1),TF(2),TF(3),
/∗  8 ∗/TF(4), TF(5), TF(6),TF(7),TF(8),TF(9),TF(10),TF(11),
/∗ 16 ∗/TF(12), TF(13), TF(14),c(’[’),HOLE,RF(1),OOPS, OOPS,
/∗ 24 ∗/HOLE, LF(4), ’\f’,LF(6),HOLE,SHIFTKEYS+CAPSLOCK,
OOPS,OOPS,
/∗ 32 ∗/OOPS,OOPS,OOPS,OOPS,OOPS,OOPS, OOPS, OOPS,
/∗ 40 ∗/OOPS,c(’^’),c(’@’),’\b’,HOLE,OOPS,OOPS,OOPS,
/∗ 48 ∗/HOLE,LF(7),STRING+UPARROW,
LF(9),HOLE,’\t’,CTRLQ,c(’W’),
/∗ 56 ∗/c(’E’),c(’R’),c(’T’),c(’Y’),c(’U’),c(’I’),c(’O’),c(’P’),
/∗ 64 ∗/c(’[’),c(’]’),c(’_’),HOLE,OOPS,OOPS,OOPS,HOLE,
/∗ 72 ∗/STRING+LEFTARROW,
STRING+HOMEARROW,
STRING+RIGHTARROW,
HOLE,SHIFTKEYS+SHIFTLOCK,
c(’A’),CTRLS,c(’D’),
/∗ 80 ∗/c(’F’),c(’G’),c(’H’),c(’J’),c(’K’),c(’L’),OOPS,OOPS,
/∗ 88 ∗/c(’\\’),
’\r’,HOLE,OOPS,OOPS,OOPS,HOLE, NOSCROLL,
/∗ 96 ∗/STRING+DOWNARROW,
LF(97),HOLE,HOLE,SHIFTKEYS+LEFTSHIFT,
c(’Z’),c(’X’),c(’C’),
/∗104 ∗/c(’V’),c(’B’),c(’N’),c(’M’),OOPS,OOPS,OOPS,SHIFTKEYS+RIGHTSHIFT,
/∗112 ∗/NOP,0x7F,OOPS,NOP,OOPS,HOLE,HOLE,HOLE,
/∗120 ∗/HOLE,HOLE,SHIFTKEYS+LEFTCTRL,
’\0’,SHIFTKEYS+RIGHTCTRL,
HOLE,HOLE,IDLE,
};
  /∗ "Key Up" keyboard table for Micro Switch 103SD32-2 ∗/
 static struct keymap keytab_ms_up = {
/∗  0 ∗/HOLE,BUCKYBITS+SYSTEMBIT,
NOP,NOP,HOLE,NOP,NOP,NOP,
/∗  8 ∗/NOP, NOP, NOP,NOP,NOP,NOP,NOP,NOP,
/∗ 16 ∗/NOP, NOP, NOP,NOP,HOLE,NOP,NOP,NOP,
/∗ 24 ∗/HOLE, NOP, NOP,NOP,HOLE,SHIFTKEYS+CAPSLOCK,
NOP,NOP,
/∗ 32 ∗/NOP,NOP,NOP,NOP,NOP,NOP,NOP,NOP,
/∗ 40 ∗/NOP,NOP,NOP,NOP,HOLE,NOP,NOP,NOP,
/∗ 48 ∗/HOLE,NOP,NOP,NOP,HOLE,NOP,NOP,NOP,
/∗ 56 ∗/NOP,NOP,NOP,NOP,NOP,NOP,NOP,NOP,
/∗ 64 ∗/NOP,NOP,NOP,HOLE,NOP,NOP,NOP,HOLE,
/∗ 72 ∗/NOP,NOP,NOP,HOLE,SHIFTKEYS+SHIFTLOCK,
NOP, NOP,NOP,
/∗ 80 ∗/NOP,NOP,NOP,NOP,NOP,NOP,NOP,NOP,
/∗ 88 ∗/NOP,NOP,HOLE,NOP,NOP,NOP,HOLE,NOP,
/∗ 96 ∗/NOP,NOP,HOLE,HOLE,SHIFTKEYS+LEFTSHIFT,
NOP,NOP,NOP,
/∗104 ∗/NOP,NOP,NOP,NOP,NOP,NOP,NOP,SHIFTKEYS+RIGHTSHIFT,
/∗112 ∗/NOP,NOP,NOP,NOP,NOP,HOLE,HOLE,HOLE,
/∗120 ∗/HOLE,HOLE,SHIFTKEYS+LEFTCTRL,
NOP,SHIFTKEYS+RIGHTCTRL,
HOLE,HOLE,RESET,
};
  /∗ Index to keymaps for Micro Switch 103SD32-2 ∗/
static struct keyboard keyindex_ms = {
&keytab_ms_lc,
&keytab_ms_uc,
&keytab_ms_cl,
&keytab_ms_ct,
&keytab_ms_up,
CTLSMASK,/∗ Shift bits which stay on with idle keyboard ∗/
0x0000,/∗ Bucky bits which stay on with idle keyboard ∗/
1,77,/∗ abort keys ∗/
};
 /∗ Unshifted keyboard table for Sun-2 keyboard ∗/
 static struct keymap keytab_s2_lc = {
/∗  0 ∗/HOLE,BUCKYBITS+SYSTEMBIT,
LF(2),LF(3),HOLE,TF(1),TF(2),TF(3),
/∗  8 ∗/TF(4), TF(5), TF(6),TF(7),TF(8),TF(9),TF(10),TF(11),
/∗ 16 ∗/TF(12),TF(13),TF(14),TF(15),HOLE,RF(1),RF(2), RF(3),
/∗ 24 ∗/HOLE, LF(4), LF(5),LF(6),HOLE,c(’[’),’1’,’2’,
/∗ 32 ∗/’3’,’4’,’5’,’6’,’7’,’8’,’9’,’0’,
/∗ 40 ∗/’-’,’=’,’‘’,’\b’,HOLE,RF(4),RF(5),RF(6),
/∗ 48 ∗/HOLE,LF(7),LF(8),LF(9),HOLE,’\t’,’q’,’w’,
/∗ 56 ∗/’e’,’r’,’t’,’y’,’u’,’i’,’o’,’p’,
/∗ 64 ∗/’[’,’]’,0x7F,HOLE,RF(7),STRING+UPARROW,
RF(9),HOLE,
/∗ 72 ∗/LF(10),LF(11),LF(12),HOLE,SHIFTKEYS+LEFTCTRL,
’a’, ’s’,’d’,
/∗ 80 ∗/’f’,’g’,’h’,’j’,’k’,’l’,’;’,’\”,
/∗ 88 ∗/’\\’,’\r’,HOLE,STRING+LEFTARROW,
RF(11),STRING+RIGHTARROW,
HOLE,LF(13),
/∗ 96 ∗/LF(14),LF(15),HOLE,SHIFTKEYS+LEFTSHIFT,
’z’,’x’,’c’,’v’,
/∗104 ∗/’b’,’n’,’m’,’,’,’.’,’/’,SHIFTKEYS+RIGHTSHIFT,
’\n’,
/∗112 ∗/RF(13),STRING+DOWNARROW,
RF(15),HOLE,HOLE,HOLE,HOLE, HOLE,
/∗120 ∗/BUCKYBITS+METABIT,
’ ’,BUCKYBITS+METABIT,
HOLE,HOLE,HOLE,ERROR,IDLE,
};
 /∗ Shifted keyboard table for Sun-2 keyboard ∗/
 static struct keymap keytab_s2_uc = {
/∗  0 ∗/HOLE,BUCKYBITS+SYSTEMBIT,
LF(2),LF(3),HOLE,TF(1),TF(2),TF(3),
/∗  8 ∗/TF(4), TF(5), TF(6),TF(7),TF(8),TF(9),TF(10),TF(11),
/∗ 16 ∗/TF(12),TF(13),TF(14),TF(15),HOLE,RF(1),RF(2), RF(3),
/∗ 24 ∗/HOLE, LF(4), LF(5),LF(6),HOLE,c(’[’),’!’,’@’,
/∗ 32 ∗/’#’,’$’,’%’,’^’,’&’,’∗’,’(’,’)’,
/∗ 40 ∗/’_’,’+’,’~’,’\b’,HOLE,RF(4),RF(5),RF(6),
/∗ 48 ∗/HOLE,LF(7),LF(8),LF(9),HOLE,’\t’,’Q’,’W’,
/∗ 56 ∗/’E’,’R’,’T’,’Y’,’U’,’I’,’O’,’P’,
/∗ 64 ∗/’{’,’}’,0x7F,HOLE,RF(7),STRING+UPARROW,
RF(9),HOLE,
/∗ 72 ∗/LF(10),LF(11),LF(12),HOLE,SHIFTKEYS+LEFTCTRL,
’A’, ’S’,’D’,
/∗ 80 ∗/’F’,’G’,’H’,’J’,’K’,’L’,’:’,’"’,
/∗ 88 ∗/’|’,’\r’,HOLE,STRING+LEFTARROW,
RF(11),STRING+RIGHTARROW,
HOLE,LF(13),
/∗ 96 ∗/LF(14),LF(15),HOLE,SHIFTKEYS+LEFTSHIFT,
’Z’,’X’,’C’,’V’,
/∗104 ∗/’B’,’N’,’M’,’<’,’>’,’?’,SHIFTKEYS+RIGHTSHIFT,
’\n’,
/∗112 ∗/RF(13),STRING+DOWNARROW,
RF(15),HOLE,HOLE,HOLE,HOLE, HOLE,
/∗120 ∗/BUCKYBITS+METABIT,
’ ’,BUCKYBITS+METABIT,
HOLE,HOLE,HOLE,ERROR,IDLE,
};
  /∗ Controlled keyboard table for Sun-2 keyboard ∗/
 static struct keymap keytab_s2_ct = {
/∗  0 ∗/HOLE,BUCKYBITS+SYSTEMBIT,
LF(2),LF(3),HOLE,TF(1),TF(2),TF(3),
/∗  8 ∗/TF(4), TF(5), TF(6),TF(7),TF(8),TF(9),TF(10),TF(11),
/∗ 16 ∗/TF(12),TF(13),TF(14),TF(15),HOLE,RF(1),RF(2), RF(3),
/∗ 24 ∗/HOLE, LF(4), LF(5),LF(6),HOLE,c(’[’),’1’,c(’@’),
/∗ 32 ∗/’3’,’4’,’5’,c(’^’),’7’,’8’,’9’,’0’,
/∗ 40 ∗/c(’_’),’=’,c(’^’),’\b’,HOLE,RF(4),RF(5),RF(6),
/∗ 48 ∗/HOLE,LF(7),LF(8),LF(9),HOLE,’\t’,c(’q’),c(’w’),
/∗ 56 ∗/c(’e’),c(’r’),c(’t’),c(’y’),c(’u’),c(’i’),c(’o’),c(’p’),
/∗ 64 ∗/c(’[’),c(’]’),0x7F,HOLE,RF(7),STRING+UPARROW,
RF(9),HOLE,
/∗ 72 ∗/LF(10),LF(11),LF(12),HOLE,SHIFTKEYS+LEFTCTRL,
c(’a’),c(’s’),c(’d’),
/∗ 80 ∗/c(’f’),c(’g’),c(’h’),c(’j’),c(’k’),c(’l’),’;’,’\”,
/∗ 88 ∗/c(’\\’),
’\r’,HOLE,STRING+LEFTARROW,
RF(11),STRING+RIGHTARROW,
HOLE,LF(13),
/∗ 96 ∗/LF(14),LF(15),HOLE,SHIFTKEYS+LEFTSHIFT,
c(’z’),c(’x’),c(’c’),c(’v’),
/∗104 ∗/c(’b’),c(’n’),c(’m’),’,’,’.’,c(’_’),SHIFTKEYS+RIGHTSHIFT,
’\n’,
/∗112 ∗/RF(13),STRING+DOWNARROW,
RF(15),HOLE,HOLE,HOLE,HOLE, HOLE,
/∗120 ∗/BUCKYBITS+METABIT,
c(’ ’),BUCKYBITS+METABIT,
HOLE,HOLE,HOLE,ERROR,IDLE,
};
   /∗ "Key Up" keyboard table for Sun-2 keyboard ∗/
 static struct keymap keytab_s2_up = {
/∗  0 ∗/HOLE,BUCKYBITS+SYSTEMBIT,
OOPS,OOPS,HOLE,OOPS,OOPS, OOPS,
/∗  8 ∗/OOPS, OOPS, OOPS,OOPS,OOPS,OOPS, OOPS, OOPS,
/∗ 16 ∗/OOPS, OOPS, OOPS,OOPS,HOLE,OOPS, OOPS, NOP,
/∗ 24 ∗/HOLE, OOPS, OOPS,OOPS,HOLE,NOP,NOP, NOP,
/∗ 32 ∗/NOP,NOP,NOP,NOP,NOP,NOP,NOP,NOP,
/∗ 40 ∗/NOP,NOP,NOP,NOP,HOLE,OOPS,OOPS,NOP,
/∗ 48 ∗/HOLE,OOPS,OOPS,OOPS,HOLE,NOP,NOP, NOP,
/∗ 56 ∗/NOP,NOP,NOP,NOP,NOP,NOP,NOP,NOP,
/∗ 64 ∗/NOP,NOP,NOP,HOLE,OOPS,OOPS,NOP,HOLE,
/∗ 72 ∗/OOPS,OOPS,OOPS,HOLE,SHIFTKEYS+LEFTCTRL,
NOP, NOP,NOP,
/∗ 80 ∗/NOP,NOP,NOP,NOP,NOP,NOP,NOP,NOP,
/∗ 88 ∗/NOP,NOP,HOLE,OOPS,OOPS,NOP,HOLE,OOPS,
/∗ 96 ∗/OOPS,OOPS,HOLE,SHIFTKEYS+LEFTSHIFT,
NOP,NOP,NOP,NOP,
/∗104 ∗/NOP,NOP,NOP,NOP,NOP,NOP,SHIFTKEYS+RIGHTSHIFT,
NOP,
/∗112 ∗/OOPS,OOPS,NOP,HOLE,HOLE,HOLE,HOLE, HOLE,
/∗120 ∗/BUCKYBITS+METABIT,
NOP,BUCKYBITS+METABIT,
HOLE,HOLE,HOLE,HOLE,RESET,
};
 /∗ Index to keymaps for Sun-2 keyboard ∗/
static struct keyboard keyindex_s2 = {
&keytab_s2_lc,
&keytab_s2_uc,
0,
&keytab_s2_ct,
&keytab_s2_up,
0x0000,/∗ Shift bits which stay on with idle keyboard ∗/
0x0000,/∗ Bucky bits which stay on with idle keyboard ∗/
1,77,/∗ abort keys ∗/
};
 /∗ Unshifted keyboard table for "VT100 style" ∗/
 static struct keymap keytab_vt_lc = {
/∗  0 ∗/HOLE,BUCKYBITS+SYSTEMBIT,
HOLE,HOLE,HOLE,HOLE,HOLE, HOLE,
/∗  8 ∗/HOLE, HOLE, STRING+UPARROW,
STRING+DOWNARROW,
STRING+LEFTARROW,
STRING+RIGHTARROW,
HOLE,TF(1),
/∗ 16 ∗/TF(2),TF(3),TF(4),c(’[’),’1’,’2’,’3’,’4’,
/∗ 24 ∗/’5’, ’6’, ’7’,’8’,’9’,’0’,’-’,’=’,
/∗ 32 ∗/’‘’,c(’H’),BUCKYBITS+METABIT,
’7’,’8’,’9’,’-’,’\t’,
/∗ 40 ∗/’q’,’w’,’e’,’r’,’t’,’y’,’u’,’i’,
/∗ 48 ∗/’o’,’p’,’[’,’]’,0x7F,’4’,’5’,’6’,
/∗ 56 ∗/’,’,SHIFTKEYS+LEFTCTRL,
SHIFTKEYS+CAPSLOCK,
’a’,’s’,’d’,’f’,’g’,
/∗ 64 ∗/’h’,’j’,’k’,’l’,’;’,’\”,’\r’,’\\’,
/∗ 72 ∗/’1’,’2’,’3’,NOP,NOSCROLL,
SHIFTKEYS+LEFTSHIFT,
’z’,’x’,
/∗ 80 ∗/’c’,’v’,’b’,’n’,’m’,’,’,’.’,’/’,
/∗ 88 ∗/SHIFTKEYS+RIGHTSHIFT,
’\n’,’0’,HOLE,’.’,’\r’,HOLE,HOLE,
/∗ 96 ∗/HOLE,HOLE,’ ’,HOLE,HOLE,HOLE,HOLE, HOLE,
/∗104 ∗/HOLE,HOLE,HOLE,HOLE,HOLE,HOLE, HOLE, HOLE,
/∗112 ∗/HOLE,HOLE,HOLE,HOLE,HOLE,HOLE, HOLE, HOLE,
/∗120 ∗/HOLE,HOLE,HOLE,HOLE,HOLE,HOLE, HOLE, IDLE,
};
  /∗ Shifted keyboard table for "VT100 style" ∗/
 static struct keymap keytab_vt_uc = {
/∗  0 ∗/HOLE,BUCKYBITS+SYSTEMBIT,
HOLE,HOLE,HOLE,HOLE,HOLE, HOLE,
/∗  8 ∗/HOLE, HOLE, STRING+UPARROW,
STRING+DOWNARROW,
STRING+LEFTARROW,
STRING+RIGHTARROW,
HOLE,TF(1),
/∗ 16 ∗/TF(2),TF(3),TF(4),c(’[’),’!’,’@’,’#’,’$’,
/∗ 24 ∗/’%’, ’^’, ’&’,’∗’,’(’,’)’,’_’,’+’,
/∗ 32 ∗/’~’,c(’H’),BUCKYBITS+METABIT,
’7’,’8’,’9’,’-’,’\t’,
/∗ 40 ∗/’Q’,’W’,’E’,’R’,’T’,’Y’,’U’,’I’,
/∗ 48 ∗/’O’,’P’,’{’,’}’,0x7F,’4’,’5’,’6’,
/∗ 56 ∗/’,’,SHIFTKEYS+LEFTCTRL,
SHIFTKEYS+CAPSLOCK,
’A’,’S’,’D’,’F’,’G’,
/∗ 64 ∗/’H’,’J’,’K’,’L’,’:’,’"’,’\r’,’|’,
/∗ 72 ∗/’1’,’2’,’3’,NOP,NOSCROLL,
SHIFTKEYS+LEFTSHIFT,
’Z’,’X’,
/∗ 80 ∗/’C’,’V’,’B’,’N’,’M’,’<’,’>’,’?’,
/∗ 88 ∗/SHIFTKEYS+RIGHTSHIFT,
’\n’,’0’,HOLE,’.’,’\r’,HOLE,HOLE,
/∗ 96 ∗/HOLE,HOLE,’ ’,HOLE,HOLE,HOLE,HOLE, HOLE,
/∗104 ∗/HOLE,HOLE,HOLE,HOLE,HOLE,HOLE, HOLE, HOLE,
/∗112 ∗/HOLE,HOLE,HOLE,HOLE,HOLE,HOLE, HOLE, HOLE,
/∗120 ∗/HOLE,HOLE,HOLE,HOLE,HOLE,HOLE, HOLE, IDLE,
};
 /∗ Caps Locked keyboard table for "VT100 style" ∗/
 static struct keymap keytab_vt_cl = {
/∗  0 ∗/HOLE,BUCKYBITS+SYSTEMBIT,
HOLE,HOLE,HOLE,HOLE,HOLE, HOLE,
/∗  8 ∗/HOLE, HOLE, STRING+UPARROW,
STRING+DOWNARROW,
STRING+LEFTARROW,
STRING+RIGHTARROW,
HOLE,TF(1),
/∗ 16 ∗/TF(2),TF(3),TF(4),c(’[’),’1’,’2’,’3’,’4’,
/∗ 24 ∗/’5’, ’6’, ’7’,’8’,’9’,’0’,’-’,’=’,
/∗ 32 ∗/’‘’,c(’H’),BUCKYBITS+METABIT,
’7’,’8’,’9’,’-’,’\t’,
/∗ 40 ∗/’Q’,’W’,’E’,’R’,’T’,’Y’,’U’,’I’,
/∗ 48 ∗/’O’,’P’,’[’,’]’,0x7F,’4’,’5’,’6’,
/∗ 56 ∗/’,’,SHIFTKEYS+LEFTCTRL,
SHIFTKEYS+CAPSLOCK,
’A’,’S’,’D’,’F’,’G’,
/∗ 64 ∗/’H’,’J’,’K’,’L’,’;’,’\”,’\r’,’\\’,
/∗ 72 ∗/’1’,’2’,’3’,NOP,NOSCROLL,
SHIFTKEYS+LEFTSHIFT,
’Z’,’X’,
/∗ 80 ∗/’C’,’V’,’B’,’N’,’M’,’,’,’.’,’/’,
/∗ 88 ∗/SHIFTKEYS+RIGHTSHIFT,
’\n’,’0’,HOLE,’.’,’\r’,HOLE,HOLE,
/∗ 96 ∗/HOLE,HOLE,’ ’,HOLE,HOLE,HOLE,HOLE, HOLE,
/∗104 ∗/HOLE,HOLE,HOLE,HOLE,HOLE,HOLE, HOLE, HOLE,
/∗112 ∗/HOLE,HOLE,HOLE,HOLE,HOLE,HOLE, HOLE, HOLE,
/∗120 ∗/HOLE,HOLE,HOLE,HOLE,HOLE,HOLE, HOLE, IDLE,
};
 /∗ Controlled keyboard table for "VT100 style" ∗/
 static struct keymap keytab_vt_ct = {
/∗  0 ∗/HOLE,BUCKYBITS+SYSTEMBIT,
HOLE,HOLE,HOLE,HOLE,HOLE, HOLE,
/∗  8 ∗/HOLE, HOLE, STRING+UPARROW,
STRING+DOWNARROW,
STRING+LEFTARROW,
STRING+RIGHTARROW,
HOLE,TF(1),
/∗ 16 ∗/TF(2),TF(3),TF(4),c(’[’),’1’,c(’@’),’3’,’4’,
/∗ 24 ∗/’5’,c(’^’),’7’,’8’,’9’,’0’,c(’_’),’=’,
/∗ 32 ∗/c(’^’),c(’H’),BUCKYBITS+METABIT,
’7’,’8’,’9’,’-’,’\t’,
/∗ 40 ∗/CTRLQ,c(’W’),c(’E’),c(’R’),c(’T’),c(’Y’),c(’U’),c(’I’),
/∗ 48 ∗/c(’O’),c(’P’),c(’[’),c(’]’),0x7F,’4’,’5’,’6’,
/∗ 56 ∗/’,’,SHIFTKEYS+LEFTCTRL,
SHIFTKEYS+CAPSLOCK,
c(’A’),CTRLS,c(’D’),c(’F’),c(’G’),
/∗ 64 ∗/c(’H’),c(’J’),c(’K’),c(’L’),’:’,’"’,’\r’,c(’\\’),
/∗ 72 ∗/’1’,’2’,’3’,NOP,NOSCROLL,
SHIFTKEYS+LEFTSHIFT,
c(’Z’),c(’X’),
/∗ 80 ∗/c(’C’),c(’V’),c(’B’),c(’N’),c(’M’),’,’,’.’,c(’_’),
/∗ 88 ∗/SHIFTKEYS+RIGHTSHIFT,
’\n’,’0’,HOLE,’.’,’\r’,HOLE,HOLE,
/∗ 96 ∗/HOLE,HOLE,c(’ ’),HOLE,HOLE,HOLE,HOLE, HOLE,
/∗104 ∗/HOLE,HOLE,HOLE,HOLE,HOLE,HOLE, HOLE, HOLE,
/∗112 ∗/HOLE,HOLE,HOLE,HOLE,HOLE,HOLE, HOLE, HOLE,
/∗120 ∗/HOLE,HOLE,HOLE,HOLE,HOLE,HOLE, HOLE, IDLE,
};
  /∗ "Key up" keyboard table for "VT100 style" ∗/
 static struct keymap keytab_vt_up = {
/∗  0 ∗/HOLE,BUCKYBITS+SYSTEMBIT,
HOLE,HOLE,HOLE,HOLE,HOLE, HOLE,
/∗  8 ∗/HOLE, HOLE, NOP,NOP,NOP,NOP,HOLE,NOP,
/∗ 16 ∗/NOP,NOP,NOP,NOP,NOP,NOP,NOP,NOP,
/∗ 24 ∗/NOP, NOP, NOP,NOP,NOP,NOP,NOP,NOP,
/∗ 32 ∗/NOP,NOP,BUCKYBITS+METABIT,
NOP,NOP,NOP,NOP,NOP,
/∗ 40 ∗/NOP,NOP,NOP,NOP,NOP,NOP,NOP,NOP,
/∗ 48 ∗/NOP,NOP,NOP,NOP,NOP,NOP,NOP,NOP,
/∗ 56 ∗/NOP,SHIFTKEYS+LEFTCTRL,
SHIFTKEYS+CAPSLOCK,
NOP,NOP,NOP,NOP,NOP,
/∗ 64 ∗/NOP,NOP,NOP,NOP,NOP,NOP,NOP,NOP,
/∗ 72 ∗/NOP,NOP,NOP,NOP,NOP,SHIFTKEYS+LEFTSHIFT,
NOP,NOP,
/∗ 80 ∗/NOP,NOP,NOP,NOP,NOP,NOP,NOP,NOP,
/∗ 88 ∗/SHIFTKEYS+RIGHTSHIFT,
NOP,NOP,HOLE,NOP,NOP,HOLE,HOLE,
/∗ 96 ∗/HOLE,HOLE,NOP,HOLE,HOLE,HOLE,HOLE, HOLE,
/∗104 ∗/HOLE,HOLE,HOLE,HOLE,HOLE,HOLE, HOLE, HOLE,
/∗112 ∗/HOLE,HOLE,HOLE,HOLE,HOLE,HOLE, HOLE, HOLE,
/∗120 ∗/HOLE,HOLE,HOLE,HOLE,HOLE,HOLE, HOLE, RESET,
};
  /∗ Index to keymaps for "VT100 style" keyboard ∗/
static struct keyboard keyindex_vt = {
&keytab_vt_lc,
&keytab_vt_uc,
&keytab_vt_cl,
&keytab_vt_ct,
&keytab_vt_up,
CAPSMASK+CTLSMASK, /∗ Shift keys that stay on at idle keyboard ∗/
0x0000,/∗ Bucky bits that stay on at idle keyboard ∗/
1,59,/∗ abort keys ∗/
};
 /∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗/
/∗   Index table for the whole shebang   ∗/
/∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗/
int nkeytables = 3;/∗ max 16 ∗/
struct keyboard ∗keytables[] = {
&keyindex_ms,
&keyindex_vt,
&keyindex_s2,
};
 /∗
Keyboard String Table
  This defines the strings sent by various keys (as selected in the
tables above).
∗/
 #definekstescinit(c){’\033’, ’[’, ’c’, ’\0’}
char keystringtab[16][KTAB_STRLEN] = {
kstescinit(H) /∗home∗/,
kstescinit(A) /∗up∗/,
kstescinit(B) /∗down∗/,
kstescinit(D) /∗left∗/,
kstescinit(C) /∗right∗/,
};

SEE ALSO

cons(4S)

BUGS

This keyboard translation implementation is essentially the PROM monitor mechanism moved into the kernel.  It will almost certainly be reworked in the future to take advantage of the greater flexibility available to the kernel that was not available in the PROM. 

Sun Release 1.1  —  Last change: 19 March 1984

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