[PD-cvs] externals/hcs/usbhid Makefile, 1.1, 1.2 usbhid-help.pd, 1.2, 1.3 usbhid.c, 1.1, 1.2

Hans-Christoph Steiner eighthave at users.sourceforge.net
Mon Jul 30 20:15:48 CEST 2007


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

Modified Files:
	Makefile usbhid-help.pd usbhid.c 
Log Message:
first probes at write support, switching to Mac OS X for dev platform

Index: usbhid-help.pd
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/usbhid/usbhid-help.pd,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** usbhid-help.pd	1 Aug 2006 05:19:51 -0000	1.2
--- usbhid-help.pd	30 Jul 2007 18:15:46 -0000	1.3
***************
*** 1,8 ****
! #N canvas 339 22 633 553 10;
! #X obj 132 376 usbhid;
! #X msg 184 91 close;
! #X msg 184 117 reset;
! #X text 240 307 GARBAGE FOR TESTING;
! #X msg 197 155 print;
  #X text 317 72 Gravis/Destroyer Tiltpad;
  #N canvas 0 22 462 312 buttons 0;
--- 1,8 ----
! #N canvas 127 169 633 586 10;
! #X obj 132 406 usbhid;
! #X msg 194 120 close;
! #X msg 194 146 reset;
! #X text 240 337 GARBAGE FOR TESTING;
! #X msg 207 184 print;
  #X text 317 72 Gravis/Destroyer Tiltpad;
  #N canvas 0 22 462 312 buttons 0;
***************
*** 48,66 ****
  #X connect 15 0 8 0;
  #X connect 16 0 9 0;
! #X restore 65 515 pd buttons test;
! #X obj 127 462 unpack float float float float;
! #X obj 44 83 metro 400;
! #X obj 46 57 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
  ;
! #X floatatom 186 499 5 0 0 0 - - -;
! #X floatatom 256 500 5 0 0 0 - - -;
! #X floatatom 336 495 5 0 0 0 - - -;
  #X msg 20 5 open vendorId productId;
  #X msg 176 71 open 0x047D 0x4008;
! #X floatatom 125 496 5 0 0 0 - - -;
! #X msg 239 273 debug \$1;
! #X obj 239 251 hradio 15 1 0 10 empty empty empty 0 -6 0 8 -262144
! -1 -1 9;
! #X obj 27 441 print data;
  #N canvas 458 151 458 489 parsing 0;
  #X obj 77 6 inlet;
--- 48,66 ----
  #X connect 15 0 8 0;
  #X connect 16 0 9 0;
! #X restore 65 545 pd buttons test;
! #X obj 127 492 unpack float float float float;
! #X obj 44 113 metro 400;
! #X obj 46 87 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
  ;
! #X floatatom 186 529 5 0 0 0 - - -;
! #X floatatom 256 530 5 0 0 0 - - -;
! #X floatatom 336 525 5 0 0 0 - - -;
  #X msg 20 5 open vendorId productId;
  #X msg 176 71 open 0x047D 0x4008;
! #X floatatom 125 526 5 0 0 0 - - -;
! #X msg 239 303 debug \$1;
! #X obj 239 281 hradio 15 1 0 10 empty empty empty 0 -6 0 8 -262144
! -1 -1 0;
! #X obj 27 471 print data;
  #N canvas 458 151 458 489 parsing 0;
  #X obj 77 6 inlet;
***************
*** 90,117 ****
  #X connect 10 0 2 1;
  #X connect 10 1 11 0;
! #X restore 226 418 pd parsing;
! #X text 8 122 how many bytes to read;
! #X msg 194 136 refresh;
! #X text 259 137 reinit and refresh device list;
! #X text 233 117 resets device (don't really know what that does tho)
  ;
! #X obj 171 419 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
  1;
! #X obj 171 397 route open device;
! #X msg 44 104 get 4;
! #X msg 82 137 get 2;
! #X msg 212 179 descriptor;
! #X text 291 179 get descriptor;
! #X msg 219 213 descriptor 1 30 1 31 1 38;
! #X text 398 212 [descriptor page# usage# ...(;
! #X text 218 197 for writing to the device:;
! #X msg 25 208 set 2;
! #X msg 237 323 close \, open 0x045e 0x0039 \, descriptor;
! #X text 183 382 <- status outlet;
! #X text 21 383 data outlet ->;
  #X msg 163 49 open 0x046d 0xc01d;
  #X text 305 49 Logitech USB-PS/2 Optical Mouse;
  #X msg 156 25 open 0x1043 0x0015;
  #X text 294 26 CUI v1.0;
  #X connect 0 0 7 0;
  #X connect 0 0 18 0;
