[PD-cvs] externals/io/hidio hidio.c, 1.15, 1.16 hidio.h, 1.13, 1.14 hidio_darwin.c, 1.6, 1.7 hidio_linux.c, 1.4, 1.5

Hans-Christoph Steiner eighthave at users.sourceforge.net
Mon Jan 1 03:17:29 CET 2007


Update of /cvsroot/pure-data/externals/io/hidio
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18919

Modified Files:
	hidio.c hidio.h hidio_darwin.c hidio_linux.c 
Log Message:

The output message is pre-generated by hidio_build_element_list() and stored
in t_hid_element->output_message.  Then just the value is updated.  This saves
a bit of CPU time since this is run for every event that is output.
Previously, for each event outputted, it had to allocate a t_atom[3] and run a
SETSYMBOL for the name and a SETFLOAT for the instance.


Index: hidio_darwin.c
===================================================================
RCS file: /cvsroot/pure-data/externals/io/hidio/hidio_darwin.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** hidio_darwin.c	1 Jan 2007 01:06:11 -0000	1.6
--- hidio_darwin.c	1 Jan 2007 02:17:27 -0000	1.7
***************
*** 418,421 ****
--- 418,428 ----
  			new_element->pHIDElement = (void *) pCurrentHIDElement;
  			get_usage_symbols(pCurrentHIDElement, new_element);
+ #ifdef PD
+ 			SETSYMBOL(new_element->output_message, new_element->name); 
+ 			SETFLOAT(new_element->output_message + 1, new_element->instance);
+ #else /* Max */
+ 			atom_setsym(new_element->output_message, new_element->name);
+ 			atom_setlong(new_element->output_message + 1, (long)new_element->instance);
+ #endif /* PD */
  			new_element->relative = pCurrentHIDElement->relative;
  			new_element->instance = get_type_name_instance(new_element->type, 

Index: hidio.h
===================================================================
RCS file: /cvsroot/pure-data/externals/io/hidio/hidio.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** hidio.h	1 Jan 2007 01:06:11 -0000	1.13
--- hidio.h	1 Jan 2007 02:17:27 -0000	1.14
***************
*** 152,155 ****
--- 152,156 ----
      t_int max; // from device report
      t_float instance; // usage page/usage instance # (e.g. [absolute x 2 163( )
+ 	t_atom output_message[3]; // pre-generated message for hidio_output_event()
      t_int value; // output the sum of events in a poll for relative axes
      t_int previous_value; //only output on change on abs and buttons

Index: hidio_linux.c
===================================================================
RCS file: /cvsroot/pure-data/externals/io/hidio/hidio_linux.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** hidio_linux.c	1 Jan 2007 01:06:11 -0000	1.4
--- hidio_linux.c	1 Jan 2007 02:17:27 -0000	1.5
***************
*** 360,363 ****
--- 360,365 ----
                          else
                              new_element->relative = 0;
+ 						SETSYMBOL(new_element->output_message, new_element->name); 
+ 						SETFLOAT(new_element->output_message + 1, new_element->instance);
                          // fill in the t_hid_element struct here
                          post("x->x_device_number: %d   element_count[]: %d",

Index: hidio.c
===================================================================
RCS file: /cvsroot/pure-data/externals/io/hidio/hidio.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** hidio.c	1 Jan 2007 01:06:11 -0000	1.15
--- hidio.c	1 Jan 2007 02:17:27 -0000	1.16
***************
*** 287,315 ****
  
  
! void hidio_output_event(t_hidio *x, t_hid_element *output_data)
  {
- 	if( (output_data->relative) || // relative data should always be output
- 		(output_data->value != output_data->previous_value) )
- 	{
  /*		debug_post(LOG_DEBUG,"hidio_output_event: instance %d/%d last: %llu", 
  				   x->x_instance+1, hidio_instance_count,
  				   last_execute_time[x->x_device_number]);*/
- 		t_atom event_data[3];
- 		/* TODO: this output message should be stored in t_hid_element, then just
- 		 * the value updated.  That would save a bit of CPU time since this is
- 		 * run for every event that is output. */
  #ifdef PD
! 		SETSYMBOL(event_data, output_data->name); 
! 		SETFLOAT(event_data + 1, output_data->instance);
! 		SETFLOAT(event_data + 2, output_data->value);
  #else /* Max */
! 		atom_setsym(event_data, output_data->name);
! 		//TODO: why is this line repeated?
! 		atom_setsym(event_data, output_data->name);
! 		atom_setlong(event_data + 1, (long)output_data->instance);
! 		atom_setlong(event_data + 2, (long)output_data->value);
  #endif /* PD */
! 		outlet_anything(x->x_data_outlet, output_data->type, 3, event_data);
! 	}
  }
  
--- 287,305 ----
  
  
! /* output_message[3] is pre-generated by hidio_build_element_list() and
!  * stored in t_hid_element, then just the value is updated.  This saves a bit
!  * of CPU time since this is run for every event that is output. */
! void hidio_output_event(t_hidio *x, t_hid_element *output_element)
  {
  /*		debug_post(LOG_DEBUG,"hidio_output_event: instance %d/%d last: %llu", 
  				   x->x_instance+1, hidio_instance_count,
  				   last_execute_time[x->x_device_number]);*/
  #ifdef PD
! 		SETFLOAT(output_element->output_message + 2, output_element->value);
  #else /* Max */
! 		atom_setlong(output_element->output_message + 2, (long)output_element->value);
  #endif /* PD */
! 		outlet_anything(x->x_data_outlet, output_element->type, 3, 
! 						output_element->output_message);
  }
  
***************
*** 455,462 ****
  	t_hid_element *current_element;
  	unsigned int i;
- #ifdef PD
- 	double right_now = clock_getlogicaltime();
- #else
  	double right_now;
  	clock_getftime(&right_now);
  #endif /* PD */
--- 445,453 ----
  	t_hid_element *current_element;
  	unsigned int i;
  	double right_now;
+ 
+ #ifdef PD
+ 	right_now = clock_getlogicaltime();
+ #else /* Max */
  	clock_getftime(&right_now);
  #endif /* PD */





More information about the Pd-cvs mailing list