-- File: KeyDefs.Mesa  Modified by: Sandman, March 21, 1978  3:42 PM
-- Copyright  Xerox Corporation 1979, 1980

KeyDefs: DEFINITIONS =
  BEGIN

  updown: TYPE = {down, up};

  KeyArray: TYPE = ARRAY [0..5) OF WORD;

  KeyBits: TYPE = MACHINE DEPENDENT RECORD [
    blank: [0..377B],
    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 = LOOPHOLE[177033B];

  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]; -- 0=> down, normal is 7B = MouseButton[None]

  Mouse: POINTER TO MouseBits = LOOPHOLE[Keys];

  KeyName: TYPE = {
    x0, x1, x2, x3, x4, x5, x6, x7, 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 can be 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]];

  ChangeKey: PROCEDURE [key: KeyName, action: KeyItem]
    RETURNS [oldAction: KeyItem];

  Keyboard: PROGRAM;
  KeyStreams: PROGRAM;

  END.