/*
    ####             #    #     # #
    #   #            #    #       #          The FreeWare C library for 
    #   #  ##   ###  #  # #     # ###             RISC OS machines
    #   # #  # #     # #  #     # #  #   ___________________________________
    #   # ####  ###  ##   #     # #  #                                      
    #   # #        # # #  #     # #  #    Please refer to the accompanying
    ####   ### ####  #  # ##### # ###    documentation for conditions of use
    ________________________________________________________________________

    File:    Kbd.h
    Author:  Copyright  1993 Jason Williams
    Version: 1.01 (24 Jul 1993)
    Purpose: Reading from the keyboard

    Mods:    24-07-93  JW  Added Desk_Kbd_GET
*/


#ifndef __Desk_Kbd_h
#define __Desk_Kbd_h

#ifdef __cplusplus
	extern "C" {
#endif


#ifndef __Desk_Core_h
#include "Desk.Core.h"
#endif


extern Desk_bool Desk_Kbd_KeyDown(int keynum);
  /*  Checks to see if the given key is currently depressed.
   *  'keynum' is a negative INKEY number (as defined below)
   *     or a value from 0..127 to scan a range od keys
   *  Generally, it's use is for things like (eg) checking if CTRL is held
   *  down when a click is made, as in:
   *    if (Desk_Kbd_KeyDown(Desk_inkey_CTRL)) ...
   */


typedef enum
{
  Desk_inkey_ADJUST       = -12,                       /* MOUSE 'Adjust' button   */
  Desk_inkey_MENU         = -11,                       /* MOUSE 'Menu' button     */
  Desk_inkey_SELECT       = -10,                       /* MOUSE 'Select' button   */

  Desk_inkey_RALT         = -9,                        /* Right ALT key           */
  Desk_inkey_LALT         = -6,                        /* Left ALT key            */
  Desk_inkey_ALT          = -3,                        /* Either/Both ALT keys    */

  Desk_inkey_RCTRL        = -8,                        /* Right CTRL key          */
  Desk_inkey_LCTRL        = -5,                        /* Left CTRL key           */
  Desk_inkey_CTRL         = -2,                        /* Either/Both CTRL keys   */

  Desk_inkey_RSHIFT       = -7,                        /* Right SHIFT key         */
  Desk_inkey_LSHIFT       = -4,                        /* Left SHIFT key          */
  Desk_inkey_SHIFT        = -1                         /* Either/Both SHIFT keys  */
} Desk_kbd_neginkey;
/*
 *  In the DeskTop environment, you shouldn't ever need to read more than these
 *  keys via this method (everything else should come in via WIMP
 *  events). If you need other values, look up the Appendix on INKEY values
 *  in the BBC BASIC Guide (mine has this on page 411)
 */



extern char Desk_Kbd_GET(void);
  /*
   *  Returns the ASCII code of the next key pressed (this may be a key already
   *  waiting in the keyboard buffer). (i.e. an Desk_OS_ReadC veneer)
   *  This is similar to BASIC's GET command, hence the name.
   */



typedef struct
{
  unsigned alt         : 1;
  unsigned ctrl        : 1;
  unsigned shift       : 1;
  unsigned Desk_left_alt    : 1;
  unsigned Desk_left_ctrl   : 1;
  unsigned Desk_left_shift  : 1;
  unsigned Desk_right_alt   : 1;
  unsigned Desk_right_ctrl  : 1;
  unsigned Desk_right_shift : 1;
  
} Desk_kbd_modifiers;
/*
For each modifier key, when the flag is Desk_bool_TRUE it means that the key
is held down.
*/


extern Desk_kbd_modifiers Desk_Kbd_GetModifiers(Desk_bool detailed);
/*
    
    Inputs:   detailed - normally Desk_bool_FALSE, but set to Desk_bool_TRUE if you want to
      	      	      	 know which (as in left or right) modifiers are
      	      	      	 held down.
    Returns:  The status of the modifier keys (the left... and right...
      	      fields are only accurate when detailed = Desk_bool_TRUE).
    Purpose:  To find out the state of various modifier (shift) keys.
      	      This is useful when handling mouse clicks, and so on.
*/


#ifdef __cplusplus
}
#endif


#endif
