// Connect to the P5Glove hardware
bool P5GloveStandalone::connectToHardware(const int gloveNumber)
{
   vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL)
      << "[P5Glove] Connecting To P5Glove Hardware number " << gloveNumber
      << std::endl << vprDEBUG_FLUSH;

   for ( unsigned int i = 0 ; i < 4 ; ++i )
   {
      mGlove = p5glove_open(gloveNumber);
      if ( mGlove == NULL )
      {
         break;
      }

      if ( p5glove_sample(mGlove, -1) >= 0 )
      {
         break;
      }

      p5glove_close(mGlove);
      mGlove = NULL;
   }

   if ( mGlove == NULL )
   {
      vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_WARNING_LVL)
         << "[P5Glove] Cannot connect to Hardware glove!\n" << vprDEBUG_FLUSH;
      return false;
   }

//   p5g_reset_prev(mGlove);
   return true;
}
// Destructor
P5GloveStandalone::~P5GloveStandalone()
{
   if ( NULL != mGlove )
   {
      p5glove_close(mGlove);
   }
}
Пример #3
0
/* Brain-Dead P5 data dump.
 */
int main(int argc, char **argv)
{
	P5Glove glove;
	int sample;

	glove=p5glove_open(0);
	if (glove == NULL) {
		fprintf(stderr, "%s: Can't open glove interface\n", argv[0]);
		return 1;
	}

	for (sample=0; sample < 100 ; ) {
		int i,err;

		err=p5glove_sample(glove, -1);
		if (err < 0 && errno == EAGAIN)
			continue;
		if (err < 0) {
			perror("Glove Failure");
			exit(1);
		}

		printf("%2d: ",sample);
		sample++;

		dump_cooked(glove,err);

		printf("\n");
	}

	p5glove_close(glove);

    return 0;
}
Пример #4
0
void p5_free(t_p5 *p5){
	post("Closing p5 glove");
	p5glove_close(p5->glove);
	p5->glove = NULL;
}