home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff344.lzh / Keyboard / Keyboard.def < prev    next >
Text File  |  1990-04-14  |  4KB  |  104 lines

  1. DEFINITION MODULE Keyboard;
  2. (*******************************************************************************
  3. Name         : Keyboard.DEF
  4. Version      : 1.0
  5. Purpose      : Enables access to RAWKEY events via Intuition.
  6. Author       : PGE
  7. Date Started : 12/MAR/90.
  8. Date Complete: 18/MAR/90.
  9. Modified     : 25/MAR/90.added further comments
  10. *******************************************************************************)
  11.  
  12. FROM ConsoleDevice IMPORT KeyMapPtr;
  13. FROM Intuition     IMPORT IntuiMessagePtr;
  14.  
  15. CONST
  16.   NullChar  = 0C;
  17.   bs        = 10C;    (* back space *)
  18.   lf        = 12C;    (* line feed *)
  19.   vt        = 13C;    (* vertical tab *) (* RETURN key or ENTER key on
  20.                                          the Amiga *)
  21.   ff        = 14C;    (* form feed *)
  22.   cr        = 15C;    (* carriage return *)
  23.   esc       = 33C;    (* escape *)
  24.   space     = 40C;
  25.   asterix   = 52C;
  26.   comma     = ",";
  27.   minus     = 55C;    (* - *)
  28.   dot       = 56C;    (* . *)
  29.   colon     = 72C;    (* : *)
  30.   underscore= "_";
  31.   vert      = 174C;   (* | *)
  32.   del       = 177C;   (* delete *)
  33.   CSI       = 233C;
  34.  
  35. (* KeyID may be one of the following *)
  36.   KUP       = 301;   (* Arrow keys *)
  37.   KDOWN     = 302;
  38.   KRIGHT    = 303;
  39.   KLEFT     = 304;
  40.   KSUP      = 305;   (* Shifted arrow keys *)
  41.   KSDOWN    = 306;
  42.   KSRIGHT   = 307;
  43.   KSLEFT    = 308;
  44.   KHELP     = 309;   (* Help key *)
  45.   KF1       = 331;   (* Function keys F1-F10 *)
  46.   KF2       = 332;
  47.   KF3       = 333;
  48.   KF4       = 334;
  49.   KF5       = 335;
  50.   KF6       = 336;
  51.   KF7       = 337;
  52.   KF8       = 338;
  53.   KF9       = 339;
  54.   KF10      = 340;
  55.   KSF1      = 341;   (* Shifted function keys F1-F10 *)
  56.   KSF2      = 342;
  57.   KSF3      = 343;
  58.   KSF4      = 344;
  59.   KSF5      = 345;
  60.   KSF6      = 346;
  61.   KSF7      = 347;
  62.   KSF8      = 348;
  63.   KSF9      = 349;
  64.   KSF10     = 350;
  65.  
  66. PROCEDURE OpenKey() : INTEGER;
  67. (* Before reading RAWKEYs from Intuition we have to do some housekeeping.
  68.    This procedure gets a pointer to the Console Device by opening a
  69. Console Device without attaching it to any window. Its purpose is to
  70. make the Console Device function RawKeyConvert available.
  71.    The procedure returns 0 if it succeeds, -1 if it failed. *)
  72.  
  73. PROCEDURE CloseKey;
  74. (* After doing all our key reading we have to do some final housekeeping.
  75.    This procedure closes the Console Device opened by RawOpen.
  76.    If the Console Device was not successfully opened RawClose will
  77. return without doing anything. *)
  78.  
  79. PROCEDURE ReadKey(VAR KeyMessage : IntuiMessagePtr; (* in  *)
  80.                   VAR KeyID      : INTEGER;         (* out *)
  81.                   VAR KeyMap     : KeyMapPtr        (* in  *) ) : INTEGER;
  82. (* This routine will return the key that was pressed on the keyboard
  83. taking into account so called deadkeys and the key map being used, such
  84. as a German keyboard.
  85.  
  86.    Pass it KeyMessage - obtained from a GetMsg
  87.            KeyID      - not passed anything
  88.            KeyMap     - when set to NULL the routine will do its
  89.                         translation on the default key map. (The routine
  90.                         has not been tested for non NULL values.)
  91.    When it has returned
  92.            KeyMessage         - not used
  93.            KeyID              - only used when the function procedure is 0.
  94.                                 See constant definitions for values.
  95.            KeyMap             - not used
  96.            function procedure -  0     A special key was pressed, so look
  97.                                        at KeyID for its value
  98.                                 -1     routine has failed
  99.                                 -2     either a key up message or it was
  100.                                        not a raw key
  101.                                 1,2..  ASCII character      *)
  102.  
  103. END Keyboard.
  104.