home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pmos2002.zip / DEF / keyboard.def < prev    next >
Text File  |  1997-12-19  |  4KB  |  83 lines

  1. DEFINITION MODULE Keyboard;
  2.  
  3.         (************************************************)
  4.         (*                                              *)
  5.         (*      Module to deal with keyboard input.     *)
  6.         (*                                              *)
  7.         (*  Programmer:         P. Moylan               *)
  8.         (*  Last edited:        19 December 1997        *)
  9.         (*  Status:             OK                      *)
  10.         (*                                              *)
  11.         (************************************************)
  12.  
  13. FROM Semaphores IMPORT
  14.     (* type *)  Semaphore;
  15.  
  16. PROCEDURE KeyPressed(): BOOLEAN;
  17.  
  18.     (* Returns TRUE iff a character is available. *)
  19.  
  20. PROCEDURE InKey (): CHAR;
  21.  
  22.     (* Reads a single character code from the keyboard. *)
  23.  
  24. PROCEDURE PutBack (ch: CHAR);
  25.  
  26.     (* This is an "un-read" operation, i.e. the character ch will       *)
  27.     (* re-appear on the next call to InKey.  This facility is provided  *)
  28.     (* for the use of software which can overshoot by one character     *)
  29.     (* when reading its input - a situation which can often occur.      *)
  30.     (* Some versions of this module will allow several calls to PutBack *)
  31.     (* before the next call to InKey, but no guarantee is made in that  *)
  32.     (* case of uniform treatment from version to version.               *)
  33.  
  34. PROCEDURE StuffKeyboardBuffer (ch: CHAR);
  35.  
  36.     (* Stores ch as if it had come from the keyboard, so that a         *)
  37.     (* subsequent InKey() will pick it up.                              *)
  38.  
  39.     (* NOTE: Procedures PutBack and StuffKeyboardBuffer do almost the   *)
  40.     (* same thing, but not quite.  The differences are:                 *)
  41.     (*  1. StuffKeyboardBuffer stores characters in a first-in-first-out*)
  42.     (*     order, whereas PutBack uses last-in-first-out.               *)
  43.     (*  2. StuffKeyboardBuffer is intended for the case of a task       *)
  44.     (*     sending data to another task (where that other task is       *)
  45.     (*     expecting keyboard input), and PutBack is designed for the   *)
  46.     (*     case of a task talking to itself (i.e. the PutBack(ch) and   *)
  47.     (*     the InKey() are in the same task).  If you get this the      *)
  48.     (*     wrong way around then you could have timing-related          *)
  49.     (*     problems, up to and including deadlock.                      *)
  50.  
  51. PROCEDURE StuffKeyboardBuffer2 (ch: CHAR);
  52.  
  53.     (* Like StuffKeyboardBuffer, but stores a two-byte sequence: Nul    *)
  54.     (* followed by ch.                                                  *)
  55.  
  56. PROCEDURE SetLocks (code: CARDINAL);
  57.  
  58.     (* Set/clear the caps lock, num lock, and scroll lock conditions.   *)
  59.     (* The code is defined in KBDRIVER.DEF.                             *)
  60.  
  61. PROCEDURE LockStatus (): CARDINAL;
  62.  
  63.     (* Returns the current state of the caps lock, num lock, and scroll *)
  64.     (* lock conditions, using the code defined in KBDRIVER.DEF.         *)
  65.  
  66. PROCEDURE HotKey (FunctionKey: BOOLEAN;  code: CHAR;  S: Semaphore);
  67.  
  68.     (* After this procedure is called, typing the key combination for   *)
  69.     (* 'code' will cause a Signal(S).  Set FunctionKey=TRUE to trap one *)
  70.     (* of the two-character special function keys, and FALSE otherwise. *)
  71.     (* The character is consumed; if it should be passed on, then the   *)
  72.     (* user's hot key handler can do a PutBack().  Note: there is no    *)
  73.     (* provision for having multiple hot key handlers for the same key; *)
  74.     (* any existing hot key mapping will be overridden.                 *)
  75.  
  76. PROCEDURE NotDetached(): BOOLEAN;
  77.  
  78.     (* Returns TRUE unless called by a process running detached.        *)
  79.     (* (A detached process may not do keyboard, screen, or mouse I/O.)  *)
  80.  
  81. END Keyboard.
  82.  
  83.