DEFINITION MODULE Keyboard;

(* (C) Copyright 1987 Fitted Software Tools. All rights reserved. *)


(* This module provides an interface to the BIOS keyboard routines.
*)

CONST
      Break = 80X;
      ShiftTab = 81X;
      AltQ = 82X;
      AltW = 83X;
      AltE = 84X;
      AltR = 85X;
      AltT = 86X;
      AltY = 87X;
      AltU = 88X;
      AltI = 89X;
      AltO = 8AX;
      AltP = 8BX;

      AltA = 90X;
      AltS = 91X;
      AltD = 92X;
      AltF = 93X;
      AltG = 94X;
      AltH = 95X;
      AltJ = 96X;
      AltK = 97X;
      AltL = 98X;
 
      AltZ = 09EX;
      AltX = 09FX;
      AltC = 0A0X;
      AltV = 0A1X;
      AltB = 0A2X;
      AltN = 0A3X;
      AltM = 0A4X;

      F1 = 0ADX;
      F2 = 0AEX;
      F3 = 0AFX;
      F4 = 0B0X;
      F5 = 0B1X;
      F6 = 0B2X;
      F7 = 0B3X;
      F8 = 0B4X;
      F9 = 0B5X;
      F10 = 0B6X;
 
      Home = 0B9X;
      Up = 0BAX;
      PgUp = 0BBX;
      Left = 0BDX;
      Right = 0BFX;
      End = 0C1X;
      Down = 0C2X;
      PgDn = 0C3X;
      Ins = 0C4X;
      Del = 0C5X;
 
      SF1 = 0C6X;
      SF2 = 0C7X;
      SF3 = 0C8X;
      SF4 = 0C9X;
      SF5 = 0CAX;
      SF6 = 0CBX;
      SF7 = 0CCX;
      SF8 = 0CDX;
      SF9 = 0CEX;
      SF10 = 0CFX;
      CF1 = 0D0X;
      CF2 = 0D1X;
      CF3 = 0D2X;
      CF4 = 0D3X;
      CF5 = 0D4X;
      CF6 = 0D5X;
      CF7 = 0D6X;
      CF8 = 0D7X;
      CF9 = 0D8X;
      CF10 = 0D9X;
      AF1 = 0DAX;
      AF2 = 0DBX;
      AF3 = 0DCX;
      AF4 = 0DDX;
      AF5 = 0DEX;
      AF6 = 0DFX;
      AF7 = 0E0X;
      AF8 = 0E1X;
      AF9 = 0E2X;
      AF10 = 0E3X;
 
      CtrlPrtSc = 0E4X;
      CtrlLeft = 0E5X;
      CtrlRight = 0E6X;
      CtrlEnd = 0E7X;
      CtrlPgDn = 0E8X;
      CtrlHome = 0E9X;

      Alt1 = 0EAX;
      Alt2 = 0EBX;
      Alt3 = 0ECX;
      Alt4 = 0EDX;
      Alt5 = 0EEX;
      Alt6 = 0EFX;
      Alt7 = 0F0X;
      Alt8 = 0F1X;
      Alt9 = 0F2X;
      Alt0 = 0F3X;
      AltMinus  = 0F4X;
      AltEquals = 0F5X;
 
      CtrlPgUp = 0F6X;


TYPE ShiftKeys   = (rightShift, leftShift, Ctrl, Alt, ScrollLock, NumLock );
     ShiftStatus = SET OF ShiftKeys;


PROCEDURE KeyPressed() :BOOLEAN;
  (*
    Is there a character waiting?
  *)

PROCEDURE GetKey( VAR k :CHAR );
  (*
    Like BASIC INKEY.
    Returns either a character or a 0C and the extended character code
    on the next call.
  *)

PROCEDURE GetKeyCh( VAR ch :CHAR );
  (*
    Extended character codes are remapped into the upper 128 ascii codes
    as by the constants declared above.
  *)
 
PROCEDURE GetShiftStatus( VAR st :ShiftStatus );
  (*
    Gets the status of shift/control keys.
  *)
 

END Keyboard.