--- 90,119 ----
  #X connect 10 0 2 1;
  #X connect 10 1 11 0;
! #X restore 226 448 pd parsing;
! #X text 8 152 how many bytes to read;
! #X msg 204 165 refresh;
! #X text 269 166 reinit and refresh device list;
! #X text 243 146 resets device (don't really know what that does tho)
  ;
! #X obj 171 449 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
  1;
! #X obj 171 427 route open device;
! #X msg 44 134 get 4;
! #X msg 82 167 get 2;
! #X msg 212 209 descriptor;
! #X text 291 209 get descriptor;
! #X msg 219 243 descriptor 1 30 1 31 1 38;
! #X text 398 242 [descriptor page# usage# ...(;
! #X text 218 227 for writing to the device:;
! #X msg 25 238 set 2;
! #X msg 237 353 close \, open 0x045e 0x0039 \, descriptor;
! #X text 183 412 <- status outlet;
! #X text 21 413 data outlet ->;
  #X msg 163 49 open 0x046d 0xc01d;
  #X text 305 49 Logitech USB-PS/2 Optical Mouse;
  #X msg 156 25 open 0x1043 0x0015;
  #X text 294 26 CUI v1.0;
+ #X msg 181 96 open 0x077d 0x0410;
+ #X text 311 97 Griffin Technology PowerMate;
  #X connect 0 0 7 0;
  #X connect 0 0 18 0;
***************
*** 141,142 ****
--- 143,145 ----
  #X connect 37 0 0 0;
  #X connect 39 0 0 0;
+ #X connect 41 0 0 0;

Index: Makefile
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/usbhid/Makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Makefile	9 Aug 2006 21:32:52 -0000	1.1
--- Makefile	30 Jul 2007 18:15:46 -0000	1.2
***************
*** 15,17 ****
  
  etags:
! 	etags *.[ch] ~/cvs/pure-data/pd/src/*.[ch] /usr/include/*.h /usr/include/sys/*.h
--- 15,18 ----
  
  etags:
! 	etags *.[ch] ../../../pd/src/*.[ch] libhid-svn/*/*.? \
! 		/usr/include/*.h /usr/include/sys/*.h

Index: usbhid.c
===================================================================
RCS file: /cvsroot/pure-data/externals/hcs/usbhid/usbhid.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** usbhid.c	1 Aug 2006 03:02:21 -0000	1.1
--- usbhid.c	30 Jul 2007 18:15:46 -0000	1.2
***************
*** 295,299 ****
  	int length;
  	t_int ret = 0;
! 	char buffer[STRING_BUFFER_LENGTH];
  
  	if ( !hid_is_opened(hidif) ) 
--- 295,300 ----
  	int length;
  	t_int ret = 0;
! 	char buffer[STRING_BUFFER_LENGTH] = "";
! 	char return_buffer[STRING_BUFFER_LENGTH] = "";
  
  	if ( !hid_is_opened(hidif) ) 
***************
*** 307,312 ****
  		if (length > 0)
  		{
! 			strncat(device_string, buffer, STRING_BUFFER_LENGTH - strlen(device_string));
! 			strncat(device_string, " ",1);
  			ret = 1;
  		}
--- 308,313 ----
  		if (length > 0)
  		{
! 			strncat(return_buffer, buffer, STRING_BUFFER_LENGTH - strlen(device_string));
! 			strncat(return_buffer, " ",1);
  			ret = 1;
  		}
***************
*** 324,329 ****
  		if (length > 0)
  		{
! 			strncat(device_string, buffer, STRING_BUFFER_LENGTH - strlen(device_string));
! 			strncat(device_string, " ",1);
  			ret = 1;
  		}
--- 325,330 ----
  		if (length > 0)
  		{
! 			strncat(return_buffer, buffer, STRING_BUFFER_LENGTH - strlen(device_string));
! 			strncat(return_buffer, " ",1);
  			ret = 1;
  		}
***************
*** 340,348 ****
  									   STRING_BUFFER_LENGTH);
  		if (length > 0)
! 			strncat(device_string, buffer, STRING_BUFFER_LENGTH - strlen(device_string));
  		else
  			post("(unable to fetch product string)");
  	}
! 	
  	return ret;
  }
--- 341,352 ----
  									   STRING_BUFFER_LENGTH);
  		if (length > 0)
! 			strncat(return_buffer, buffer, STRING_BUFFER_LENGTH - strlen(device_string));
  		else
  			post("(unable to fetch product string)");
  	}
! 
! 	if (return_buffer)
! 		strncpy(device_string, return_buffer, STRING_BUFFER_LENGTH);
! 
  	return ret;
  }
***************
*** 436,442 ****
  
  /* -------------------------------------------------------------------------- */
