home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / cxl-1.zip / CXLKEY.H < prev    next >
C/C++ Source or Header  |  1989-03-27  |  4KB  |  105 lines

  1. /*
  2.    ┌──────────────────────────────────────────────────────────────────────────┐
  3.    │                                                                          │
  4.    │  CXLKEY.H  -  CXL is Copyright (c) 1987-1989 by Mike Smedley.            │
  5.    │                                                                          │
  6.    │  This header file contains function prototypes and definitions for       │
  7.    │  keyboard functions.  Keyboard functions for windowing functions are     │
  8.    │  defined in CXLWIN.H                                                     │
  9.    │                                                                          │
  10.    └──────────────────────────────────────────────────────────────────────────┘
  11. */
  12.  
  13. #if defined(__TURBOC__)                         /* Turbo C */
  14.     #if __STDC__
  15.         #define _Cdecl
  16.     #else
  17.         #define _Cdecl  cdecl
  18.     #endif
  19.     #define _Near
  20. #elif defined(__ZTC__)                          /* Zortech C++ */
  21.     #define _Cdecl
  22.     #define _Near
  23. #elif defined(M_I86) && !defined(__ZTC__)       /* Microsoft C/QuickC */
  24.     #if !defined(NO_EXT_KEYS)
  25.         #define _Cdecl  cdecl
  26.         #define _Near   near
  27.     #else
  28.         #define _Cdecl
  29.         #define _Near
  30.     #endif
  31. #elif defined(__POWERC__)                       /* Power C */
  32.     #define _Cdecl
  33.     #define _Near
  34. #endif
  35.  
  36. /*---------------------------[ function prototypes ]-------------------------*/
  37.  
  38. void     _Cdecl capsoff(void);
  39. void     _Cdecl capson(void);
  40. int      _Cdecl getchf(char *valid,int defchar);
  41. int      _Cdecl getns(char *str,int maxchars);
  42. unsigned _Cdecl getxch(void);
  43. int      _Cdecl inputsf(char *str,char *fmt);
  44. void     _Cdecl kbclear(void);
  45. int      _Cdecl kbmhit(void);
  46. int      _Cdecl kbput(unsigned xch);
  47. int      _Cdecl kbputs(char *str);
  48. unsigned _Cdecl kbstat(void);
  49. void     _Cdecl numoff(void);
  50. void     _Cdecl numon(void);
  51. int      _Cdecl scancode(int ch);
  52. int      _Cdecl setonkey(unsigned keycode,void (_Cdecl *func) (void),
  53.                          unsigned pass);
  54. int      _Cdecl waitkey(void);
  55. int      _Cdecl waitkeyt(int duration);
  56.  
  57. /*------------------------[ definition of kbuf record ]----------------------*/
  58.  
  59. struct _kbuf_t {
  60.     struct _kbuf_t *prev;       /* previous record */
  61.     struct _kbuf_t *next;       /* next record     */
  62.     unsigned xch;               /* keypress        */
  63. };
  64.  
  65. /*-----------------------[ definition of onkey record ]----------------------*/
  66.  
  67. struct _onkey_t {
  68.     struct _onkey_t *prev;      /* pointer to previous record      */
  69.     struct _onkey_t *next;      /* pointer to next record          */
  70.     unsigned int keycode;       /* Scan/ASCII code of trap key     */
  71.     void (*func) (void);        /* address of onkey function       */
  72.     unsigned int pass;          /* key to pass back, 0=don't pass  */
  73. };
  74.  
  75. /*-------------------[ definition of keyboard info record ]------------------*/
  76.  
  77. struct _kbinfo_t {
  78.     struct _kbuf_t *kbuf;       /* pointer to head record in key buffer      */
  79.     struct _onkey_t *onkey;     /* pointer to head record in onkey list      */
  80.     void (*kbloop) (void);      /* pointer to function to call while waiting */
  81.     unsigned char inmenu;       /* inmenu flag used by menuing functions     */
  82. };
  83.  
  84. extern struct _kbinfo_t _Near _Cdecl _kbinfo;
  85.  
  86. /*-------------[ keyboard status codes returned from kbstat() ]--------------*/
  87.  
  88. #define RSHIFT      1       /* right shift pressed   */
  89. #define LSHIFT      2       /* left shift pressed    */
  90. #define CTRL        4       /* <Ctrl> pressed        */
  91. #define ALT         8       /* <Alt> pressed         */
  92. #define SCRLOCK     16      /* <Scroll Lock> toggled */
  93. #define NUMLOCK     32      /* <Num Lock> toggled    */
  94. #define CAPSLOCK    64      /* <Caps Lock> toggled   */
  95. #define INS         128     /* <Ins> toggled         */
  96.  
  97. /*-----------------------[ macro-function definitions ]-----------------------*/
  98.  
  99. #if !defined(MK_FP)
  100. #define MK_FP(seg,ofs)      ((void far *) (((unsigned long)(seg) << 16) | \
  101.                             (unsigned)(ofs)))
  102. #endif
  103. #define clearkeys()         while(kbhit()) getch()
  104. #define setkbloop(a)        (_kbinfo.kbloop=a)
  105.