/******************************************************************************
glovedata.h

The format about which information about the glove is stored.  Note
that while at the moment pitch and yaw measurements are not available,
they may be at some future time. Similarly for the little finger.

Copyright (c) Waleed Kadous 1995. 
waleed@cse.unsw.edu.au
http://www.cse.unsw.edu.au/~waleed/
*****************************************************************************/

#include <stdio.h>

/* Buttons on the PowerGlove control pad */

/* 0 through to 9 map onto the 0 to 9 on the control pad. */

#define PGLOVE_PROG  (0x84)
#define PGLOVE_ENTER (0x80)
#define PGLOVE_CENTER (0x00)

/* Note: There is an ambiguity here -- pressing "Center" and "0" */
/* results in the same signal being sent -- so don't use "Center" and */
/* "0" buttons together. */

#define PGLOVE_UP    (0x0C)
#define PGLOVE_RIGHT (0x0D)
#define PGLOVE_DOWN  (0x0E)
#define PGLOVE_LEFT  (0x0F)
#define PGLOVE_SEL   (0x83)
#define PLOVE_START  (0x82)
#define PGLOVE_A     (0x0A)
#define PGLOVE_B     (0x0B)
/* No key pressed is indicated by FF */
#define PGLOVE_NOKEY (0xFF)

typedef struct {
  float x, y, z; 
  /* Works out to be +/- 1 roughly where "1" = 1 metre approximately */
  float roll, pitch, yaw;
  /* Roll, pitch and yaw is expressed as a value between 0 and */
  /* 1. Negative values indicate the information is not valid or */
  /* available */
  float thumb, fore, index, ring, little;
  /* Finger positions. It is assumed these are between 0 (straight) */
  /* and 1 (flexed completely). Also assumed they are always available */
  unsigned char keycode, gstat1, gstat2, recvals;
  /* Various status bits about the glove. May be ignored if desired */
} glovedata;

/* Prints glove information in comma separated sequence in the same */
/* order above. Also, a file writing version. */

void printglove(glovedata* gd);
void fprintglove(FILE *outfile, glovedata* gd);

/* Complements printglove, and can read the output of printglove back */
/* into a glovedata struct. Also a file reading version. */
int readglove(glovedata* gd);
int freadglove(FILE *infile, glovedata *gd);


  

