home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / desklib / !DeskLib / h / Kbd < prev    next >
Encoding:
Text File  |  1994-05-29  |  3.9 KB  |  118 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Kbd.h
  12.     Author:  Copyright © 1993 Jason Williams
  13.     Version: 1.01 (24 Jul 1993)
  14.     Purpose: Reading from the keyboard
  15.  
  16.     Mods:    24-07-93  JW  Added Kbd_GET
  17. */
  18.  
  19.  
  20. #ifndef __dl_kbd_h
  21. #define __dl_kbd_h
  22.  
  23. #ifndef __dl_core_h
  24. #include "core.h"
  25. #endif
  26.  
  27.  
  28.   /*  Kbd_Keydown(keynum)
  29.    *  Checks to see if the given key is currently depressed.
  30.    *  'keynum' is a negative INKEY number (as defined below)
  31.    *  Generally, it's use is for things like (eg) checking if CTRL is held
  32.    *  down when a click is made, as in:
  33.    *    if (Kbd_KeyDown(inkey_CTRL)) ...
  34.    */
  35. extern BOOL Kbd_KeyDown(int keynum);
  36.  
  37.  
  38. /*  In the DeskTop environment, you shouldn't ever need to read more than the
  39.  *  the following keys via this method (everything else should come in via WIMP
  40.  *  events). If you need other values, look up the Appendix on INKEY values
  41.  *  in the BBC BASIC Guide (mine has this on page 411)
  42.  */
  43.  
  44. typedef enum
  45. {
  46.   inkey_ADJUST       = -12,                       /* MOUSE 'Adjust' button   */
  47.   inkey_MENU         = -11,                       /* MOUSE 'Menu' button     */
  48.   inkey_SELECT       = -10,                       /* MOUSE 'Select' button   */
  49.  
  50.   inkey_RALT         = -9,                        /* Right ALT key           */
  51.   inkey_LALT         = -6,                        /* Left ALT key            */
  52.   inkey_ALT          = -3,                        /* Either/Both ALT keys    */
  53.  
  54.   inkey_RCTRL        = -8,                        /* Right CTRL key          */
  55.   inkey_LCTRL        = -5,                        /* Left CTRL key           */
  56.   inkey_CTRL         = -2,                        /* Either/Both CTRL keys   */
  57.  
  58.   inkey_RSHIFT       = -7,                        /* Right SHIFT key         */
  59.   inkey_LSHIFT       = -4,                        /* Left SHIFT key          */
  60.   inkey_SHIFT        = -1                         /* Either/Both SHIFT keys  */
  61. } kbd_neginkey;
  62.  
  63.  
  64.  
  65.   /*  Kbd_GET()
  66.    *  Returns the ASCII code of the next key pressed (this may be a key already
  67.    *  waiting in the keyboard buffer). (i.e. an OS_ReadC veneer)
  68.    *  This is similar to BASIC's GET command, hence the name.
  69.    */
  70. extern char Kbd_GET(void);
  71.  
  72.  
  73.  
  74. /****************************************************************************
  75.  
  76.   typedef kbd_modifiers
  77.   
  78.   For each modifier key, when the flag is TRUE it means that the key
  79.   is held down.
  80.  
  81. ****************************************************************************/
  82.  
  83.  
  84. typedef struct
  85. {
  86.   unsigned alt         : 1;
  87.   unsigned ctrl        : 1;
  88.   unsigned shift       : 1;
  89.   unsigned left_alt    : 1;
  90.   unsigned left_ctrl   : 1;
  91.   unsigned left_shift  : 1;
  92.   unsigned right_alt   : 1;
  93.   unsigned right_ctrl  : 1;
  94.   unsigned right_shift : 1;
  95.   
  96. } kbd_modifiers;
  97.  
  98.  
  99. /****************************************************************************
  100.  
  101.     kbd_modifiers Kbd_GetModifiers(BOOL detailed)
  102.     
  103.     Inputs:   detailed - normally FALSE, but set to TRUE if you want to
  104.                                know which (as in left or right) modifiers are
  105.                                held down.
  106.     Returns:  The status of the modifier keys (the left... and right...
  107.                 fields are only accurate when detailed = TRUE).
  108.     Purpose:  To find out the state of various modifier (shift) keys.
  109.                 This is useful when handling mouse clicks, and so on.
  110.  
  111. ****************************************************************************/
  112.  
  113.  
  114. extern kbd_modifiers Kbd_GetModifiers(BOOL detailed);
  115.  
  116.  
  117. #endif
  118.