home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / d / ddx-mips.zip / MIPSMOUS.H < prev    next >
C/C++ Source or Header  |  1992-08-11  |  3KB  |  101 lines

  1. /*
  2.  * $XConsortium$
  3.  *
  4.  * Copyright 1991 MIPS Computer Systems, Inc.
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of MIPS not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  MIPS makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * MIPS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL MIPS
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  */
  23. /* $Header: mipsMouse.h,v 1.6 92/08/11 16:38:15 dd Exp $ */
  24. #ifndef __DDX_MIPSMOUSE_H
  25. #define    __DDX_MIPSMOUSE_H
  26.  
  27. #define NBUTTONS    3
  28.  
  29. #define RAW_LEFT    4
  30. #define RAW_MIDDLE    2
  31. #define RAW_RIGHT    1
  32.  
  33. /* mouse device name */
  34.  
  35. #define    MOUSEDEV    "/dev/mouse"
  36.  
  37. /* motion buffer */
  38. #ifdef X11R4
  39. #define MOUSEQSIZE      100
  40.  
  41. typedef struct {
  42.     int        time;
  43.     int        scrn;
  44.     int        dx, dy;
  45.     int        bmask;
  46. } mouseQ_t;
  47. #endif /* X11R4 */
  48.  
  49. /* 5 byte format */
  50. #define MS5_SYNCMASK    0xf8
  51. #define MS5_SYNCVAL    0x80
  52. #define MS5_BUTTON(s)    ((~(s)[0]) & 7)
  53. #define    MS5_XVAL(s)    ((signed char) (s)[1] + (signed char)(s)[3])
  54. #define    MS5_YVAL(s)    (-((signed char) (s)[2] + (signed char) (s)[4]))
  55.  
  56. /* 3 byte format */
  57. #define    MS3_SYNCMASK    0x08
  58. #define    MS3_BUTTON(s)    ("\0\4\1\5\2\6\3\7"[(s)[0] & 7])
  59. #define    MS3_XVAL(s)    (((s)[0] & 0x10 ? -256 : 0) | (unsigned char) (s)[1])
  60. #define    MS3_YVAL(s)    (-(((s)[0] & 0x20 ? -256 : 0) | (unsigned char) (s)[2]))
  61. #define    MS3_XBADOVF(s)    (((s)[0] & 0x40) && \
  62.                 (s)[1] != ((s)[0] & 0x10) ? 0xff : 0)
  63. #define    MS3_YBADOVF(s)    (((s)[0] & 0x80) && \
  64.                 (s)[2] != ((s)[0] & 0x20) ? 0xff : 0)
  65.  
  66. /* mouse private structure */
  67.  
  68. typedef
  69. struct _mousePriv {
  70.     int fd;            /* File descriptor of the mouse */
  71.     short unit;        /* unit number (not used) */
  72.     short cap;        /* Device capabilities */
  73.     short baud;        /* Baud rate */
  74.     short rate;        /* Sampling rate */
  75.     char type;        /* mouse type */
  76. #define    MIPS_MOUSE_DEFAULT    0
  77. #define    MIPS_MOUSE_MOUSEMAN    1
  78. #define    MIPS_MOUSE_3BYTE    2
  79.     char buttonstate;    /* Which buttons are down */
  80.     struct {
  81.         char mask;
  82.         char val;
  83.     } buttonmap[NBUTTONS];    /* Conversion between mouse and cursor
  84.                  * buttons */
  85.     INT16 rootX, rootY;    /* Current mouse position */
  86.     void (*decode) ();    /* mouse character decode function */
  87.     int decode_state;    /* for decode function */
  88.     int decode_sync;    /* for decode function */
  89.     char msbuf[8];        /* mouse buffer */
  90.     PtrCtrl ctrl;        /* Pointer control */
  91. #ifdef X11R4
  92.     int scrn;        /* What screen the cursor is on */
  93. #endif /* X11R4 */
  94. } MousePriv, *MousePrivPtr;
  95.  
  96. /* keyboard and mouse defines */
  97.  
  98. extern MousePriv    mousePriv;
  99.  
  100. #endif /* __DDX_MIPSMOUSE_H */
  101.