home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / misc / dr.str / Source / Glove.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-29  |  1.7 KB  |  47 lines  |  [TEXT/KAHL]

  1. /**********************************************************************************
  2.    Header for Macintosh - PowerGlove interface code
  3.    Taken from:
  4.      Jon Blossom (blossom@cs.yale.edu)  20 January, 1992
  5.  ********************************************************************************/
  6.  
  7. #ifndef _POWER_GLOVE_
  8. #define _POWER_GLOVE_
  9.  
  10. #define CONT_FLAG        -96
  11.  
  12. #define A_BUTTON        0x0A        /* Glove button codes */
  13. #define B_BUTTON        0x0B
  14. #define START_BUTTON    0x82
  15. #define SELECT_BUTTON   0x83
  16. #define CENTER_BUTTON   0x00
  17. #define UP_BUTTON       0x0D
  18. #define DOWN_BUTTON     0x0E
  19. #define LEFT_BUTTON     0x0C
  20. #define RIGHT_BUTTON    0x0F
  21.  
  22. #define RING_MASK        0x03        /* Masks for reading finger data */
  23. #define MIDDLE_MASK        0x0C
  24. #define INDEX_MASK        0x30
  25. #define THUMB_MASK        0xC0
  26.  
  27. #define CONTSTR            "C"            /* Character to put glove in continuous mode */
  28. #define REQUESTSTR        "R"            /* Character to put glove in request mode */
  29. #define QUERYSTR        "?"            /* Character to request a packet from glove */
  30. #define PACKETSIZE        6            /* Reading 6 byte packets from SCC */
  31.  
  32.  
  33. typedef struct glove {
  34.     short   x, y, z;                        /* x,y: 3mm precision, z: 14mm */
  35.     short   rot;                            /* rotation 0-11, in 30-40 degree incs */
  36.     short   thumb, index, middle, ring;     /* bend in fingers 0-3, 3 = tight bend */
  37.     short   buttons;
  38. } GloveState;
  39.  
  40. void    delay(long ticks);                    /* Delays for number of mac ticks */
  41. void    OpenGlove(int settings);            /* Initialize the power glove */
  42. void    CloseGlove(void);                    /* Close the serial port */
  43. void    GetGlove(GloveState *s);            /* Read the current glove state */
  44. void    DisplayGlove(GloveState *s);        /* Display current glove state to stdout */
  45.  
  46. #endif _POWER_GLOVE_
  47.