home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xibm.zip / AIX / hftQueue.h < prev    next >
C/C++ Source or Header  |  1992-02-11  |  5KB  |  179 lines

  1. /*
  2.  * $Id: hftQueue.h,v 5.1 1992/02/12 00:21:36 jfc Exp $
  3.  *
  4.  * Copyright IBM Corporation 1987,1988,1989
  5.  *
  6.  * All Rights Reserved
  7.  *
  8.  * Permission to use, copy, modify, and distribute this software and its
  9.  * documentation for any purpose and without fee is hereby granted,
  10.  * provided that the above copyright notice appear in all copies and that 
  11.  * both that copyright notice and this permission notice appear in
  12.  * supporting documentation, and that the name of IBM not be
  13.  * used in advertising or publicity pertaining to distribution of the
  14.  * software without specific, written prior permission.
  15.  *
  16.  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  17.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  18.  * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  19.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  20.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  21.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  22.  * SOFTWARE.
  23.  *
  24. */
  25.     /*
  26.      *    Dispatches events from the hft queue to handlers appropriate
  27.      *    to the various devices.
  28.      *
  29.      *    int
  30.      *    hftInitQueue()
  31.      *        Initializes the hft queue.  
  32.      *        returns TRUE for success, FALSE on failure (queue
  33.      *        already initialized or can't open HFT).
  34.      *    
  35.      *    hftTermQueue()
  36.      *        Terminates the hft queue.  
  37.      *
  38.      *    hftInterruptAlways()
  39.      *        causes the queue to interrupt every time an event 
  40.      *        arrives    present.
  41.      *
  42.      *    hftInterruptOnFirst()
  43.      *        causes the queue to interrupt only when an event
  44.      *        is added to an empty queue.
  45.      *
  46.      *    hftEvHandler
  47.      *    hftInstallHandler(evType,pHandler)
  48.      *    int         evType;
  49.      *    hftEvHandler    pHandler;
  50.      *        Installs handler for events of type 'evType.'
  51.      *        evType should be one of HFT_LOCATOR, HFT_TABLET,
  52.      *        HFT_KEYBOARD,HFT_LPFK,HFT_DIAL,HFT_ADAPT, HFT_GRANTED, 
  53.      *        HFT_RETRACTED,     HFT_BEFORE_EVENTS, HFT_AFTER_EVENTS, 
  54.      *        HFT_EVENT_ARRIVED.  Each handler receives an
  55.      *        hftEvent.  To remove a handler, specify HFT_IGNORE.
  56.      *        hftInstallDevice returns the previous handler, or
  57.      *        HFT_ERROR if an error occured (queue not initialized,
  58.      *        bad argument).
  59.      *
  60.      *    void
  61.      *    hftAddTimeout(pHandler,length)
  62.      *        Installs a timeout handler.  pHandler will be called
  63.      *        after 'length' iterations through hftDispatchEvents.
  64.      *
  65.      *    void
  66.      *    hftDispatchEvents()
  67.      *        Dispatches events from hft queue until queue is
  68.      *        exhausted or one of the translator functions
  69.      *        returns FALSE.  An event is dispatched to it's
  70.      *        device specific handler if one is defined, or to the 
  71.      *        handler for HFT_ANY if it exists.  If neither handler
  72.      *        is defined, the event is ignored.
  73.      *
  74.      *    int
  75.      *    hftFD()
  76.      *        File descriptor (if any) which may be selected
  77.      *        to determine if input is available on the hft
  78.      *        queue.
  79.      */
  80.  
  81. #define    HFT_KEYBOARD        0
  82. #define    HFT_LOCATOR        1
  83. #define    HFT_ADAPT        2
  84. #define    HFT_TABLET        3
  85. #define    HFT_LPFK        4
  86. #define    HFT_DIAL        5
  87. #define    HFT_GRANTED        6
  88. #define    HFT_RETRACTED        7
  89. #define    HFT_EVENT_ARRIVED    8
  90. #define    HFT_BEFORE_EVENTS    9
  91. #define    HFT_AFTER_EVENTS    10
  92. #define    HFT_NEVENTS        11
  93.  
  94. #define    HFT_IGNORE        ((hftEvHandler)0)
  95. #define    HFT_ERROR        ((hftEvHandler)-1)
  96.  
  97. typedef    struct _HFTKEYEV {
  98.     char    kePos;
  99.     char    keScan;
  100.     char    keStatus[2];
  101. } hftKeyEv;
  102.  
  103. /* MUST BE THE SAME AS /usr/include/sys/hft.h */
  104. #define    HFT_LBUTTON    0x80
  105. #define    HFT_RBUTTON    0x40
  106. #define HFT_MBUTTON     0x20
  107. #define    HFT_BUTTONS    (HFT_LBUTTON|HFT_RBUTTON)
  108.  
  109. #define    HFT_BUTTON1    0x80
  110. #define    HFT_BUTTON2    0x40
  111. #define    HFT_BUTTON3    0x20
  112. #define    HFT_BUTTON4    0x10
  113. #define    HFT_TABLET_BUTTONS (HFT_BUTTON1|HFT_BUTTON2|HFT_BUTTON3|HFT_BUTTON4)
  114.  
  115. #define HF_SHORT(f)        ((signed short)((f)[0]<<8|(f)[1]))
  116. #define    HF_SETSHORT(f,v)    (((f)[1]=(v)&0xff),(f[0]=(v)>>8))
  117.  
  118. typedef struct _HFTLOCEV {
  119.     unsigned char    leDeltaX[2];
  120.     unsigned char    leDeltaY[2];
  121.     char        leSeconds[3];
  122.     char        leSixtieths;
  123.     unsigned char    leButtons;
  124.     char        leStype;
  125. } hftLocEv;
  126.  
  127. typedef struct _HFTLPFKEV {
  128.     unsigned char    lpfkeKeyNo[2];
  129.     unsigned char    lpfkeReserved[2];
  130.     char        lpfkeSeconds[3];
  131.     char        lpfkeSixtieths;
  132.     unsigned char    lpfkeButtons;
  133.     char        lpfkeStype;
  134. } hftLPFKEv;
  135.  
  136. typedef struct _HFTDIALEV {
  137.     unsigned char    deDialNo[2];
  138.     unsigned char    deDelta[2];
  139.     char        deSeconds[3];
  140.     char        deSixtieths;
  141.     unsigned char    deButtons;
  142.     char        deStype;
  143. } hftDialEv;
  144.  
  145. typedef struct _HFTADPEV {
  146.     char    aeQueue;
  147.     char    aeData[20];
  148. } hftAdaptEv;
  149.  
  150. typedef    struct {
  151.     int    hftEvType;
  152.     union {
  153.         hftKeyEv    hftKey;
  154.         hftLocEv    hftLoc;
  155.         hftAdaptEv    hftAdapt;
  156.         hftDialEv    hftDial;
  157.         hftLPFKEv    hftLpfk;
  158.     } hftEv;
  159. } hftEvent;
  160.  
  161. #ifndef AIXrt
  162. typedef void (*hftEvHandler)();
  163. #else
  164. typedef int (*hftEvHandler)();
  165. #endif
  166.  
  167. extern    int         hftQFD;
  168. extern    unsigned     hftPending;
  169. extern    unsigned     hftGrantPending;
  170. extern    unsigned     hftRetractPending;
  171. extern    void         hftInterruptAlways();
  172. extern    void         hftInterruptOnFirst();
  173. extern    int         hftInitQueue();
  174. extern    void         hftTermQueue();
  175. extern    void         hftAddTimeout();
  176. extern    hftEvHandler     hftInstallHandler();
  177. extern    void         hftDispatchEvents();
  178. extern    int         hftFD();
  179.