home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / msdos / misc2 / dialv23.lzh / KEYBOARD.INC < prev    next >
Text File  |  1985-08-03  |  3KB  |  92 lines

  1.  
  2. {********* This file is an "include" file to be used with DIAL.PAS. *********}
  3.  
  4.  
  5. Function Level2Key : Boolean;
  6. {
  7. This uses level 2 console in calls to get input characters You should  NOT  mix
  8. Level  2  inputs  with the above ReadKey inputs, as you'll screw up the level 2
  9. key buffer.  This routine is only  included  to  clear  the  level  2  keyboard
  10. buffer.
  11. }
  12. Var
  13.   InString : Str80;
  14.   Regs     : Register_Set;
  15. Begin
  16.   InString := '';
  17.   Regs.CX := 0;
  18.   Regs.DI := 2;
  19.   Intr(24,Regs);
  20.   If Regs.CL = Successful Then
  21.     Begin
  22.       Level2Key := True;
  23.       InString := CHR(Regs.AL);
  24.     End
  25.   Else Level2Key := False;
  26. End; {Function Level2Key}
  27.  
  28.  
  29. Procedure ClearLevel2Buffer;
  30. {
  31. To clear the level 2 keyboard input buffer, we'll read the  level  2  buffer
  32. until  it's  empty;  or  until  we've  read  a  ridulously  large  number of
  33. characters.
  34. }
  35. Var
  36.   cntr : Integer;
  37. Begin
  38.   cntr := 0;
  39.   While (Level2Key) And (cntr < 255) Do Begin cntr := cntr + 1; End;
  40. End; {Procedure ClearLevel2Buffer}
  41.  
  42.  
  43. Function Level1Key: Integer;
  44. {
  45. Read a character via the level 1 capability of the Rainbow.  Don't return until
  46. we have a character.  Return with the character value as function value and
  47. possible global booleans set for shift, control, function, and caps lock set.
  48. }
  49. Const
  50.   No_Char_Ready      = 0;
  51.   Lvl2_In_Progress   = 1;
  52.   Char_Entered       = 255;
  53. Var
  54.   ch                : char;
  55.   rc                : integer;
  56.   char_ready        : boolean;
  57.   regs              : Register_Set;
  58. Begin
  59.   char_ready := false;
  60.   Repeat
  61.     Begin
  62.       lv1_fnc   := false;     {say none of these are true yet}
  63.       lv1_shft  := false;
  64.       lv1_ctrl  := false;
  65.       lv1_caps  := false;
  66.       With regs do
  67.         Begin
  68.           ax := 0;            {clear where results are returned}
  69.           cx := 0;
  70.           di := 6;            {level 1 input}
  71.         End;
  72.       Intr(24,Regs);          {get a character maybe}
  73.       Case (regs.cx and $00ff) of
  74.         No_Char_Ready:    Begin
  75.                           End;
  76.         Lvl2_In_Progress: ClearLevel2Buffer;
  77.         Char_Entered:     Begin
  78.                             rc := (regs.ax and $ff);
  79.                             if ((regs.ax and $0100) <> 0) then lv1_fnc  := true;
  80.                             if ((regs.ax and $0200) <> 0) then lv1_shft := true;
  81.                             if ((regs.ax and $0400) <> 0) then lv1_ctrl := true;
  82.                             if ((regs.ax and $0800) <> 0) then lv1_caps := true;
  83.                             char_ready := true;
  84.                           End;
  85.         Else              Begin             {i don't understand}
  86.                           End;
  87.       End;
  88.     End;
  89.   Until char_ready;
  90.   Level1Key := RC;
  91. End; {Function Level1Key}
  92.