! static void usbhid_set(t_usbhid *x, t_float length_arg)
  {
! 	if(x->debug_level) post("usbhid_set");
  	int packet_bytes = (int)length_arg;
  	char packet[packet_bytes];
--- 440,447 ----
  
  /* -------------------------------------------------------------------------- */
! static void usbhid_get(t_usbhid *x, t_float length_arg)
  {
! 	if(x->debug_level) post("usbhid_get");
! 	int i;
  	int packet_bytes = (int)length_arg;
  	char packet[packet_bytes];
***************
*** 444,453 ****
   	if ( !hid_is_opened(x->x_hidinterface) )
  	{
! 		error("[usbhid] device not open, can't set data");
  		return;
  	}
! 	x->x_hid_return = hid_set_output_report(x->x_hidinterface, 
! 										   x->x_write_elements, 
! 										   x->x_write_element_count, 
  										   packet, 
  										   length_arg);
--- 449,458 ----
   	if ( !hid_is_opened(x->x_hidinterface) )
  	{
! 		error("[usbhid] device not open, can't get data");
  		return;
  	}
! 	x->x_hid_return = hid_get_input_report(x->x_hidinterface, 
! 										   NULL, 
! 										   x->x_read_element_count, 
  										   packet, 
  										   length_arg);
***************
*** 458,471 ****
  		reset_output(x);
  		add_float_to_output(x, x->x_hid_return);
! 		outlet_anything(x->x_status_outlet, gensym("setError"), 
  						x->output_count, x->output);
  	}
  }
  
  /* -------------------------------------------------------------------------- */
! static void usbhid_get(t_usbhid *x, t_float length_arg)
  {
! 	if(x->debug_level) post("usbhid_get");
! 	int i;
  	int packet_bytes = (int)length_arg;
  	char packet[packet_bytes];
--- 463,482 ----
  		reset_output(x);
  		add_float_to_output(x, x->x_hid_return);
! 		outlet_anything(x->x_status_outlet, gensym("getError"), 
  						x->output_count, x->output);
  	}
+ 
+ 	reset_output(x);
+ 	for(i=0; i<packet_bytes; ++i)
+ 		add_float_to_output(x,packet[i]);
+ 	outlet_list(x->x_data_outlet, &s_list, x->output_count, x->output);
+ 	post("x->x_read_elements %d",x->x_read_elements);
  }
  
+ 
  /* -------------------------------------------------------------------------- */
! static void usbhid_set(t_usbhid *x, t_float length_arg)
  {
! 	if(x->debug_level) post("usbhid_set");
  	int packet_bytes = (int)length_arg;
  	char packet[packet_bytes];
***************
*** 473,482 ****
   	if ( !hid_is_opened(x->x_hidinterface) )
  	{
! 		error("[usbhid] device not open, can't get data");
  		return;
  	}
! 	x->x_hid_return = hid_get_input_report(x->x_hidinterface, 
! 										   NULL, 
! 										   x->x_read_element_count, 
  										   packet, 
  										   length_arg);
--- 484,493 ----
   	if ( !hid_is_opened(x->x_hidinterface) )
  	{
! 		error("[usbhid] device not open, can't set data");
  		return;
  	}
! 	x->x_hid_return = hid_set_output_report(x->x_hidinterface, 
! 										   x->x_write_elements, 
! 										   x->x_write_element_count, 
  										   packet, 
  										   length_arg);
***************
*** 487,499 ****
  		reset_output(x);
  		add_float_to_output(x, x->x_hid_return);
! 		outlet_anything(x->x_status_outlet, gensym("getError"), 
  						x->output_count, x->output);
  	}
- 
- 	reset_output(x);
- 	for(i=0; i<packet_bytes; ++i)
- 		add_float_to_output(x,packet[i]);
- 	outlet_list(x->x_data_outlet, &s_list, x->output_count, x->output);
- 	post("x->x_read_elements %d",x->x_read_elements);
  }
  
--- 498,504 ----
  		reset_output(x);
  		add_float_to_output(x, x->x_hid_return);
! 		outlet_anything(x->x_status_outlet, gensym("setError"), 
  						x->output_count, x->output);
  	}
  }
  





More information about the Pd-cvs mailing list