/*
 *  wKeys.h    Structure definitions for wKeys program, which moves
 *             and activates windows and screens via keystrokes.
 *
 *             Copyright (c) 1987 by Davide P. Cervone
 *  You may use this code provided this copyright notice is left intact.
 */


/*
 *  HotKey is the structure that holds the information needed to bind a
 *  key to a function.  Each HotKey is a pair of longwords, the first
 *  represents a combination of the key-code and qualifier mask for the
 *  key to be bound to a function.  Using a single longword for this makes
 *  it easy to compare against the currently pressed key.
 *
 *  The second longword represents the qualifier mask that specifies the 
 *  qualifier flags that are important to distinguish this key binding from
 *  other bindings with the same scan-code but different qualifiers.  It is
 *  the logical OR of all the qualifiers used by any key definition with
 *  the same scan-code as this one.  This longword contains 0xFF in the 
 *  same position where the first one has the scan-code, so ANDing this mask
 *  against a KeyCode longword does not mask out the key code.
 *
 *  The second longword also contains a byte that represents the action that
 *  the key will perform when it is pressed.
 */

struct HotKey
{
   union
   {
      struct
      {
         UBYTE Code;                /* the InputEvent ie_Code field */
         UBYTE Flags;               /* SHIFT, AMIGA, and ALT (0 otherwise) */
         UWORD Qualifiers;          /* the InputEvent ie_Qualfiers field */
      } PartCode;
      long FullCode;                /* KeyCode longword */
   } Key;
   union
   {
      struct
      {
         UBYTE FF;                  /* always 0xFF */
         UBYTE Action;              /* the action to be performed by this key */
         UWORD Mask;                /* the qualifier mask */
      } PartMask;
      long FullMask;                /* the KeyMask longword */
   } Mask;
};

#define hk_Code     Key.PartCode.Code
#define hk_Flags    Key.PartCode.Flags
#define hk_Qual     Key.PartCode.Qualifiers
#define hk_KeyCode  Key.FullCode
#define hk_FF       Mask.PartMask.FF
#define hk_Action   Mask.PartMask.Action
#define hk_Mask     Mask.PartMask.Mask
#define hk_KeyMask  Mask.FullMask


/*
 *  This is the structure used in the linked list when building the key
 *  definition array.  It is the same as a HotKey except it contains pointers
 *  to the next and previous items so that it can be sorted by mSort().
 */

struct HotKeyItem
{
   struct HotKeyItem *Next;
   struct HotKeyItem *Prev;
   struct HotKey HotKey;
};

#define hki_Code     HotKey.hk_Code
#define hki_Flags    HotKey.hk_Flags
#define hki_Qual     HotKey.hk_Qual
#define hki_KeyCode  HotKey.hk_KeyCode
#define hki_FF       HotKey.hk_FF
#define hki_Action   HotKey.hk_Action
#define hki_Mask     HotKey.hk_Mask
#define hki_KeyMask  HotKey.hk_KeyMask


/*
 *  These are the actions that can be perfomed.  They must correspond to the
 *  Action[] array in the input handler.  You can add functions to the end
 *  of this list provided you add them into the Action[] array in 
 *  wKeys-Handler.c, and the Action[] array in BindWKeys.c.
 */

#define SCREENTOFRONT     1
#define SCREENTOBACK      2
#define ACTIVATEPREVIOUS  3
#define ACTIVATENEXT      4
#define WINDOWTOBACK      5
#define WINDOWTOFRONT     6
#define BACKTOFRONT       7
#define FRONTTOBACK       8

#define KEYCODE(qual,key)       (((key)<<24)|(qual))
#define KEY(e)                  KEYCODE((e)->ie_Qualifier,(e)->ie_Code)
