home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / ibm / AIX / hftQueue.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-16  |  5.2 KB  |  200 lines

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