[PD-cvs] externals/hcs/hid TODO, 1.26, 1.27 hid.c, 1.26, 1.27 hid.h, 1.25, 1.26 hid_darwin.c, 1.25, 1.26

Hans-Christoph Steiner eighthave at users.sourceforge.net
Sat Jun 3 01:41:39 CEST 2006


Update of /cvsroot/pure-data/externals/hcs/hid
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23680

Modified Files:
	TODO hid.c hid.h hid_darwin.c 
Log Message:
first attempt at having one instance do all of the device polling, based on clock_getlogicaltime().  It works for multiple instances in one patch, but does not work for multiple instances in different patches (i.e. they both still seem to get events...)

Index: TODO
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/TODO,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** TODO	2 Jun 2006 21:32:53 -0000	1.26
--- TODO	2 Jun 2006 23:41:36 -0000	1.27
***************
*** 66,69 ****
--- 66,71 ----
  http://lists.apple.com/archives/mac-games-dev/2005/Oct/msg00060.html
  
+ - current method only works for instances in the same patch...
+ 
  ______________________________________________________________________________
  = [poll 1( message set to exact delay based on block size

Index: hid_darwin.c
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid_darwin.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** hid_darwin.c	2 Jun 2006 21:32:53 -0000	1.25
--- hid_darwin.c	2 Jun 2006 23:41:36 -0000	1.26
***************
*** 625,630 ****
  void hid_get_events(t_hid *x)
  {
- 	//debug_print(LOG_DEBUG,"hid_get_events");
- 	
  	unsigned int i;
  	pRecDevice  pCurrentHIDDevice;
--- 625,628 ----
***************
*** 661,670 ****
  								   (pRecElement)current_element->os_pointer);
  		}
- 		if(current_element->previous_value != current_element->value)
- 		{
- 			hid_output_event(x, current_element);
- 			if(!current_element->relative)
- 				current_element->previous_value = current_element->value;
- 		}
  	}
  }
--- 659,662 ----

Index: hid.h
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** hid.h	2 Jun 2006 21:32:53 -0000	1.25
--- hid.h	2 Jun 2006 23:41:36 -0000	1.26
***************
*** 43,46 ****
--- 43,47 ----
  	void                *x_ff_device;
  	short               x_device_number;
+ 	short               x_instance;
  	t_int               x_has_ff;
  	t_int               x_started;
***************
*** 63,66 ****
--- 64,70 ----
  t_int hid_instance_count;
  
+ /* this is used to test for the first instance to execute */
+ double last_execute_time[MAX_DEVICES];
+ 
  extern unsigned short global_debug_level;
  

Index: hid.c
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/hid/hid.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** hid.c	2 Jun 2006 21:32:53 -0000	1.26
--- hid.c	2 Jun 2006 23:41:36 -0000	1.27
***************
*** 340,346 ****
  {
  //	debug_print(LOG_DEBUG,"hid_read");
! 
! 	hid_get_events(x);
  	
  	if (x->x_started) 
  	{
--- 340,364 ----
  {
  //	debug_print(LOG_DEBUG,"hid_read");
! 	unsigned int i;
! 	double right_now = clock_getlogicaltime();
! 	t_hid_element *current_element;
  	
+ 	if(right_now > last_execute_time[x->x_device_number])
+ 	{
+ 		hid_get_events(x);
+ 		last_execute_time[x->x_device_number] = right_now;
+ /*		post("executing: instance %d/%d at %ld", 
+ 		x->x_instance, hid_instance_count, right_now);*/
+ 	}
+ 	for(i=0; i< element_count[x->x_device_number]; ++i)
+ 	{
+ 		current_element = element[x->x_device_number][i];
+ 		if(current_element->previous_value != current_element->value)
+ 		{
+ 			hid_output_event(x, current_element);
+ 			if(!current_element->relative)
+ 				current_element->previous_value = current_element->value;
+ 		}
+ 	}
  	if (x->x_started) 
  	{
***************
*** 352,374 ****
  }
  
- /* eventually, this will be used to open devices by long name
- static void hid_anything(t_hid *x, t_symbol *s, t_int argc, t_atom *argv)
- {
- 	int i;
- 	t_symbol *my_symbol;
- 	//char device_name[MAXPDSTRING];
- 		
- 	startpost("ANYTHING! selector: %s data:");
- 	for(i=0; i<argc; ++i)
- 	{
- 		my_symbol = atom_getsymbolarg(i,argc,argv);
- 		if(my_symbol != NULL)
- 			post(" %s",my_symbol->s_name);
- 		else
- 			post(" %f",atom_getfloatarg(i,argc,argv));
- 	}
- }
- */
- 
  static void hid_info(t_hid *x)
  {
--- 370,373 ----
***************
*** 412,415 ****
--- 411,415 ----
  {
  	t_hid *x = (t_hid *)pd_new(hid_class);
+ 	unsigned int i;
    
  	debug_print(LOG_DEBUG,"hid_%s",s->s_name);
***************
*** 435,438 ****
--- 435,439 ----
    x->x_started = 0;
    x->x_delay = DEFAULT_DELAY;
+   for(i=0; i<MAX_DEVICES; ++i) last_execute_time[i] = 0;
  
    x->x_clock = clock_new(x, (t_method)hid_read);
***************
*** 444,447 ****
--- 445,449 ----
    x->x_device_number = get_device_number_from_arguments(argc, argv);
    
+   x->x_instance = hid_instance_count;
    hid_instance_count++;
  





More information about the Pd-cvs mailing list