Page Numbers: Yes First Page: 32 X: 527 Y: 10.5"
Margins: Binding: 13
Odd Heading: Not-on-first-page
Alto/Mesa Keyboard Package
Even Heading:
Alto/Mesa Keyboard Package
Alto/Mesa Keyboard Package
October 1980
The Keyboard package consists of the modules KeyStreams and Keyboard; it provides a Teletype style interface to the undecoded keyboard through a device independent stream interface. Multiple, independent keyboard streams are supported. A default keyboard stream is created at initialization time. (See the section on StreamIO for higher level operations.) The Keyboard Package also optionally causes the hardware cursor to track the mouse. A single keyboard process runs at interrupt level approximately 60 times per second to sample the keyboard hardware.
The following procedures and types are defined in StreamDefs.
KeyboardHandle: TYPE = POINTER TO Keyboard StreamObject;
The standard operations on a keyboard stream are:
reset[s]
Clears the buffer associated with s; any characters in the buffer are lost.
get[s]
Returns the next character in the buffer; if endof[s] is TRUE, WAITs until it is FALSE.
putback[s, i]
Modifies the stream so that the next get[s] will return i, independent of any type-ahead. If the buffer is full, putback is a no-op (sorry about that).
put[s, i]
Produces a StreamAccess error.
endof[s]
TRUE if there are no characters in the buffer.
destroy[s]
Destroys s in an orderly way, freeing the space it occupies. Any characters in the buffer at the time of the destroy are lost. If s is the current keystream, the StreamOperation error results.
Other keyboard-related operations include:
CreateKeyStream: PROCEDURE RETURNS [KeyboardHandle];
Creates a new keyboard stream. Any number of streams may be created. Each stream has its own buffer for type ahead. (Space for the StreamObject is allocated from the system heap.)
GetDefaultKey: PROCEDURE RETURNS [KeyboardHandle];
Returns the default stream (created at initialization time).
GetCurrentKey: PROCEDURE RETURNS [KeyboardHandle];
Returns the current stream. Initially the default keyboard stream is current.
OpenKeyStream: PROCEDURE [stream: StreamHandle];
Makes stream the current keyboard stream. The stream which was current before the call is undisturbed, except that input characters are no longer directed to it by the keyboard process, but to stream instead.
CloseKeyStream: PROCEDURE [stream: StreamHandle];
Makes the default keyboard stream current. Characters already typed remain in stream’s buffer. The StreamOperation error results if stream is not the current stream.
trackCursor: BOOLEAN;
Setting the variable to TRUE enables cursor tracking; FALSE disables it. When tracking is enabled, the mouse coordinates are copied to the cursor coordinates each time the keyboard process runs.
CursorTrack: PROCEDURE [b: BOOLEAN] = INLINE {trackCursor ← b};
Provided for compatibility.
Low Level Access
The basic system does not provide access to the keyset or mouse through the stream. Definitions are provided for clients wishing to access the bits of the keyboard directly or to change the interpretation of any of the keys. The module KeyDefs defines types and procedures for lower level access to the keyboard hardware.
updown: TYPE = {down, up};
KeyBits: TYPE = MACHINE DEPENDENT RECORD [
blank: [0..377B],
-- not used
Keyset1, Keyset2, Keyset3, Keyset4, Keyset5: updown,
Red, Blue, Yellow: updown,
Five, Four, Six, E, Seven, D, U, V,
Zero, K, Dash, P, Slash, BackSlash, LF, BS: updown,
Three, Two, W, Q, S, A, Nine, I,
X, O, L, Comma, Quote, RightBracket, Spare2, Spare1: updown,
One, ESC, TAB, F, Ctrl, C, J, B,
Z, LeftShift, Period, SemiColon, Return, Arrow, DEL, FL3: updown,
R, T, G, Y, H, Eight, N, M,
Lock, Space, LeftBracket, Equal, RightShift, Spare3, FL4, FR5: updown];
Keys: POINTER TO KeyBits = -- magic memory location -- ;
MouseButton: TYPE = {RedYellowBlue, RedBlue, RedYellow, Red, BlueYellow, Blue, Yellow, None};
MouseBits: TYPE = MACHINE DEPENDENT RECORD [
blank: [0..377B],
-- Diablo, Versatec, etc.
keyset: [0..37B],
-- 0 => down, i.e. normal state is 37B
buttons: MouseButton];
Mouse: POINTER TO MouseBits = -- magic memory location -- ;
KeyName: TYPE = {
. . . ,
-- unused values
Keyset1, Keyset2, Keyset3, Keyset4, Keyset5,
Red, Blue, Yellow,
Five, Four, Six, E, Seven, D, U, V,
Zero, K, Dash, P, Slash, BackSlash, LF, BS,
Three, Two, W, Q, S, A, Nine, I,
X, O, L, Comma, Quote, RightBracket, Spare2, Spare1,
One, ESC, TAB, F, Ctrl, C, J, B,
Z, LeftShift, Period, SemiColon, Return, Arrow, DEL, FL3,
R, T, G, Y, H, Eight, N, M,
Lock, Space, LeftBracket, Equal, RightShift, Spare3, FL4, FR5};
Alto II names for some keys are different.
FL1: KeyName = DEL;
FL2: KeyName = LF;
BW: KeyName = Spare1;
FR1: KeyName = Spare3;
FR2: KeyName = BackSlash;
FR3: KeyName = Arrow;
FR4: KeyName = Spare2;
KeyItem: TYPE = RECORD [
Letter:
BOOLEAN,
ShiftCode: [0..177B],
NormalCode: [0..377B]];
There is a KeyItem for every key (including mouse and keyset keys). A NormalCode = 0 causes the key to be ignored; a ShiftCode = 0 puts in a zero for the key when the shift key is down; Letter means that the ShiftCode is selected by the shift lock key. Note that the ShiftCode is 7 bits and the NormalCode is 8 bits.
ChangeKey: PROCEDURE [key: KeyName, action: KeyItem]
RETURNS [oldAction: KeyItem];
This procedure changes the meaning of a key and returns the old value.
Destruction
Clients of Mesa who wish to provide their own keyboard procedures may delete the standard keyboard handler by calling:
DestroyKeyHandler: PROCEDURE;
It destroys the keyboard PROCESS and UNNEWs all the keyboard modules.