// 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;
}
Example #2
0
int main(int argc,char **argv)
{
	printf("Keys:\n"
	       "ESC/q: quit\n"
	       "    w: pitch forward\n"
	       "    s: pitch back\n"
	       "    a: rotate left\n"
	       "    d: rotate right\n"
	       "    R: reset all rotations\n"
	       "    h: Toggle reference led display\n"
	       "    x: Toggle reference axis display\n"
	       "    p: Toggle glove position information\n"
	       "    r: Toggle glove rotation information\n");
	glutInit(&argc,argv);

	glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH);
	glutInitWindowSize(600,600);
	glutCreateWindow(argv[0]);

	render_init();

	glove=p5glove_open(0);
	if (glove==NULL) {
		perror(argv[0]);
		exit(1);
	}

	glutDisplayFunc(render_display);
	glutIdleFunc(render_next);
	glutKeyboardFunc(render_keyboard);
	glutReshapeFunc(render_reshape);
	glutMainLoop();

    return 0;
}
Example #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;
}
Example #4
0
//t_symbol *s, int argc, t_atom *argv){
void *p5_new(t_float delaytime){
	t_p5 *p5 = (t_p5*) pd_new(p5_class);

	//Init p5 glove
	p5->glove = p5glove_open(0);
	if (p5->glove == NULL) {
		error("*** p5 error: Couldn't open p5 glove device.\n");
		return NULL;
	}

	/* Buttons */
	p5->btn_a_out = outlet_new(&(p5->p5_obj), &s_float);
	p5->btn_b_out = outlet_new(&(p5->p5_obj), &s_float);
	p5->btn_c_out = outlet_new(&(p5->p5_obj), &s_float);

	/* Fingers */
	p5->thumb_out = outlet_new(&(p5->p5_obj), &s_float);
	p5->index_out = outlet_new(&(p5->p5_obj), &s_float);
	p5->middle_out = outlet_new(&(p5->p5_obj), &s_float);
	p5->ring_out = outlet_new(&(p5->p5_obj), &s_float);
	p5->pinky_out = outlet_new(&(p5->p5_obj), &s_float);

	/* Position */
	p5->xpos_out = outlet_new(&(p5->p5_obj), &s_float);
	p5->ypos_out = outlet_new(&(p5->p5_obj), &s_float);
	p5->zpos_out = outlet_new(&(p5->p5_obj), &s_float);

	/* Set up our clock tick so that we re"trigger" */
	if(delaytime == 0){
		p5->delaytime = DEFAULT_RETRIG_TIME;
	}
	else{
		p5->delaytime = (int)delaytime;
	}
	//post("DEBUG: Set p5 glove delay time to %f", p5->delaytime);
	p5->clock = clock_new(p5, (t_method)p5_read);
	clock_delay(p5->clock, p5->delaytime);
	
	return p5;
}