home *** CD-ROM | disk | FTP | other *** search
/ Virtual Reality Zone / VRZONE.ISO / mac / PC / REND386 / JIREND / POINTER.H < prev    next >
C/C++ Source or Header  |  1993-04-11  |  7KB  |  172 lines

  1. /* Definition for a generic 3-D pointing device interface */
  2.   
  3. /* Written by Dave Stampe Aug. 92 */
  4.   
  5. /* Copyright 1992 by Dave Stampe and Bernie Roehl.
  6.    May be freely used to write software for release into the public domain;
  7.    all commercial endeavours MUST contact Bernie Roehl and Dave Stampe
  8.    for permission to incorporate any part of this software into their
  9.    products!
  10.  */
  11.   
  12. /* configuration structure: part of driver */
  13. /* MUST corresp. to lefthand coord sys or negate scale! */
  14. /* for non- ht devices, the scaling may be adjusted as desired */
  15.   
  16. typedef struct _pconfig {
  17.    long xres, yres, zres;     /* position res: mm/tick in <16.16>  */
  18.    long maxx, maxy, maxz;     /* numeric range             */
  19.    long minx, miny, minz;
  20.   
  21.    long xrres, yrres, zrres;  /* rotation res: deg/tick in <16.16  */
  22.    long maxxr, maxyr, maxzr;  /* numeric range                */
  23.    long minxr, minyr, minzr;  /* min, max: left-hand dir.     */
  24.   
  25.    int maxsx, maxsy;    /* limits on mouse-mode motion (writable) */
  26.   
  27.    int databits;     /* what data is available from device */
  28.    int commands;     /* what sort of control is available  */
  29.    int nullkey;          /* button code for null keypress      */
  30.    int flexnum;      /* number of flex parameters          */
  31.    int delay;        /* millisec. read delay               */
  32.    int idelay;       /* internal delay in ms               */
  33.    int rrate;        /* max. reads per second possible     */
  34.    int type;         /* suggested useage                   */
  35.    char id[80];      /* id or more data                    */
  36. } pconfig;
  37.   
  38. /* databits: */
  39.   
  40. #define P_HASB1    0x0001   /* what buttons we can have  */
  41. #define P_HASB2    0x0002   /* also mask for button bits */
  42. #define P_HASB3    0x0004
  43. #define P_HASX     0x0008   /* which axes we can read */
  44. #define P_HASY     0x0010
  45. #define P_HASZ     0x0020
  46. #define P_HASRX    0x0040   /* what rotations are available */
  47. #define P_HASRY    0x0080
  48. #define P_HASRZ    0x0100
  49. #define P_HASGEST  0x0200   /* gestural interface   */
  50. #define P_HASFLEX  0x0400   /* fingers?             */
  51. #define P_HASKEYS  0x0800   /* do we have a keypad? */
  52. #define P_HASSCR   0x1000   /* capable of emulating XY mouse */
  53.   
  54.   
  55. /* commands to driver (modes): */
  56.   
  57. #define P_CENTER    1   /* recenter without reinitializing */
  58. #define P_SCREEN    2   /* screen mouse mode read     */
  59. #define P_POINTER   4   /* any extended pointing mode */
  60.   
  61. /* type: bits specifying suggested uses */
  62.   
  63. #define P_NOPOS 0   /* just a keypad or something */
  64. #define P_IS2D  1   /* 2D mouse, for example      */
  65. #define P_IS2DP 2   /* 2D, but Z mapped by button */
  66. #define P_IS3D  4   /* 3D mouse, for example      */
  67. #define P_IS6D  8   /* 6D mouse, for example      */
  68. #define P_IS3DG 16  /* 3D glove-- don't use rot   */
  69. #define P_IS6DG 32  /* 6D glove-- use rotation    */
  70. #define P_IS3RH 64  /* 3D (rotation) head tracker */
  71. #define P_IS3TH 128 /* 3D (position) head tracker */
  72. #define P_IS6H  256 /* full 6D head tracker       */
  73.   
  74. /* driver interface packet */
  75.   
  76. typedef struct _pt{
  77.    long x, y, z;          /* location in scaled coordinates     */
  78.    long dx, dy, dz;       /* position change from last read     */
  79.    long rx, ry, rz;       /* scaled orientation around x, y, z  */
  80.    long drx, dry, drz;    /* orientation change from last read  */
  81.    unsigned buttons;      /* 16 bits: raw mouse buttons         */
  82.    unsigned gesture;      /* glove gesture ID, or a mapping     */
  83.    unsigned keys;         /* keypad return value                */
  84.    int flex[16];          /* 16 words of flexion (i.e. fingers) */
  85.    int changed;
  86.    int wpos_valid;        /* set if world pos'n is valid        */
  87.    MATRIX wpos;           /* world position/rotation            */
  88. } POINTER;
  89.   
  90. typedef struct _pb {
  91.    int   driver_type;            /* 0 = driver, 1 = internal */
  92.    pconfig *(*driver_pointer)(); /* address of driver entry  */
  93.    pconfig *pdata;
  94.    long xmult, ymult, zmult;    /* used to process reads    */
  95.    long xadd, yadd, zadd;
  96.    long xrmult, yrmult, zrmult;
  97.    long xradd, yradd, zradd;
  98.    int oldsx, oldsy;             /* mouse emulation */
  99.    POINTER oldp;
  100. } pdrblock;
  101.   
  102.   
  103. typedef pdrblock PDRIVER ; /* points to driver data block */
  104.   
  105.             /* loads driver, initializes   */
  106.             /* return NULL if failure      */
  107.             /* drfile is NULL for internal */
  108.             /* type gives preferred mode   */
  109. extern PDRIVER *pointer_init(int type, char *drfile);
  110.   
  111.             /* makes sure device is available, OK */
  112.             /* returns *pconfig or NULL           */
  113. extern pconfig *pointer_check(PDRIVER *p);
  114.   
  115.             /* reads pointer, scales data and        */
  116.             /* returns bitwise OR of the following:  */
  117. extern int pointer_read(PDRIVER *p, POINTER *pointer);
  118.   
  119. #define PNEW_POS  1   /* raw xyz change           */
  120. #define PNEW_ROT  2   /* raw rot. change          */
  121. #define PNEW_BUT  4   /* button pressed/released  */
  122. #define PNEW_GEST 8   /* gesture change           */
  123. #define PNEW_KEY  16  /* new key pressed/released */
  124. #define PNEW_FLEX 32  /* new flexion              */
  125.   
  126.          /* recenters, recalibrates, etc */
  127. extern void pointer_reset(PDRIVER *p);
  128.   
  129.          /* disconnects driver */
  130. extern void pointer_quit(PDRIVER *p);
  131.   
  132.          /* changes device mode */
  133. extern pconfig *device_command(PDRIVER *p, int command);
  134.   
  135.          /* sets scaling (+/- given value) */
  136.   
  137. extern void pointer_tscale(PDRIVER *p, long x, long y, long z);
  138. extern void pointer_rscale(PDRIVER *p, long rx, long ry, long rz);
  139.   
  140.   
  141. extern void pointer_abscale(PDRIVER *p, long xs, long ys, long zs,
  142. long rxs, long rys, long rzs);
  143.   
  144.          /* uses internal tick-resolution scaling for abs. devices */
  145. extern void init_pointer(POINTER *p); /* presets pointer structure */
  146.   
  147. extern int last_pointer(PDRIVER *d,POINTER *p); /* copy of last read value */
  148.   
  149.           /* mouse-emulation read: return change flags for button, pos'n */
  150. extern int mouse_read(PDRIVER *p, int *x, int *y, unsigned *b);
  151.   
  152.           /* mouse-emulation get last data: return change flags for button, pos'n */
  153. extern int mouse_last(PDRIVER *p, int *x, int *y, int *b);
  154.   
  155. extern void set_mouse_limits(PDRIVER *p, int maxx, int maxy);
  156.   
  157. /* driver call equates: call *driver_pointer with this code */
  158. /* all return *pconfig or integer */
  159.   
  160. #define DRIVER_INIT  0   /* rtns *pconfig, args = type    */
  161. #define DRIVER_RESET 1   /* no rtn, no args               */
  162. #define DRIVER_READ  2   /* rtns NULL if no data ready, else *pconfig */
  163.                   /* args = *pointer, mode */
  164. #define DRIVER_CMD   3   /* args = mode, rtns *pconfig    */
  165. #define DRIVER_CHECK 4   /* no args, rtns *pconfig        */
  166. #define DRIVER_QUIT  5   /* no args, no rtn               */
  167.   
  168. extern PDRIVER *mouseptr_init(char *mname);
  169.   
  170. /* End of pointer.h */
  171.   
  172.