Text preview for : Keyboard.mesa_Oct77.pdf part of xerox Keyboard.mesa Oct77 xerox mesa 3.0_1977 listing Keyboard.mesa_Oct77.pdf



Back to : Keyboard.mesa_Oct77.pdf | Home

keybOARD. mESA 24-0CT-77 18: 30: 50 Page 1


-- Keyboard.Mesa Edited by Johnsson on September 22, 1977 8:18 AM
DIRECTORY
KeyDefs: FROM "keydefs",
Mopcodes: FROM "mopcodes",
StreamDefs: FROM "streamdefs",
InlineDefs: FROM "inlinedefs",
ControlDefs: FROM "controldefs",
ProcessDofs: FROM "processdefs":
DEFINITIONS FROM ProcessDefs. InlineDefs. KeyDefs. StreamOefs;
Keyboard: PROGRAM IMPORTS StreamDefs SHARES ProcessDefs. StreamDefs
BEGIN
-- variables set by KeyStreams
ks: PUBLIC KeyboardHandle;
COT: PUBLIC BOOLEAN;
cursorTracking: PUBLIC BOOLEAN;
IdleProc: PUBLIC PROCEDURE;
KeyTable: PUBLIC POINTER TO ARRAY [0 .. 80) OF KeyItem;
-- The Keyboard part:
-- fixed addresses for keyboard and mouse
Keys: POINTER TO KeyArray ~ LOOPHOLE[KeyDefs.Keys];
Coordinate: TYPE = RECORD [x.y: INTEGER];
Mouse: POINTER TO Coordinate ~ LOOPHOLE[424B]:
Cursor: POINTER TO Coordinate ~ LOOPHOLE[426B];
Xmax: CARDINAL = 606-16:
Ymax: CARDINAL = 808-16;
ns. os: KeyArray;
OldState: PUBLIC POINTER TO KeyArray = @os;
NewState: POINTER TO KeyArray = @ns:
GetDebugger: MACHINE CODE = INLINE [Mopcodes.zKFCB. ControlOefs.sInterrupt];
ProcessKeyboard: PUBLIC PROCEDURE
BEGIN
bitcount. start: [0 .. 15];
char: [0 .. 377B];
entry: Keyltem;
i: [O .. SIZE[KeyArray]);
interruptS tate: updown ~ up:
new in: CARDINAL;
ph: Processllandle;
pp: ProcessPriority;
StateWord: WORD:
stroke: POINTER TO KeyBits LOOPHOLE[NewState];
DO
first update the cursor
IF cursorTracking THEN
BFGIN
Mouse.x ~ Cursor.x ~ MAX[O.MIN[Xmax.Mouse.x]]:
Mouse.y ~ Cursor.y ~ MAX[O.MIN[Ymax.Mouse.y]];
[NO:
NewStatet ~ Keyst;
-- The following code checks for Clrl-Swat. the debugger interrupt keys.
-- This code could be made into a separate process.
IF slroke.Clrl = down AND slroke.Spare3 = down TIIEN
BrGIN
If inlerruptState = up TIIFN
BFGTN
interruplSlate ~ down:
rOR pp OrCRrASING IN ProcessPriority 00
ph ~ PV[pp]:
Ir ph /I ProcessNTL AND ph II NIL AND ph.state. inslbyte /I Mopcodes . .lBRK TIIFN
keybOARD.mESA 24-0CT-77 18:30:60 Page 2


BEGIN
ph.state.instbyte ~ Mopcodes.zBRK:
BLOCK[]: -- try to take breakpoint
IF PV[pp] = ph AND ph.state.instbyte 0 THEN EXIT:
END:
REPEAT FINISHED => GetDebugger[]:
ENDLOOP:
NewState~ ~ Keys~:
END:
END
ELSE interruptState ~ up:
-- The following code checks for down transitions in the keyboard state
-- and enters characters in the current keystream buffer
FOR i IN [0 .. SIZE[KeyArray]) DO
IF (StateWord ~ BITXOR[OldState[i],NewState[i]]) II 0 THEN
BEGIN -- found one or more transitions
start ~ 0:
DO
FOR bitcount IN [start .. 15] DO
IF LOOPHOLE[StateWord,INTEGER] StateWord ~ BITSHIFT[StateWord.l]:
ENDLOOP:
entry ~ KeyTable[i*16 + bitcount]:
IF (char ~ entry.NormalCode) II a
AND BITAND[OldState[i].BITSHIFT[100000B,-bitcount]] # 0 THEN
BEGIN
SELECT updown[down] FROM
stroke.Ctrl =>
IF char = 177B THEN BEGIN COT ~ TRUE: GOTO skip END
ELSE char ~ BITAND[char. 37B]:
stroke.LeftShift, stroke.RightShift =>
char ~ entry.ShiftCode:
stroke. Lock =>
IF entry. Letter THEN char ~ entry.ShiftCode:
ENDCASE:
IF (new'n~ks.in+l) = KeyBufChars THEN newin ~ 0:
IF newin II ks.out THEN
BEGIN
ks.buffer[ks. in] ~ LOOPHOLE[char]:
ks.in~newin;
END:
EXITS skip => NULL:
END:
IF (StateWord ~ BITSHIFT[StateWord,l])=O THEN EXIT:
start ~ bitcount+1:
ENDLOOP:
END:
ENDLOOP:
OldState~ ~ NewState~:
BLOCK[] :
ENDLOOP:
END:
ReadChar: PUBLIC PROCEDURE [stream: StreamHandle] RETURNS [char: UNSPECIFIED] =
BEGIN char ~ 0:
WITII s: stream SELECT FROM
Keyboard =>
DO -- until character typed
IF s. ou t II s. in THEN
BEGIN
char ~ s.buffer[s.out]:
s. ou t ...
IF S.out = KeyBufChars-l
THEN a
ElSE s.out+l:
RnURN
fNO:
IF IdleProcll1 OOPIiOI frO] THfN IdleProc[];
-- BIOCK[]: when scheduler arrives
ENDIOOP;
fNOCAS[ => SIGNAL Slreamfrror[slream.SlreamType]:
RrrURN:
[NO;
InpulBufferfmply: PUBLIC PROC[[)URf [slream:Slreamllandle] RfTURNS [BOOlfAN]
keybOARD.mESA 24-0CT-77 18:30:50 Page 3


BEGIN
WITH s:stream SELECT FROM
Keyboard =) RETURN[s.in = s.out):
ENDCASE =) SIGNAL StreamError[stream,StreamType):
RETURN[ FALSE]:
END:
OldState~ ~ Keys~:


END.