1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. package Keyboard is 
  10.  
  11.     pragma Pure; 
  12.  
  13.     -- Represents special keys used to modify key presses or mouse clicks 
  14.     type Modifiers_Type is (ALT, CTRL, SHIFT, CMD); 
  15.     type Modifiers_Array is array (Modifiers_Type) of Boolean; 
  16.  
  17.     -- A Modifiers_Array value with no modifiers set 
  18.     MODIFIERS_NONE : constant Modifiers_Array := Modifiers_Array'(others=>False); 
  19.  
  20.     -- Returns True if all modifiers in 'l' and 'r' match exactly. 
  21.     function "="( l, r : Modifiers_Array ) return Boolean; 
  22.  
  23.     -- Returns True if no modifiers are set. 
  24.     function None( mods : Modifiers_Array ) return Boolean; 
  25.  
  26.     -- Returns True if only the Alt modifier is set. 
  27.     function Only_Alt( mods : Modifiers_Array ) return Boolean; 
  28.  
  29.     -- Returns True if only the Ctrl modifier is set. 
  30.     function Only_Ctrl( mods : Modifiers_Array ) return Boolean; 
  31.  
  32.     -- Returns True if only the Shift modifier is set. 
  33.     function Only_Shift( mods : Modifiers_Array ) return Boolean; 
  34.  
  35.     -- Returns True if only the Command modifier is set. 
  36.     function Only_Cmd( mods : Modifiers_Array ) return Boolean; 
  37.  
  38.     ---------------------------------------------------------------------------- 
  39.  
  40.     -- Represents a trinary logic value, where the third value is undefined. 
  41.     type Trillian is (Yes, No, Either); 
  42.  
  43.     -- Returns True if 'l' and 'r' match or if 'r' is Either. 
  44.     function "="( l : Boolean; r : Trillian ) return Boolean; 
  45.  
  46.     -- Returns True if 'l' and 'r' match or if 'l' is Either. 
  47.     function "="( l : Trillian; r : Boolean ) return Boolean; 
  48.  
  49.     ---------------------------------------------------------------------------- 
  50.  
  51.     -- An array of trinary modifier states- on, off, either. A Modifiers_Pattern 
  52.     -- value is used to match a Modifiers_Array by setting definite values for 
  53.     -- the modifiers you want to match, and using the Either value to match 
  54.     -- anything else. 
  55.     type Modifiers_Pattern is array (Modifiers_Type) of Trillian; 
  56.  
  57.     -- All modifiers with a value of Either: this will match any Modifiers_Array. 
  58.     MODIFIERS_ANY : constant Modifiers_Pattern := Modifiers_Pattern'(others=>Either); 
  59.  
  60.     -- Returns True if the pattern in 'r' matches the definite state in 'l'. 
  61.     function "="( l : Modifiers_Array; r : Modifiers_Pattern ) return Boolean; 
  62.  
  63.     -- Returns True if the pattern in 'l' matches the definite state in 'r'. 
  64.     function "="( l : Modifiers_Pattern; r : Modifiers_Array ) return Boolean; 
  65.  
  66. end Keyboard;