home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 202.img / SCO386N2.TD0 / usr / include / sys / event.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-09  |  3.4 KB  |  157 lines

  1. /*
  2.  *    @(#) event.h 1.5 88/08/09 
  3.  *
  4.  *    Copyright (C) The Santa Cruz Operation, 1988.
  5.  *    Copyright (C) Microsoft Corporation, 1988.
  6.  *    This Module contains Proprietary Information of
  7.  *    The Santa Cruz Operation, Microsoft Corporation
  8.  *    and AT&T, and should be treated as Confidential.
  9.  */
  10.  
  11. /*
  12.  * THIS FILE CONTAINS CODE WHICH IS DESIGNED TO BE
  13.  * PORTABLE BETWEEN DIFFERENT MACHINE ARCHITECTURES
  14.  * AND CONFIGURATIONS. IT SHOULD NOT REQUIRE ANY 
  15.  * MODIFICATIONS WHEN ADAPTING XENIX TO NEW HARDWARE.  
  16.  */
  17.  
  18. #ifdef M_I386
  19. # define    QPAGE    PGSIZE
  20. #else
  21. # define    QPAGE    4096
  22. #endif
  23.  
  24. /* This number chosen to make an event 16 bytes long */
  25. #define        EV_STR_BUFSIZE    8
  26.  
  27. typedef struct {
  28.     long    timestamp;
  29.     short    tag;
  30.     union {
  31.         char    buttons;
  32.         char    bufcnt;
  33.     } u1;
  34.     union {
  35.         unsigned char buf[EV_STR_BUFSIZE];
  36.         union {
  37.             struct {
  38.                 unsigned long    x,y;
  39.             } abs;
  40.             struct {
  41.                 long    dx,dy;
  42.             } rel;
  43.         } loc;
  44.     } un;
  45. } EVENT;
  46.  
  47. /* Values for event tag */
  48. #define    T_OTHER        0x0001
  49. #define    T_BUTTON    0x0002
  50. #define    T_STRING    0x0004
  51. #define    T_ABS_LOCATOR    0x0008
  52. #define    T_REL_LOCATOR    0x0010
  53. #define    T_LOCATOR    (T_ABS_LOCATOR | T_REL_LOCATOR)
  54.  
  55. /* Shorthand notations */
  56. #define    EV_TIME(x)    ((x).timestamp)
  57. #define    EV_TAG(x)    ((x).tag)        /* device making event*/
  58. #define    EV_BUFCNT(x)    ((x).u1.bufcnt)        /* num bytes in buffr */
  59. #define    EV_BUTTONS(x)    ((x).u1.buttons)
  60. #define    EV_BUF(x)    ((x).un.buf)        /* pointer to buffer  */
  61. #define    EV_DX(v)    ((v).un.loc.rel.dx)
  62. #define    EV_DY(v)    ((v).un.loc.rel.dy)
  63. #define    EV_X(v)        ((v).un.loc.abs.x)
  64. #define    EV_Y(v)        ((v).un.loc.abs.y)
  65.  
  66. /* Bit definitions within the character reserved for button state */
  67. #define    BUTTON1        0x01
  68. #define    BUTTON2        0x02
  69. #define    BUTTON3        0x04
  70. #define    BUTTON4        0x08
  71. #define    RT_BUTTON    BUTTON1
  72. #define    MD_BUTTON    BUTTON2
  73. #define    LT_BUTTON    BUTTON3
  74.  
  75. /* This number makes a queue one page (4K bytes) long */
  76. #define        QSIZE        ((QPAGE - 3 * sizeof(long))/sizeof(EVENT))
  77.  
  78. typedef struct {
  79.     long    overrun;
  80.     long    head;
  81.     long    tail;
  82.     EVENT    queue[QSIZE];
  83. } QUEUE;
  84.  
  85. /* 
  86.  * Locator events may be ratioed as they enter the queue.
  87.  * The user supplies a multiplication factor, then the driver
  88.  * right shifts by a constant amount.
  89.  */
  90.  
  91. #define    LOC_RSHIFT    13
  92.  
  93. #define    R_ONEHALF    0x1000
  94. #define    R_TIMES1    0x2000
  95. #define    R_TIMES2    0x4000
  96. #define    R_TIMES4    0x8000
  97.  
  98. /* The type of an event mask */
  99. typedef    unsigned short    emask_t;
  100.  
  101. /* The type of a device mask */
  102. typedef unsigned short    dmask_t;
  103.  
  104. /* The mouse line discipline */
  105. #define    MLD    2
  106.  
  107. #ifdef M_KERNEL
  108.  
  109. #define    EVLDSILOSZ    5
  110.  
  111. struct evldsilo {
  112.     short    count;
  113.     unsigned char buf[EVLDSILOSZ];
  114.     short    eq_handle;
  115.     short    ratio;
  116.     void    (*addevent)();
  117.     unsigned char oldbuttons;
  118.     long    oldx, oldy;
  119. };
  120.  
  121. struct evldchan {
  122.     unsigned short    open;
  123.     void    (*eventize)();        /* routine to make events */
  124.     struct evldsilo    silo;
  125. };
  126.  
  127. struct evdev {
  128.     long    dev_id;        /* identifies HW gin device 0=invalid*/
  129.     long    term_id;    /* identifies controlling tty */
  130.     short    channel;    /* channel to which events are going */
  131. };
  132.  
  133. /*
  134.  * values for flags
  135.  */
  136. #define READ_COLLISION        TRCOLL
  137. #define EXCEPT_COLLISION    TECOLL
  138.  
  139. struct ev_selstr {
  140.     struct proc *read;
  141.     /* Writing to the event driver is not defined or supported. */
  142.     struct proc *except;
  143.     char    flags;
  144. };
  145.  
  146. struct evchan {
  147.     long    term_id;    /* & of tp of controlling tty if any */
  148.     uchar_t status;        /* UNUSED, OPEN, ACTIVE, SUSPENDED */
  149.     QUEUE    *qp;        /* Kernel's pointer to the queue */
  150.     caddr_t    uqp;        /* User's pointer to the queue */
  151.     paddr_t    physaddr;
  152.     emask_t    emask;
  153.     struct ev_selstr selstr;
  154. };
  155.  
  156. #endif
  157.